Skip to content

fix: migrate validation issues #4834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
$platformValidationService: IPlatformValidationService,
private $buildDataService: IBuildDataService,
protected $logger: ILogger) {
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
}

public dashedOptions = {
Expand Down Expand Up @@ -65,16 +65,16 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
$logger: ILogger,
$buildDataService: IBuildDataService,
private $migrateController: IMigrateController) {
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
}

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

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

super.validatePlatform(platform);

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

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

public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
const platform = this.$devicePlatformsConstants.Android;
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [platform] });
this.$androidBundleValidatorHelper.validateRuntimeVersion(this.$projectData);
let result = await super.canExecuteCommandBase(platform, { notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true } });
if (result.canExecute) {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
}

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

this.$androidBundleValidatorHelper.validateNoAab();

Expand Down
11 changes: 9 additions & 2 deletions lib/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@ export class MigrateCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];

constructor(
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $migrateController: IMigrateController,
private $projectData: IProjectData,
private $errors: IErrors) {
this.$projectData.initializeProjectData();
}

public async execute(args: string[]): Promise<void> {
await this.$migrateController.migrate({ projectDir: this.$projectData.projectDir });
await this.$migrateController.migrate({
projectDir: this.$projectData.projectDir,
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
});
}

public async canExecute(args: string[]): Promise<boolean> {
const shouldMigrateResult = await this.$migrateController.shouldMigrate({ projectDir: this.$projectData.projectDir });
const shouldMigrateResult = await this.$migrateController.shouldMigrate({
projectDir: this.$projectData.projectDir,
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
});

if (!shouldMigrateResult) {
this.$errors.failWithoutHelp('Project is compatible with NativeScript "v6.0.0". To get the latest NativesScript packages execute "tns update".');
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export class PrepareCommand extends ValidatePlatformCommandBase implements IComm
$platformsDataService: IPlatformsDataService,
private $prepareDataService: PrepareDataService,
private $migrateController: IMigrateController) {
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
super($options, $platformsDataService, $platformValidationService, $projectData);
this.$projectData.initializeProjectData();
}

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

public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });
const platform = args[0];
const result = await this.$platformCommandParameter.validate(platform) &&
await this.$platformValidationService.validateOptions(this.$options.provision, this.$options.teamId, this.$projectData, platform);
await this.$migrateController.validate({ projectDir: this.$projectData.projectDir, platforms: [platform] });
if (!result) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class PreviewCommand implements ICommand {
this.$errors.fail(`The arguments '${args.join(" ")}' are not valid for the preview command.`);
}

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

await this.$networkConnectivityValidator.validate();
return true;
Expand Down
10 changes: 4 additions & 6 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@ export class RunCommandBase implements ICommand {
this.$errors.fail(ERROR_NO_VALID_SUBCOMMAND_FORMAT, "run");
}

await this.$migrateController.validate({ projectDir: this.$projectData.projectDir });

this.$androidBundleValidatorHelper.validateNoAab();

this.$projectData.initializeProjectData();
this.platform = args[0] || this.platform;

if (!this.platform && !this.$hostInfo.isDarwin) {
this.platform = this.$devicePlatformsConstants.Android;
}

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

return true;
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ abstract class TestCommandBase {
devices = await this.$liveSyncCommandHelper.getDeviceInstances(this.platform);
}

if (!this.$options.env) { this.$options.env = { }; }
if (!this.$options.env) { this.$options.env = {}; }
this.$options.env.unitTesting = true;

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

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

this.$projectData.initializeProjectData();
this.$analyticsService.setShouldDispose(this.$options.justlaunch || !this.$options.watch);
Expand Down
12 changes: 9 additions & 3 deletions lib/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export class UpdateCommand implements ICommand {
public static readonly PROJECT_UP_TO_DATE_MESSAGE = 'This project is up to date.';

constructor(
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
private $updateController: IUpdateController,
private $migrateController: IMigrateController,
private $options: IOptions,
Expand All @@ -13,15 +14,20 @@ export class UpdateCommand implements ICommand {
}

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

public async canExecute(args: string[]): Promise<boolean> {
if (await this.$migrateController.shouldMigrate({projectDir: this.$projectData.projectDir})) {
const shouldMigrate = await this.$migrateController.shouldMigrate({
projectDir: this.$projectData.projectDir,
platforms: [this.$devicePlatformsConstants.Android, this.$devicePlatformsConstants.iOS]
});

if (shouldMigrate) {
this.$errors.failWithoutHelp(UpdateCommand.SHOULD_MIGRATE_PROJECT_MESSAGE);
}

if (!await this.$updateController.shouldUpdate({projectDir:this.$projectData.projectDir, version: args[0]})) {
if (!await this.$updateController.shouldUpdate({ projectDir: this.$projectData.projectDir, version: args[0] })) {
this.$errors.failWithoutHelp(UpdateCommand.PROJECT_UP_TO_DATE_MESSAGE);
}

Expand Down
Loading