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

feat(cli): Allow users to include Cordova plugins to the static list #5175

Merged
merged 2 commits into from
Oct 28, 2021
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: 7 additions & 2 deletions cli/src/cordova.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,14 +518,19 @@ export function getIncompatibleCordovaPlugins(platform: string): string[] {
return pluginList;
}

export function needsStaticPod(plugin: Plugin): boolean {
const pluginList = [
export function needsStaticPod(plugin: Plugin, config: Config): boolean {
let pluginList = [
'phonegap-plugin-push',
'@havesource/cordova-plugin-push',
'cordova-plugin-firebasex',
'@batch.com/cordova-plugin',
'onesignal-cordova-plugin',
];
if (config.app.extConfig?.cordova?.staticPlugins) {
pluginList = pluginList.concat(
config.app.extConfig?.cordova?.staticPlugins,
);
}
return pluginList.includes(plugin.id);
}

Expand Down
8 changes: 8 additions & 0 deletions cli/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ export interface CapacitorConfig {
* @since 1.3.0
*/
preferences?: { [key: string]: string | undefined };

/**
* List of Cordova plugins that need to be static but are not
* already in the static plugin list.
*
* @since 3.3.0
*/
staticPlugins?: string[];
};

/**
Expand Down
6 changes: 3 additions & 3 deletions cli/src/ios/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ async function generatePodFile(
});
});
});
const staticPlugins = cordovaPlugins.filter(needsStaticPod);
const staticPlugins = cordovaPlugins.filter(p => needsStaticPod(p, config));
const noStaticPlugins = cordovaPlugins.filter(
el => !staticPlugins.includes(el),
);
Expand Down Expand Up @@ -241,7 +241,7 @@ async function generateCordovaPodspecs(
cordovaPlugins: Plugin[],
config: Config,
) {
const staticPlugins = cordovaPlugins.filter(needsStaticPod);
const staticPlugins = cordovaPlugins.filter(p => needsStaticPod(p, config));
const noStaticPlugins = cordovaPlugins.filter(
el => !staticPlugins.includes(el),
);
Expand Down Expand Up @@ -424,7 +424,7 @@ async function copyPluginsNativeFiles(
const codeFiles = sourceFiles.concat(headerFiles);
const frameworks = getPlatformElement(p, platform, 'framework');
let sourcesFolderName = 'sources';
if (needsStaticPod(p)) {
if (needsStaticPod(p, config)) {
sourcesFolderName += 'static';
}
const sourcesFolder = join(
Expand Down