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