create-better-t-stack 3.9.0 → 3.11.0-pr749.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/bin/create-better-t-stack +98 -0
- package/package.json +69 -59
- package/src/api.ts +203 -0
- package/src/cli.ts +185 -0
- package/src/constants.ts +270 -0
- package/src/helpers/addons/addons-setup.ts +201 -0
- package/src/helpers/addons/examples-setup.ts +137 -0
- package/src/helpers/addons/fumadocs-setup.ts +99 -0
- package/src/helpers/addons/oxlint-setup.ts +36 -0
- package/src/helpers/addons/ruler-setup.ts +135 -0
- package/src/helpers/addons/starlight-setup.ts +45 -0
- package/src/helpers/addons/tauri-setup.ts +90 -0
- package/src/helpers/addons/tui-setup.ts +64 -0
- package/src/helpers/addons/ultracite-setup.ts +228 -0
- package/src/helpers/addons/vite-pwa-setup.ts +59 -0
- package/src/helpers/addons/wxt-setup.ts +86 -0
- package/src/helpers/core/add-addons.ts +85 -0
- package/src/helpers/core/add-deployment.ts +102 -0
- package/src/helpers/core/api-setup.ts +280 -0
- package/src/helpers/core/auth-setup.ts +203 -0
- package/src/helpers/core/backend-setup.ts +69 -0
- package/src/helpers/core/command-handlers.ts +354 -0
- package/src/helpers/core/convex-codegen.ts +14 -0
- package/src/helpers/core/create-project.ts +134 -0
- package/src/helpers/core/create-readme.ts +694 -0
- package/src/helpers/core/db-setup.ts +184 -0
- package/src/helpers/core/detect-project-config.ts +41 -0
- package/src/helpers/core/env-setup.ts +481 -0
- package/src/helpers/core/git.ts +23 -0
- package/src/helpers/core/install-dependencies.ts +29 -0
- package/src/helpers/core/payments-setup.ts +48 -0
- package/src/helpers/core/post-installation.ts +403 -0
- package/src/helpers/core/project-config.ts +250 -0
- package/src/helpers/core/runtime-setup.ts +76 -0
- package/src/helpers/core/template-manager.ts +917 -0
- package/src/helpers/core/workspace-setup.ts +184 -0
- package/src/helpers/database-providers/d1-setup.ts +28 -0
- package/src/helpers/database-providers/docker-compose-setup.ts +50 -0
- package/src/helpers/database-providers/mongodb-atlas-setup.ts +182 -0
- package/src/helpers/database-providers/neon-setup.ts +240 -0
- package/src/helpers/database-providers/planetscale-setup.ts +78 -0
- package/src/helpers/database-providers/prisma-postgres-setup.ts +193 -0
- package/src/helpers/database-providers/supabase-setup.ts +196 -0
- package/src/helpers/database-providers/turso-setup.ts +309 -0
- package/src/helpers/deployment/alchemy/alchemy-combined-setup.ts +80 -0
- package/src/helpers/deployment/alchemy/alchemy-next-setup.ts +52 -0
- package/src/helpers/deployment/alchemy/alchemy-nuxt-setup.ts +105 -0
- package/src/helpers/deployment/alchemy/alchemy-react-router-setup.ts +33 -0
- package/src/helpers/deployment/alchemy/alchemy-solid-setup.ts +33 -0
- package/src/helpers/deployment/alchemy/alchemy-svelte-setup.ts +99 -0
- package/src/helpers/deployment/alchemy/alchemy-tanstack-router-setup.ts +34 -0
- package/src/helpers/deployment/alchemy/alchemy-tanstack-start-setup.ts +99 -0
- package/src/helpers/deployment/alchemy/env-dts-setup.ts +76 -0
- package/src/helpers/deployment/alchemy/index.ts +7 -0
- package/src/helpers/deployment/server-deploy-setup.ts +55 -0
- package/src/helpers/deployment/web-deploy-setup.ts +58 -0
- package/src/index.ts +51 -0
- package/src/prompts/addons.ts +200 -0
- package/src/prompts/api.ts +49 -0
- package/src/prompts/auth.ts +84 -0
- package/src/prompts/backend.ts +83 -0
- package/src/prompts/config-prompts.ts +138 -0
- package/src/prompts/database-setup.ts +112 -0
- package/src/prompts/database.ts +57 -0
- package/src/prompts/examples.ts +60 -0
- package/src/prompts/frontend.ts +118 -0
- package/src/prompts/git.ts +16 -0
- package/src/prompts/install.ts +16 -0
- package/src/prompts/orm.ts +53 -0
- package/src/prompts/package-manager.ts +32 -0
- package/src/prompts/payments.ts +50 -0
- package/src/prompts/project-name.ts +86 -0
- package/src/prompts/runtime.ts +47 -0
- package/src/prompts/server-deploy.ts +91 -0
- package/src/prompts/web-deploy.ts +107 -0
- package/src/tui/app.tsx +1062 -0
- package/src/types.ts +70 -0
- package/src/utils/add-package-deps.ts +57 -0
- package/src/utils/analytics.ts +39 -0
- package/src/utils/better-auth-plugin-setup.ts +71 -0
- package/src/utils/bts-config.ts +122 -0
- package/src/utils/command-exists.ts +16 -0
- package/src/utils/compatibility-rules.ts +337 -0
- package/src/utils/compatibility.ts +11 -0
- package/src/utils/config-processing.ts +130 -0
- package/src/utils/config-validation.ts +470 -0
- package/src/utils/display-config.ts +96 -0
- package/src/utils/docker-utils.ts +70 -0
- package/src/utils/errors.ts +30 -0
- package/src/utils/file-formatter.ts +11 -0
- package/src/utils/generate-reproducible-command.ts +53 -0
- package/src/utils/get-latest-cli-version.ts +27 -0
- package/src/utils/get-package-manager.ts +13 -0
- package/src/utils/open-url.ts +18 -0
- package/src/utils/package-runner.ts +23 -0
- package/src/utils/project-directory.ts +102 -0
- package/src/utils/project-name-validation.ts +43 -0
- package/src/utils/render-title.ts +48 -0
- package/src/utils/setup-catalogs.ts +192 -0
- package/src/utils/sponsors.ts +101 -0
- package/src/utils/telemetry.ts +19 -0
- package/src/utils/template-processor.ts +64 -0
- package/src/utils/templates.ts +94 -0
- package/src/utils/ts-morph.ts +26 -0
- package/src/validation.ts +117 -0
- package/templates/auth/better-auth/convex/backend/convex/auth.config.ts.hbs +5 -7
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +17 -17
- package/templates/auth/better-auth/convex/backend/convex/http.ts.hbs +4 -4
- package/templates/auth/better-auth/convex/web/react/next/src/app/api/auth/[...all]/route.ts.hbs +2 -2
- package/templates/auth/better-auth/convex/web/react/next/src/components/user-menu.tsx.hbs +10 -10
- package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-server.ts.hbs +13 -5
- package/templates/auth/better-auth/convex/web/react/tanstack-router/src/components/user-menu.tsx.hbs +14 -12
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/components/user-menu.tsx.hbs +13 -16
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/lib/auth-server.ts.hbs +11 -5
- package/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/api/auth/$.ts.hbs +4 -4
- package/templates/auth/better-auth/fullstack/tanstack-start/src/routes/api/auth/$.ts.hbs +1 -1
- package/templates/auth/better-auth/web/react/next/src/components/user-menu.tsx.hbs +17 -15
- package/templates/auth/better-auth/web/react/react-router/src/components/user-menu.tsx.hbs +16 -15
- package/templates/auth/better-auth/web/react/tanstack-router/src/components/{user-menu.tsx → user-menu.tsx.hbs} +16 -15
- package/templates/auth/better-auth/web/react/tanstack-start/src/components/{user-menu.tsx → user-menu.tsx.hbs} +16 -15
- package/templates/backend/convex/packages/backend/convex/README.md +4 -4
- package/templates/backend/convex/packages/backend/convex/convex.config.ts.hbs +17 -0
- package/templates/backend/convex/packages/backend/convex/tsconfig.json.hbs +1 -1
- package/templates/examples/ai/convex/packages/backend/convex/agent.ts.hbs +9 -0
- package/templates/examples/ai/convex/packages/backend/convex/chat.ts.hbs +67 -0
- package/templates/examples/ai/native/bare/app/(drawer)/ai.tsx.hbs +301 -3
- package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +296 -10
- package/templates/examples/ai/native/uniwind/app/(drawer)/ai.tsx.hbs +180 -1
- package/templates/examples/ai/web/react/next/src/app/ai/page.tsx.hbs +172 -9
- package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx.hbs +156 -6
- package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx.hbs +156 -4
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx.hbs +159 -6
- package/templates/frontend/react/next/package.json.hbs +8 -7
- package/templates/frontend/react/next/src/app/layout.tsx.hbs +28 -1
- package/templates/frontend/react/next/src/components/mode-toggle.tsx.hbs +4 -6
- package/templates/frontend/react/next/src/components/providers.tsx.hbs +14 -4
- package/templates/frontend/react/react-router/package.json.hbs +2 -1
- package/templates/frontend/react/{tanstack-router/src/components/mode-toggle.tsx → react-router/src/components/mode-toggle.tsx.hbs} +4 -6
- package/templates/frontend/react/tanstack-router/package.json.hbs +2 -1
- package/templates/frontend/react/{react-router/src/components/mode-toggle.tsx → tanstack-router/src/components/mode-toggle.tsx.hbs} +4 -6
- package/templates/frontend/react/tanstack-start/package.json.hbs +2 -1
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +6 -0
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +13 -14
- package/templates/frontend/react/tanstack-start/vite.config.ts.hbs +5 -0
- package/templates/frontend/react/web-base/components.json +5 -2
- package/templates/frontend/react/web-base/src/components/ui/button.tsx.hbs +57 -0
- package/templates/frontend/react/web-base/src/components/ui/card.tsx.hbs +103 -0
- package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx.hbs +26 -0
- package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx.hbs +262 -0
- package/templates/frontend/react/web-base/src/components/ui/input.tsx.hbs +20 -0
- package/templates/frontend/react/web-base/src/components/ui/label.tsx.hbs +20 -0
- package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx.hbs +13 -0
- package/templates/frontend/react/web-base/src/components/ui/sonner.tsx.hbs +44 -0
- package/templates/frontend/react/web-base/src/index.css.hbs +58 -64
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -8
- package/dist/index.d.mts +0 -347
- package/dist/index.mjs +0 -4
- package/dist/src-DLvUK0Qf.mjs +0 -7069
- package/templates/auth/better-auth/convex/backend/convex/convex.config.ts.hbs +0 -7
- package/templates/examples/ai/web/react/base/src/components/response.tsx.hbs +0 -22
- package/templates/frontend/react/web-base/src/components/ui/button.tsx +0 -56
- package/templates/frontend/react/web-base/src/components/ui/card.tsx +0 -75
- package/templates/frontend/react/web-base/src/components/ui/checkbox.tsx +0 -27
- package/templates/frontend/react/web-base/src/components/ui/dropdown-menu.tsx +0 -228
- package/templates/frontend/react/web-base/src/components/ui/input.tsx +0 -21
- package/templates/frontend/react/web-base/src/components/ui/label.tsx +0 -19
- package/templates/frontend/react/web-base/src/components/ui/skeleton.tsx +0 -13
- package/templates/frontend/react/web-base/src/components/ui/sonner.tsx +0 -25
- /package/templates/auth/better-auth/web/react/tanstack-router/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-router/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-router/src/routes/{login.tsx → login.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-start/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-start/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/react/tanstack-start/src/routes/{login.tsx → login.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/solid/src/components/{sign-in-form.tsx → sign-in-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/solid/src/components/{sign-up-form.tsx → sign-up-form.tsx.hbs} +0 -0
- /package/templates/auth/better-auth/web/solid/src/routes/{login.tsx → login.tsx.hbs} +0 -0
- /package/templates/frontend/react/react-router/src/components/{theme-provider.tsx → theme-provider.tsx.hbs} +0 -0
- /package/templates/frontend/react/tanstack-router/src/components/{theme-provider.tsx → theme-provider.tsx.hbs} +0 -0
- /package/templates/frontend/react/web-base/src/lib/{utils.ts → utils.ts.hbs} +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import consola from "consola";
|
|
3
|
+
import fs from "fs-extra";
|
|
4
|
+
import pc from "picocolors";
|
|
5
|
+
import type { AvailableDependencies } from "../../constants";
|
|
6
|
+
import type { ProjectConfig } from "../../types";
|
|
7
|
+
import { addPackageDependency } from "../../utils/add-package-deps";
|
|
8
|
+
import { setupCloudflareD1 } from "../database-providers/d1-setup";
|
|
9
|
+
import { setupDockerCompose } from "../database-providers/docker-compose-setup";
|
|
10
|
+
import { setupMongoDBAtlas } from "../database-providers/mongodb-atlas-setup";
|
|
11
|
+
import { setupNeonPostgres } from "../database-providers/neon-setup";
|
|
12
|
+
import { setupPlanetScale } from "../database-providers/planetscale-setup";
|
|
13
|
+
import { setupPrismaPostgres } from "../database-providers/prisma-postgres-setup";
|
|
14
|
+
import { setupSupabase } from "../database-providers/supabase-setup";
|
|
15
|
+
import { setupTurso } from "../database-providers/turso-setup";
|
|
16
|
+
|
|
17
|
+
export async function setupDatabase(config: ProjectConfig, cliInput?: { manualDb?: boolean }) {
|
|
18
|
+
const { database, orm, dbSetup, backend, projectDir } = config;
|
|
19
|
+
|
|
20
|
+
if (backend === "convex" || database === "none") {
|
|
21
|
+
if (backend !== "convex") {
|
|
22
|
+
const serverDir = path.join(projectDir, "apps/server");
|
|
23
|
+
const serverDbDir = path.join(serverDir, "src/db");
|
|
24
|
+
if (await fs.pathExists(serverDbDir)) {
|
|
25
|
+
await fs.remove(serverDbDir);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const dbPackageDir = path.join(projectDir, "packages/db");
|
|
32
|
+
const webDir = path.join(projectDir, "apps/web");
|
|
33
|
+
const webDirExists = await fs.pathExists(webDir);
|
|
34
|
+
|
|
35
|
+
if (!(await fs.pathExists(dbPackageDir))) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
if (orm === "prisma") {
|
|
41
|
+
if (database === "mongodb") {
|
|
42
|
+
await addPackageDependency({
|
|
43
|
+
customDependencies: {
|
|
44
|
+
"@prisma/client": "6.19.0",
|
|
45
|
+
},
|
|
46
|
+
customDevDependencies: {
|
|
47
|
+
prisma: "6.19.0",
|
|
48
|
+
},
|
|
49
|
+
projectDir: dbPackageDir,
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
const prismaDependencies: AvailableDependencies[] = ["@prisma/client"];
|
|
53
|
+
const prismaDevDependencies: AvailableDependencies[] = ["prisma"];
|
|
54
|
+
|
|
55
|
+
if (database === "mysql" && dbSetup === "planetscale") {
|
|
56
|
+
prismaDependencies.push("@prisma/adapter-planetscale", "@planetscale/database");
|
|
57
|
+
} else if (database === "mysql") {
|
|
58
|
+
prismaDependencies.push("@prisma/adapter-mariadb");
|
|
59
|
+
} else if (database === "sqlite") {
|
|
60
|
+
if (dbSetup === "d1") {
|
|
61
|
+
prismaDependencies.push("@prisma/adapter-d1");
|
|
62
|
+
} else {
|
|
63
|
+
prismaDependencies.push("@prisma/adapter-libsql");
|
|
64
|
+
}
|
|
65
|
+
} else if (database === "postgres") {
|
|
66
|
+
if (dbSetup === "neon") {
|
|
67
|
+
prismaDependencies.push("@prisma/adapter-neon", "@neondatabase/serverless", "ws");
|
|
68
|
+
prismaDevDependencies.push("@types/ws");
|
|
69
|
+
} else if (dbSetup === "prisma-postgres") {
|
|
70
|
+
prismaDependencies.push("@prisma/adapter-pg");
|
|
71
|
+
} else {
|
|
72
|
+
prismaDependencies.push("@prisma/adapter-pg");
|
|
73
|
+
prismaDependencies.push("pg");
|
|
74
|
+
prismaDevDependencies.push("@types/pg");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
await addPackageDependency({
|
|
79
|
+
dependencies: prismaDependencies,
|
|
80
|
+
devDependencies: prismaDevDependencies,
|
|
81
|
+
projectDir: dbPackageDir,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (await fs.pathExists(webDir)) {
|
|
86
|
+
if (database === "mongodb") {
|
|
87
|
+
await addPackageDependency({
|
|
88
|
+
customDependencies: {
|
|
89
|
+
"@prisma/client": "6.19.0",
|
|
90
|
+
},
|
|
91
|
+
projectDir: webDir,
|
|
92
|
+
});
|
|
93
|
+
} else {
|
|
94
|
+
await addPackageDependency({
|
|
95
|
+
dependencies: ["@prisma/client"],
|
|
96
|
+
projectDir: webDir,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} else if (orm === "drizzle") {
|
|
101
|
+
if (database === "sqlite") {
|
|
102
|
+
await addPackageDependency({
|
|
103
|
+
dependencies: ["drizzle-orm", "@libsql/client", "libsql"],
|
|
104
|
+
devDependencies: ["drizzle-kit"],
|
|
105
|
+
projectDir: dbPackageDir,
|
|
106
|
+
});
|
|
107
|
+
if (webDirExists) {
|
|
108
|
+
await addPackageDependency({
|
|
109
|
+
dependencies: ["@libsql/client", "libsql"],
|
|
110
|
+
projectDir: webDir,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
} else if (database === "postgres") {
|
|
114
|
+
if (dbSetup === "neon") {
|
|
115
|
+
await addPackageDependency({
|
|
116
|
+
dependencies: ["drizzle-orm", "@neondatabase/serverless", "ws"],
|
|
117
|
+
devDependencies: ["drizzle-kit", "@types/ws"],
|
|
118
|
+
projectDir: dbPackageDir,
|
|
119
|
+
});
|
|
120
|
+
} else if (dbSetup === "planetscale") {
|
|
121
|
+
await addPackageDependency({
|
|
122
|
+
dependencies: ["drizzle-orm", "pg"],
|
|
123
|
+
devDependencies: ["drizzle-kit", "@types/pg"],
|
|
124
|
+
projectDir: dbPackageDir,
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
await addPackageDependency({
|
|
128
|
+
dependencies: ["drizzle-orm", "pg"],
|
|
129
|
+
devDependencies: ["drizzle-kit", "@types/pg"],
|
|
130
|
+
projectDir: dbPackageDir,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
} else if (database === "mysql") {
|
|
134
|
+
if (dbSetup === "planetscale") {
|
|
135
|
+
await addPackageDependency({
|
|
136
|
+
dependencies: ["drizzle-orm", "@planetscale/database"],
|
|
137
|
+
devDependencies: ["drizzle-kit"],
|
|
138
|
+
projectDir: dbPackageDir,
|
|
139
|
+
});
|
|
140
|
+
} else {
|
|
141
|
+
await addPackageDependency({
|
|
142
|
+
dependencies: ["drizzle-orm", "mysql2"],
|
|
143
|
+
devDependencies: ["drizzle-kit"],
|
|
144
|
+
projectDir: dbPackageDir,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
} else if (orm === "mongoose") {
|
|
149
|
+
await addPackageDependency({
|
|
150
|
+
dependencies: ["mongoose"],
|
|
151
|
+
devDependencies: [],
|
|
152
|
+
projectDir: dbPackageDir,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (dbSetup === "docker") {
|
|
157
|
+
await setupDockerCompose(config);
|
|
158
|
+
} else if (database === "sqlite" && dbSetup === "turso") {
|
|
159
|
+
await setupTurso(config, cliInput);
|
|
160
|
+
} else if (database === "sqlite" && dbSetup === "d1") {
|
|
161
|
+
await setupCloudflareD1(config);
|
|
162
|
+
} else if (database === "postgres") {
|
|
163
|
+
if (dbSetup === "prisma-postgres") {
|
|
164
|
+
await setupPrismaPostgres(config, cliInput);
|
|
165
|
+
} else if (dbSetup === "neon") {
|
|
166
|
+
await setupNeonPostgres(config, cliInput);
|
|
167
|
+
} else if (dbSetup === "planetscale") {
|
|
168
|
+
await setupPlanetScale(config);
|
|
169
|
+
} else if (dbSetup === "supabase") {
|
|
170
|
+
await setupSupabase(config, cliInput);
|
|
171
|
+
}
|
|
172
|
+
} else if (database === "mysql") {
|
|
173
|
+
if (dbSetup === "planetscale") {
|
|
174
|
+
await setupPlanetScale(config);
|
|
175
|
+
}
|
|
176
|
+
} else if (database === "mongodb" && dbSetup === "mongodb-atlas") {
|
|
177
|
+
await setupMongoDBAtlas(config, cliInput);
|
|
178
|
+
}
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error instanceof Error) {
|
|
181
|
+
consola.error(pc.red(error.message));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { readBtsConfig } from "../../utils/bts-config";
|
|
4
|
+
|
|
5
|
+
export async function detectProjectConfig(projectDir: string) {
|
|
6
|
+
try {
|
|
7
|
+
const btsConfig = await readBtsConfig(projectDir);
|
|
8
|
+
if (btsConfig) {
|
|
9
|
+
return {
|
|
10
|
+
projectDir,
|
|
11
|
+
projectName: path.basename(projectDir),
|
|
12
|
+
database: btsConfig.database,
|
|
13
|
+
orm: btsConfig.orm,
|
|
14
|
+
backend: btsConfig.backend,
|
|
15
|
+
runtime: btsConfig.runtime,
|
|
16
|
+
frontend: btsConfig.frontend,
|
|
17
|
+
addons: btsConfig.addons,
|
|
18
|
+
examples: btsConfig.examples,
|
|
19
|
+
auth: btsConfig.auth,
|
|
20
|
+
payments: btsConfig.payments,
|
|
21
|
+
packageManager: btsConfig.packageManager,
|
|
22
|
+
dbSetup: btsConfig.dbSetup,
|
|
23
|
+
api: btsConfig.api,
|
|
24
|
+
webDeploy: btsConfig.webDeploy,
|
|
25
|
+
serverDeploy: btsConfig.serverDeploy,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return null;
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function isBetterTStackProject(projectDir: string) {
|
|
36
|
+
try {
|
|
37
|
+
return await fs.pathExists(path.join(projectDir, "bts.jsonc"));
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import type { ProjectConfig } from "../../types";
|
|
4
|
+
import { generateAuthSecret } from "./auth-setup";
|
|
5
|
+
|
|
6
|
+
function getClientServerVar(frontend: string[], backend: ProjectConfig["backend"]) {
|
|
7
|
+
const hasNextJs = frontend.includes("next");
|
|
8
|
+
const hasNuxt = frontend.includes("nuxt");
|
|
9
|
+
const hasSvelte = frontend.includes("svelte");
|
|
10
|
+
const hasTanstackStart = frontend.includes("tanstack-start");
|
|
11
|
+
|
|
12
|
+
// For fullstack self, no base URL is needed (same-origin)
|
|
13
|
+
if (backend === "self") {
|
|
14
|
+
return { key: "", value: "", write: false } as const;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let key = "VITE_SERVER_URL";
|
|
18
|
+
if (hasNextJs) key = "NEXT_PUBLIC_SERVER_URL";
|
|
19
|
+
else if (hasNuxt) key = "NUXT_PUBLIC_SERVER_URL";
|
|
20
|
+
else if (hasSvelte) key = "PUBLIC_SERVER_URL";
|
|
21
|
+
else if (hasTanstackStart) key = "VITE_SERVER_URL";
|
|
22
|
+
|
|
23
|
+
return { key, value: "http://localhost:3000", write: true } as const;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getConvexVar(frontend: string[]) {
|
|
27
|
+
const hasNextJs = frontend.includes("next");
|
|
28
|
+
const hasNuxt = frontend.includes("nuxt");
|
|
29
|
+
const hasSvelte = frontend.includes("svelte");
|
|
30
|
+
const hasTanstackStart = frontend.includes("tanstack-start");
|
|
31
|
+
if (hasNextJs) return "NEXT_PUBLIC_CONVEX_URL";
|
|
32
|
+
if (hasNuxt) return "NUXT_PUBLIC_CONVEX_URL";
|
|
33
|
+
if (hasSvelte) return "PUBLIC_CONVEX_URL";
|
|
34
|
+
if (hasTanstackStart) return "VITE_CONVEX_URL";
|
|
35
|
+
return "VITE_CONVEX_URL";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface EnvVariable {
|
|
39
|
+
key: string;
|
|
40
|
+
value: string | null | undefined;
|
|
41
|
+
condition: boolean;
|
|
42
|
+
comment?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function addEnvVariablesToFile(filePath: string, variables: EnvVariable[]) {
|
|
46
|
+
await fs.ensureDir(path.dirname(filePath));
|
|
47
|
+
|
|
48
|
+
let envContent = "";
|
|
49
|
+
if (await fs.pathExists(filePath)) {
|
|
50
|
+
envContent = await fs.readFile(filePath, "utf8");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let modified = false;
|
|
54
|
+
let contentToAdd = "";
|
|
55
|
+
const exampleVariables: string[] = [];
|
|
56
|
+
|
|
57
|
+
for (const { key, value, condition, comment } of variables) {
|
|
58
|
+
if (condition) {
|
|
59
|
+
const regex = new RegExp(`^${key}=.*$`, "m");
|
|
60
|
+
const valueToWrite = value ?? "";
|
|
61
|
+
exampleVariables.push(`${key}=`);
|
|
62
|
+
|
|
63
|
+
if (regex.test(envContent)) {
|
|
64
|
+
const existingMatch = envContent.match(regex);
|
|
65
|
+
if (existingMatch && existingMatch[0] !== `${key}=${valueToWrite}`) {
|
|
66
|
+
envContent = envContent.replace(regex, `${key}=${valueToWrite}`);
|
|
67
|
+
modified = true;
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
if (comment) {
|
|
71
|
+
contentToAdd += `# ${comment}\n`;
|
|
72
|
+
}
|
|
73
|
+
contentToAdd += `${key}=${valueToWrite}\n`;
|
|
74
|
+
modified = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (contentToAdd) {
|
|
80
|
+
if (envContent.length > 0 && !envContent.endsWith("\n")) {
|
|
81
|
+
envContent += "\n";
|
|
82
|
+
}
|
|
83
|
+
envContent += contentToAdd;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (modified) {
|
|
87
|
+
await fs.writeFile(filePath, envContent.trimEnd());
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const exampleFilePath = filePath.replace(/\.env$/, ".env.example");
|
|
91
|
+
let exampleEnvContent = "";
|
|
92
|
+
if (await fs.pathExists(exampleFilePath)) {
|
|
93
|
+
exampleEnvContent = await fs.readFile(exampleFilePath, "utf8");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let exampleModified = false;
|
|
97
|
+
let exampleContentToAdd = "";
|
|
98
|
+
|
|
99
|
+
for (const exampleVar of exampleVariables) {
|
|
100
|
+
const key = exampleVar.split("=")[0];
|
|
101
|
+
const regex = new RegExp(`^${key}=.*$`, "m");
|
|
102
|
+
if (!regex.test(exampleEnvContent)) {
|
|
103
|
+
exampleContentToAdd += `${exampleVar}\n`;
|
|
104
|
+
exampleModified = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (exampleContentToAdd) {
|
|
109
|
+
if (exampleEnvContent.length > 0 && !exampleEnvContent.endsWith("\n")) {
|
|
110
|
+
exampleEnvContent += "\n";
|
|
111
|
+
}
|
|
112
|
+
exampleEnvContent += exampleContentToAdd;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (exampleModified || !(await fs.pathExists(exampleFilePath))) {
|
|
116
|
+
await fs.writeFile(exampleFilePath, exampleEnvContent.trimEnd());
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function setupEnvironmentVariables(config: ProjectConfig) {
|
|
121
|
+
const {
|
|
122
|
+
backend,
|
|
123
|
+
frontend,
|
|
124
|
+
database,
|
|
125
|
+
auth,
|
|
126
|
+
examples,
|
|
127
|
+
dbSetup,
|
|
128
|
+
projectDir,
|
|
129
|
+
webDeploy,
|
|
130
|
+
serverDeploy,
|
|
131
|
+
} = config;
|
|
132
|
+
|
|
133
|
+
const hasReactRouter = frontend.includes("react-router");
|
|
134
|
+
const hasTanStackRouter = frontend.includes("tanstack-router");
|
|
135
|
+
const hasTanStackStart = frontend.includes("tanstack-start");
|
|
136
|
+
const hasNextJs = frontend.includes("next");
|
|
137
|
+
const hasNuxt = frontend.includes("nuxt");
|
|
138
|
+
const hasSvelte = frontend.includes("svelte");
|
|
139
|
+
const hasSolid = frontend.includes("solid");
|
|
140
|
+
const hasWebFrontend =
|
|
141
|
+
hasReactRouter ||
|
|
142
|
+
hasTanStackRouter ||
|
|
143
|
+
hasTanStackStart ||
|
|
144
|
+
hasNextJs ||
|
|
145
|
+
hasNuxt ||
|
|
146
|
+
hasSolid ||
|
|
147
|
+
hasSvelte;
|
|
148
|
+
|
|
149
|
+
if (hasWebFrontend) {
|
|
150
|
+
const clientDir = path.join(projectDir, "apps/web");
|
|
151
|
+
if (await fs.pathExists(clientDir)) {
|
|
152
|
+
const baseVar = getClientServerVar(frontend, backend);
|
|
153
|
+
const envVarName = backend === "convex" ? getConvexVar(frontend) : baseVar.key;
|
|
154
|
+
const serverUrl = backend === "convex" ? "https://<YOUR_CONVEX_URL>" : baseVar.value;
|
|
155
|
+
|
|
156
|
+
const clientVars: EnvVariable[] = [
|
|
157
|
+
{
|
|
158
|
+
key: envVarName,
|
|
159
|
+
value: serverUrl,
|
|
160
|
+
condition: backend === "convex" ? true : baseVar.write,
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
if (hasNextJs) {
|
|
165
|
+
clientVars.push({
|
|
166
|
+
key: "PORT",
|
|
167
|
+
value: "3001",
|
|
168
|
+
condition: true,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (backend === "convex" && auth === "clerk") {
|
|
173
|
+
if (hasNextJs) {
|
|
174
|
+
clientVars.push(
|
|
175
|
+
{
|
|
176
|
+
key: "NEXT_PUBLIC_CLERK_FRONTEND_API_URL",
|
|
177
|
+
value: "",
|
|
178
|
+
condition: true,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
key: "NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY",
|
|
182
|
+
value: "",
|
|
183
|
+
condition: true,
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
key: "CLERK_SECRET_KEY",
|
|
187
|
+
value: "",
|
|
188
|
+
condition: true,
|
|
189
|
+
},
|
|
190
|
+
);
|
|
191
|
+
} else if (hasReactRouter || hasTanStackRouter || hasTanStackStart) {
|
|
192
|
+
clientVars.push({
|
|
193
|
+
key: "VITE_CLERK_PUBLISHABLE_KEY",
|
|
194
|
+
value: "",
|
|
195
|
+
condition: true,
|
|
196
|
+
});
|
|
197
|
+
if (hasTanStackStart) {
|
|
198
|
+
clientVars.push({
|
|
199
|
+
key: "CLERK_SECRET_KEY",
|
|
200
|
+
value: "",
|
|
201
|
+
condition: true,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (backend === "convex" && auth === "better-auth") {
|
|
208
|
+
if (hasNextJs) {
|
|
209
|
+
clientVars.push({
|
|
210
|
+
key: "NEXT_PUBLIC_CONVEX_SITE_URL",
|
|
211
|
+
value: "https://<YOUR_CONVEX_URL>",
|
|
212
|
+
condition: true,
|
|
213
|
+
});
|
|
214
|
+
} else if (hasReactRouter || hasTanStackRouter || hasTanStackStart) {
|
|
215
|
+
clientVars.push({
|
|
216
|
+
key: "VITE_CONVEX_SITE_URL",
|
|
217
|
+
value: "https://<YOUR_CONVEX_URL>",
|
|
218
|
+
condition: true,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
await addEnvVariablesToFile(path.join(clientDir, ".env"), clientVars);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (
|
|
228
|
+
frontend.includes("native-bare") ||
|
|
229
|
+
frontend.includes("native-uniwind") ||
|
|
230
|
+
frontend.includes("native-unistyles")
|
|
231
|
+
) {
|
|
232
|
+
const nativeDir = path.join(projectDir, "apps/native");
|
|
233
|
+
if (await fs.pathExists(nativeDir)) {
|
|
234
|
+
let envVarName = "EXPO_PUBLIC_SERVER_URL";
|
|
235
|
+
let serverUrl = "http://localhost:3000";
|
|
236
|
+
|
|
237
|
+
if (backend === "self") {
|
|
238
|
+
// Both TanStack Start and Next.js use port 3001 for fullstack
|
|
239
|
+
serverUrl = "http://localhost:3001";
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (backend === "convex") {
|
|
243
|
+
envVarName = "EXPO_PUBLIC_CONVEX_URL";
|
|
244
|
+
serverUrl = "https://<YOUR_CONVEX_URL>";
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const nativeVars: EnvVariable[] = [
|
|
248
|
+
{
|
|
249
|
+
key: envVarName,
|
|
250
|
+
value: serverUrl,
|
|
251
|
+
condition: true,
|
|
252
|
+
},
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
if (backend === "convex" && auth === "clerk") {
|
|
256
|
+
nativeVars.push({
|
|
257
|
+
key: "EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY",
|
|
258
|
+
value: "",
|
|
259
|
+
condition: true,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (backend === "convex" && auth === "better-auth") {
|
|
264
|
+
nativeVars.push({
|
|
265
|
+
key: "EXPO_PUBLIC_CONVEX_SITE_URL",
|
|
266
|
+
value: "https://<YOUR_CONVEX_URL>",
|
|
267
|
+
condition: true,
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
await addEnvVariablesToFile(path.join(nativeDir, ".env"), nativeVars);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (backend === "convex") {
|
|
275
|
+
const convexBackendDir = path.join(projectDir, "packages/backend");
|
|
276
|
+
if (await fs.pathExists(convexBackendDir)) {
|
|
277
|
+
const envLocalPath = path.join(convexBackendDir, ".env.local");
|
|
278
|
+
let commentBlocks = "";
|
|
279
|
+
|
|
280
|
+
if (examples?.includes("ai")) {
|
|
281
|
+
commentBlocks += `# Set Google AI API key for AI agent
|
|
282
|
+
# npx convex env set GOOGLE_GENERATIVE_AI_API_KEY=your_google_api_key
|
|
283
|
+
|
|
284
|
+
`;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (auth === "better-auth") {
|
|
288
|
+
const hasWeb = hasWebFrontend;
|
|
289
|
+
commentBlocks += `# Set Convex environment variables
|
|
290
|
+
# npx convex env set BETTER_AUTH_SECRET=$(openssl rand -base64 32)
|
|
291
|
+
${hasWeb ? "# npx convex env set SITE_URL http://localhost:3001\n" : ""}`;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (commentBlocks) {
|
|
295
|
+
let existingContent = "";
|
|
296
|
+
if (await fs.pathExists(envLocalPath)) {
|
|
297
|
+
existingContent = await fs.readFile(envLocalPath, "utf8");
|
|
298
|
+
}
|
|
299
|
+
await fs.writeFile(envLocalPath, commentBlocks + existingContent);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
const convexBackendVars: EnvVariable[] = [];
|
|
303
|
+
|
|
304
|
+
if (examples?.includes("ai")) {
|
|
305
|
+
convexBackendVars.push({
|
|
306
|
+
key: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
307
|
+
value: "",
|
|
308
|
+
condition: true,
|
|
309
|
+
comment: "Google AI API key for AI agent",
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (auth === "better-auth") {
|
|
314
|
+
const hasNative =
|
|
315
|
+
frontend.includes("native-bare") ||
|
|
316
|
+
frontend.includes("native-uniwind") ||
|
|
317
|
+
frontend.includes("native-unistyles");
|
|
318
|
+
const hasWeb = hasWebFrontend;
|
|
319
|
+
|
|
320
|
+
if (hasNative) {
|
|
321
|
+
convexBackendVars.push({
|
|
322
|
+
key: "EXPO_PUBLIC_CONVEX_SITE_URL",
|
|
323
|
+
value: "",
|
|
324
|
+
condition: true,
|
|
325
|
+
comment: "Same as CONVEX_URL but ends in .site",
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (hasWeb) {
|
|
330
|
+
convexBackendVars.push(
|
|
331
|
+
{
|
|
332
|
+
key: hasNextJs ? "NEXT_PUBLIC_CONVEX_SITE_URL" : "VITE_CONVEX_SITE_URL",
|
|
333
|
+
value: "",
|
|
334
|
+
condition: true,
|
|
335
|
+
comment: "Same as CONVEX_URL but ends in .site",
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
key: "SITE_URL",
|
|
339
|
+
value: "http://localhost:3001",
|
|
340
|
+
condition: true,
|
|
341
|
+
comment: "Web app URL for authentication",
|
|
342
|
+
},
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (convexBackendVars.length > 0) {
|
|
348
|
+
await addEnvVariablesToFile(envLocalPath, convexBackendVars);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const serverDir = path.join(projectDir, "apps/server");
|
|
355
|
+
|
|
356
|
+
let corsOrigin = "http://localhost:3001";
|
|
357
|
+
if (backend === "self") {
|
|
358
|
+
corsOrigin = "http://localhost:3001";
|
|
359
|
+
} else if (hasReactRouter || hasSvelte) {
|
|
360
|
+
corsOrigin = "http://localhost:5173";
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
let databaseUrl: string | null = null;
|
|
364
|
+
|
|
365
|
+
if (database !== "none" && dbSetup === "none") {
|
|
366
|
+
switch (database) {
|
|
367
|
+
case "postgres":
|
|
368
|
+
databaseUrl = "postgresql://postgres:password@localhost:5432/postgres";
|
|
369
|
+
break;
|
|
370
|
+
case "mysql":
|
|
371
|
+
databaseUrl = "mysql://root:password@localhost:3306/mydb";
|
|
372
|
+
break;
|
|
373
|
+
case "mongodb":
|
|
374
|
+
databaseUrl = "mongodb://localhost:27017/mydatabase";
|
|
375
|
+
break;
|
|
376
|
+
case "sqlite":
|
|
377
|
+
if (config.runtime === "workers" || webDeploy === "alchemy" || serverDeploy === "alchemy") {
|
|
378
|
+
databaseUrl = "http://127.0.0.1:8080";
|
|
379
|
+
} else {
|
|
380
|
+
const dbAppDir = backend === "self" ? "apps/web" : "apps/server";
|
|
381
|
+
databaseUrl = `file:${path.join(config.projectDir, dbAppDir, "local.db")}`;
|
|
382
|
+
}
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const serverVars: EnvVariable[] = [
|
|
388
|
+
{
|
|
389
|
+
key: "BETTER_AUTH_SECRET",
|
|
390
|
+
value: generateAuthSecret(),
|
|
391
|
+
condition: !!auth,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
key: "BETTER_AUTH_URL",
|
|
395
|
+
value: backend === "self" ? "http://localhost:3001" : "http://localhost:3000",
|
|
396
|
+
condition: !!auth,
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
key: "POLAR_ACCESS_TOKEN",
|
|
400
|
+
value: "",
|
|
401
|
+
condition: config.payments === "polar",
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
key: "POLAR_SUCCESS_URL",
|
|
405
|
+
value: `${corsOrigin}/success?checkout_id={CHECKOUT_ID}`,
|
|
406
|
+
condition: config.payments === "polar",
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
key: "CORS_ORIGIN",
|
|
410
|
+
value: corsOrigin,
|
|
411
|
+
condition: true,
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
key: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
415
|
+
value: "",
|
|
416
|
+
condition: examples?.includes("ai") || false,
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
key: "DATABASE_URL",
|
|
420
|
+
value: databaseUrl,
|
|
421
|
+
condition: database !== "none" && dbSetup === "none",
|
|
422
|
+
},
|
|
423
|
+
];
|
|
424
|
+
|
|
425
|
+
if (backend === "self") {
|
|
426
|
+
const webDir = path.join(projectDir, "apps/web");
|
|
427
|
+
if (await fs.pathExists(webDir)) {
|
|
428
|
+
await addEnvVariablesToFile(path.join(webDir, ".env"), serverVars);
|
|
429
|
+
}
|
|
430
|
+
} else if (await fs.pathExists(serverDir)) {
|
|
431
|
+
await addEnvVariablesToFile(path.join(serverDir, ".env"), serverVars);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
const isUnifiedAlchemy = webDeploy === "alchemy" && serverDeploy === "alchemy";
|
|
435
|
+
const isIndividualAlchemy = webDeploy === "alchemy" || serverDeploy === "alchemy";
|
|
436
|
+
|
|
437
|
+
if (isUnifiedAlchemy) {
|
|
438
|
+
const rootEnvPath = path.join(projectDir, ".env");
|
|
439
|
+
const rootAlchemyVars: EnvVariable[] = [
|
|
440
|
+
{
|
|
441
|
+
key: "ALCHEMY_PASSWORD",
|
|
442
|
+
value: "please-change-this",
|
|
443
|
+
condition: true,
|
|
444
|
+
},
|
|
445
|
+
];
|
|
446
|
+
await addEnvVariablesToFile(rootEnvPath, rootAlchemyVars);
|
|
447
|
+
} else if (isIndividualAlchemy) {
|
|
448
|
+
if (webDeploy === "alchemy") {
|
|
449
|
+
const webDir = path.join(projectDir, "apps/web");
|
|
450
|
+
if (await fs.pathExists(webDir)) {
|
|
451
|
+
const webAlchemyVars: EnvVariable[] = [
|
|
452
|
+
{
|
|
453
|
+
key: "ALCHEMY_PASSWORD",
|
|
454
|
+
value: "please-change-this",
|
|
455
|
+
condition: true,
|
|
456
|
+
},
|
|
457
|
+
];
|
|
458
|
+
await addEnvVariablesToFile(path.join(webDir, ".env"), webAlchemyVars);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
if (serverDeploy === "alchemy") {
|
|
463
|
+
const serverAlchemyVars: EnvVariable[] = [
|
|
464
|
+
{
|
|
465
|
+
key: "ALCHEMY_PASSWORD",
|
|
466
|
+
value: "please-change-this",
|
|
467
|
+
condition: true,
|
|
468
|
+
},
|
|
469
|
+
];
|
|
470
|
+
|
|
471
|
+
if (backend === "self") {
|
|
472
|
+
const webDir = path.join(projectDir, "apps/web");
|
|
473
|
+
if (await fs.pathExists(webDir)) {
|
|
474
|
+
await addEnvVariablesToFile(path.join(webDir, ".env"), serverAlchemyVars);
|
|
475
|
+
}
|
|
476
|
+
} else {
|
|
477
|
+
await addEnvVariablesToFile(path.join(serverDir, ".env"), serverAlchemyVars);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|