@ -3,6 +3,33 @@ const { readFile } = require('fs/promises');
const ini = require ( 'ini' ) ;
const { BuildType } = require ( '../lib/build-type' ) ;
const commonConfigurationPropertyNames = [ 'PUBNUB_PUB_KEY' , 'PUBNUB_SUB_KEY' ] ;
const configurationPropertyNames = [
... commonConfigurationPropertyNames ,
'COLLECTIBLES_V1' ,
'INFURA_PROJECT_ID' ,
'ONBOARDING_V2' ,
'PHISHING_WARNING_PAGE_URL' ,
'PORTFOLIO_URL' ,
'SEGMENT_HOST' ,
'SEGMENT_WRITE_KEY' ,
'SENTRY_DSN_DEV' ,
'SIWE_V1' ,
'SWAPS_USE_DEV_APIS' ,
] ;
const productionConfigurationPropertyNames = [
... commonConfigurationPropertyNames ,
'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' ,
] ;
/ * *
* Get configuration for non - production builds .
*
@ -20,22 +47,17 @@ async function getConfig() {
throw error ;
}
}
const environmentVariables = { } ;
for ( const propertyName of configurationPropertyNames ) {
if ( process . env [ propertyName ] ) {
environmentVariables [ propertyName ] = process . env [ propertyName ] ;
}
}
return {
COLLECTIBLES _V1 : process . env . COLLECTIBLES _V1 ,
INFURA _PROJECT _ID : process . env . INFURA _PROJECT _ID ,
ONBOARDING _V2 : process . env . ONBOARDING _V2 ,
PHISHING _WARNING _PAGE _URL : process . env . PHISHING _WARNING _PAGE _URL ,
PORTFOLIO _URL : process . env . PORTFOLIO _URL ,
PUBNUB _PUB _KEY : process . env . PUBNUB _PUB _KEY ,
PUBNUB _SUB _KEY : process . env . PUBNUB _SUB _KEY ,
SEGMENT _HOST : process . env . SEGMENT _HOST ,
SEGMENT _WRITE _KEY : process . env . SEGMENT _WRITE _KEY ,
SENTRY _DSN _DEV :
process . env . SENTRY _DSN _DEV ? ?
'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' ,
SIWE _V1 : process . env . SIWE _V1 ,
SWAPS _USE _DEV _APIS : process . env . SWAPS _USE _DEV _APIS ,
... ini . parse ( configContents ) ,
... environmentVariables ,
} ;
}
@ -61,17 +83,17 @@ async function getProductionConfig(buildType) {
throw error ;
}
}
const environmentVariables = { } ;
for ( const propertyName of productionConfigurationPropertyNames ) {
if ( process . env [ propertyName ] ) {
environmentVariables [ propertyName ] = process . env [ propertyName ] ;
}
}
const prodConfig = {
INFURA _BETA _PROJECT _ID : process . env . INFURA _BETA _PROJECT _ID ,
INFURA _FLASK _PROJECT _ID : process . env . INFURA _FLASK _PROJECT _ID ,
INFURA _PROD _PROJECT _ID : process . env . INFURA _PROD _PROJECT _ID ,
PUBNUB _PUB _KEY : process . env . PUBNUB _PUB _KEY ,
PUBNUB _SUB _KEY : process . env . PUBNUB _SUB _KEY ,
SEGMENT _BETA _WRITE _KEY : process . env . SEGMENT _BETA _WRITE _KEY ,
SEGMENT _FLASK _WRITE _KEY : process . env . SEGMENT _FLASK _WRITE _KEY ,
SEGMENT _PROD _WRITE _KEY : process . env . SEGMENT _PROD _WRITE _KEY ,
SENTRY _DSN : process . env . SENTRY _DSN ,
... ini . parse ( prodConfigContents ) ,
... environmentVariables ,
} ;
const requiredEnvironmentVariables = {