Skip to content

Commit 86e7634

Browse files
committed
refactor: runtime migrations to use same logic as package migrations
1 parent b2d51da commit 86e7634

File tree

2 files changed

+111
-139
lines changed

2 files changed

+111
-139
lines changed

lib/controllers/migrate-controller.ts

Lines changed: 110 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ import {
2626
IPackageInstallationManager,
2727
IPackageManager,
2828
IPlatformCommandHelper,
29-
IPlatformValidationService,
3029
} from "../declarations";
31-
import {
32-
IAddPlatformService,
33-
IPlatformsDataService,
34-
} from "../definitions/platform";
30+
import { IPlatformsDataService } from "../definitions/platform";
3531
import { IPluginsService } from "../definitions/plugins";
3632
import {
3733
IChildProcess,
38-
IDictionary,
3934
IErrors,
4035
IFileSystem,
4136
IResourceLoader,
@@ -67,15 +62,12 @@ export class MigrateController
6762
protected $packageManager: IPackageManager,
6863
protected $pacoteService: IPacoteService,
6964
// private $androidResourcesMigrationService: IAndroidResourcesMigrationService,
70-
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
7165
private $logger: ILogger,
7266
private $errors: IErrors,
73-
private $addPlatformService: IAddPlatformService,
7467
private $pluginsService: IPluginsService,
7568
private $projectDataService: IProjectDataService,
7669
private $projectConfigService: IProjectConfigService,
7770
private $options: IOptions,
78-
private $platformValidationService: IPlatformValidationService,
7971
private $resources: IResourceLoader,
8072
private $injector: IInjector,
8173
private $settingsService: ISettingsService,
@@ -284,20 +276,46 @@ export class MigrateController
284276
desiredVersion: "~1.39.0",
285277
isDev: true,
286278
},
279+
280+
// runtimes
281+
{
282+
packageName: "tns-ios",
283+
minVersion: "6.5.3",
284+
replaceWith: "@nativescript/ios",
285+
isDev: true,
286+
},
287+
{
288+
packageName: "tns-android",
289+
minVersion: "6.5.4",
290+
replaceWith: "@nativescript/android",
291+
isDev: true,
292+
},
293+
{
294+
packageName: "@nativescript/ios",
295+
minVersion: "6.5.3",
296+
desiredVersion: "~8.1.0",
297+
isDev: true,
298+
},
299+
{
300+
packageName: "@nativescript/android",
301+
minVersion: "7.0.0",
302+
desiredVersion: "~8.1.0",
303+
isDev: true,
304+
},
287305
];
288306

289-
get verifiedPlatformVersions(): IDictionary<IDependencyVersion> {
290-
return {
291-
[this.$devicePlatformsConstants.Android.toLowerCase()]: {
292-
minVersion: "6.5.3",
293-
desiredVersion: "~8.0.0", // :::8.1.0
294-
},
295-
[this.$devicePlatformsConstants.iOS.toLowerCase()]: {
296-
minVersion: "6.5.4",
297-
desiredVersion: "~8.0.0", // :::8.1.0
298-
},
299-
};
300-
}
307+
// get verifiedPlatformVersions(): IDictionary<IDependencyVersion> {
308+
// return {
309+
// [this.$devicePlatformsConstants.Android.toLowerCase()]: {
310+
// minVersion: "6.5.3",
311+
// desiredVersion: "~8.1.0", // :::8.1.0
312+
// },
313+
// [this.$devicePlatformsConstants.iOS.toLowerCase()]: {
314+
// minVersion: "6.5.4",
315+
// desiredVersion: "~8.1.0", // :::8.1.0
316+
// },
317+
// };
318+
// }
301319

302320
public async shouldMigrate({
303321
projectDir,
@@ -631,50 +649,49 @@ export class MigrateController
631649
}
632650
}
633651

634-
for (let platform of platforms) {
635-
platform = platform?.toLowerCase();
652+
// for (let platform of platforms) {
653+
// platform = platform?.toLowerCase();
636654

637-
if (
638-
!this.$platformValidationService.isValidPlatform(platform, projectData)
639-
) {
640-
continue;
641-
}
655+
// if (
656+
// !this.$platformValidationService.isValidPlatform(platform, projectData)
657+
// ) {
658+
// continue;
659+
// }
642660

643-
const hasRuntimeDependency = this.hasRuntimeDependency({
644-
platform,
645-
projectData,
646-
});
661+
// const hasRuntimeDependency = this.hasRuntimeDependency({
662+
// platform,
663+
// projectData,
664+
// });
647665

648-
if (!hasRuntimeDependency) {
649-
continue;
650-
}
666+
// if (!hasRuntimeDependency) {
667+
// continue;
668+
// }
651669

652-
const verifiedPlatformVersion = this.verifiedPlatformVersions[
653-
platform.toLowerCase()
654-
];
655-
const shouldUpdateRuntime = await this.shouldUpdateRuntimeVersion(
656-
verifiedPlatformVersion,
657-
platform,
658-
projectData,
659-
loose
660-
);
670+
// const verifiedPlatformVersion =
671+
// this.verifiedPlatformVersions[platform.toLowerCase()];
672+
// const shouldUpdateRuntime = await this.shouldUpdateRuntimeVersion(
673+
// verifiedPlatformVersion,
674+
// platform,
675+
// projectData,
676+
// loose
677+
// );
661678

662-
if (!shouldUpdateRuntime) {
663-
continue;
664-
}
679+
// if (!shouldUpdateRuntime) {
680+
// continue;
681+
// }
665682

666-
this.$logger.trace(
667-
`${shouldMigrateCommonMessage}Platform '${platform}' should be updated.`
668-
);
669-
if (loose) {
670-
this.$logger.warn(
671-
`Platform '${platform}' should be updated. The minimum version supported is ${verifiedPlatformVersion.minVersion}`
672-
);
673-
continue;
674-
}
675-
676-
return true;
677-
}
683+
// this.$logger.trace(
684+
// `${shouldMigrateCommonMessage}Platform '${platform}' should be updated.`
685+
// );
686+
// if (loose) {
687+
// this.$logger.warn(
688+
// `Platform '${platform}' should be updated. The minimum version supported is ${verifiedPlatformVersion.minVersion}`
689+
// );
690+
// continue;
691+
// }
692+
693+
// return true;
694+
// }
678695

679696
return false;
680697
}
@@ -706,20 +723,6 @@ export class MigrateController
706723
);
707724
}
708725

709-
private async shouldUpdateRuntimeVersion(
710-
version: IDependencyVersion,
711-
platform: string,
712-
projectData: IProjectData,
713-
loose: boolean
714-
): Promise<boolean> {
715-
const installedVersion = await this.getMaxRuntimeVersion({
716-
platform,
717-
projectData,
718-
});
719-
720-
return this.isOutdatedVersion(installedVersion, version, loose);
721-
}
722-
723726
private async getCachedShouldMigrate(
724727
projectDir: string,
725728
platform: string
@@ -1046,48 +1049,47 @@ export class MigrateController
10461049
await this.migrateDependency(dependency, projectData, loose);
10471050
}
10481051

1049-
for (const platform of platforms) {
1050-
const lowercasePlatform = platform.toLowerCase();
1051-
const hasRuntimeDependency = this.hasRuntimeDependency({
1052-
platform,
1053-
projectData,
1054-
});
1052+
// for (const platform of platforms) {
1053+
// const lowercasePlatform = platform.toLowerCase();
1054+
// const hasRuntimeDependency = this.hasRuntimeDependency({
1055+
// platform,
1056+
// projectData,
1057+
// });
10551058

1056-
if (!hasRuntimeDependency) {
1057-
continue;
1058-
}
1059+
// if (!hasRuntimeDependency) {
1060+
// continue;
1061+
// }
10591062

1060-
const shouldUpdate = await this.shouldUpdateRuntimeVersion(
1061-
this.verifiedPlatformVersions[lowercasePlatform],
1062-
platform,
1063-
projectData,
1064-
loose
1065-
);
1063+
// const shouldUpdate = await this.shouldUpdateRuntimeVersion(
1064+
// this.verifiedPlatformVersions[lowercasePlatform],
1065+
// platform,
1066+
// projectData,
1067+
// loose
1068+
// );
10661069

1067-
if (!shouldUpdate) {
1068-
continue;
1069-
}
1070+
// if (!shouldUpdate) {
1071+
// continue;
1072+
// }
10701073

1071-
const verifiedPlatformVersion = this.verifiedPlatformVersions[
1072-
lowercasePlatform
1073-
];
1074-
const platformData = this.$platformsDataService.getPlatformData(
1075-
lowercasePlatform,
1076-
projectData
1077-
);
1074+
// const verifiedPlatformVersion =
1075+
// this.verifiedPlatformVersions[lowercasePlatform];
1076+
// const platformData = this.$platformsDataService.getPlatformData(
1077+
// lowercasePlatform,
1078+
// projectData
1079+
// );
10781080

1079-
this.spinner.info(
1080-
`Updating ${platform} platform to version ${verifiedPlatformVersion.desiredVersion.green}.`
1081-
);
1081+
// this.spinner.info(
1082+
// `Updating ${platform} platform to version ${verifiedPlatformVersion.desiredVersion.green}.`
1083+
// );
10821084

1083-
await this.$addPlatformService.setPlatformVersion(
1084-
platformData,
1085-
projectData,
1086-
verifiedPlatformVersion.desiredVersion
1087-
);
1085+
// await this.$addPlatformService.setPlatformVersion(
1086+
// platformData,
1087+
// projectData,
1088+
// verifiedPlatformVersion.desiredVersion
1089+
// );
10881090

1089-
this.spinner.succeed();
1090-
}
1091+
// this.spinner.succeed();
1092+
// }
10911093
}
10921094

10931095
private async migrateDependency(

yarn.lock

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,13 +1188,6 @@
11881188
"resolved" "https://registry.npmjs.org/binaryextensions/-/binaryextensions-4.13.0.tgz"
11891189
"version" "4.13.0"
11901190

1191-
"bindings@^1.5.0":
1192-
"integrity" "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="
1193-
"resolved" "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz"
1194-
"version" "1.5.0"
1195-
dependencies:
1196-
"file-uri-to-path" "1.0.0"
1197-
11981191
"bmp-js@^0.1.0":
11991192
"integrity" "sha1-4Fpj95amwf8l9Hcex62twUjAcjM="
12001193
"resolved" "https://registry.npmjs.org/bmp-js/-/bmp-js-0.1.0.tgz"
@@ -2674,7 +2667,7 @@
26742667
"resolved" "https://registry.npmjs.org/file-type/-/file-type-9.0.0.tgz"
26752668
"version" "9.0.0"
26762669

2677-
"file-uri-to-path@1", "[email protected]":
2670+
"file-uri-to-path@1":
26782671
"integrity" "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
26792672
"resolved" "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz"
26802673
"version" "1.0.0"
@@ -2886,24 +2879,6 @@
28862879
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
28872880
"version" "1.0.0"
28882881

2889-
"fsevents@^1.2.7":
2890-
"integrity" "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw=="
2891-
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz"
2892-
"version" "1.2.13"
2893-
dependencies:
2894-
"bindings" "^1.5.0"
2895-
"nan" "^2.12.1"
2896-
2897-
"fsevents@~2.1.2":
2898-
"integrity" "sha512-Auw9a4AxqWpa9GUfj370BMPzzyncfBABW8Mab7BGWBYDj4Isgq+cDKtx0i6u9jcX9pQDnswsaaOTgTmA5pEjuQ=="
2899-
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.1.3.tgz"
2900-
"version" "2.1.3"
2901-
2902-
"fsevents@~2.3.1":
2903-
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
2904-
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
2905-
"version" "2.3.2"
2906-
29072882
"ftp@~0.3.10":
29082883
"integrity" "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0="
29092884
"resolved" "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz"
@@ -4956,11 +4931,6 @@
49564931
"resolved" "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz"
49574932
"version" "0.0.8"
49584933

4959-
"nan@^2.12.1":
4960-
"integrity" "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
4961-
"resolved" "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz"
4962-
"version" "2.14.1"
4963-
49644934
"nanoid@^1.0.7":
49654935
"integrity" "sha512-4ug4BsuHxiVHoRUe1ud6rUFT3WUMmjXt1W0quL0CviZQANdan7D8kqN5/maw53hmAApY/jfzMRkC57BNNs60ZQ=="
49664936
"resolved" "https://registry.npmjs.org/nanoid/-/nanoid-1.3.4.tgz"

0 commit comments

Comments
 (0)