From dfff05aad3e160143822f496114384b28aabd48a Mon Sep 17 00:00:00 2001 From: Rob Lauer Date: Fri, 15 Dec 2017 01:29:20 -0600 Subject: [PATCH 1/4] minor grammatical update (#3267) --- lib/services/subscription-service.ts | 2 +- test/services/subscription-service.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/subscription-service.ts b/lib/services/subscription-service.ts index 73778df593..e1302d865a 100644 --- a/lib/services/subscription-service.ts +++ b/lib/services/subscription-service.ts @@ -11,7 +11,7 @@ export class SubscriptionService implements ISubscriptionService { public async subscribeForNewsletter(): Promise { if (await this.shouldAskForEmail()) { - this.$logger.out("Leave your e-mail address here to subscribe for NativeScript newsletter and product updates, tips and tricks:"); + this.$logger.out("Enter your e-mail address to subscribe to the NativeScript Newsletter and hear about product updates, tips & tricks, and community happenings:"); const email = await this.getEmail("(press Enter for blank)"); await this.$userSettingsService.saveSetting("EMAIL_REGISTERED", true); await this.sendEmail(email); diff --git a/test/services/subscription-service.ts b/test/services/subscription-service.ts index c9fc7548e6..6223e531a9 100644 --- a/test/services/subscription-service.ts +++ b/test/services/subscription-service.ts @@ -155,7 +155,7 @@ describe("subscriptionService", () => { await subscriptionService.subscribeForNewsletter(); - assert.equal(loggerOutput, "Leave your e-mail address here to subscribe for NativeScript newsletter and product updates, tips and tricks:"); + assert.equal(loggerOutput, "Enter your e-mail address to subscribe to the NativeScript Newsletter and hear about product updates, tips & tricks, and community happenings:"); }); const expectedMessageInPrompter = "(press Enter for blank)"; From 3d7ed15239248ef70e63614239fdce27baa1dd57 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Wed, 3 Jan 2018 13:29:51 +0200 Subject: [PATCH 2/4] Add check for JAVA 9 (#3294) * Add check for JAVA 9 Currently Gradle cannot work with JAVA 9, so detect if it has been used and break the build for Android. Also the check will print warning when `tns doctor` is called. Also update submodule, where the following change is applied: Fix detection of Javac version The command `javac -version` prints result to stderr when JAVA 8 is used and to stdout when JAVA 9 is used. Current check in CLI uses the stderr output, so when JAVA 9 is installed it fails to detect the correct version. In order to support both JAVA 8 and JAVA 9, capture both stdout and stderr and get the version from there. Also remove unneeded check for Java version - we care about JAVA Compiler, which is included in JDK. * Handle case when Javac version is a single number (9 for example) In some cases javac version is a single number, for example 9. In this case our validation fails to detect the correct version and to check if we support this version. In order to resolve this issue, use the `appendZeroesToVersion` method in order to make the versin semver valid. Change the return type of `validateJavacVersion` method - it does not require to return a Promise. Add unit tests for `validateJavacVersion` method. --- lib/android-tools-info.ts | 17 ++-- lib/common | 2 +- lib/declarations.d.ts | 2 +- lib/services/android-project-service.ts | 2 +- lib/services/doctor-service.ts | 4 +- test/android-tools-info.ts | 112 ++++++++++++++++++++++++ test/stubs.ts | 2 +- 7 files changed, 130 insertions(+), 11 deletions(-) create mode 100644 test/android-tools-info.ts diff --git a/lib/android-tools-info.ts b/lib/android-tools-info.ts index 020b1b3dcd..9d92d71969 100644 --- a/lib/android-tools-info.ts +++ b/lib/android-tools-info.ts @@ -2,6 +2,7 @@ import * as path from "path"; import * as semver from "semver"; import { EOL } from "os"; import { cache } from "./common/decorators"; +import { appendZeroesToVersion } from './common/helpers'; export class AndroidToolsInfo implements IAndroidToolsInfo { private static ANDROID_TARGET_PREFIX = "android"; @@ -10,6 +11,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { private static REQUIRED_BUILD_TOOLS_RANGE_PREFIX = ">=23"; private static VERSION_REGEX = /((\d+\.){2}\d+)/; private static MIN_JAVA_VERSION = "1.8.0"; + private static MAX_JAVA_VERSION = "1.9.0"; private showWarningsAsErrors: boolean; private toolsInfo: IAndroidToolsInfoData; @@ -101,7 +103,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { return detectedErrors || !isAndroidHomeValid; } - public async validateJavacVersion(installedJavaVersion: string, options?: { showWarningsAsErrors: boolean }): Promise { + public validateJavacVersion(installedJavacVersion: string, options?: { showWarningsAsErrors: boolean }): boolean { let hasProblemWithJavaVersion = false; if (options) { this.showWarningsAsErrors = options.showWarningsAsErrors; @@ -110,11 +112,16 @@ export class AndroidToolsInfo implements IAndroidToolsInfo { const additionalMessage = "You will not be able to build your projects for Android." + EOL + "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL + " described in " + this.$staticConfig.SYS_REQUIREMENTS_LINK; - const matchingVersion = (installedJavaVersion || "").match(AndroidToolsInfo.VERSION_REGEX); - if (matchingVersion && matchingVersion[1]) { - if (semver.lt(matchingVersion[1], AndroidToolsInfo.MIN_JAVA_VERSION)) { + + const matchingVersion = appendZeroesToVersion(installedJavacVersion || "", 3).match(AndroidToolsInfo.VERSION_REGEX); + const installedJavaCompilerVersion = matchingVersion && matchingVersion[1]; + if (installedJavaCompilerVersion) { + if (semver.lt(installedJavaCompilerVersion, AndroidToolsInfo.MIN_JAVA_VERSION)) { + hasProblemWithJavaVersion = true; + this.printMessage(`Javac version ${installedJavacVersion} is not supported. You have to install at least ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage); + } else if (semver.gte(installedJavaCompilerVersion, AndroidToolsInfo.MAX_JAVA_VERSION)) { hasProblemWithJavaVersion = true; - this.printMessage(`Javac version ${installedJavaVersion} is not supported. You have to install at least ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage); + this.printMessage(`Javac version ${installedJavacVersion} is not supported. You have to install version ${AndroidToolsInfo.MIN_JAVA_VERSION}.`, additionalMessage); } } else { hasProblemWithJavaVersion = true; diff --git a/lib/common b/lib/common index 0d981032ba..d3fa315437 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 0d981032bad65fcbf429ac1e81b89f99442ca2ff +Subproject commit d3fa31543765bbd6c95b96464c421659fc13d8aa diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index dcf4388e43..9d9f8b1308 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -490,7 +490,7 @@ interface IAndroidToolsInfo { * @param {any} options Defines if the warning messages should treated as error. * @return {boolean} True if there are detected issues, false otherwise. */ - validateJavacVersion(installedJavaVersion: string, options?: { showWarningsAsErrors: boolean }): Promise; + validateJavacVersion(installedJavaVersion: string, options?: { showWarningsAsErrors: boolean }): boolean; /** * Validates if ANDROID_HOME environment variable is set correctly. diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index 95d56fa403..73dfa4c7bd 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -138,7 +138,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject const javaCompilerVersion = await this.$sysInfo.getJavaCompilerVersion(); - await this.$androidToolsInfo.validateJavacVersion(javaCompilerVersion, { showWarningsAsErrors: true }); + this.$androidToolsInfo.validateJavacVersion(javaCompilerVersion, { showWarningsAsErrors: true }); await this.$androidToolsInfo.validateInfo({ showWarningsAsErrors: true, validateTargetSdk: true }); } diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index a03a52a888..e71a825a98 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -104,9 +104,9 @@ class DoctorService implements IDoctorService { } const androidToolsIssues = this.$androidToolsInfo.validateInfo(); - const javaVersionIssue = await this.$androidToolsInfo.validateJavacVersion(sysInfo.javacVersion); + const javaCompilerVersionIssue = this.$androidToolsInfo.validateJavacVersion(sysInfo.javacVersion); const pythonIssues = await this.validatePythonPackages(); - const doctorResult = result || androidToolsIssues || javaVersionIssue || pythonIssues; + const doctorResult = result || androidToolsIssues || javaCompilerVersionIssue || pythonIssues; if (!configOptions || configOptions.trackResult) { await this.$analyticsService.track("DoctorEnvironmentSetup", doctorResult ? "incorrect" : "correct"); diff --git a/test/android-tools-info.ts b/test/android-tools-info.ts new file mode 100644 index 0000000000..f548462455 --- /dev/null +++ b/test/android-tools-info.ts @@ -0,0 +1,112 @@ +import { Yok } from "../lib/common/yok"; +import { AndroidToolsInfo } from "../lib/android-tools-info"; +import { EOL } from "os"; +import { format } from "util"; +import { assert } from "chai"; + +interface ITestData { + javacVersion: string; + expectedResult: boolean; + warnings?: string[]; +} + +describe("androidToolsInfo", () => { + let loggedWarnings: string[] = []; + let loggedMarkdownMessages: string[] = []; + const sysRequirementsLink = ""; + + const additionalMsg = "You will not be able to build your projects for Android." + EOL + + "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL + + " described in " + sysRequirementsLink; + + beforeEach(() => { + loggedWarnings = []; + loggedMarkdownMessages = []; + }); + + const createTestInjector = (): IInjector => { + const testInjector = new Yok(); + testInjector.register("childProcess", {}); + testInjector.register("errors", { + failWithoutHelp: (message: string, ...args: any[]): any => { + const loggedError = format(message, args); + throw new Error(loggedError); + } + }); + testInjector.register("fs", {}); + testInjector.register("hostInfo", {}); + testInjector.register("logger", { + warn: (...args: string[]): void => { + loggedWarnings.push(format.apply(null, args)); + }, + + printMarkdown: (...args: string[]): void => { + loggedMarkdownMessages.push(format.apply(null, args)); + } + }); + testInjector.register("options", {}); + testInjector.register("staticConfig", { + SYS_REQUIREMENTS_LINK: sysRequirementsLink + }); + return testInjector; + }; + + describe("validateJavacVersion", () => { + const testData: ITestData[] = [ + { + javacVersion: "1.8.0", + expectedResult: false + }, + { + javacVersion: "1.8.0_152", + expectedResult: false + }, + { + javacVersion: "9", + expectedResult: true, + warnings: ["Javac version 9 is not supported. You have to install version 1.8.0."] + }, + { + javacVersion: "9.0.1", + expectedResult: true, + warnings: ["Javac version 9.0.1 is not supported. You have to install version 1.8.0."] + }, + { + javacVersion: "1.7.0", + expectedResult: true, + warnings: ["Javac version 1.7.0 is not supported. You have to install at least 1.8.0."] + }, + { + javacVersion: "1.7.0_132", + expectedResult: true, + warnings: ["Javac version 1.7.0_132 is not supported. You have to install at least 1.8.0."] + }, + { + javacVersion: null, + expectedResult: true, + warnings: ["Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable."] + } + ]; + + _.each(testData, ({ javacVersion, expectedResult, warnings }) => { + it(`returns ${expectedResult} when version is ${javacVersion}`, () => { + const testInjector = createTestInjector(); + const androidToolsInfo = testInjector.resolve(AndroidToolsInfo); + assert.deepEqual(androidToolsInfo.validateJavacVersion(javacVersion), expectedResult); + if (warnings && warnings.length) { + assert.deepEqual(loggedWarnings, warnings); + assert.deepEqual(loggedMarkdownMessages, [additionalMsg]); + } else { + assert.equal(loggedWarnings.length, 0); + assert.equal(loggedMarkdownMessages.length, 0); + } + }); + }); + + it("throws error when passing showWarningsAsErrors to true and javac is not installed", () => { + const testInjector = createTestInjector(); + const androidToolsInfo = testInjector.resolve(AndroidToolsInfo); + assert.throws(() => androidToolsInfo.validateJavacVersion(null, { showWarningsAsErrors: true }), "Error executing command 'javac'. Make sure you have installed The Java Development Kit (JDK) and set JAVA_HOME environment variable."); + }); + }); +}); diff --git a/test/stubs.ts b/test/stubs.ts index 2f97a9f7f4..2e32020b30 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -532,7 +532,7 @@ export class AndroidToolsInfoStub implements IAndroidToolsInfo { return true; } - public async validateJavacVersion(installedJavaVersion: string, options?: { showWarningsAsErrors: boolean }): Promise { + public validateJavacVersion(installedJavaVersion: string, options?: { showWarningsAsErrors: boolean }): boolean { return true; } From 59de9b93d82e832161a9a3480d179ea54a7d8cf4 Mon Sep 17 00:00:00 2001 From: miroslavaivanova Date: Thu, 4 Jan 2018 13:08:31 +0200 Subject: [PATCH 3/4] release notes 3.4.0 (#3297) * release notes 3.4.0 * add implemented item * remove a fixed issue from changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8adca28f11..753b221f10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,20 @@ NativeScript CLI Changelog ================ +3.4.0 (2017, December 20) +== + +### New +* [Implemented #3171](https://github.com/NativeScript/nativescript-cli/issues/3171): Make --chrome the default for tns debug ios + +### Fixed +* [Fixed #3268](https://github.com/NativeScript/nativescript-cli/issues/3268): tns run android - EMFILE: too many open files +* [Fixed #3202](https://github.com/NativeScript/nativescript-cli/issues/3202): `tns update ` does not work +* [Fixed #3187](https://github.com/NativeScript/nativescript-cli/issues/3187): Android tns debug, crashing when there is a response from server + 3.3.1 (2017, November 17) +== + ### Fixed * [Fixed #3164](https://github.com/NativeScript/nativescript-cli/issues/3164): `npm run build-*-bundle` gets stuck at nativescript-unit-test-runner hook. * [Fixed #3182](https://github.com/NativeScript/nativescript-cli/issues/3182): CLI fails when unable to start Analytics Broker process. From d86db21a917e0a69a5e8ef4fa4b6523b3c61b7d8 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Tue, 9 Jan 2018 09:05:48 +0200 Subject: [PATCH 4/4] Update submodule to release branch --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index d3fa315437..671e5d3d22 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit d3fa31543765bbd6c95b96464c421659fc13d8aa +Subproject commit 671e5d3d220012236714e28438e76161051fe3d9