From ade35754a442666e5211fd581d6c901c157b94d0 Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 1 Oct 2018 10:49:00 +0300 Subject: [PATCH] fix: don't show warnings for non-nativescript plugins on `tns preview --bundle` command --- .../playground/preview-app-plugins-service.ts | 13 ++++++------- .../playground/preview-app-plugins-service.ts | 16 +++++----------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/lib/services/livesync/playground/preview-app-plugins-service.ts b/lib/services/livesync/playground/preview-app-plugins-service.ts index 6eec41a018..24fe97202c 100644 --- a/lib/services/livesync/playground/preview-app-plugins-service.ts +++ b/lib/services/livesync/playground/preview-app-plugins-service.ts @@ -65,8 +65,12 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService { } private getWarningForPlugin(data: IPreviewAppLiveSyncData, localPlugin: string, localPluginVersion: string, devicePluginVersion: string, device: Device): string { - if (data && data.appFilesUpdaterOptions && data.appFilesUpdaterOptions.bundle && this.isNativeScriptPluginWithoutNativeCode(localPlugin, device.platform, data.projectDir)) { - return null; + if (data && data.appFilesUpdaterOptions && data.appFilesUpdaterOptions.bundle) { + const pluginPackageJsonPath = path.join(data.projectDir, NODE_MODULES_DIR_NAME, localPlugin, PACKAGE_JSON_FILE_NAME); + const isNativeScriptPlugin = this.$pluginsService.isNativeScriptPlugin(pluginPackageJsonPath); + if (!isNativeScriptPlugin || (isNativeScriptPlugin && !this.hasNativeCode(localPlugin, device.platform, data.projectDir))) { + return null; + } } return this.getWarningForPluginCore(localPlugin, localPluginVersion, devicePluginVersion, device.id); @@ -91,11 +95,6 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService { return util.format(PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, localPlugin, deviceId); } - private isNativeScriptPluginWithoutNativeCode(localPlugin: string, platform: string, projectDir: string): boolean { - const pluginPackageJsonPath = path.join(projectDir, NODE_MODULES_DIR_NAME, localPlugin, PACKAGE_JSON_FILE_NAME); - return this.$pluginsService.isNativeScriptPlugin(pluginPackageJsonPath) && !this.hasNativeCode(localPlugin, platform, projectDir); - } - private hasNativeCode(localPlugin: string, platform: string, projectDir: string): boolean { const nativeFolderPath = path.join(projectDir, NODE_MODULES_DIR_NAME, localPlugin, PLATFORMS_DIR_NAME, platform.toLowerCase()); return this.$fs.exists(nativeFolderPath) && !this.$fs.isEmptyDir(nativeFolderPath); diff --git a/test/services/playground/preview-app-plugins-service.ts b/test/services/playground/preview-app-plugins-service.ts index 858e98a12c..920fc6d699 100644 --- a/test/services/playground/preview-app-plugins-service.ts +++ b/test/services/playground/preview-app-plugins-service.ts @@ -265,7 +265,7 @@ describe("previewAppPluginsService", () => { describe("comparePluginsOnDevice with bundle", () => { const testCases = [ { - name: "should show warning for non nativescript plugin that has lower major version", + name: "should not show warning for non nativescript plugin that has lower major version", localPlugins: { lodash: "1.2.3" }, @@ -274,12 +274,10 @@ describe("previewAppPluginsService", () => { }, isNativeScriptPlugin: false, hasPluginNativeCode: false, - expectedWarnings: [ - util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, "lodash", "1.2.3", "2.3.3") - ] + expectedWarnings: [] }, { - name: "should show warning for non nativescript plugin that has greather major version", + name: "should not show warning for non nativescript plugin that has greather major version", localPlugins: { lodash: "3.2.3" }, @@ -288,9 +286,7 @@ describe("previewAppPluginsService", () => { }, isNativeScriptPlugin: false, hasPluginNativeCode: false, - expectedWarnings: [ - util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, "lodash", "3.2.3", "2.3.3") - ] + expectedWarnings: [] }, { name: "should show warning for non nativescript plugin that has greather minor version", @@ -302,9 +298,7 @@ describe("previewAppPluginsService", () => { }, isNativeScriptPlugin: false, hasPluginNativeCode: false, - expectedWarnings: [ - util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION, "lodash", "3.4.5", "3.3.0") - ] + expectedWarnings: [] }, { name: "should not show warning for non nativescript plugin that has the same version",