Skip to content

Commit

Permalink
fix: Require project to provide app center token
Browse files Browse the repository at this point in the history
Previously flagship was using private branding brand app center token for authentication.
This solution requires you to self manage app center token, which allows teams outside Branding Brand organization to use code push.
  • Loading branch information
pavlemilicevicbb authored and skyeckstrom committed Oct 23, 2018
1 parent 4ca8e46 commit e349966
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
26 changes: 22 additions & 4 deletions packages/flagship/src/lib/modules/react-native-code-push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
logInfo
} from '../../helpers';

const kBrandingBrandAppCenterToken = '0fd777da29f2545597bf45c20149b087eaba5f3b';

/**
* Patches Android for the module.
*
Expand All @@ -17,6 +15,14 @@ const kBrandingBrandAppCenterToken = '0fd777da29f2545597bf45c20149b087eaba5f3b';
export function android(configuration: Config): void {
logInfo('patching Android for react-native-codepush');

if (!(configuration.codepush
&& configuration.codepush.appCenterToken)
) {
logError('codepush.appCenterToken must be specified in project config');

return process.exit(1);
}

const assetsPath = path.android.assetsPath();
const appCenterConfigPath = path.resolve(assetsPath, 'appcenter-config.json');
const codepush = configuration.codepush;
Expand Down Expand Up @@ -69,7 +75,11 @@ export function android(configuration: Config): void {
// Include the readonly Branding Brand app center token ONLY in development
// builds
if (!configuration.disableDevFeature) {
nativeConstants.addAndroid(configuration, 'AppCenterToken', kBrandingBrandAppCenterToken);
nativeConstants.addAndroid(
configuration,
'AppCenterToken',
configuration.codepush.appCenterToken
);
}

fs.update(
Expand All @@ -90,6 +100,14 @@ export function android(configuration: Config): void {
export function ios(configuration: Config): void {
logInfo('patching iOS for react-native-codepush');

if (!(configuration.codepush
&& configuration.codepush.appCenterToken)
) {
logError('codepush.appCenterToken must be specified in project config');

return process.exit(1);
}

const appCenterConfigPath = path.resolve(
path.ios.nativeProjectPath(configuration),
'AppCenter-Config.plist'
Expand All @@ -115,6 +133,6 @@ export function ios(configuration: Config): void {
// Include the readonly Branding Brand app center token ONLY in development
// builds
if (!configuration.disableDevFeature) {
nativeConstants.addIOS(configuration, 'AppCenterToken', kBrandingBrandAppCenterToken);
nativeConstants.addIOS(configuration, 'AppCenterToken', configuration.codepush.appCenterToken);
}
}
1 change: 1 addition & 0 deletions packages/flagship/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Config {
googleMapApiKey: string;

codepush?: {
appCenterToken: string;
android: CodepushConfig;
ios: CodepushConfig;
};
Expand Down

0 comments on commit e349966

Please sign in to comment.