Skip to content

Commit ba29271

Browse files
committed
fix(windows): syncing
1 parent b5171b8 commit ba29271

7 files changed

Lines changed: 470 additions & 79 deletions

File tree

lib/common/mobile/windows/windows-device.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class WindowsDevice implements Mobile.IDevice {
2121
errorHelp: null,
2222
isTablet: false,
2323
type: DeviceTypes.Device,
24-
platform: "windows",
24+
platform: "Windows",
2525
connectionTypes: [DeviceConnectionType.Local],
2626
};
2727

lib/controllers/prepare-controller.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ export class PrepareController extends EventEmitter {
482482
"app",
483483
"package.json",
484484
);
485+
} else if (
486+
this.$mobileHelper.isWindowsPlatform(platformData.platformNameLowerCase)
487+
) {
488+
// Windows apps place the packaged app under <projectRoot>/<projectName>/App
489+
packagePath = path.join(
490+
platformData.projectRoot,
491+
projectData.projectName,
492+
"app",
493+
"package.json",
494+
);
485495
} else {
486496
packagePath = path.join(
487497
platformData.projectRoot,

lib/data/prepare-data.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class PrepareData extends ControllerDataBase {
1414
constructor(
1515
public projectDir: string,
1616
public platform: string,
17-
data: IOptions
17+
data: IOptions,
1818
) {
1919
super(projectDir, platform, data);
2020

@@ -64,3 +64,12 @@ export class IOSPrepareData extends PrepareData {
6464
}
6565

6666
export class AndroidPrepareData extends PrepareData {}
67+
68+
export class WindowsPrepareData extends PrepareData {
69+
public packageFamilyName?: string;
70+
71+
constructor(projectDir: string, platform: string, data: IOptions) {
72+
super(projectDir, platform, data);
73+
this.packageFamilyName = (data as any).packageFamilyName;
74+
}
75+
}

lib/services/platform/add-platform-service.ts

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class AddPlatformService implements IAddPlatformService {
2525
// private $projectDataService: IProjectDataService,
2626
private $packageManager: IPackageManager,
2727
private $terminalSpinnerService: ITerminalSpinnerService,
28-
private $analyticsService: IAnalyticsService // private $tempService: ITempService
28+
private $analyticsService: IAnalyticsService, // private $tempService: ITempService
2929
) {}
3030

3131
public async addProjectHost() {}
@@ -34,7 +34,7 @@ export class AddPlatformService implements IAddPlatformService {
3434
projectData: IProjectData,
3535
platformData: IPlatformData,
3636
packageToInstall: string,
37-
addPlatformData: IAddPlatformData
37+
addPlatformData: IAddPlatformData,
3838
): Promise<string> {
3939
const spinner = this.$terminalSpinnerService.createSpinner();
4040

@@ -46,11 +46,34 @@ export class AddPlatformService implements IAddPlatformService {
4646
// : await this.installPackage(projectData.projectDir, packageToInstall);
4747
const frameworkDirPath = await this.installPackage(
4848
projectData.projectDir,
49-
packageToInstall
49+
packageToInstall,
5050
);
51+
52+
const frameworkPackageJsonPath = path.join(
53+
frameworkDirPath || "",
54+
"..",
55+
"package.json",
56+
);
57+
58+
if (!frameworkDirPath || !this.$fs.exists(frameworkPackageJsonPath)) {
59+
throw new Error(
60+
`Installed framework package.json not found at ${frameworkPackageJsonPath}`,
61+
);
62+
}
63+
5164
const frameworkPackageJsonContent = this.$fs.readJson(
52-
path.join(frameworkDirPath, "..", "package.json")
65+
frameworkPackageJsonPath,
5366
);
67+
68+
if (
69+
!frameworkPackageJsonContent ||
70+
!frameworkPackageJsonContent.version
71+
) {
72+
throw new Error(
73+
`Installed framework package.json at ${frameworkPackageJsonPath} does not contain a version`,
74+
);
75+
}
76+
5477
const frameworkVersion = frameworkPackageJsonContent.version;
5578

5679
// await this.setPlatformVersion(platformData, projectData, frameworkVersion);
@@ -64,15 +87,15 @@ export class AddPlatformService implements IAddPlatformService {
6487
platformData,
6588
projectData,
6689
frameworkDirPath,
67-
frameworkVersion
90+
frameworkVersion,
6891
);
6992
}
7093

7194
return frameworkVersion;
7295
} catch (err) {
7396
const platformPath = path.join(
7497
projectData.platformsDir,
75-
platformData.platformNameLowerCase
98+
platformData.platformNameLowerCase,
7699
);
77100
this.$fs.deleteDirectory(platformPath);
78101
throw err;
@@ -84,11 +107,11 @@ export class AddPlatformService implements IAddPlatformService {
84107
public async setPlatformVersion(
85108
platformData: IPlatformData,
86109
projectData: IProjectData,
87-
frameworkVersion: string
110+
frameworkVersion: string,
88111
): Promise<void> {
89112
await this.installPackage(
90113
projectData.projectDir,
91-
`${platformData.frameworkPackageName}@${frameworkVersion}`
114+
`${platformData.frameworkPackageName}@${frameworkVersion}`,
92115
);
93116
}
94117

@@ -106,7 +129,7 @@ export class AddPlatformService implements IAddPlatformService {
106129

107130
private async installPackage(
108131
projectDir: string,
109-
packageName: string
132+
packageName: string,
110133
): Promise<string> {
111134
const frameworkDir = this.resolveFrameworkDir(projectDir, packageName);
112135
if (frameworkDir && this.$fs.exists(frameworkDir)) {
@@ -122,7 +145,7 @@ export class AddPlatformService implements IAddPlatformService {
122145
dev: true,
123146
"save-dev": true,
124147
"save-exact": true,
125-
} as any
148+
} as any,
126149
);
127150

128151
if (!installedPackage.name) {
@@ -172,7 +195,7 @@ export class AddPlatformService implements IAddPlatformService {
172195
} catch (err) {
173196
this.$logger.trace(
174197
`Couldn't resolve installed framework. Continuing with install...`,
175-
err
198+
err,
176199
);
177200
}
178201
return null;
@@ -183,36 +206,36 @@ export class AddPlatformService implements IAddPlatformService {
183206
platformData: IPlatformData,
184207
projectData: IProjectData,
185208
frameworkDirPath: string,
186-
frameworkVersion: string
209+
frameworkVersion: string,
187210
): Promise<void> {
188211
// here we should use ios OR android
189212
const platformDir =
190213
this.$options.hostProjectPath ??
191214
path.join(
192215
projectData.platformsDir,
193-
platformData.normalizedPlatformName.toLowerCase()
216+
platformData.normalizedPlatformName.toLowerCase(),
194217
);
195218

196219
this.$fs.deleteDirectory(platformDir);
197220
//if iosHost - dont create project
198221
await platformData.platformProjectService.createProject(
199222
path.resolve(frameworkDirPath),
200223
frameworkVersion,
201-
projectData
224+
projectData,
202225
);
203226
platformData.platformProjectService.ensureConfigurationFileInAppResources(
204-
projectData
227+
projectData,
205228
);
206229
await platformData.platformProjectService.interpolateData(projectData);
207230
platformData.platformProjectService.afterCreateProject(
208231
platformData.projectRoot,
209-
projectData
232+
projectData,
210233
);
211234
}
212235

213236
private async trackPlatformVersion(
214237
frameworkVersion: string,
215-
platformData: IPlatformData
238+
platformData: IPlatformData,
216239
): Promise<void> {
217240
await this.$analyticsService.trackEventActionInGoogleAnalytics({
218241
action: TrackActionNames.AddPlatform,

lib/services/prepare-data-service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
import { IOSPrepareData, AndroidPrepareData } from "../data/prepare-data";
1+
import {
2+
IOSPrepareData,
3+
AndroidPrepareData,
4+
WindowsPrepareData,
5+
} from "../data/prepare-data";
26
import { injector } from "../common/yok";
37
import { IOptions } from "../declarations";
48

59
export class PrepareDataService implements IPrepareDataService {
610
constructor(private $mobileHelper: Mobile.IMobileHelper) {}
711

812
public getPrepareData(projectDir: string, platform: string, data: IOptions) {
9-
const platformLowerCase = platform.toLowerCase();
13+
const platformLowerCase = platform && platform.toLowerCase();
1014

1115
if (this.$mobileHelper.isApplePlatform(platform)) {
1216
return new IOSPrepareData(projectDir, platformLowerCase, data);
1317
} else if (this.$mobileHelper.isAndroidPlatform(platform)) {
1418
return new AndroidPrepareData(projectDir, platformLowerCase, data);
19+
} else if (this.$mobileHelper.isWindowsPlatform(platform)) {
20+
return new WindowsPrepareData(projectDir, platformLowerCase, data);
1521
}
1622
}
1723
}

0 commit comments

Comments
 (0)