forked from Mijago/D2ArmorPicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-env.ts
58 lines (50 loc) · 1.56 KB
/
set-env.ts
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
const writeFile = require("fs").writeFile
const production = process.env.PRODUCTION === "1"
const beta_branch = process.env.BETA === "1"
const version = "2.3.0"
// Configure Angular `environment.ts` file path
const targetPath = production
? './src/environments/environment.prod.ts'
: beta_branch
? './src/environments/environment.prod.ts'
: './src/environments/environment.ts';
// Load node modules
require('dotenv').config({
path: production
? ".env"
: beta_branch
? ".env_beta"
: ".env_dev"
});
const revision = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString().trim()
var version_tag = production
? ""
: beta_branch
? "-beta-" + revision
: "-dev-" + revision
const data = {
version: version + version_tag,
revision: revision,
production: production,
beta: beta_branch,
apiKey: process.env.D2AP_BUNGIE_API_KEY,
clientId: process.env.D2AP_BUNGIE_CLIENT_ID,
client_secret: process.env.D2AP_BUNGIE_CLIENT_SECRET,
nodeEnv: process.env.NODE_ENV,
offlineMode: false,
featureFlags: {
enableModslotLimitation: process.env.D2AP_FEATURE_ENABLE_MODSLOT_LIMITATION == "1",
enableZeroWaste: process.env.D2AP_FEATURE_ENABLE_ZERO_WASTE == "1",
}
}
// `environment.ts` file structure
const envConfigFile = `export const environment = ${JSON.stringify(data, null, 2)};`;
writeFile(targetPath, envConfigFile, (err: NodeJS.ErrnoException | null) => {
if (err) {
throw console.error(err);
} else {
console.log(`Angular environment.ts file generated correctly at ${targetPath} \n`);
}
});