Skip to content
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

fix(cli): Allow to filter incompatible plugins per platform #1645

Merged
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
9 changes: 5 additions & 4 deletions cli/src/android/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ export function getAndroidPlugins(allPlugins: Plugin[]): Plugin[] {
}

export function resolvePlugin(plugin: Plugin): Plugin | null {
const platform = 'android';
if (plugin.manifest && plugin.manifest.android) {
let pluginFilesPath = plugin.manifest.android.src ? plugin.manifest.android.src : 'android';
let pluginFilesPath = plugin.manifest.android.src ? plugin.manifest.android.src : platform;
const absolutePath = join(plugin.rootPath, pluginFilesPath, plugin.id);
// Android folder shouldn't have subfolders, but they used to, so search for them for compatibility reasons
if (existsSync(absolutePath)) {
pluginFilesPath = join('android', plugin.id);
pluginFilesPath = join(platform, plugin.id);
}
plugin.android = {
type: PluginType.Core,
Expand All @@ -30,9 +31,9 @@ export function resolvePlugin(plugin: Plugin): Plugin | null {
} else if (plugin.xml) {
plugin.android = {
type: PluginType.Cordova,
path: 'src/android'
path: 'src/' + platform
};
if(getIncompatibleCordovaPlugins().includes(plugin.id) || !getPluginPlatform(plugin, 'android')) {
if(getIncompatibleCordovaPlugins(platform).includes(plugin.id) || !getPluginPlatform(plugin, platform)) {
plugin.android.type = PluginType.Incompatible;
}
} else {
Expand Down
12 changes: 8 additions & 4 deletions cli/src/cordova.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export async function checkAndInstallDependencies(config: Config, plugins: Plugi
if (p.xml['dependency']) {
allDependencies = allDependencies.concat(p.xml['dependency']);
}
allDependencies = allDependencies.filter((dep: any) => !getIncompatibleCordovaPlugins().includes(dep.$.id) && incompatible.filter(p => p.id === dep.$.id || p.xml.$.id === dep.$.id).length === 0);
allDependencies = allDependencies.filter((dep: any) => !getIncompatibleCordovaPlugins(platform).includes(dep.$.id) && incompatible.filter(p => p.id === dep.$.id || p.xml.$.id === dep.$.id).length === 0);
if (allDependencies) {
await Promise.all(allDependencies.map(async (dep: any) => {
if (cordovaPlugins.filter(p => p.id === dep.$.id || p.xml.$.id === dep.$.id).length === 0) {
Expand All @@ -314,9 +314,13 @@ export async function checkAndInstallDependencies(config: Config, plugins: Plugi
return needsUpdate;
}

export function getIncompatibleCordovaPlugins(){
return ["cordova-plugin-statusbar", "cordova-plugin-splashscreen", "cordova-plugin-ionic-webview",
export function getIncompatibleCordovaPlugins(platform: string){
let pluginList = ["cordova-plugin-statusbar", "cordova-plugin-splashscreen", "cordova-plugin-ionic-webview",
"cordova-plugin-crosswalk-webview", "cordova-plugin-wkwebview-engine", "cordova-plugin-console",
"cordova-plugin-compat", "cordova-plugin-music-controls", "cordova-plugin-add-swift-support",
"cordova-plugin-ionic-keyboard", "cordova-plugin-braintree"];
}
if (platform === "ios") {
pluginList.push("cordova-plugin-googlemaps");
}
return pluginList;
}
7 changes: 4 additions & 3 deletions cli/src/ios/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ export function getIOSPlugins(allPlugins: Plugin[]): Plugin[] {
}

export function resolvePlugin(plugin: Plugin): Plugin | null {
const platform = 'ios';
if (plugin.manifest && plugin.manifest.ios) {
plugin.ios = {
name: plugin.name,
type: PluginType.Core,
path: plugin.manifest.ios.src ? plugin.manifest.ios.src : 'ios'
path: plugin.manifest.ios.src ? plugin.manifest.ios.src : platform
};
} else if (plugin.xml) {
plugin.ios = {
name: plugin.name,
type: PluginType.Cordova,
path: 'src/ios'
path: 'src/' + platform
};
if(getIncompatibleCordovaPlugins().includes(plugin.id) || !getPluginPlatform(plugin, 'ios')) {
if(getIncompatibleCordovaPlugins(platform).includes(plugin.id) || !getPluginPlatform(plugin, platform)) {
plugin.ios.type = PluginType.Incompatible;
}
} else {
Expand Down