Skip to content

Commit

Permalink
feat(cli): Allow users to include Cordova plugins to the static list (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Oct 28, 2021
1 parent 32ecf22 commit 664149a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
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

0 comments on commit 664149a

Please sign in to comment.