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

Allow disabling each platform individually #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
65 changes: 47 additions & 18 deletions plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConfigPlugin, withPlugins } from "@expo/config-plugins";
import { ConfigPlugin, StaticPlugin, withPlugins } from "@expo/config-plugins";
import {
AndroidProps,
withAndroidAppCenterConfigFile,
Expand All @@ -24,38 +24,67 @@ interface PluginProps {
iosAppCenterPath?: string;

androidOptions?: AndroidProps;
/**
* Disable iOS App Center integration
* @default false
*/
disableiOS?: boolean;
/**
* Disable Android App Center integration
* @default false
*/
disableAndroid?: boolean;
}

/**
* A config plugin for configuring `appcenter`
*/
const withAppCenter: ConfigPlugin<PluginProps> = (
config,
{ androidAppCenterPath, iosAppCenterPath, androidOptions = {} } = {}
{
androidAppCenterPath,
iosAppCenterPath,
androidOptions = {},
disableiOS = false,
disableAndroid = false,
} = {}
) => {
if (disableiOS && disableAndroid) {
return config;
}
const resolvedAndroidConfigPath =
androidAppCenterPath || DEFAULT_ANDROID_APP_CENTER_CONFIG_PATH;

const resolvedIosConfigPath =
iosAppCenterPath || DEFAULT_IOS_APP_CENTER_CONFIG_PATH;

const iosPlugins = disableiOS
? []
: [
withAppCenterAppDelegate,
[
withIosAppCenterConfigFile,
{
relativePath: resolvedIosConfigPath,
},
],
];

const androidPlugins = disableAndroid
? []
: [
[withAppCenterStringsXML, androidOptions],
[
withAndroidAppCenterConfigFile,
{
relativePath: resolvedAndroidConfigPath,
},
],
];

return withPlugins(config, [
// iOS
withAppCenterAppDelegate,
[
withIosAppCenterConfigFile,
{
relativePath: resolvedIosConfigPath,
},
],
// Android
[withAppCenterStringsXML, androidOptions],
[
withAndroidAppCenterConfigFile,
{
relativePath: resolvedAndroidConfigPath,
},
],
...(iosPlugins as StaticPlugin[]),
...(androidPlugins as StaticPlugin[]),
]);
};

Expand Down