Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/services/livesync/playground/preview-app-plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
16 changes: 5 additions & 11 deletions test/services/playground/preview-app-plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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: <string[]>[]
},
{
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"
},
Expand All @@ -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",
Expand All @@ -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",
Expand Down