-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-env-files.js
More file actions
51 lines (48 loc) · 1.41 KB
/
Copy pathcreate-env-files.js
File metadata and controls
51 lines (48 loc) · 1.41 KB
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
const fs = require("fs");
const path = require("path");
const successColor = "\x1b[32m%s\x1b[0m";
const checkSign = "\u{2705}";
const dotenv = require("dotenv").config({ path: "./.env" });
const createNewConfigFile = (fileName, filePath, fileContent) => {
return {
fileName,
filePath: path.join(__dirname, `${filePath}${fileName}`),
fileContent,
};
};
const filesToCreate = [
createNewConfigFile(
"environment.ts",
"./src/app/config/",
`export const environment = {
firebase: {
apiKey: '${process.env.YEX_FIREBASE_API_KEY}',
authDomain: '${process.env.YEX_FIREBASE_AUTH_DOMAIN}',
projectId: '${process.env.YEX_FIREBASE_PROJECT_ID}',
storageBucket: '${process.env.YEX_FIREBASE_STORAGE_BUCKET}',
messagingSenderId: '${process.env.YEX_FIREBASE_MESSAGING_SENDER_ID}',
appId: '${process.env.YEX_FIREBASE_MEASUREMENT_ID}',
measurementId: '${process.env.YEX_WHITELIST_EMAILS}',
}
}`
),
createNewConfigFile(
"auth.whitelist.ts",
"./src/app/auth/",
`export const whitelist: string[] = '${process.env.YEX_WHITELIST_EMAILS}'.split(',')`
),
];
filesToCreate.forEach((file) => {
const { fileName, filePath, fileContent } = file;
fs.writeFile(filePath, fileContent, (err) => {
if (err) {
console.error(err);
throw err;
} else {
console.log(
successColor,
`${checkSign} Successfully generated ${fileName}`
);
}
});
});