Skip to content

Commit fc46f1c

Browse files
committed
feat: migration improvements [WIP]
1 parent f70c2af commit fc46f1c

File tree

6 files changed

+276
-89
lines changed

6 files changed

+276
-89
lines changed

lib/commands/migrate.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IProjectData } from "../definitions/project";
22
import { IMigrateController } from "../definitions/migrate";
33
import { ICommand, ICommandParameter } from "../common/definitions/commands";
44
import { injector } from "../common/yok";
5+
import { ShouldMigrate } from "../constants";
56

67
export class MigrateCommand implements ICommand {
78
public allowedParameters: ICommandParameter[] = [];
@@ -16,28 +17,31 @@ export class MigrateCommand implements ICommand {
1617
}
1718

1819
public async execute(args: string[]): Promise<void> {
19-
const shouldMigrateResult = await this.$migrateController.shouldMigrate({
20+
const migrationData = {
2021
projectDir: this.$projectData.projectDir,
2122
platforms: [
2223
this.$devicePlatformsConstants.Android,
2324
this.$devicePlatformsConstants.iOS,
2425
],
25-
});
26+
};
27+
const shouldMigrateResult = await this.$migrateController.shouldMigrate(
28+
migrationData
29+
);
2630

27-
if (!shouldMigrateResult) {
31+
if (shouldMigrateResult.shouldMigrate === ShouldMigrate.NO) {
2832
this.$logger.printMarkdown(
2933
'__Project is compatible with NativeScript "v7.0.0". To get the latest NativeScript packages execute "ns update".__'
3034
);
3135
return;
36+
} else if (shouldMigrateResult.shouldMigrate === ShouldMigrate.ADVISED) {
37+
// todo: this shouldn't be here, because this is already the `ns migrate` path.
38+
this.$logger.printMarkdown(
39+
'__Project should work with NativeScript "v7.0.0" but a migration is advised. Run ns migrate to migrate.__'
40+
);
41+
return;
3242
}
3343

34-
await this.$migrateController.migrate({
35-
projectDir: this.$projectData.projectDir,
36-
platforms: [
37-
this.$devicePlatformsConstants.Android,
38-
this.$devicePlatformsConstants.iOS,
39-
],
40-
});
44+
await this.$migrateController.migrate(migrationData);
4145
}
4246
}
4347

lib/constants.ts

+6
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ export class DebugCommandErrors {
208208
"Unsupported device OS for debugging";
209209
}
210210

211+
export const enum ShouldMigrate {
212+
NO,
213+
YES,
214+
ADVISED,
215+
}
216+
211217
export const enum NativePlatformStatus {
212218
requiresPlatformAdd = "1",
213219
requiresPrepare = "2",

0 commit comments

Comments
 (0)