From d82b290c9a61bd8c1b21d3707dfa465024036ea9 Mon Sep 17 00:00:00 2001 From: fatme Date: Fri, 22 Nov 2019 09:55:20 +0200 Subject: [PATCH 1/2] feat: show message when there is plugins with native dependencies from preview command In case when there are one or more plugin with native dependencies on preview command, we want to show a message that the users should use `tns run` command instead. --- .../livesync/playground/preview-app-plugins-service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/services/livesync/playground/preview-app-plugins-service.ts b/lib/services/livesync/playground/preview-app-plugins-service.ts index 3759bb2b90..2b58ec468d 100644 --- a/lib/services/livesync/playground/preview-app-plugins-service.ts +++ b/lib/services/livesync/playground/preview-app-plugins-service.ts @@ -4,7 +4,7 @@ import * as util from "util"; import { Device } from "nativescript-preview-sdk"; import { PluginComparisonMessages } from "./preview-app-constants"; import { NODE_MODULES_DIR_NAME } from "../../../common/constants"; -import { PLATFORMS_DIR_NAME, PACKAGE_JSON_FILE_NAME, TNS_CORE_THEME_NAME, SCOPED_TNS_CORE_THEME_NAME } from "../../../constants"; +import { PLATFORMS_DIR_NAME, PACKAGE_JSON_FILE_NAME, TNS_CORE_THEME_NAME, SCOPED_TNS_CORE_THEME_NAME, LoggerConfigData } from "../../../constants"; export class PreviewAppPluginsService implements IPreviewAppPluginsService { constructor(private $errors: IErrors, @@ -40,6 +40,11 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService { public async comparePluginsOnDevice(data: IPreviewAppLiveSyncData, device: Device): Promise { const warnings = await this.getPluginsUsageWarnings(data, device); _.map(warnings, warning => this.$logger.warn(warning)); + + if (warnings && warnings.length) { + this.$logger.warn(`In the app are used one or more NativeScript plugins with native dependencies. +Those plugins will not work while building the project via \`$ tns preview\`. Please, use \`$ tns run \` command instead.`, { [LoggerConfigData.wrapMessageWithBorders]: true }); + } } public getExternalPlugins(device: Device): string[] { From 0c8bc501be39e5847ca34de6a3abb88b493bcfe5 Mon Sep 17 00:00:00 2001 From: fatme Date: Fri, 22 Nov 2019 11:22:33 +0200 Subject: [PATCH 2/2] chore: fix unit tests --- test/services/playground/preview-app-plugins-service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/services/playground/preview-app-plugins-service.ts b/test/services/playground/preview-app-plugins-service.ts index a42125848d..99603944bf 100644 --- a/test/services/playground/preview-app-plugins-service.ts +++ b/test/services/playground/preview-app-plugins-service.ts @@ -42,7 +42,11 @@ function createTestInjector(localPlugins: IStringDictionary, options?: { isNativ }); injector.register("logger", { trace: () => ({}), - warn: (message: string) => warnParams.push(message) + warn: (message: string, opts: any) => { + if (!opts || !opts.wrapMessageWithBorders) { + warnParams.push(message); + } + } }); injector.register("packageInstallationManager", PackageInstallationManagerStub);