-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathmigrate.ts
43 lines (37 loc) · 1.26 KB
/
migrate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { IProjectData } from "../definitions/project";
import { IMigrateController } from "../definitions/migrate";
import { ICommand, ICommandParameter } from "../common/definitions/commands";
import { injector } from "../common/yok";
export class MigrateCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $migrateController: IMigrateController,
private $staticConfig: Config.IStaticConfig,
private $projectData: IProjectData,
private $logger: ILogger
) {
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
const migrationData = {
projectDir: this.$projectData.projectDir,
platforms: [
this.$devicePlatformsConstants.Android,
this.$devicePlatformsConstants.iOS,
],
};
const shouldMigrateResult = await this.$migrateController.shouldMigrate(
migrationData
);
if (!shouldMigrateResult) {
const cliVersion = this.$staticConfig.version;
this.$logger.printMarkdown(
`__Project is compatible with NativeScript \`v${cliVersion}\`__`
);
return;
}
await this.$migrateController.migrate(migrationData);
}
}
injector.registerCommand("migrate", MigrateCommand);