-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-env.js
30 lines (26 loc) · 922 Bytes
/
set-env.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const { writeFileSync } = require('fs');
const { resolve } = require('path');
const isProduction = process.argv[2] === 'production';
const oidcKey = process.env.CONSOLE_OIDC_KEY;
const apiUrl = process.env.CONSOLE_API_URL || 'http://127.0.0.1:5000';
const targetPath = resolve(
__dirname,
`apps/restorecommerce/src/environments/environment${
isProduction ? '' : '.development'
}.ts`
);
// Define environment variables
const envConfigFile = `import { IEnvironment } from '@console-core/types';
export const environment: Readonly<IEnvironment> = {
production: ${isProduction},
oidcKey: '${oidcKey}',
storagePrefix: '${isProduction ? 'console.prod.' : 'console.dev.'}',
urls: {
api: '${apiUrl}',
graphql: '${apiUrl}/graphql',
},
};
`;
// Write the content to the environment file
writeFileSync(targetPath, envConfigFile, 'utf8');
console.log(`Environment variables written to ${targetPath}`);