Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Make manifest.env available in build and export commands
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorm committed Apr 23, 2019
1 parent 181053b commit 2c22b6f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
22 changes: 0 additions & 22 deletions packages/xdl/src/Project.js
Original file line number Diff line number Diff line change
Expand Up @@ -1656,22 +1656,6 @@ export async function stopReactNativeServerAsync(projectRoot: string) {
});
}

let blacklistedEnvironmentVariables = new Set([
'EXPO_APPLE_PASSWORD',
'EXPO_ANDROID_KEY_PASSWORD',
'EXPO_ANDROID_KEYSTORE_PASSWORD',
'EXPO_IOS_DIST_P12_PASSWORD',
'EXPO_IOS_PUSH_P12_PASSWORD',
'EXPO_CLI_PASSWORD',
]);

function shouldExposeEnvironmentVariableInManifest(key) {
if (blacklistedEnvironmentVariables.has(key.toUpperCase())) {
return false;
}
return key.startsWith('REACT_NATIVE_') || key.startsWith('EXPO_');
}

export async function startExpoServerAsync(projectRoot: string) {
_assertValidProjectRoot(projectRoot);
await stopExpoServerAsync(projectRoot);
Expand Down Expand Up @@ -1713,12 +1697,6 @@ export async function startExpoServerAsync(projectRoot: string) {
projectRoot,
};
manifest.packagerOpts = packagerOpts;
manifest.env = {};
for (let key of Object.keys(process.env)) {
if (shouldExposeEnvironmentVariableInManifest(key)) {
manifest.env[key] = process.env[key];
}
}
let entryPoint = await Exp.determineEntryPointAsync(projectRoot);
let platform = req.headers['exponent-platform'] || 'ios';
entryPoint = UrlUtils.getPlatformSpecificBundleUrl(entryPoint, platform);
Expand Down
27 changes: 26 additions & 1 deletion packages/xdl/src/project/ProjectUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ function _getLogger(projectRoot: string) {
return logger;
}

let blacklistedEnvironmentVariables = new Set([
'EXPO_APPLE_PASSWORD',
'EXPO_ANDROID_KEY_PASSWORD',
'EXPO_ANDROID_KEYSTORE_PASSWORD',
'EXPO_IOS_DIST_P12_PASSWORD',
'EXPO_IOS_PUSH_P12_PASSWORD',
'EXPO_CLI_PASSWORD',
]);

function shouldExposeEnvironmentVariableInManifest(key) {
if (blacklistedEnvironmentVariables.has(key.toUpperCase())) {
return false;
}
return key.startsWith('REACT_NATIVE_') || key.startsWith('EXPO_');
}

export function logWithLevel(
projectRoot: string,
level: string,
Expand Down Expand Up @@ -133,7 +149,16 @@ export async function readConfigJsonAsync(
projectRoot: string
): Promise<{ exp?: Object, pkg?: Object, rootConfig?: Object }> {
try {
return await ConfigUtils.readConfigJsonAsync(projectRoot);
let { exp, pkg } = await ConfigUtils.readConfigJsonAsync(projectRoot);

exp.env = {};
for (let key of Object.keys(process.env)) {
if (shouldExposeEnvironmentVariableInManifest(key)) {
exp.env[key] = process.env[key];
}
}

return { exp, pkg };
} catch (error) {
logError(projectRoot, 'expo', error.message);
return { exp: null, pkg: null };
Expand Down

0 comments on commit 2c22b6f

Please sign in to comment.