Skip to content

Commit 89b5799

Browse files
author
Fatme
authored
Merge pull request #4044 from NativeScript/sis0k0/fix-preview-version-check
fix(preview): skip check if local plugin version is invalid
2 parents de59f12 + f9cdbc6 commit 89b5799

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

docs/man_pages/lib-management/plugin.md

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ Lets you manage the plugins for your project.
1717
* `add` - Installs the specified plugin and its dependencies.
1818
* `remove` - Uninstalls the specified plugin and its dependencies.
1919
* `update` - Uninstalls and installs the specified plugin(s) and its dependencies.
20-
* `find` - Finds NativeScript plugins in npm.
21-
* `search` - Finds NativeScript plugins in npm.
2220
* `build` - Builds the Android parts of a NativeScript plugin.
2321
* `create` - Creates a project for building a new NativeScript plugin.
2422

lib/services/livesync/playground/preview-app-plugins-service.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,25 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService {
7474
private getWarningForPluginCore(localPlugin: string, localPluginVersion: string, devicePluginVersion: string, deviceId: string): string {
7575
this.$logger.trace(`Comparing plugin ${localPlugin} with localPluginVersion ${localPluginVersion} and devicePluginVersion ${devicePluginVersion}`);
7676

77-
if (devicePluginVersion) {
78-
const localPluginVersionData = semver.coerce(localPluginVersion);
79-
const devicePluginVersionData = semver.coerce(devicePluginVersion);
80-
81-
if (localPluginVersionData.major !== devicePluginVersionData.major) {
82-
return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion);
83-
} else if (localPluginVersionData.minor > devicePluginVersionData.minor) {
84-
return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion);
85-
}
77+
if (!devicePluginVersion) {
78+
return util.format(PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, localPlugin, deviceId);
79+
}
8680

81+
const shouldSkipCheck = !semver.valid(localPluginVersion) && !semver.validRange(localPluginVersion);
82+
if (shouldSkipCheck) {
8783
return null;
8884
}
8985

90-
return util.format(PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, localPlugin, deviceId);
86+
const localPluginVersionData = semver.coerce(localPluginVersion);
87+
const devicePluginVersionData = semver.coerce(devicePluginVersion);
88+
89+
if (localPluginVersionData.major !== devicePluginVersionData.major) {
90+
return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion);
91+
} else if (localPluginVersionData.minor > devicePluginVersionData.minor) {
92+
return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion);
93+
}
94+
95+
return null;
9196
}
9297

9398
private hasNativeCode(localPlugin: string, platform: string, projectDir: string): boolean {

test/services/playground/preview-app-plugins-service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ describe("previewAppPluginsService", () => {
243243
"nativescript-theme-core": "3.5.0"
244244
},
245245
expectedWarnings: []
246+
},
247+
{
248+
name: "should not show warning when the local plugin version is tag",
249+
localPlugins: {
250+
"tns-core-modules": "rc"
251+
},
252+
previewAppPlugins: {
253+
"tns-core-modules": "5.0.0"
254+
},
255+
expectedWarnings: <string[]>[]
246256
}
247257
];
248258

0 commit comments

Comments
 (0)