MCPcopy
hub / github.com/CapSoftware/Cap / main

Function main

scripts/env-cli.js:28–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26};
27
28async function main() {
29 intro("Welcome to the Cap env setup CLI!");
30
31 const targets = await multiselect({
32 message: "Which apps will you be working on?",
33 options: [
34 { value: "desktop", label: "Desktop" },
35 { value: "web", label: "Web" },
36 ],
37 required: true,
38 });
39
40 if (isCancel(targets)) return;
41
42 const file = await fs
43 .readFile("./target/env-profiles/default.json", "utf8")
44 .catch(() => null);
45 let allEnvs = file ? JSON.parse(file) : {};
46
47 let envs = {
48 NODE_ENV: "development",
49 };
50
51 const hasWeb = targets.includes("web");
52 const hasDesktop = targets.includes("desktop");
53
54 /** @type {boolean | symbol} */
55 let usingDockerEnvironment = false;
56
57 if (hasWeb) {
58 envs.VITE_SERVER_URL = "http://localhost:3000";
59 envs.WEB_URL = "http://localhost:3000";
60 envs.NEXTAUTH_URL = envs.WEB_URL;
61 envs.WORKFLOWS_RPC_SECRET = crypto.randomBytes(32).toString("base64");
62 envs.MEDIA_SERVER_URL = "http://localhost:3456";
63 envs.MEDIA_SERVER_WEBHOOK_SECRET = crypto
64 .randomBytes(32)
65 .toString("base64");
66
67 if (!allEnvs.NEXTAUTH_SECRET) {
68 allEnvs.NEXTAUTH_SECRET = crypto.randomBytes(32).toString("base64");
69 log.info("Generated NEXTAUTH_SECRET");
70 }
71 envs.NEXTAUTH_SECRET = allEnvs.NEXTAUTH_SECRET;
72
73 if (!allEnvs.DATABASE_ENCRYPTION_KEY) {
74 allEnvs.DATABASE_ENCRYPTION_KEY = crypto.randomBytes(32).toString("hex");
75 log.info("Generated DATABASE_ENCRYPTION_KEY");
76 }
77 envs.DATABASE_ENCRYPTION_KEY = allEnvs.DATABASE_ENCRYPTION_KEY;
78
79 usingDockerEnvironment = await confirm({
80 message: "Will you be running S3 and MySQL via Docker?",
81 });
82
83 if (isCancel(usingDockerEnvironment)) return;
84 if (!usingDockerEnvironment) {
85 log.info("Database Envs");

Callers 1

env-cli.jsFile · 0.70

Calls 1

textFunction · 0.50

Tested by

no test coverage detected