From f0dfab282457dc705ee596061766489fd7fdeb30 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Wed, 28 Jun 2017 06:28:42 +0300 Subject: [PATCH 1/5] Cherry-pick "fix android with webpack" from master (#2930) * fix android with webpack (#2925) * Update CHANGELOG --- CHANGELOG.md | 1 + lib/definitions/plugins.d.ts | 2 ++ lib/services/platform-service.ts | 19 +++++++++++++++++-- lib/services/plugins-service.ts | 4 ++-- test/platform-commands.ts | 1 + test/platform-service.ts | 1 + 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a994e9ea7..2d88b73194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ NativeScript CLI Changelog * [Fixed #2892](https://github.com/NativeScript/nativescript-cli/issues/2892): Not copying the CFBundleURLTypes from the plist file to the project * [Fixed #2916](https://github.com/NativeScript/nativescript-cli/issues/2916): If no device or emulator is attached `tns debug android` kills the commandline process and doesn't start an emulator * [Fixed #2923](https://github.com/NativeScript/nativescript-cli/issues/2923): Fix asking for user email on postinstall +* [Fixed #2929](https://github.com/NativeScript/nativescript-cli/issues/2929): Android release builds with webpack disregards plugin's gradle dependencies. 3.1.0 (2017, June 22) diff --git a/lib/definitions/plugins.d.ts b/lib/definitions/plugins.d.ts index 99c50b7893..24926cd12a 100644 --- a/lib/definitions/plugins.d.ts +++ b/lib/definitions/plugins.d.ts @@ -12,6 +12,8 @@ interface IPluginsService { */ getDependenciesFromPackageJson(projectDir: string): IPackageJsonDepedenciesResult; validate(platformData: IPlatformData, projectData: IProjectData): Promise; + preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise; + convertToPluginData(cacheData: any, projectDir: string): IPluginData; } interface IPackageJsonDepedenciesResult { diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 8b92bc5a19..f1a3bd5b94 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -39,7 +39,8 @@ export class PlatformService extends EventEmitter implements IPlatformService { private $npm: INodePackageManager, private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants, private $projectChangesService: IProjectChangesService, - private $analyticsService: IAnalyticsService) { + private $analyticsService: IAnalyticsService, + private $nodeModulesDependenciesBuilder: INodeModulesDependenciesBuilder) { super(); } @@ -223,13 +224,17 @@ export class PlatformService extends EventEmitter implements IPlatformService { let platformData = this.$platformsData.getPlatformData(platform, projectData); await this.$pluginsService.validate(platformData, projectData); + const bundle = appFilesUpdaterOptions.bundle; + await this.ensurePlatformInstalled(platform, platformTemplate, projectData, config); - let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle: appFilesUpdaterOptions.bundle, release: appFilesUpdaterOptions.release, provision: config.provision }); + let changesInfo = this.$projectChangesService.checkForChanges(platform, projectData, { bundle, release: appFilesUpdaterOptions.release, provision: config.provision }); this.$logger.trace("Changes info in prepare platform:", changesInfo); if (changesInfo.hasChanges) { await this.cleanProject(platform, appFilesUpdaterOptions, platformData, projectData); + } + if (changesInfo.hasChanges || bundle) { await this.preparePlatformCore(platform, appFilesUpdaterOptions, projectData, config, changesInfo, filesToSync); this.$projectChangesService.savePrepareInfo(platform, projectData); } else { @@ -302,6 +307,16 @@ export class PlatformService extends EventEmitter implements IPlatformService { if (!changesInfo || changesInfo.modulesChanged) { await this.copyTnsModules(platform, projectData); + } else if (appFilesUpdaterOptions.bundle) { + let dependencies = this.$nodeModulesDependenciesBuilder.getProductionDependencies(projectData.projectDir); + for (let dependencyKey in dependencies) { + const dependency = dependencies[dependencyKey]; + let isPlugin = !!dependency.nativescript; + if (isPlugin) { + let pluginData = this.$pluginsService.convertToPluginData(dependency, projectData.projectDir); + await this.$pluginsService.preparePluginNativeCode(pluginData, platform, projectData); + } + } } let directoryPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME); diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts index c1fae529f9..df436d5e9d 100644 --- a/lib/services/plugins-service.ts +++ b/lib/services/plugins-service.ts @@ -139,7 +139,7 @@ export class PluginsService implements IPluginsService { this.$projectFilesManager.processPlatformSpecificFiles(pluginScriptsDestinationPath, platform); } - private async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise { + public async preparePluginNativeCode(pluginData: IPluginData, platform: string, projectData: IProjectData): Promise { let platformData = this.$platformsData.getPlatformData(platform, projectData); pluginData.pluginPlatformsFolderPath = (_platform: string) => path.join(pluginData.fullPath, "platforms", _platform); @@ -228,7 +228,7 @@ export class PluginsService implements IPluginsService { }; } - private convertToPluginData(cacheData: any, projectDir: string): IPluginData { + public convertToPluginData(cacheData: any, projectDir: string): IPluginData { let pluginData: any = {}; pluginData.name = cacheData.name; pluginData.version = cacheData.version; diff --git a/test/platform-commands.ts b/test/platform-commands.ts index 9c5b8ee2d9..63288c0261 100644 --- a/test/platform-commands.ts +++ b/test/platform-commands.ts @@ -96,6 +96,7 @@ function createTestInjector() { testInjector.register("injector", testInjector); testInjector.register("hooksService", stubs.HooksServiceStub); testInjector.register("staticConfig", StaticConfigLib.StaticConfig); + testInjector.register("nodeModulesDependenciesBuilder", {}); testInjector.register('platformService', PlatformServiceLib.PlatformService); testInjector.register('errors', ErrorsNoFailStub); testInjector.register('logger', stubs.LoggerStub); diff --git a/test/platform-service.ts b/test/platform-service.ts index d8898f0b26..e4ce0e5352 100644 --- a/test/platform-service.ts +++ b/test/platform-service.ts @@ -30,6 +30,7 @@ function createTestInjector() { testInjector.register('platformService', PlatformServiceLib.PlatformService); testInjector.register('errors', stubs.ErrorsStub); testInjector.register('logger', stubs.LoggerStub); + testInjector.register("nodeModulesDependenciesBuilder", {}); testInjector.register('npmInstallationManager', stubs.NpmInstallationManagerStub); testInjector.register('projectData', stubs.ProjectDataStub); testInjector.register('platformsData', stubs.PlatformsDataStub); From fd4fcef51bc5f97635fa7d166dc221739f2fafee Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Wed, 5 Jul 2017 15:30:06 +0300 Subject: [PATCH 2/5] Track exceptions in separate Analytics project (#2948) * Track exceptions in separate Analytics project Track all exceptions from CLI in a separate analytics project. Also track the result of `tns error-reporting enable/disable` in the same project where the exceptions are tracked. Update common-lib where the following changes had been applied: Allow tracking exceptions in a different Analytics project. In case the specified CLI wants to track exceptions to a separeate project, it can do it by setting the new property in staticConfig - `ANALYTICS_EXCEPTIONS_API_KEY`. Allow tracking the result of `tns error-reporting enable/disable` to the same project where exceptions tracking is sent. Speed up check if current Analytics request is sent - we check on 1000ms, while in fact it takes between 150 and 400ms. So make the check on 100ms. * Bump CLI version to 3.1.2 --- lib/common | 2 +- lib/config.ts | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/common b/lib/common index d5e8675ed3..f1706350f3 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit d5e8675ed30da6f096643ff1aac4c6d2ec18b46f +Subproject commit f1706350f378b77abf00276af31fee90bfb8120c diff --git a/lib/config.ts b/lib/config.ts index 68e9409bca..a3b9d77e49 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -24,6 +24,7 @@ export class StaticConfig extends StaticConfigBase implements IStaticConfig { public CLIENT_NAME = "tns"; public CLIENT_NAME_ALIAS = "NativeScript"; public ANALYTICS_API_KEY = "5752dabccfc54c4ab82aea9626b7338e"; + public ANALYTICS_EXCEPTIONS_API_KEY = "35478fe7de68431399e96212540a3d5d"; public TRACK_FEATURE_USAGE_SETTING_NAME = "TrackFeatureUsage"; public ERROR_REPORT_SETTING_NAME = "TrackExceptions"; public ANALYTICS_INSTALLATION_ID_SETTING_NAME = "AnalyticsInstallationID"; diff --git a/package.json b/package.json index 44623ea456..c66f8c9465 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nativescript", "preferGlobal": true, - "version": "3.1.1", + "version": "3.1.2", "author": "Telerik ", "description": "Command-line interface for building NativeScript projects", "bin": { From 4e2c5108ccebbfccc29475038de5ec9cd7d702e5 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Wed, 5 Jul 2017 16:39:33 +0300 Subject: [PATCH 3/5] Fix plugins prompts on postinstall (#2949) * Fix plugins prompts on postinstall In case some plugins (like `nativescript-plugin-firebase`) try to prompt the user on postinstall, users are unable to answer the question when `tns plugin add ` is used. The reason is that the stdin of current process is not passed to the stdin of the `npm install` process and the user has no way to input the result. Fix this by using "inherit" of current stdio when the console is interactive. * Update CHANGELOG for 3.1.2 --- CHANGELOG.md | 7 +++++++ lib/node-package-manager.ts | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d88b73194..3b014a88ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ NativeScript CLI Changelog ================ + +3.1.2 (2017, July 06) +== + +### Fixed +* [Fixed #2950](https://github.com/NativeScript/nativescript-cli/issues/2950): Unable to provide user input on postinstall of plugin + 3.1.1 (2017, June 28) == diff --git a/lib/node-package-manager.ts b/lib/node-package-manager.ts index c64f2c8236..8289e66baa 100644 --- a/lib/node-package-manager.ts +++ b/lib/node-package-manager.ts @@ -1,5 +1,6 @@ import * as path from "path"; import { exported } from "./common/decorators"; +import { isInteractive } from "./common/helpers"; export class NodePackageManager implements INodePackageManager { private static SCOPED_DEPENDENCY_REGEXP = /^(@.+?)(?:@(.+?))?$/; @@ -194,16 +195,20 @@ export class NodePackageManager implements INodePackageManager { private async getNpmInstallResult(params: string[], cwd: string): Promise { return new Promise((resolve, reject) => { const npmExecutable = this.getNpmExecutableName(); - let childProcess = this.$childProcess.spawn(npmExecutable, params, { cwd, stdio: "pipe" }); + const stdioValue = isInteractive() ? "inherit" : "pipe"; + + const childProcess = this.$childProcess.spawn(npmExecutable, params, { cwd, stdio: stdioValue }); let isFulfilled = false; let capturedOut = ""; let capturedErr = ""; - childProcess.stdout.on("data", (data: string) => { - this.$logger.write(data.toString()); - capturedOut += data; - }); + if (childProcess.stdout) { + childProcess.stdout.on("data", (data: string) => { + this.$logger.write(data.toString()); + capturedOut += data; + }); + } if (childProcess.stderr) { childProcess.stderr.on("data", (data: string) => { From 6ecffae57a623474e99e9108be4fc027ff6586a9 Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Wed, 5 Jul 2017 17:50:06 +0300 Subject: [PATCH 4/5] Upate to latest common-lib --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index 8be9f921aa..cc5d470197 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit 8be9f921aa50000405af9ded63c770da7910d741 +Subproject commit cc5d47019765a918e0937e45ffb31597076d3d6f From b6d4427215ec4ee48d283b2b1e5de1398888bd59 Mon Sep 17 00:00:00 2001 From: Rosen Vladimirov Date: Wed, 5 Jul 2017 19:01:59 +0300 Subject: [PATCH 5/5] Fix LICENSE years (#2953) --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 2c63567572..dda4f06e7e 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ Apache License same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2015-2016 Telerik AD + Copyright (c) 2015-2017 Telerik AD Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -198,4 +198,4 @@ Apache License distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License.