2021-03-18 18:02:25 +01:00
|
|
|
const { writeFile } = require('fs');
|
|
|
|
const { argv } = require('yargs');
|
|
|
|
const colors = require('colors');
|
|
|
|
require('dotenv').config();
|
|
|
|
|
|
|
|
const environment = argv.environment;
|
|
|
|
const isProduction = environment === 'prod';
|
|
|
|
|
2021-05-12 16:12:02 +02:00
|
|
|
const targetPath = isProduction ? `./src/environments/environment.prod.ts` : `./src/environments/environment.dev.ts`;
|
2021-03-18 18:02:25 +01:00
|
|
|
|
|
|
|
const environmentVars = `import {NgxLoggerLevel} from 'ngx-logger';
|
|
|
|
|
|
|
|
export const environment = {
|
|
|
|
production: ${isProduction},
|
2021-03-18 18:16:43 +01:00
|
|
|
bloxbergChainId: ${process.env.CIC_CHAIN_ID || 8996},
|
2021-03-24 08:43:07 +01:00
|
|
|
logLevel: ${process.env.LOG_LEVEL || 'NgxLoggerLevel.ERROR'},
|
2021-03-21 12:04:21 +01:00
|
|
|
serverLogLevel: ${process.env.SERVER_LOG_LEVEL || 'NgxLoggerLevel.OFF'},
|
2021-05-12 16:12:02 +02:00
|
|
|
loggingUrl: '${process.env.CIC_LOGGING_URL || ''}',
|
2021-03-18 18:16:43 +01:00
|
|
|
cicMetaUrl: '${process.env.CIC_META_URL || 'https://meta.dev.grassrootseconomics.net'}',
|
2021-05-12 16:12:02 +02:00
|
|
|
publicKeysUrl: '${process.env.CIC_KEYS_URL || 'https://dev.grassrootseconomics.net/.well-known/publickeys'}',
|
2021-03-18 18:16:43 +01:00
|
|
|
cicCacheUrl: '${process.env.CIC_CACHE_URL || 'https://cache.dev.grassrootseconomics.net'}',
|
2021-05-12 16:12:02 +02:00
|
|
|
web3Provider: '${process.env.CIC_WEB3_PROVIDER || 'wss://bloxberg-ws.dev.grassrootseconomics.net'}',
|
2021-03-18 18:16:43 +01:00
|
|
|
cicUssdUrl: '${process.env.CIC_USSD_URL || 'https://ussd.dev.grassrootseconomics.net'}',
|
2021-05-12 16:12:02 +02:00
|
|
|
registryAddress: '${process.env.CIC_REGISTRY_ADDRESS || '0xea6225212005e86a4490018ded4bf37f3e772161'}',
|
2021-03-18 18:16:43 +01:00
|
|
|
trustedDeclaratorAddress: '${process.env.CIC_TRUSTED_ADDRESS || '0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C'}'
|
2021-03-18 18:02:25 +01:00
|
|
|
};
|
|
|
|
`;
|
|
|
|
|
|
|
|
function setConfigs(configs): void {
|
|
|
|
writeFile(targetPath, configs, err => {
|
|
|
|
if (err) {
|
|
|
|
throw console.error(err);
|
|
|
|
} else {
|
2021-03-18 18:16:43 +01:00
|
|
|
console.log(colors.green(`Wrote variables to '${targetPath}`));
|
2021-03-18 18:02:25 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isProduction) {
|
2021-03-18 18:16:43 +01:00
|
|
|
console.log(colors.cyan('Running in production environment!'));
|
2021-03-18 18:02:25 +01:00
|
|
|
setConfigs(environmentVars);
|
|
|
|
} else {
|
2021-03-18 18:16:43 +01:00
|
|
|
console.log(colors.cyan('Running in development environment!'));
|
2021-03-18 18:02:25 +01:00
|
|
|
setConfigs(environmentVars);
|
|
|
|
}
|
|
|
|
|