diff --git a/lib/commands/build.ts b/lib/commands/build.ts index 6acdb2c8f0..c665231967 100644 --- a/lib/commands/build.ts +++ b/lib/commands/build.ts @@ -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); @@ -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 { @@ -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 { @@ -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 { @@ -122,7 +117,6 @@ export class BuildAndroidCommand extends BuildCommandBase implements ICommand { public async canExecute(args: string[]): Promise { 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) { diff --git a/lib/commands/debug.ts b/lib/commands/debug.ts index 3317b632df..f606d9b418 100644 --- a/lib/commands/debug.ts +++ b/lib/commands/debug.ts @@ -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, @@ -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; } diff --git a/lib/commands/deploy.ts b/lib/commands/deploy.ts index aa7f613e95..ae414976c6 100644 --- a/lib/commands/deploy.ts +++ b/lib/commands/deploy.ts @@ -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); @@ -31,7 +30,6 @@ export class DeployOnDeviceCommand extends ValidatePlatformCommandBase implement public async canExecute(args: string[]): Promise { this.$androidBundleValidatorHelper.validateNoAab(); - this.$bundleValidatorHelper.validate(this.$projectData); if (!args || !args.length || args.length > 1) { return false; } diff --git a/lib/commands/preview.ts b/lib/commands/preview.ts index a8bffb0bc4..f891b5fca9 100644 --- a/lib/commands/preview.ts +++ b/lib/commands/preview.ts @@ -2,7 +2,6 @@ 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, @@ -43,7 +42,7 @@ export class PreviewCommand implements ICommand { } await this.$networkConnectivityValidator.validate(); - this.$bundleValidatorHelper.validate(this.$projectData, PreviewCommand.MIN_SUPPORTED_WEBPACK_VERSION); + this.$bundleValidatorHelper.validate(this.$projectData, "1.0.0"); return true; } } diff --git a/lib/common/mobile/mobile-core/devices-service.ts b/lib/common/mobile/mobile-core/devices-service.ts index 4a139363a6..347f5d5c52 100644 --- a/lib/common/mobile/mobile-core/devices-service.ts +++ b/lib/common/mobile/mobile-core/devices-service.ts @@ -444,6 +444,7 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi } } catch (err) { err.deviceIdentifier = device.deviceInfo.identifier; + this.$logger.trace(`Error while executing action on device ${device.deviceInfo.identifier}. The error is ${err}`); errors.push(err); } } @@ -454,9 +455,9 @@ export class DevicesService extends EventEmitter implements Mobile.IDevicesServi preErrorMsg = "Multiple errors were thrown:" + EOL; } - const singleError = (new Error(`${preErrorMsg}${errors.map(e => e.message || e).join(EOL)}`)); - singleError.allErrors = errors; - throw singleError; + const errorMessage = `${preErrorMsg}${errors.map(e => e.message || e).join(EOL)}`; + const suppressCommandHelp = _.some(errors, (e: any) => e.suppressCommandHelp); + this.$errors.fail({ formatStr: errorMessage, suppressCommandHelp }); } return result; diff --git a/lib/controllers/prepare-controller.ts b/lib/controllers/prepare-controller.ts index 29b9be2b2a..402538101c 100644 --- a/lib/controllers/prepare-controller.ts +++ b/lib/controllers/prepare-controller.ts @@ -17,6 +17,7 @@ export class PrepareController extends EventEmitter { private persistedData: IFilesChangeEventData[] = []; constructor( + private $bundleValidatorHelper: IBundleValidatorHelper, private $platformController: IPlatformController, public $hooksService: IHooksService, private $logger: ILogger, @@ -32,12 +33,14 @@ export class PrepareController extends EventEmitter { @performanceLog() @hook("prepare") public async prepare(prepareData: IPrepareData): Promise { + const projectData = this.$projectDataService.getProjectData(prepareData.projectDir); + this.$bundleValidatorHelper.validate(projectData, "1.0.0"); + await this.$platformController.addPlatformIfNeeded(prepareData); this.$logger.info("Preparing project..."); let result = null; - const projectData = this.$projectDataService.getProjectData(prepareData.projectDir); const platformData = this.$platformsDataService.getPlatformData(prepareData.platform, projectData); if (prepareData.watch) { diff --git a/lib/helpers/livesync-command-helper.ts b/lib/helpers/livesync-command-helper.ts index ac58ac0976..ea2fbc1e5d 100644 --- a/lib/helpers/livesync-command-helper.ts +++ b/lib/helpers/livesync-command-helper.ts @@ -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, @@ -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, @@ -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; } diff --git a/lib/services/project-changes-service.ts b/lib/services/project-changes-service.ts index c539525cc7..a82a9a009c 100644 --- a/lib/services/project-changes-service.ts +++ b/lib/services/project-changes-service.ts @@ -1,7 +1,6 @@ import * as path from "path"; import { NativePlatformStatus, PACKAGE_JSON_FILE_NAME, APP_GRADLE_FILE_NAME, BUILD_XCCONFIG_FILE_NAME, PLATFORMS_DIR_NAME } from "../constants"; import { getHash, hook } from "../common/helpers"; -import { PrepareData } from "../data/prepare-data"; const prepareInfoFileName = ".nsprepareinfo"; @@ -51,7 +50,7 @@ export class ProjectChangesService implements IProjectChangesService { } @hook("checkForChanges") - public async checkForChanges(platformData: IPlatformData, projectData: IProjectData, prepareData: PrepareData): Promise { + public async checkForChanges(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { this._changesInfo = new ProjectChangesInfo(); const isNewPrepareInfo = await this.ensurePrepareInfo(platformData, projectData, prepareData); if (!isNewPrepareInfo) { @@ -158,7 +157,7 @@ export class ProjectChangesService implements IProjectChangesService { await this.savePrepareInfo(platformData, projectData, null); } - private async ensurePrepareInfo(platformData: IPlatformData, projectData: IProjectData, prepareData: PrepareData): Promise { + private async ensurePrepareInfo(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { this._prepareInfo = this.getPrepareInfo(platformData); if (this._prepareInfo) { const prepareInfoFile = path.join(platformData.projectRoot, prepareInfoFileName); diff --git a/test/controllers/prepare-controller.ts b/test/controllers/prepare-controller.ts index ef0b4a0fd0..78b4af2d43 100644 --- a/test/controllers/prepare-controller.ts +++ b/test/controllers/prepare-controller.ts @@ -54,6 +54,10 @@ function createTestInjector(data: { hasNativeChanges: boolean }): IInjector { isFileInIgnoreList: () => false }); + injector.register("bundleValidatorHelper", { + validate: () => ({}) + }); + const prepareController: PrepareController = injector.resolve("prepareController"); prepareController.emit = (eventName: string, eventData: any) => { emittedEventNames.push(eventName);