Skip to content

feat: validate the version of nativescript-dev-webpack plugin on every command #4796

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 6 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 2 additions & 8 deletions lib/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
protected $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
protected $buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
private $bundleValidatorHelper: IBundleValidatorHelper,
private $buildDataService: IBuildDataService,
protected $logger: ILogger) {
super($options, $platformsDataService, $platformValidationService, $projectData);
Expand All @@ -33,8 +32,6 @@ export abstract class BuildCommandBase extends ValidatePlatformCommandBase {
if (!this.$platformValidationService.isPlatformSupportedForOS(platform, this.$projectData)) {
this.$errors.fail(`Applications for platform ${platform} can not be built on this OS`);
}

this.$bundleValidatorHelper.validate(this.$projectData);
}

protected async validateArgs(args: string[], platform: string): Promise<ICanExecuteCommandOutput> {
Expand Down Expand Up @@ -65,10 +62,9 @@ export class BuildIosCommand extends BuildCommandBase implements ICommand {
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
$bundleValidatorHelper: IBundleValidatorHelper,
$logger: ILogger,
$buildDataService: IBuildDataService) {
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
super($options, $errors, $projectData, $platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
}

public async execute(args: string[]): Promise<void> {
Expand Down Expand Up @@ -101,11 +97,10 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand {
$devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
$buildController: IBuildController,
$platformValidationService: IPlatformValidationService,
$bundleValidatorHelper: IBundleValidatorHelper,
protected $androidBundleValidatorHelper: IAndroidBundleValidatorHelper,
$buildDataService: IBuildDataService,
protected $logger: ILogger) {
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $bundleValidatorHelper, $buildDataService, $logger);
super($options, $errors, $projectData, platformsDataService, $devicePlatformsConstants, $buildController, $platformValidationService, $buildDataService, $logger);
}

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

public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
const platform = this.$devicePlatformsConstants.Android;
super.validatePlatform(platform);
this.$androidBundleValidatorHelper.validateRuntimeVersion(this.$projectData);
let result = await super.canExecuteCommandBase(platform, { notConfiguredEnvOptions: { hideSyncToPreviewAppOption: true } });
if (result.canExecute) {
Expand Down
5 changes: 0 additions & 5 deletions lib/commands/debug.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { cache } from "../common/decorators";
import { ValidatePlatformCommandBase } from "./command-base";
import { LiveSyncCommandHelper } from "../helpers/livesync-command-helper";

export class DebugPlatformCommand extends ValidatePlatformCommandBase implements ICommand {
public allowedParameters: ICommandParameter[] = [];

constructor(private platform: string,
private $bundleValidatorHelper: IBundleValidatorHelper,
protected $devicesService: Mobile.IDevicesService,
$platformValidationService: IPlatformValidationService,
$projectData: IProjectData,
Expand Down Expand Up @@ -64,9 +62,6 @@ export class DebugPlatformCommand extends ValidatePlatformCommandBase implements
this.$errors.fail("--release flag is not applicable to this command");
}

const minSupportedWebpackVersion = this.$options.hmr ? LiveSyncCommandHelper.MIN_SUPPORTED_WEBPACK_VERSION_WITH_HMR : null;
this.$bundleValidatorHelper.validate(this.$projectData, minSupportedWebpackVersion);

const result = await super.canExecuteCommandBase(this.platform, { validateOptions: true, notConfiguredEnvOptions: { hideCloudBuildOption: true, hideSyncToPreviewAppOption: true } });
return result;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class DeployOnDeviceCommand extends ValidatePlatformCommandBase implement
private $errors: IErrors,
private $mobileHelper: Mobile.IMobileHelper,
$platformsDataService: IPlatformsDataService,
private $bundleValidatorHelper: IBundleValidatorHelper,
private $deployCommandHelper: DeployCommandHelper,
private $androidBundleValidatorHelper: IAndroidBundleValidatorHelper) {
super($options, $platformsDataService, $platformValidationService, $projectData);
Expand All @@ -31,7 +30,6 @@ export class DeployOnDeviceCommand extends ValidatePlatformCommandBase implement

public async canExecute(args: string[]): Promise<boolean | ICanExecuteCommandOutput> {
this.$androidBundleValidatorHelper.validateNoAab();
this.$bundleValidatorHelper.validate(this.$projectData);
if (!args || !args.length || args.length > 1) {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions lib/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { DEVICE_LOG_EVENT_NAME } from "../common/constants";

export class PreviewCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
private static MIN_SUPPORTED_WEBPACK_VERSION = "0.17.0";

constructor(private $analyticsService: IAnalyticsService,
private $bundleValidatorHelper: IBundleValidatorHelper,
private $errors: IErrors,
private $logger: ILogger,
private $previewAppController: IPreviewAppController,
Expand Down Expand Up @@ -43,7 +41,6 @@ export class PreviewCommand implements ICommand {
}

await this.$networkConnectivityValidator.validate();
this.$bundleValidatorHelper.validate(this.$projectData, PreviewCommand.MIN_SUPPORTED_WEBPACK_VERSION);
return true;
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/common/services/commands-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export class CommandsService implements ICommandsService {
private $helpService: IHelpService,
private $extensibilityService: IExtensibilityService,
private $optionsTracker: IOptionsTracker,
private $projectDataService: IProjectDataService) {
private $projectDataService: IProjectDataService,
private $bundleValidatorHelper: IBundleValidatorHelper) {
}

public allCommands(opts: { includeDevCommands: boolean }): string[] {
Expand Down Expand Up @@ -115,6 +116,8 @@ export class CommandsService implements ICommandsService {

const dashedOptions = command ? command.dashedOptions : null;
this.$options.validateOptions(dashedOptions, projectData);

this.$bundleValidatorHelper.validate(projectData, "1.0.0");
}

return this.canExecuteCommand(commandName, commandArguments);
Expand Down
6 changes: 0 additions & 6 deletions lib/helpers/livesync-command-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { RunOnDeviceEvents } from "../constants";
import { DeployController } from "../controllers/deploy-controller";

export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
public static MIN_SUPPORTED_WEBPACK_VERSION_WITH_HMR = "0.17.0";

constructor(
private $buildDataService: IBuildDataService,
private $projectData: IProjectData,
Expand All @@ -15,7 +13,6 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
private $injector: IInjector,
private $buildController: IBuildController,
private $analyticsService: IAnalyticsService,
private $bundleValidatorHelper: IBundleValidatorHelper,
private $errors: IErrors,
private $iOSSimulatorLogProvider: Mobile.IiOSSimulatorLogProvider,
private $cleanupService: ICleanupService,
Expand Down Expand Up @@ -133,9 +130,6 @@ export class LiveSyncCommandHelper implements ILiveSyncCommandHelper {
result[availablePlatform.toLowerCase()] = validateOutput;
}

const minSupportedWebpackVersion = this.$options.hmr ? LiveSyncCommandHelper.MIN_SUPPORTED_WEBPACK_VERSION_WITH_HMR : null;
this.$bundleValidatorHelper.validate(this.$projectData, minSupportedWebpackVersion);

return result;
}

Expand Down