Skip to content

Commit bb21c3d

Browse files
committed
fix: support tags for platform versions
1 parent 803a6ac commit bb21c3d

File tree

6 files changed

+16
-27
lines changed

6 files changed

+16
-27
lines changed

lib/common/definitions/mobile.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ declare module Mobile {
993993
platformNames: string[];
994994
isAndroidPlatform(platform: string): boolean;
995995
isiOSPlatform(platform: string): boolean;
996-
isWP8Platform(platform: string): boolean;
997996
normalizePlatformName(platform: string): string;
998997
validatePlatformName(platform: string): string;
999998
buildDevicePath(...args: string[]): string;
@@ -1016,7 +1015,6 @@ declare module Mobile {
10161015
interface IDevicePlatformsConstants {
10171016
iOS: string;
10181017
Android: string;
1019-
WP8: string;
10201018
}
10211019

10221020
interface IDeviceApplication {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export class DevicePlatformsConstants implements Mobile.IDevicePlatformsConstants {
22
public iOS = "iOS";
33
public Android = "Android";
4-
public WP8 = "WP8";
54
}
65
$injector.register("devicePlatformsConstants", DevicePlatformsConstants);

lib/common/mobile/mobile-helper.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ export class MobileHelper implements Mobile.IMobileHelper {
2121
return !!(platform && (this.$devicePlatformsConstants.iOS.toLowerCase() === platform.toLowerCase()));
2222
}
2323

24-
public isWP8Platform(platform: string): boolean {
25-
return !!(platform && (this.$devicePlatformsConstants.WP8.toLowerCase() === platform.toLowerCase()));
26-
}
27-
2824
public normalizePlatformName(platform: string): string {
2925
if (this.isAndroidPlatform(platform)) {
3026
return "Android";
3127
} else if (this.isiOSPlatform(platform)) {
3228
return "iOS";
33-
} else if (this.isWP8Platform(platform)) {
34-
return "WP8";
3529
}
3630

3731
return undefined;

lib/constants.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,6 @@ export class PluginNativeDirNames {
265265
public static Android = "android";
266266
}
267267

268-
export const DEVICE_PLATFORMS: IDictionary<string> = {
269-
iOS: "iOS",
270-
Android: "Android"
271-
};
272-
273268
export const PODFILE_NAME = "Podfile";
274269

275270
export class IosProjectConstants {

lib/controllers/base-update-controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class BaseUpdateController {
4444
const currentPlatformVersion = this.$platformCommandHelper.getCurrentPlatformVersion(lowercasePlatform, projectData);
4545
const platformData = this.$platformsDataService.getPlatformData(lowercasePlatform, projectData);
4646
if (currentPlatformVersion) {
47-
const maxPlatformSatisfyingVersion = await this.$packageInstallationManager.maxSatisfyingVersion(platformData.frameworkPackageName, currentPlatformVersion) || currentPlatformVersion;
47+
const maxPlatformSatisfyingVersion = await this.getMaxDependencyVersion(platformData.frameworkPackageName, currentPlatformVersion) || currentPlatformVersion;
4848
if (semver.gte(maxPlatformSatisfyingVersion, targetVersion)) {
4949
return false;
5050
}

lib/controllers/migrate-controller.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
1010
protected $platformsDataService: IPlatformsDataService,
1111
protected $packageInstallationManager: IPackageInstallationManager,
1212
protected $packageManager: IPackageManager,
13+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1314
private $logger: ILogger,
1415
private $addPlatformService: IAddPlatformService,
1516
private $pluginsService: IPluginsService,
@@ -58,15 +59,17 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
5859
{ packageName: "nativescript-cardview", verifiedVersion: "3.2.0"}
5960
];
6061

61-
static readonly verifiedPlatformVersions: IDictionary<string> = {
62-
[constants.DEVICE_PLATFORMS.Android.toLowerCase()]: "6.0.0-2019-06-11-172137-01",
63-
[constants.DEVICE_PLATFORMS.iOS.toLowerCase()]: "6.0.0-2019-06-10-154118-03"
64-
};
65-
6662
static readonly tempFolder: string = ".migration_backup";
67-
static readonly updateFailMessage: string = "Could not migrate the project!";
63+
static readonly migrateFailMessage: string = "Could not migrate the project!";
6864
static readonly backupFailMessage: string = "Could not backup project folders!";
6965

66+
get verifiedPlatformVersions(): IDictionary<string> {
67+
return {
68+
[this.$devicePlatformsConstants.Android.toLowerCase()]: "6.0.0-2019-06-11-172137-01",
69+
[this.$devicePlatformsConstants.iOS.toLowerCase()]: "6.0.0-2019-06-10-154118-03"
70+
};
71+
}
72+
7073
public async migrate({projectDir}: {projectDir: string}): Promise<void> {
7174
const projectData = this.$projectDataService.getProjectData(projectDir);
7275
const tmpDir = path.join(projectDir, MigrateController.tempFolder);
@@ -86,7 +89,7 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
8689
await this.migrateDependencies(projectData);
8790
} catch (error) {
8891
this.restoreBackup(MigrateController.folders, tmpDir, projectData);
89-
this.$logger.error(MigrateController.updateFailMessage);
92+
this.$logger.error(MigrateController.migrateFailMessage);
9093
}
9194
}
9295

@@ -103,8 +106,8 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
103106
return true;
104107
}
105108
}
106-
for (const platform in constants.DEVICE_PLATFORMS) {
107-
if (await this.shouldUpdateRuntimeVersion({ targetVersion: MigrateController.verifiedPlatformVersions[platform.toLowerCase()], platform, projectData, shouldAdd: true})) {
109+
for (const platform in this.$devicePlatformsConstants) {
110+
if (await this.shouldUpdateRuntimeVersion({ targetVersion: this.verifiedPlatformVersions[platform.toLowerCase()], platform, projectData, shouldAdd: true})) {
108111
return true;
109112
}
110113
}
@@ -140,10 +143,10 @@ export class MigrateController extends BaseUpdateController implements IMigrateC
140143
}
141144
}
142145

143-
for (const platform in constants.DEVICE_PLATFORMS) {
146+
for (const platform in this.$devicePlatformsConstants) {
144147
const lowercasePlatform = platform.toLowerCase();
145-
if (await this.shouldUpdateRuntimeVersion({targetVersion: MigrateController.verifiedPlatformVersions[lowercasePlatform], platform, projectData, shouldAdd: true})) {
146-
const verifiedPlatformVersion = MigrateController.verifiedPlatformVersions[lowercasePlatform];
148+
if (await this.shouldUpdateRuntimeVersion({targetVersion: this.verifiedPlatformVersions[lowercasePlatform], platform, projectData, shouldAdd: true})) {
149+
const verifiedPlatformVersion = this.verifiedPlatformVersions[lowercasePlatform];
147150
const platformData = this.$platformsDataService.getPlatformData(lowercasePlatform, projectData);
148151
this.$logger.info(`Updating ${platform} platform to version '${verifiedPlatformVersion}'.`);
149152
await this.$addPlatformService.setPlatformVersion(platformData, projectData, verifiedPlatformVersion);

0 commit comments

Comments
 (0)