From 2501c5583b2190a90e47c902814bcf3864c92e26 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Tue, 17 Dec 2019 11:16:46 +0200 Subject: [PATCH 01/10] chore: generate 6.3.0 changelog --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18aa3ae739..7cca5c4053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ NativeScript CLI Changelog ================ + +6.3.0 (2019, December 17) +=== + +### New + +* [Implemented #5128](https://github.com/NativeScript/nativescript-cli/issues/5128): Support for node v13 +* [Implemented #5155](https://github.com/NativeScript/nativescript-cli/issues/5155): Improve transition from tns preview to tns run +* [Implemented #5180](https://github.com/NativeScript/nativescript-cli/issues/5180): Cache the result of environment checks + +### Fixed + +* [Fixed #4982](https://github.com/NativeScript/nativescript-cli/issues/4982): `tns deploy` does not verify if the project should be migrated +* [Fixed #5069](https://github.com/NativeScript/nativescript-cli/issues/5069): Android API 29 emulator error +* [Fixed #5113](https://github.com/NativeScript/nativescript-cli/issues/5113): tns test init page does not list frameworks properly. +* [Fixed #5115](https://github.com/NativeScript/nativescript-cli/issues/5115): tns update command doesn't work in some plugins' demo apps +* [Fixed #5149](https://github.com/NativeScript/nativescript-cli/issues/5149): `tns update` should handle scoped packages +* [Fixed #5159](https://github.com/NativeScript/nativescript-cli/issues/5159): applyPluginsCocoaPods fails on case sensitive volumes +* [Fixed #5173](https://github.com/NativeScript/nativescript-cli/issues/5173): `--justlaunch` flag enables HMR + 6.2.2 (2019, November 22) == From e94fa816533ce7709655303bba7e56dbd95efbec Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Mon, 6 Jan 2020 16:17:14 +0200 Subject: [PATCH 02/10] fix: `tns info` should work with scoped modules Currently the `tns info` command fails when executed inside application in which `tns-core-modules` package is not available as dependency. This may happen in case you use only `@nativescript/core` package. The problem is that CLI is trying to read the package.json of the `/node_modules/tns-core-modules` and this operation fails. To fix this, add checks for both `tns-core-modules` and `@nativescript/core` packages. Warnings/information will be shown only for the package used in package.json, i.e. in case you use `tns-core-modules`, we'll show information only for it. --- lib/declarations.d.ts | 6 ++--- lib/services/versions-service.ts | 39 ++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/lib/declarations.d.ts b/lib/declarations.d.ts index 71c137847e..7afd8d6e9b 100644 --- a/lib/declarations.d.ts +++ b/lib/declarations.d.ts @@ -798,10 +798,10 @@ interface IVersionsService { getNativescriptCliVersion(): Promise; /** - * Gets version information about tns-core-modules. - * @return {Promise} The version information. + * Gets version information about tns-core-modules and @nativescript/core packages. + * @return {Promise} The version information. */ - getTnsCoreModulesVersion(): Promise; + getTnsCoreModulesVersion(): Promise; /** * Gets versions information about nativescript runtimes. diff --git a/lib/services/versions-service.ts b/lib/services/versions-service.ts index 9f5ef644a2..865e4a8652 100644 --- a/lib/services/versions-service.ts +++ b/lib/services/versions-service.ts @@ -37,26 +37,51 @@ class VersionsService implements IVersionsService { }; } - public async getTnsCoreModulesVersion(): Promise { + public async getTnsCoreModulesVersion(): Promise { const latestTnsCoreModulesVersion = await this.$packageInstallationManager.getLatestVersion(constants.TNS_CORE_MODULES_NAME); const nativescriptCoreModulesInfo: IVersionInformation = { componentName: constants.TNS_CORE_MODULES_NAME, latestVersion: latestTnsCoreModulesVersion }; + const versionInformations: IVersionInformation[] = []; + if (this.projectData) { const nodeModulesPath = path.join(this.projectData.projectDir, constants.NODE_MODULES_FOLDER_NAME); + const scopedPackagePath = path.join(nodeModulesPath, constants.SCOPED_TNS_CORE_MODULES); const tnsCoreModulesPath = path.join(nodeModulesPath, constants.TNS_CORE_MODULES_NAME); + + const dependsOnNonScopedPackage = !!this.projectData.dependencies[constants.TNS_CORE_MODULES_NAME]; + const dependsOnScopedPackage = !!this.projectData.dependencies[constants.SCOPED_TNS_CORE_MODULES]; + + // ensure the dependencies are installed, so we can get their actual versions from node_modules if (!this.$fs.exists(nodeModulesPath) || - !this.$fs.exists(tnsCoreModulesPath)) { + (dependsOnNonScopedPackage && !this.$fs.exists(tnsCoreModulesPath)) || + (dependsOnScopedPackage && !this.$fs.exists(scopedPackagePath))) { await this.$pluginsService.ensureAllDependenciesAreInstalled(this.projectData); } - const currentTnsCoreModulesVersion = this.$fs.readJson(path.join(tnsCoreModulesPath, constants.PACKAGE_JSON_FILE_NAME)).version; - nativescriptCoreModulesInfo.currentVersion = currentTnsCoreModulesVersion; + if (dependsOnNonScopedPackage && this.$fs.exists(tnsCoreModulesPath)) { + const currentTnsCoreModulesVersion = this.$fs.readJson(path.join(tnsCoreModulesPath, constants.PACKAGE_JSON_FILE_NAME)).version; + nativescriptCoreModulesInfo.currentVersion = currentTnsCoreModulesVersion; + versionInformations.push(nativescriptCoreModulesInfo); + } + + if (dependsOnScopedPackage && this.$fs.exists(scopedPackagePath)) { + const scopedModulesInformation: IVersionInformation = { + componentName: constants.SCOPED_TNS_CORE_MODULES, + latestVersion: await this.$packageInstallationManager.getLatestVersion(constants.SCOPED_TNS_CORE_MODULES) + }; + + const currentScopedPackageVersion = this.$fs.readJson(path.join(scopedPackagePath, constants.PACKAGE_JSON_FILE_NAME)).version; + scopedModulesInformation.currentVersion = currentScopedPackageVersion; + versionInformations.push(scopedModulesInformation); + } + } else { + versionInformations.push(nativescriptCoreModulesInfo); } - return nativescriptCoreModulesInfo; + return versionInformations; } public async getRuntimesVersions(): Promise { @@ -101,9 +126,9 @@ class VersionsService implements IVersionsService { } if (this.projectData) { - const nativescriptCoreModulesInformation: IVersionInformation = await this.getTnsCoreModulesVersion(); + const nativescriptCoreModulesInformation: IVersionInformation[] = await this.getTnsCoreModulesVersion(); if (nativescriptCoreModulesInformation) { - allComponents.push(nativescriptCoreModulesInformation); + allComponents.push(...nativescriptCoreModulesInformation); } const runtimesVersions: IVersionInformation[] = await this.getRuntimesVersions(); From 448e2c6bb61211b9e79cd6d70be19206b6336ce5 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Tue, 7 Jan 2020 12:47:14 +0200 Subject: [PATCH 03/10] release: cut 6.3.1 release --- CHANGELOG.md | 8 ++++++++ npm-shrinkwrap.json | 2 +- package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cca5c4053..c69e10bd6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ NativeScript CLI Changelog ================ +6.3.1 (2020, January 7) +=== + +### Fixed + +* [Fixed #5192](https://github.com/NativeScript/nativescript-cli/issues/5192): `tns info` command does not work with @nativescript/core + + 6.3.0 (2019, December 17) === diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index f39f776b37..914a1c5f07 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "6.3.0", + "version": "6.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6138919847..672fa8599d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "6.3.0", + "version": "6.3.1", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": { From c2aaed3d15c56c1428613d5607465379b9665b09 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 9 Jan 2020 10:10:06 +0200 Subject: [PATCH 04/10] chore: set release version to 6.3.2 --- npm-shrinkwrap.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 914a1c5f07..349795898d 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "6.3.1", + "version": "6.3.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 672fa8599d..d4c91177bb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "6.3.1", + "version": "6.3.2", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": { From d6a59ce6c28046920a63f9f49ccafbc71356be7e Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 9 Jan 2020 10:10:10 +0200 Subject: [PATCH 05/10] fix: emulator 29 is not started by default In case you have emulator with API Level 29 and other older emulators, CLI should run the latest available (29), but it doesn't. The problem is in the parsing of the string version - '9.0.0' is always newer than '10.0.0' which corresponds to API level 29. Fix the parsing, so now `tns run android` will correctly start latest available emulator in case there's nothing running. --- lib/common/mobile/android/android-emulator-services.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/common/mobile/android/android-emulator-services.ts b/lib/common/mobile/android/android-emulator-services.ts index a901981d19..414eeb1976 100644 --- a/lib/common/mobile/android/android-emulator-services.ts +++ b/lib/common/mobile/android/android-emulator-services.ts @@ -144,7 +144,15 @@ export class AndroidEmulatorServices implements Mobile.IEmulatorPlatformService } private getBestFit(emulators: Mobile.IDeviceInfo[]) { - const best = _(emulators).maxBy(emulator => emulator.version); + let best: Mobile.IDeviceInfo = null; + for (const emulator of emulators) { + const currentVersion = emulator.version && semver.coerce(emulator.version); + const currentBestVersion = best && best.version && semver.coerce(best.version); + if (!best || (currentVersion && currentBestVersion && semver.gt(currentVersion, currentBestVersion))) { + best = emulator; + } + } + const minVersion = semver.coerce(AndroidVirtualDevice.MIN_ANDROID_VERSION); const bestVersion = best && best.version && semver.coerce(best.version); From a360ba2e9cb34c3854af9420fbfcb88ccf3dff59 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 9 Jan 2020 10:41:02 +0200 Subject: [PATCH 06/10] chore: fix flaky unit test --- .../test/unit-tests/services/json-file-settings-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/test/unit-tests/services/json-file-settings-service.ts b/lib/common/test/unit-tests/services/json-file-settings-service.ts index 2ca75d297f..a7e946fcb3 100644 --- a/lib/common/test/unit-tests/services/json-file-settings-service.ts +++ b/lib/common/test/unit-tests/services/json-file-settings-service.ts @@ -129,7 +129,7 @@ describe("jsonFileSettingsService", () => { const result = await new Promise((resolve, reject) => { setTimeout(() => { jsonFileSettingsService.getSettingValue("prop1", { cacheTimeout: 1 }).then(resolve, reject); - }, 2); + }, 10); }); assert.equal(result, null); From 768c03bf78c15cffc910f3989e1cb888018adb88 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Thu, 9 Jan 2020 14:29:27 +0200 Subject: [PATCH 07/10] release: cut 6.3.2 release --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c69e10bd6f..7f39b5bdf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ NativeScript CLI Changelog ================ +6.3.2 (2020, January 9) +=== + +### Fixed + +* [Fixed #5200](https://github.com/NativeScript/nativescript-cli/issues/5200): api29 emulator is not recognized as latest + + 6.3.1 (2020, January 7) === From 4bd1395d1a2f2646939a29368c5b204b209c9b00 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Fri, 10 Jan 2020 11:01:09 +0200 Subject: [PATCH 08/10] feat: expose before build hooks in order to support cloud builds without an extension --- lib/services/android-project-service.ts | 2 ++ lib/services/ios-project-service.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index e33ee726be..f7434c28cb 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -5,6 +5,7 @@ import * as semver from "semver"; import * as projectServiceBaseLib from "./platform-project-service-base"; import { DeviceAndroidDebugBridge } from "../common/mobile/android/device-android-debug-bridge"; import { Configurations, LiveSyncPaths } from "../common/constants"; +import { hook } from "../common/helpers"; import { performanceLog } from ".././common/decorators"; export class AndroidProjectService extends projectServiceBaseLib.PlatformProjectServiceBase { @@ -242,6 +243,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject } @performanceLog() + @hook('buildAndroid') public async buildProject(projectRoot: string, projectData: IProjectData, buildData: IAndroidBuildData): Promise { const platformData = this.getPlatformData(projectData); await this.$gradleBuildService.buildProject(platformData.projectRoot, buildData); diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 6a0854c2fb..6046f970bb 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -14,6 +14,7 @@ import { IOSEntitlementsService } from "./ios-entitlements-service"; import { IOSBuildData } from "../data/build-data"; import { IOSPrepareData } from "../data/prepare-data"; import { BUILD_XCCONFIG_FILE_NAME, IosProjectConstants } from "../constants"; +import { hook } from "../common/helpers"; interface INativeSourceCodeGroup { name: string; @@ -193,6 +194,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ path.join(projectRoot, projectData.projectName)); } + @hook('buildIOS') public async buildProject(projectRoot: string, projectData: IProjectData, iOSBuildData: IOSBuildData): Promise { const platformData = this.getPlatformData(projectData); From ca8b03dc37232317658b792456da583cceff0c0d Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Fri, 10 Jan 2020 11:04:47 +0200 Subject: [PATCH 09/10] chore: bump version --- npm-shrinkwrap.json | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 349795898d..eb1117574b 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "6.3.2", + "version": "6.3.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -8389,4 +8389,4 @@ "integrity": "sha512-99p+ohUBZ2Es0AXrw/tpazMcJ0/acpdQXr0UPrVWF0p7i8XiOYvjiXTdwXUVCTPopBGCSDtWBzOoYNPtF3z/8w==" } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index d4c91177bb..612a03d301 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "6.3.2", + "version": "6.3.3", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": { @@ -141,4 +141,4 @@ "engines": { "node": ">=10.0.0 <14.0.0" } -} +} \ No newline at end of file From 98ee34fd29a6754bd98d669561af165b177ff3a0 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Fri, 10 Jan 2020 11:16:28 +0200 Subject: [PATCH 10/10] test: fix unit tests after a new android project service dependency --- test/services/android-project-service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/services/android-project-service.ts b/test/services/android-project-service.ts index b541c182a4..13cddd66ce 100644 --- a/test/services/android-project-service.ts +++ b/test/services/android-project-service.ts @@ -11,6 +11,7 @@ import { GradleBuildArgsService } from "../../lib/services/android/gradle-build- const createTestInjector = (): IInjector => { const testInjector = new Yok(); testInjector.register("androidProjectService", AndroidProjectService); + testInjector.register("hooksService", stubs.HooksServiceStub); testInjector.register("childProcess", stubs.ChildProcessStub); testInjector.register("hostInfo", {}); testInjector.register("projectDataService", stubs.ProjectDataService);