Skip to content

Commit a592029

Browse files
author
Dimitar Tachev
authored
Merge pull request #4834 from NativeScript/tachev/migrate-fixes
fix: migrate validation issues
2 parents c978bcf + 54b093f commit a592029

File tree

11 files changed

+84
-58
lines changed

11 files changed

+84
-58
lines changed

lib/commands/build.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
1111
$platformValidationService: IPlatformValidationService,
1212
private $buildDataService: IBuildDataService,
1313
protected $logger: ILogger) {
14-
super($options, $platformsDataService, $platformValidationService, $projectData);
15-
this.$projectData.initializeProjectData();
14+
super($options, $platformsDataService, $platformValidationService, $projectData);
15+
this.$projectData.initializeProjectData();
1616
}
1717

1818
public dashedOptions = {
@@ -65,16 +65,16 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
6565
$logger: ILogger,
6666
$buildDataService: IBuildDataService,
6767
private $migrateController: IMigrateController) {
68-
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
68+
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
6969
}
7070

7171
public async execute(args: string[]): Promise<void> {
7272
await this.executeCore([this.$devicePlatformsConstants.iOS.toLowerCase()]);
7373
}
7474

7575
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
76-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
7776
const platform = this.$devicePlatformsConstants.iOS;
77+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [platform] });
7878

7979
super.validatePlatform(platform);
8080

@@ -103,7 +103,7 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
103103
$buildDataService: IBuildDataService,
104104
protected $logger: ILogger,
105105
private $migrateController: IMigrateController) {
106-
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
106+
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
107107
}
108108

109109
public async execute(args: string[]): Promise<void> {
@@ -119,8 +119,8 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
119119
}
120120

121121
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
122-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
123122
const platform = this.$devicePlatformsConstants.Android;
123+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [platform] });
124124
this.$androidBundleValidatorHelper.validateRuntimeVersion(this.$projectData);
125125
let result = await super.canExecuteCommandBase(platform, { notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true } });
126126
if (result.canExecute) {

lib/commands/debug.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
5353
}
5454

5555
public async canExecute(args: string[]): Promise<ICanExecuteCommandOutput> {
56-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
56+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [this.platform] });
5757

5858
this.$androidBundleValidatorHelper.validateNoAab();
5959

lib/commands/migrate.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,25 @@ export class MigrateCommand implements ICommand {
22
public allowedParameters: ICommandParameter[] = [];
33

44
constructor(
5+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
56
private $migrateController: IMigrateController,
67
private $projectData: IProjectData,
78
private $errors: IErrors) {
89
this.$projectData.initializeProjectData();
910
}
1011

1112
public async execute(args: string[]): Promise<void> {
12-
await this.$migrateController.migrate({ projectDir: this.$projectData.projectDir });
13+
await this.$migrateController.migrate({
14+
projectDir: this.$projectData.projectDir,
15+
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
16+
});
1317
}
1418

1519
public async canExecute(args: string[]): Promise<boolean> {
16-
const shouldMigrateResult = await this.$migrateController.shouldMigrate({ projectDir: this.$projectData.projectDir });
20+
const shouldMigrateResult = await this.$migrateController.shouldMigrate({
21+
projectDir: this.$projectData.projectDir,
22+
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
23+
});
1724

1825
if (!shouldMigrateResult) {
1926
this.$errors.failWithoutHelp('Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".');

lib/commands/prepare.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
1818
$platformsDataService: IPlatformsDataService,
1919
private $prepareDataService: PrepareDataService,
2020
private $migrateController: IMigrateController) {
21-
super($options, $platformsDataService, $platformValidationService, $projectData);
22-
this.$projectData.initializeProjectData();
21+
super($options, $platformsDataService, $platformValidationService, $projectData);
22+
this.$projectData.initializeProjectData();
2323
}
2424

2525
public async execute(args: string[]): Promise<void> {
@@ -30,10 +30,10 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
3030
}
3131

3232
public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
33-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
3433
const platform = args[0];
3534
const result = await this.$platformCommandParameter.validate(platform) &&
3635
await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
36+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [platform] });
3737
if (!result) {
3838
return false;
3939
}

lib/commands/preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class PreviewCommand implements ICommand {
4141
this.$errors.fail(`The arguments '${args.join(" ")}' are not valid for the preview command.`);
4242
}
4343

44-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
44+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [] });
4545

4646
await this.$networkConnectivityValidator.validate();
4747
return true;

lib/commands/run.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,15 @@ export class RunCommandBase implements ICommand {
2828
this.$errors.fail(ERROR_NO_VALID_SUBCOMMAND_FORMAT, "run");
2929
}
3030

31-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
32-
33-
this.$androidBundleValidatorHelper.validateNoAab();
34-
35-
this.$projectData.initializeProjectData();
3631
this.platform = args[0] || this.platform;
37-
3832
if (!this.platform && !this.$hostInfo.isDarwin) {
3933
this.platform = this.$devicePlatformsConstants.Android;
4034
}
4135

36+
this.$androidBundleValidatorHelper.validateNoAab();
37+
this.$projectData.initializeProjectData();
38+
const platforms = this.platform ? [this.platform] : [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS];
39+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms });
4240
await this.$liveSyncCommandHelper.validatePlatform(this.platform);
4341

4442
return true;

lib/commands/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ abstract class TestCommandBase {
3535
devices = await this.$liveSyncCommandHelper.getDeviceInstances(this.platform);
3636
}
3737

38-
if (!this.$options.env) { this.$options.env = { }; }
38+
if (!this.$options.env) { this.$options.env = {}; }
3939
this.$options.env.unitTesting = true;
4040

4141
const liveSyncInfo = this.$liveSyncCommandHelper.getLiveSyncData(this.$projectData.projectDir);
@@ -49,7 +49,7 @@ abstract class TestCommandBase {
4949
}
5050

5151
async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
52-
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
52+
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [this.platform] });
5353

5454
this.$projectData.initializeProjectData();
5555
this.$analyticsService.setShouldDispose(this.$options.justlaunch || !this.$options.watch);

lib/commands/update.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export class UpdateCommand implements ICommand {
44
public static readonly PROJECT_UP_TO_DATE_MESSAGE = 'This project is up to date.';
55

66
constructor(
7+
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
78
private $updateController: IUpdateController,
89
private $migrateController: IMigrateController,
910
private $options: IOptions,
@@ -13,15 +14,20 @@ export class UpdateCommand implements ICommand {
1314
}
1415

1516
public async execute(args: string[]): Promise<void> {
16-
await this.$updateController.update({projectDir: this.$projectData.projectDir, version: args[0], frameworkPath: this.$options.frameworkPath});
17+
await this.$updateController.update({ projectDir: this.$projectData.projectDir, version: args[0], frameworkPath: this.$options.frameworkPath });
1718
}
1819

1920
public async canExecute(args: string[]): Promise<boolean> {
20-
if (await this.$migrateController.shouldMigrate({projectDir: this.$projectData.projectDir})) {
21+
const shouldMigrate = await this.$migrateController.shouldMigrate({
22+
projectDir: this.$projectData.projectDir,
23+
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
24+
});
25+
26+
if (shouldMigrate) {
2127
this.$errors.failWithoutHelp(UpdateCommand.SHOULD_MIGRATE_PROJECT_MESSAGE);
2228
}
2329

24-
if (!await this.$updateController.shouldUpdate({projectDir:this.$projectData.projectDir, version: args[0]})) {
30+
if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) {
2531
this.$errors.failWithoutHelp(UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE);
2632
}
2733

0 commit comments

Comments
 (0)