-
-
Notifications
You must be signed in to change notification settings - Fork 197
chore: don't show warnings for {N} plugins without native code when bundle option is provided #3904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import * as semver from "semver"; | |
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"; | ||
|
||
export class PreviewAppPluginsService implements IPreviewAppPluginsService { | ||
private previewAppVersionWarnings: IDictionary<string[]> = {}; | ||
|
@@ -11,15 +12,15 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService { | |
private $logger: ILogger, | ||
private $projectData: IProjectData) { } | ||
|
||
public async comparePluginsOnDevice(device: Device): Promise<void> { | ||
public async comparePluginsOnDevice(data: IPreviewAppLiveSyncData, device: Device): Promise<void> { | ||
if (!this.previewAppVersionWarnings[device.previewAppVersion]) { | ||
const devicePlugins = this.getDevicePlugins(device); | ||
const localPlugins = this.getLocalPlugins(); | ||
const warnings = _.keys(localPlugins) | ||
.map(localPlugin => { | ||
const localPluginVersion = localPlugins[localPlugin]; | ||
const devicePluginVersion = devicePlugins[localPlugin]; | ||
return this.getWarningForPlugin(localPlugin, localPluginVersion, devicePluginVersion, device.id); | ||
return this.getWarningForPlugin(data, localPlugin, localPluginVersion, devicePluginVersion, device); | ||
}) | ||
.filter(item => !!item); | ||
this.previewAppVersionWarnings[device.previewAppVersion] = warnings; | ||
|
@@ -62,7 +63,15 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService { | |
} | ||
} | ||
|
||
private getWarningForPlugin(localPlugin: string, localPluginVersion: string, devicePluginVersion: string, deviceId: string): string { | ||
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)) { | ||
return null; | ||
} | ||
|
||
return this.getWarningForPluginCore(localPlugin, localPluginVersion, devicePluginVersion, device.id); | ||
} | ||
|
||
private getWarningForPluginCore(localPlugin: string, localPluginVersion: string, devicePluginVersion: string, deviceId: string): string { | ||
this.$logger.trace(`Comparing plugin ${localPlugin} with localPluginVersion ${localPluginVersion} and devicePluginVersion ${devicePluginVersion}`); | ||
|
||
if (devicePluginVersion) { | ||
|
@@ -80,5 +89,20 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService { | |
|
||
return util.format(PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, localPlugin, deviceId); | ||
} | ||
|
||
private isNativeScriptPluginWithoutNativeCode(localPlugin: string, platform: string): boolean { | ||
return this.isNativeScriptPlugin(localPlugin) && !this.hasNativeCode(localPlugin, platform); | ||
} | ||
|
||
private isNativeScriptPlugin(localPlugin: string): boolean { | ||
const pluginPackageJsonPath = path.join(this.$projectData.projectDir, NODE_MODULES_DIR_NAME, localPlugin, "package.json"); | ||
const pluginPackageJsonContent = this.$fs.readJson(pluginPackageJsonPath); | ||
return pluginPackageJsonContent && pluginPackageJsonContent.nativescript; | ||
} | ||
|
||
private hasNativeCode(localPlugin: string, platform: string): boolean { | ||
const nativeFolderPath = path.join(this.$projectData.projectDir, NODE_MODULES_DIR_NAME, localPlugin, "platforms", platform.toLowerCase()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "platforms" -> |
||
return this.$fs.exists(nativeFolderPath) && !this.$fs.isEmptyDir(nativeFolderPath); | ||
} | ||
} | ||
$injector.register("previewAppPluginsService", PreviewAppPluginsService); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move this method to
pluginsService
.