From 58608c97eb01d18f416fb3fb8996274176060c00 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 24 May 2018 13:32:56 +0300 Subject: [PATCH 1/3] feat: Validate Java compiler version based on runtime version Update calls to `nativescript-doctor` package to pass projectDir where applicable. This allows the package to verify installed Java Compiler version against the project's Android runtime. This is required in case the installed Java version is 10 or above and the Androud runtime in the project is older than 4.1.0. In this case the user cannot build this application for Android, but have to update the Android runtime version or downgrade the Java version. --- lib/common | 2 +- lib/definitions/platform.d.ts | 2 +- lib/services/android-project-service.ts | 2 +- lib/services/doctor-service.ts | 10 +++++----- lib/services/ios-project-service.ts | 2 +- lib/services/platform-environment-requirements.ts | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/common b/lib/common index 77d58daa8e..fba05a71d4 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 77d58daa8e82825c8373b5404b17a87b2167e917 +Subproject commit fba05a71d43a878fe8547363237f1de9d871385f diff --git a/lib/definitions/platform.d.ts b/lib/definitions/platform.d.ts index b8d2a32cc2..15aba5c20f 100644 --- a/lib/definitions/platform.d.ts +++ b/lib/definitions/platform.d.ts @@ -381,5 +381,5 @@ interface IUpdateAppOptions extends IOptionalFilesToSync, IOptionalFilesToRemove } interface IPlatformEnvironmentRequirements { - checkEnvironmentRequirements(platform?: string): Promise; + checkEnvironmentRequirements(platform?: string, projectDir?: string): Promise; } \ No newline at end of file diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index 7157e0fdec..3567a47783 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -133,7 +133,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject this.validatePackageName(projectData.projectId); this.validateProjectName(projectData.projectName); - await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName); + await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName, projectData.projectDir); this.$androidToolsInfo.validateTargetSdk({ showWarningsAsErrors: true }); } diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index 514614833c..c200007451 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -17,10 +17,10 @@ class DoctorService implements IDoctorService { private $terminalSpinnerService: ITerminalSpinnerService, private $versionsService: IVersionsService) { } - public async printWarnings(configOptions?: { trackResult: boolean }): Promise { + public async printWarnings(configOptions?: { trackResult: boolean , projectDir?: string }): Promise { const infos = await this.$terminalSpinnerService.execute({ text: `Getting environment information ${EOL}` - }, () => doctor.getInfos()); + }, () => doctor.getInfos({ projectDir: configOptions && configOptions.projectDir })); const warnings = infos.filter(info => info.type === constants.WARNING_TYPE_NAME); const hasWarnings = warnings.length > 0; @@ -48,7 +48,7 @@ class DoctorService implements IDoctorService { this.$logger.error("Cannot get the latest versions information from npm. Please try again later."); } - await this.$injector.resolve("platformEnvironmentRequirements").checkEnvironmentRequirements(null); + await this.$injector.resolve("platformEnvironmentRequirements").checkEnvironmentRequirements(null, configOptions && configOptions.projectDir); } public async runSetupScript(): Promise { @@ -81,12 +81,12 @@ class DoctorService implements IDoctorService { }); } - public async canExecuteLocalBuild(platform?: string): Promise { + public async canExecuteLocalBuild(platform?: string, projectDir?: string): Promise { await this.$analyticsService.trackEventActionInGoogleAnalytics({ action: TrackActionNames.CheckLocalBuildSetup, additionalData: "Starting", }); - const infos = await doctor.getInfos({ platform }); + const infos = await doctor.getInfos({ platform, projectDir }); const warnings = this.filterInfosByType(infos, constants.WARNING_TYPE_NAME); const hasWarnings = warnings.length > 0; diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index a56a6c1961..6866df6f76 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -139,7 +139,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ return; } - await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName); + await this.$platformEnvironmentRequirements.checkEnvironmentRequirements(this.getPlatformData(projectData).normalizedPlatformName, projectData.projectDir); const xcodeBuildVersion = await this.getXcodeVersion(); if (helpers.versionCompare(xcodeBuildVersion, IOSProjectService.XCODEBUILD_MIN_VERSION) < 0) { diff --git a/lib/services/platform-environment-requirements.ts b/lib/services/platform-environment-requirements.ts index cfc1213c2f..e5b17199b2 100644 --- a/lib/services/platform-environment-requirements.ts +++ b/lib/services/platform-environment-requirements.ts @@ -30,7 +30,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ "deploy": "tns cloud deploy" }; - public async checkEnvironmentRequirements(platform?: string): Promise { + public async checkEnvironmentRequirements(platform?: string, projectDir?: string): Promise { if (process.env.NS_SKIP_ENV_CHECK) { await this.$analyticsService.trackEventActionInGoogleAnalytics({ action: TrackActionNames.CheckEnvironmentRequirements, @@ -39,7 +39,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ return true; } - const canExecute = await this.$doctorService.canExecuteLocalBuild(platform); + const canExecute = await this.$doctorService.canExecuteLocalBuild(platform, projectDir); if (!canExecute) { if (!isInteractive()) { await this.$analyticsService.trackEventActionInGoogleAnalytics({ @@ -71,7 +71,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ if (selectedOption === PlatformEnvironmentRequirements.LOCAL_SETUP_OPTION_NAME) { await this.$doctorService.runSetupScript(); - if (await this.$doctorService.canExecuteLocalBuild(platform)) { + if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir)) { return true; } @@ -102,7 +102,7 @@ export class PlatformEnvironmentRequirements implements IPlatformEnvironmentRequ if (selectedOption === PlatformEnvironmentRequirements.BOTH_CLOUD_SETUP_AND_LOCAL_SETUP_OPTION_NAME) { await this.processBothCloudBuildsAndSetupScript(); - if (await this.$doctorService.canExecuteLocalBuild(platform)) { + if (await this.$doctorService.canExecuteLocalBuild(platform, projectDir)) { return true; } From 52586e989c955258a4315eb6125f9f104fe8243b Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 24 May 2018 13:55:05 +0300 Subject: [PATCH 2/3] chore: Update nativescript-doctor to its rc version --- npm-shrinkwrap.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 595caf812c..67af81a633 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -3812,9 +3812,9 @@ "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==" }, "nativescript-doctor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/nativescript-doctor/-/nativescript-doctor-1.0.0.tgz", - "integrity": "sha512-QZ/hhDCeenIyVM3e9ly4xqldvsQwpQUv9R6Eqq7EXujysDrOyhRb2o59SbJ14uWRBYVKFILEvls+tqSWdc/wSw==", + "version": "1.1.0-rc.0", + "resolved": "https://registry.npmjs.org/nativescript-doctor/-/nativescript-doctor-1.1.0-rc.0.tgz", + "integrity": "sha1-2ABOL5lGgTHqE8+U8IhzS9j/XBU=", "requires": { "osenv": "0.1.3", "semver": "5.3.0", diff --git a/package.json b/package.json index bc5e4f541c..719596b1c9 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "minimatch": "3.0.2", "mkdirp": "0.5.1", "mute-stream": "0.0.5", - "nativescript-doctor": "1.0.0", + "nativescript-doctor": "1.1.0-rc.0", "open": "0.0.5", "ora": "2.0.0", "osenv": "0.1.3", From 58f465485b095e4656fde66efecbcaf5506743f3 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Fri, 25 May 2018 15:04:02 +0300 Subject: [PATCH 3/3] chore: Update nativescript-doctor to 1.1.0 --- npm-shrinkwrap.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 67af81a633..b42340ae95 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -3812,9 +3812,9 @@ "integrity": "sha512-Q29yeg9aFKwhLVdkTAejM/HvYG0Y1Am1+HUkFQGn5k2j8GS+v60TVmZh6nujpEAj/qql+wGUrlryO8bF+b1jEg==" }, "nativescript-doctor": { - "version": "1.1.0-rc.0", - "resolved": "https://registry.npmjs.org/nativescript-doctor/-/nativescript-doctor-1.1.0-rc.0.tgz", - "integrity": "sha1-2ABOL5lGgTHqE8+U8IhzS9j/XBU=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/nativescript-doctor/-/nativescript-doctor-1.1.0.tgz", + "integrity": "sha512-XmZO+6tLbiOGr/gLYuhmVhec0UPOSsShK/dG7LlEkiLOE7ew7LB/j/gPFAzS5I54jjudJ/qDK/cMvcZWS0TvBg==", "requires": { "osenv": "0.1.3", "semver": "5.3.0", diff --git a/package.json b/package.json index 719596b1c9..180e50cbaf 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "minimatch": "3.0.2", "mkdirp": "0.5.1", "mute-stream": "0.0.5", - "nativescript-doctor": "1.1.0-rc.0", + "nativescript-doctor": "1.1.0", "open": "0.0.5", "ora": "2.0.0", "osenv": "0.1.3",