1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Ensure we can successfully create prod builds with specific types (#18991)

This commit is contained in:
Dan J Miller 2023-05-03 15:59:11 -02:30 committed by GitHub
parent ab4843f06b
commit e8ede35dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 14 deletions

View File

@ -7,15 +7,11 @@ const { loadBuildTypesConfig } = require('../lib/build-type');
const { Variables } = require('../lib/variables');
const { ENVIRONMENT } = require('./constants');
const VARIABLES_REQUIRED_IN_PRODUCTION = [
'INFURA_BETA_PROJECT_ID',
'INFURA_FLASK_PROJECT_ID',
'INFURA_PROD_PROJECT_ID',
'SEGMENT_BETA_WRITE_KEY',
'SEGMENT_FLASK_WRITE_KEY',
'SEGMENT_PROD_WRITE_KEY',
'SENTRY_DSN',
];
const VARIABLES_REQUIRED_IN_PRODUCTION = {
main: ['INFURA_PROD_PROJECT_ID', 'SEGMENT_PROD_WRITE_KEY', 'SENTRY_DSN'],
beta: ['INFURA_BETA_PROJECT_ID', 'SEGMENT_BETA_WRITE_KEY', 'SENTRY_DSN'],
flask: ['INFURA_FLASK_PROJECT_ID', 'SEGMENT_FLASK_WRITE_KEY', 'SENTRY_DSN'],
};
async function fromIniFile(filepath) {
let configContents = '';
@ -137,9 +133,9 @@ async function getConfig(buildType, environment) {
// TODO(ritave): Move build targets and environments to builds.yml
if (environment === ENVIRONMENT.PRODUCTION) {
const undefinedVariables = VARIABLES_REQUIRED_IN_PRODUCTION.filter(
(variable) => !variables.isDefined(variable),
);
const undefinedVariables = VARIABLES_REQUIRED_IN_PRODUCTION[
buildType
].filter((variable) => !variables.isDefined(variable));
if (undefinedVariables.length !== 0) {
const message = `Some variables required to build production target are not defined.
- ${undefinedVariables.join('\n - ')}

View File

@ -126,7 +126,7 @@ function getInfuraProjectId({ buildType, variables, environment, testing }) {
return variables.get('INFURA_PROJECT_ID');
}
/** @type {string|undefined} */
const infuraKeyReference = process.env.INFURA_ENV_KEY_REF;
const infuraKeyReference = variables.get('INFURA_ENV_KEY_REF');
assert(
typeof infuraKeyReference === 'string' && infuraKeyReference.length > 0,
`Build type "${buildType}" has improperly set INFURA_ENV_KEY_REF in builds.yml. Current value: "${infuraKeyReference}"`,
@ -155,7 +155,7 @@ function getSegmentWriteKey({ buildType, variables, environment }) {
return variables.get('SEGMENT_WRITE_KEY');
}
const segmentKeyReference = process.env.SEGMENT_WRITE_KEY_REF;
const segmentKeyReference = variables.get('SEGMENT_WRITE_KEY_REF');
assert(
typeof segmentKeyReference === 'string' && segmentKeyReference.length > 0,
`Build type "${buildType}" has improperly set SEGMENT_WRITE_KEY_REF in builds.yml. Current value: "${segmentKeyReference}"`,