Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

updateLocalEnv.ts 755 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  1. import fs from "fs";
  2. import yaml from "js-yaml";
  3. const file = fs.readFileSync("chart/env/prod.yaml", "utf8");
  4. // have to do a weird stringify/parse because of some node error
  5. const prod = JSON.parse(JSON.stringify(yaml.load(file)));
  6. const vars = prod.envVars as Record<string, string>;
  7. let PUBLIC_CONFIG = "";
  8. Object.entries(vars).forEach(([key, value]) => {
  9. PUBLIC_CONFIG += `${key}=\`${value}\`\n`;
  10. });
  11. const SECRET_CONFIG =
  12. (fs.existsSync(".env.SECRET_CONFIG")
  13. ? fs.readFileSync(".env.SECRET_CONFIG", "utf8")
  14. : process.env.SECRET_CONFIG) ?? "";
  15. // Prepend the content of the env variable SECRET_CONFIG
  16. const full_config = `${PUBLIC_CONFIG}\n${SECRET_CONFIG}`;
  17. // Write full_config to .env.local
  18. fs.writeFileSync(".env.local", full_config);
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...