forked from dappforce/polkaverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export-env.js
executable file
·64 lines (50 loc) · 1.27 KB
/
export-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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint-disable @typescript-eslint/no-var-requires */
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { writeFileSync } = require('fs')
require('dotenv').config()
const varsToExport = [
'NODE_ENV',
'LOG_LEVEL',
'APP_KIND',
'APP_BASE_URL',
'CONNECTION_KIND',
'ENABLE_SEARCH',
'ENABLE_FEED',
'ENABLE_NOTIFICATIONS',
'ENABLE_ACTIVITY',
'ENABLE_SQUID_DATA_SOURCE',
'ENABLE_SESSION_KEY',
'ENABLE_EMAIL_SETTINGS',
'ENABLE_FAUCET',
'ENABLE_GRAPHQL',
'ENABLE_DOWNVOTES',
'ENABLE_CONTRIBUTION_PAGE',
'ENABLE_ONCHAIN_ACTIVITIES',
'ENABLE_MAINTENANCE_PAGE',
'MAINTENANCE_TEXT',
'GA_ID',
'SUBSTRATE_URL',
'SUBSTRATE_RPC_URL',
'OFFCHAIN_URL',
'OFFCHAIN_WS',
'GRAPHQL_URL',
'IPFS_NODE_URL',
]
function getSerializedVal(varName) {
const val = process.env[varName]
return typeof val === 'string' ? `'${val}'` : val
}
const vals = varsToExport.map(varName => `${varName}: ${getSerializedVal(varName)}`).join(',\n ')
const jsFile = `${__dirname}/public/env.js`
console.log(`Export .env to ${jsFile}`)
writeFileSync(
jsFile,
`// WARN: This is a generated file. Do not modify!
if (!window.process) window.process = {};
if (!window.process.ENV) window.process.ENV = {};
window.process.env = {
${vals}
};
`,
'utf8',
)