create-better-t-stack 2.49.1-canary.80158905 → 2.50.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/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-CyG8-I-3.js → src-BFx0Xu3C.js} +171 -357
- package/package.json +1 -1
- package/templates/api/orpc/server/{rest/src → base/src/lib}/context.ts.hbs +5 -5
- package/templates/api/orpc/web/nuxt/app/plugins/orpc.ts.hbs +1 -1
- package/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs +1 -1
- package/templates/api/orpc/web/solid/src/utils/orpc.ts.hbs +1 -1
- package/templates/api/orpc/web/svelte/src/lib/orpc.ts.hbs +1 -1
- package/templates/api/trpc/server/{rest/src → base/src/lib}/context.ts.hbs +5 -5
- package/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbs +2 -2
- package/templates/auth/better-auth/server/base/src/{index.ts.hbs → lib/auth.ts.hbs} +6 -6
- package/templates/auth/clerk/convex/web/react/tanstack-start/src/server.ts.hbs +1 -0
- package/templates/backend/server/elysia/src/index.ts.hbs +5 -5
- package/templates/backend/server/express/src/index.ts.hbs +5 -5
- package/templates/backend/server/fastify/src/index.ts.hbs +5 -5
- package/templates/backend/server/hono/src/index.ts.hbs +5 -5
- package/templates/backend/server/{base → server-base}/package.json.hbs +1 -0
- package/templates/{api/trpc/server/base → backend/server/server-base}/src/routers/index.ts.hbs +2 -2
- package/templates/backend/server/{base → server-base}/tsconfig.json.hbs +10 -5
- package/templates/base/_gitignore +1 -47
- package/templates/base/package.json.hbs +3 -1
- package/templates/db/drizzle/mysql/drizzle.config.ts.hbs +2 -7
- package/templates/db/drizzle/postgres/drizzle.config.ts.hbs +2 -7
- package/templates/db/drizzle/sqlite/drizzle.config.ts.hbs +2 -7
- package/templates/db/prisma/mongodb/prisma.config.ts.hbs +1 -5
- package/templates/db/prisma/mongodb/src/db/index.ts.hbs +5 -0
- package/templates/db/prisma/mysql/prisma.config.ts.hbs +1 -5
- package/templates/db/prisma/mysql/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
- package/templates/db/prisma/postgres/prisma.config.ts.hbs +3 -7
- package/templates/db/prisma/postgres/src/{index.ts.hbs → db/index.ts.hbs} +1 -1
- package/templates/db/prisma/sqlite/prisma.config.ts.hbs +1 -5
- package/templates/db/prisma/sqlite/src/{index.ts.hbs → db/index.ts.hbs} +3 -3
- package/templates/deploy/wrangler/web/react/tanstack-start/wrangler.jsonc.hbs +1 -1
- package/templates/examples/todo/server/drizzle/base/src/routers/todo.ts.hbs +6 -6
- package/templates/examples/todo/server/mongoose/base/src/routers/todo.ts.hbs +4 -4
- package/templates/examples/todo/server/prisma/base/src/routers/todo.ts.hbs +4 -4
- package/templates/frontend/react/tanstack-router/src/routes/__root.tsx.hbs +1 -1
- package/templates/frontend/react/tanstack-start/package.json.hbs +7 -7
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +5 -5
- package/templates/frontend/react/tanstack-start/vite.config.ts.hbs +1 -1
- package/templates/api/orpc/server/base/_gitignore +0 -34
- package/templates/api/orpc/server/base/package.json.hbs +0 -24
- package/templates/api/orpc/server/base/src/routers/index.ts.hbs +0 -55
- package/templates/api/orpc/server/base/tsconfig.json.hbs +0 -10
- package/templates/api/orpc/server/base/tsdown.config.ts.hbs +0 -7
- package/templates/api/trpc/server/base/_gitignore +0 -34
- package/templates/api/trpc/server/base/package.json.hbs +0 -23
- package/templates/api/trpc/server/base/tsconfig.json.hbs +0 -13
- package/templates/api/trpc/server/base/tsdown.config.ts.hbs +0 -7
- package/templates/auth/better-auth/server/base/_gitignore +0 -34
- package/templates/auth/better-auth/server/base/package.json.hbs +0 -24
- package/templates/auth/better-auth/server/base/tsconfig.json.hbs +0 -13
- package/templates/auth/better-auth/server/base/tsdown.config.ts.hbs +0 -7
- package/templates/backend/server/base/tsdown.config.ts.hbs +0 -14
- package/templates/base/tsconfig.base.json +0 -23
- package/templates/db/base/_gitignore +0 -34
- package/templates/db/base/package.json.hbs +0 -23
- package/templates/db/base/tsconfig.json.hbs +0 -13
- package/templates/db/base/tsdown.config.ts.hbs +0 -7
- package/templates/db/prisma/mongodb/src/index.ts.hbs +0 -5
- /package/templates/api/orpc/server/{rest/src/index.ts.hbs → base/src/lib/orpc.ts.hbs} +0 -0
- /package/templates/api/trpc/server/{rest/src/index.ts.hbs → base/src/lib/trpc.ts.hbs} +0 -0
- /package/templates/auth/better-auth/server/db/drizzle/mysql/src/{schema → db/schema}/auth.ts +0 -0
- /package/templates/auth/better-auth/server/db/drizzle/postgres/src/{schema → db/schema}/auth.ts +0 -0
- /package/templates/auth/better-auth/server/db/drizzle/sqlite/src/{schema → db/schema}/auth.ts +0 -0
- /package/templates/auth/better-auth/server/db/mongoose/mongodb/src/{models → db/models}/auth.model.ts +0 -0
- /package/templates/backend/server/{base → server-base}/_gitignore +0 -0
- /package/templates/db/drizzle/mysql/src/{index.ts.hbs → db/index.ts.hbs} +0 -0
- /package/templates/db/drizzle/postgres/src/{index.ts.hbs → db/index.ts.hbs} +0 -0
- /package/templates/db/drizzle/sqlite/src/{index.ts.hbs → db/index.ts.hbs} +0 -0
- /package/templates/db/mongoose/mongodb/src/{index.ts.hbs → db/index.ts.hbs} +0 -0
- /package/templates/examples/todo/server/mongoose/mongodb/src/db/models/{todo.model.ts.hbs → todo.model.ts} +0 -0
- /package/templates/examples/todo/server/prisma/mongodb/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
- /package/templates/examples/todo/server/prisma/mysql/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
- /package/templates/examples/todo/server/prisma/postgres/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
- /package/templates/examples/todo/server/prisma/sqlite/prisma/schema/{todo.prisma.hbs → todo.prisma} +0 -0
|
@@ -65,13 +65,12 @@ const dependencyVersionMap = {
|
|
|
65
65
|
"@better-auth/expo": "^1.3.13",
|
|
66
66
|
"@clerk/nextjs": "^6.31.5",
|
|
67
67
|
"@clerk/clerk-react": "^5.45.0",
|
|
68
|
-
"@clerk/tanstack-react-start": "^0.
|
|
68
|
+
"@clerk/tanstack-react-start": "^0.25.1",
|
|
69
69
|
"@clerk/clerk-expo": "^2.14.25",
|
|
70
70
|
"drizzle-orm": "^0.44.2",
|
|
71
71
|
"drizzle-kit": "^0.31.2",
|
|
72
72
|
"@planetscale/database": "^1.19.0",
|
|
73
73
|
"@libsql/client": "^0.15.9",
|
|
74
|
-
libsql: "^0.5.22",
|
|
75
74
|
"@neondatabase/serverless": "^1.0.1",
|
|
76
75
|
pg: "^8.14.1",
|
|
77
76
|
"@types/pg": "^8.11.11",
|
|
@@ -139,17 +138,15 @@ const dependencyVersionMap = {
|
|
|
139
138
|
"@tanstack/solid-query": "^5.87.4",
|
|
140
139
|
"@tanstack/solid-query-devtools": "^5.87.4",
|
|
141
140
|
"@tanstack/solid-router-devtools": "^1.131.44",
|
|
142
|
-
wrangler: "^4.
|
|
143
|
-
"@cloudflare/vite-plugin": "^1.
|
|
141
|
+
wrangler: "^4.40.3",
|
|
142
|
+
"@cloudflare/vite-plugin": "^1.13.8",
|
|
144
143
|
"@opennextjs/cloudflare": "^1.6.5",
|
|
145
144
|
"nitro-cloudflare-dev": "^0.2.2",
|
|
146
145
|
"@sveltejs/adapter-cloudflare": "^7.2.1",
|
|
147
146
|
"@cloudflare/workers-types": "^4.20250822.0",
|
|
148
|
-
alchemy: "^0.
|
|
147
|
+
alchemy: "^0.70.0",
|
|
149
148
|
nitropack: "^2.12.4",
|
|
150
|
-
dotenv: "^17.2.
|
|
151
|
-
tsdown: "^0.15.5",
|
|
152
|
-
zod: "^4.1.11",
|
|
149
|
+
dotenv: "^17.2.1",
|
|
153
150
|
"@polar-sh/better-auth": "^1.1.3",
|
|
154
151
|
"@polar-sh/sdk": "^0.34.16"
|
|
155
152
|
};
|
|
@@ -1378,7 +1375,7 @@ const getLatestCLIVersion = () => {
|
|
|
1378
1375
|
*/
|
|
1379
1376
|
function isTelemetryEnabled() {
|
|
1380
1377
|
const BTS_TELEMETRY_DISABLED = process.env.BTS_TELEMETRY_DISABLED;
|
|
1381
|
-
const BTS_TELEMETRY = "
|
|
1378
|
+
const BTS_TELEMETRY = "1";
|
|
1382
1379
|
if (BTS_TELEMETRY_DISABLED !== void 0) return BTS_TELEMETRY_DISABLED !== "1";
|
|
1383
1380
|
if (BTS_TELEMETRY !== void 0) return BTS_TELEMETRY === "1";
|
|
1384
1381
|
return true;
|
|
@@ -1386,8 +1383,8 @@ function isTelemetryEnabled() {
|
|
|
1386
1383
|
|
|
1387
1384
|
//#endregion
|
|
1388
1385
|
//#region src/utils/analytics.ts
|
|
1389
|
-
const POSTHOG_API_KEY = "
|
|
1390
|
-
const POSTHOG_HOST = "
|
|
1386
|
+
const POSTHOG_API_KEY = "phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs";
|
|
1387
|
+
const POSTHOG_HOST = "https://us.i.posthog.com";
|
|
1391
1388
|
function generateSessionId() {
|
|
1392
1389
|
const rand = Math.random().toString(36).slice(2);
|
|
1393
1390
|
return `cli_${Date.now().toString(36)}${rand}`;
|
|
@@ -1995,17 +1992,15 @@ const addPackageDependency = async (opts) => {
|
|
|
1995
1992
|
if (!pkgJson.dependencies) pkgJson.dependencies = {};
|
|
1996
1993
|
if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
|
|
1997
1994
|
for (const pkgName of dependencies) {
|
|
1998
|
-
const version = dependencyVersionMap[pkgName];
|
|
1995
|
+
const version = customDependencies[pkgName] || dependencyVersionMap[pkgName];
|
|
1999
1996
|
if (version) pkgJson.dependencies[pkgName] = version;
|
|
2000
1997
|
else console.warn(`Warning: Dependency ${pkgName} not found in version map.`);
|
|
2001
1998
|
}
|
|
2002
1999
|
for (const pkgName of devDependencies) {
|
|
2003
|
-
const version = dependencyVersionMap[pkgName];
|
|
2000
|
+
const version = customDevDependencies[pkgName] || dependencyVersionMap[pkgName];
|
|
2004
2001
|
if (version) pkgJson.devDependencies[pkgName] = version;
|
|
2005
2002
|
else console.warn(`Warning: Dev dependency ${pkgName} not found in version map.`);
|
|
2006
2003
|
}
|
|
2007
|
-
for (const [pkgName, version] of Object.entries(customDependencies)) pkgJson.dependencies[pkgName] = version;
|
|
2008
|
-
for (const [pkgName, version] of Object.entries(customDevDependencies)) pkgJson.devDependencies[pkgName] = version;
|
|
2009
2004
|
await fs.writeJson(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
2010
2005
|
};
|
|
2011
2006
|
|
|
@@ -2775,29 +2770,24 @@ async function setupBackendFramework(projectDir, context) {
|
|
|
2775
2770
|
return;
|
|
2776
2771
|
}
|
|
2777
2772
|
await fs.ensureDir(serverAppDir);
|
|
2778
|
-
const serverBaseDir = path.join(PKG_ROOT, "templates/backend/server/base");
|
|
2773
|
+
const serverBaseDir = path.join(PKG_ROOT, "templates/backend/server/server-base");
|
|
2779
2774
|
if (await fs.pathExists(serverBaseDir)) await processAndCopyFiles("**/*", serverBaseDir, serverAppDir, context);
|
|
2780
2775
|
const frameworkSrcDir = path.join(PKG_ROOT, `templates/backend/server/${context.backend}`);
|
|
2781
2776
|
if (await fs.pathExists(frameworkSrcDir)) await processAndCopyFiles("**/*", frameworkSrcDir, serverAppDir, context, true);
|
|
2782
2777
|
if (context.api !== "none") {
|
|
2783
|
-
const apiPackageDir = path.join(projectDir, "packages/api");
|
|
2784
|
-
await fs.ensureDir(apiPackageDir);
|
|
2785
2778
|
const apiServerBaseDir = path.join(PKG_ROOT, `templates/api/${context.api}/server/base`);
|
|
2786
|
-
if (await fs.pathExists(apiServerBaseDir)) await processAndCopyFiles("**/*", apiServerBaseDir,
|
|
2787
|
-
|
|
2788
|
-
if (
|
|
2789
|
-
else apiServerFrameworkDir = path.join(PKG_ROOT, `templates/api/${context.api}/server/rest`);
|
|
2790
|
-
if (await fs.pathExists(apiServerFrameworkDir)) await processAndCopyFiles("**/*", apiServerFrameworkDir, apiPackageDir, context, true);
|
|
2791
|
-
}
|
|
2792
|
-
if (context.database !== "none" && context.orm !== "none") {
|
|
2793
|
-
const dbPackageDir = path.join(projectDir, "packages/db");
|
|
2794
|
-
await fs.ensureDir(dbPackageDir);
|
|
2795
|
-
const dbBaseDir = path.join(PKG_ROOT, "templates/db/base");
|
|
2796
|
-
if (await fs.pathExists(dbBaseDir)) await processAndCopyFiles("**/*", dbBaseDir, dbPackageDir, context);
|
|
2797
|
-
const dbOrmSrcDir = path.join(PKG_ROOT, `templates/db/${context.orm}/${context.database}`);
|
|
2798
|
-
if (await fs.pathExists(dbOrmSrcDir)) await processAndCopyFiles("**/*", dbOrmSrcDir, dbPackageDir, context);
|
|
2779
|
+
if (await fs.pathExists(apiServerBaseDir)) await processAndCopyFiles("**/*", apiServerBaseDir, serverAppDir, context, true);
|
|
2780
|
+
const apiServerFrameworkDir = path.join(PKG_ROOT, `templates/api/${context.api}/server/${context.backend}`);
|
|
2781
|
+
if (await fs.pathExists(apiServerFrameworkDir)) await processAndCopyFiles("**/*", apiServerFrameworkDir, serverAppDir, context, true);
|
|
2799
2782
|
}
|
|
2800
2783
|
}
|
|
2784
|
+
async function setupDbOrmTemplates(projectDir, context) {
|
|
2785
|
+
if (context.backend === "convex" || context.orm === "none" || context.database === "none") return;
|
|
2786
|
+
const serverAppDir = path.join(projectDir, "apps/server");
|
|
2787
|
+
await fs.ensureDir(serverAppDir);
|
|
2788
|
+
const dbOrmSrcDir = path.join(PKG_ROOT, `templates/db/${context.orm}/${context.database}`);
|
|
2789
|
+
if (await fs.pathExists(dbOrmSrcDir)) await processAndCopyFiles("**/*", dbOrmSrcDir, serverAppDir, context);
|
|
2790
|
+
}
|
|
2801
2791
|
async function setupAuthTemplate(projectDir, context) {
|
|
2802
2792
|
if (!context.auth || context.auth === "none") return;
|
|
2803
2793
|
const serverAppDir = path.join(projectDir, "apps/server");
|
|
@@ -2877,24 +2867,20 @@ async function setupAuthTemplate(projectDir, context) {
|
|
|
2877
2867
|
return;
|
|
2878
2868
|
}
|
|
2879
2869
|
if (serverAppDirExists && context.backend !== "convex") {
|
|
2880
|
-
const authPackageDir = path.join(projectDir, "packages/auth");
|
|
2881
|
-
await fs.ensureDir(authPackageDir);
|
|
2882
2870
|
const authServerBaseSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/base`);
|
|
2883
|
-
if (await fs.pathExists(authServerBaseSrc)) await processAndCopyFiles("**/*", authServerBaseSrc,
|
|
2871
|
+
if (await fs.pathExists(authServerBaseSrc)) await processAndCopyFiles("**/*", authServerBaseSrc, serverAppDir, context);
|
|
2884
2872
|
if (context.backend === "next") {
|
|
2885
2873
|
const authServerNextSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/next`);
|
|
2886
|
-
if (await fs.pathExists(authServerNextSrc)) await processAndCopyFiles("**/*", authServerNextSrc,
|
|
2874
|
+
if (await fs.pathExists(authServerNextSrc)) await processAndCopyFiles("**/*", authServerNextSrc, serverAppDir, context);
|
|
2887
2875
|
}
|
|
2888
2876
|
if (context.orm !== "none" && context.database !== "none") {
|
|
2889
|
-
const dbPackageDir = path.join(projectDir, "packages/db");
|
|
2890
|
-
await fs.ensureDir(dbPackageDir);
|
|
2891
2877
|
const orm = context.orm;
|
|
2892
2878
|
const db = context.database;
|
|
2893
2879
|
let authDbSrc = "";
|
|
2894
2880
|
if (orm === "drizzle") authDbSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/db/drizzle/${db}`);
|
|
2895
2881
|
else if (orm === "prisma") authDbSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/db/prisma/${db}`);
|
|
2896
2882
|
else if (orm === "mongoose") authDbSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/db/mongoose/${db}`);
|
|
2897
|
-
if (authDbSrc && await fs.pathExists(authDbSrc)) await processAndCopyFiles("**/*", authDbSrc,
|
|
2883
|
+
if (authDbSrc && await fs.pathExists(authDbSrc)) await processAndCopyFiles("**/*", authDbSrc, serverAppDir, context);
|
|
2898
2884
|
}
|
|
2899
2885
|
}
|
|
2900
2886
|
if ((hasReactWeb || hasNuxtWeb || hasSvelteWeb || hasSolidWeb) && webAppDirExists) {
|
|
@@ -2941,10 +2927,8 @@ async function setupPaymentsTemplate(projectDir, context) {
|
|
|
2941
2927
|
const serverAppDirExists = await fs.pathExists(serverAppDir);
|
|
2942
2928
|
const webAppDirExists = await fs.pathExists(webAppDir);
|
|
2943
2929
|
if (serverAppDirExists && context.backend !== "convex") {
|
|
2944
|
-
const authPackageDir = path.join(projectDir, "packages/auth");
|
|
2945
|
-
await fs.ensureDir(authPackageDir);
|
|
2946
2930
|
const paymentsServerSrc = path.join(PKG_ROOT, `templates/payments/${context.payments}/server/base`);
|
|
2947
|
-
if (await fs.pathExists(paymentsServerSrc)) await processAndCopyFiles("**/*", paymentsServerSrc,
|
|
2931
|
+
if (await fs.pathExists(paymentsServerSrc)) await processAndCopyFiles("**/*", paymentsServerSrc, serverAppDir, context);
|
|
2948
2932
|
}
|
|
2949
2933
|
const hasReactWeb = context.frontend.some((f) => [
|
|
2950
2934
|
"tanstack-router",
|
|
@@ -3022,22 +3006,16 @@ async function setupExamplesTemplate(projectDir, context) {
|
|
|
3022
3006
|
const exampleBaseDir = path.join(PKG_ROOT, `templates/examples/${example}`);
|
|
3023
3007
|
if (serverAppDirExists && context.backend !== "convex" && context.backend !== "none") {
|
|
3024
3008
|
const exampleServerSrc = path.join(exampleBaseDir, "server");
|
|
3025
|
-
if (context.api !== "none") {
|
|
3026
|
-
const apiPackageDir = path.join(projectDir, "packages/api");
|
|
3027
|
-
await fs.ensureDir(apiPackageDir);
|
|
3028
|
-
const exampleOrmBaseSrc = path.join(exampleServerSrc, context.orm, "base");
|
|
3029
|
-
if (await fs.pathExists(exampleOrmBaseSrc)) await processAndCopyFiles("**/*", exampleOrmBaseSrc, apiPackageDir, context, false);
|
|
3030
|
-
}
|
|
3031
|
-
if (context.orm !== "none" && context.database !== "none") {
|
|
3032
|
-
const dbPackageDir = path.join(projectDir, "packages/db");
|
|
3033
|
-
await fs.ensureDir(dbPackageDir);
|
|
3034
|
-
const exampleDbSchemaSrc = path.join(exampleServerSrc, context.orm, context.database);
|
|
3035
|
-
if (await fs.pathExists(exampleDbSchemaSrc)) await processAndCopyFiles("**/*", exampleDbSchemaSrc, dbPackageDir, context, false);
|
|
3036
|
-
}
|
|
3037
3009
|
if (example === "ai" && context.backend === "next") {
|
|
3038
3010
|
const aiNextServerSrc = path.join(exampleServerSrc, "next");
|
|
3039
3011
|
if (await fs.pathExists(aiNextServerSrc)) await processAndCopyFiles("**/*", aiNextServerSrc, serverAppDir, context, false);
|
|
3040
3012
|
}
|
|
3013
|
+
if (context.orm !== "none" && context.database !== "none") {
|
|
3014
|
+
const exampleOrmBaseSrc = path.join(exampleServerSrc, context.orm, "base");
|
|
3015
|
+
if (await fs.pathExists(exampleOrmBaseSrc)) await processAndCopyFiles("**/*", exampleOrmBaseSrc, serverAppDir, context, false);
|
|
3016
|
+
const exampleDbSchemaSrc = path.join(exampleServerSrc, context.orm, context.database);
|
|
3017
|
+
if (await fs.pathExists(exampleDbSchemaSrc)) await processAndCopyFiles("**/*", exampleDbSchemaSrc, serverAppDir, context, false);
|
|
3018
|
+
}
|
|
3041
3019
|
}
|
|
3042
3020
|
if (webAppDirExists) {
|
|
3043
3021
|
if (hasReactWeb) {
|
|
@@ -3103,9 +3081,9 @@ async function handleExtras(projectDir, context) {
|
|
|
3103
3081
|
}
|
|
3104
3082
|
async function setupDockerComposeTemplates(projectDir, context) {
|
|
3105
3083
|
if (context.dbSetup !== "docker" || context.database === "none") return;
|
|
3106
|
-
const
|
|
3084
|
+
const serverAppDir = path.join(projectDir, "apps/server");
|
|
3107
3085
|
const dockerSrcDir = path.join(PKG_ROOT, `templates/db-setup/docker-compose/${context.database}`);
|
|
3108
|
-
if (await fs.pathExists(dockerSrcDir)) await processAndCopyFiles("**/*", dockerSrcDir,
|
|
3086
|
+
if (await fs.pathExists(dockerSrcDir)) await processAndCopyFiles("**/*", dockerSrcDir, serverAppDir, context);
|
|
3109
3087
|
}
|
|
3110
3088
|
async function setupDeploymentTemplates(projectDir, context) {
|
|
3111
3089
|
if (context.webDeploy === "alchemy" || context.serverDeploy === "alchemy") if (context.webDeploy === "alchemy" && context.serverDeploy === "alchemy") {
|
|
@@ -3526,8 +3504,8 @@ async function setupTanStackStartAlchemyDeploy(projectDir, _packageManager, opti
|
|
|
3526
3504
|
await addPackageDependency({
|
|
3527
3505
|
devDependencies: [
|
|
3528
3506
|
"alchemy",
|
|
3529
|
-
"
|
|
3530
|
-
"
|
|
3507
|
+
"dotenv",
|
|
3508
|
+
"@cloudflare/vite-plugin"
|
|
3531
3509
|
],
|
|
3532
3510
|
projectDir: webAppDir
|
|
3533
3511
|
});
|
|
@@ -3555,17 +3533,6 @@ async function setupTanStackStartAlchemyDeploy(projectDir, _packageManager, opti
|
|
|
3555
3533
|
defaultImport: "alchemy"
|
|
3556
3534
|
});
|
|
3557
3535
|
else alchemyImport.setModuleSpecifier("alchemy/cloudflare/tanstack-start");
|
|
3558
|
-
const reactImport = sourceFile.getImportDeclaration("@vitejs/plugin-react");
|
|
3559
|
-
let reactPluginIdentifier = "viteReact";
|
|
3560
|
-
if (!reactImport) sourceFile.addImportDeclaration({
|
|
3561
|
-
moduleSpecifier: "@vitejs/plugin-react",
|
|
3562
|
-
defaultImport: "viteReact"
|
|
3563
|
-
});
|
|
3564
|
-
else {
|
|
3565
|
-
const defaultImport = reactImport.getDefaultImport();
|
|
3566
|
-
if (defaultImport) reactPluginIdentifier = defaultImport.getText();
|
|
3567
|
-
else reactImport.setDefaultImport("viteReact");
|
|
3568
|
-
}
|
|
3569
3536
|
const exportAssignment = sourceFile.getExportAssignment((d) => !d.isExportEquals());
|
|
3570
3537
|
if (!exportAssignment) return;
|
|
3571
3538
|
const defineConfigCall = exportAssignment.getExpression();
|
|
@@ -3573,47 +3540,11 @@ async function setupTanStackStartAlchemyDeploy(projectDir, _packageManager, opti
|
|
|
3573
3540
|
let configObject = defineConfigCall.getArguments()[0];
|
|
3574
3541
|
if (!configObject) configObject = defineConfigCall.addArgument("{}");
|
|
3575
3542
|
if (Node.isObjectLiteralExpression(configObject)) {
|
|
3576
|
-
if (!configObject.getProperty("build")) configObject.addPropertyAssignment({
|
|
3577
|
-
name: "build",
|
|
3578
|
-
initializer: `{
|
|
3579
|
-
target: "esnext",
|
|
3580
|
-
rollupOptions: {
|
|
3581
|
-
external: ["node:async_hooks", "cloudflare:workers"],
|
|
3582
|
-
},
|
|
3583
|
-
}`
|
|
3584
|
-
});
|
|
3585
3543
|
const pluginsProperty = configObject.getProperty("plugins");
|
|
3586
3544
|
if (pluginsProperty && Node.isPropertyAssignment(pluginsProperty)) {
|
|
3587
3545
|
const initializer = pluginsProperty.getInitializer();
|
|
3588
3546
|
if (Node.isArrayLiteralExpression(initializer)) {
|
|
3589
|
-
if (!initializer.getElements().some((el) => el.getText().includes("alchemy"))) initializer.addElement("alchemy()");
|
|
3590
|
-
const tanstackElements = initializer.getElements().filter((el) => el.getText().includes("tanstackStart"));
|
|
3591
|
-
let needsReactPlugin = false;
|
|
3592
|
-
tanstackElements.forEach((element) => {
|
|
3593
|
-
if (Node.isCallExpression(element)) {
|
|
3594
|
-
const args = element.getArguments();
|
|
3595
|
-
if (args.length === 0) {
|
|
3596
|
-
element.addArgument(`{
|
|
3597
|
-
target: "cloudflare-module",
|
|
3598
|
-
customViteReactPlugin: true,
|
|
3599
|
-
}`);
|
|
3600
|
-
needsReactPlugin = true;
|
|
3601
|
-
} else if (args.length === 1 && Node.isObjectLiteralExpression(args[0])) {
|
|
3602
|
-
const configObj = args[0];
|
|
3603
|
-
if (!configObj.getProperty("target")) configObj.addPropertyAssignment({
|
|
3604
|
-
name: "target",
|
|
3605
|
-
initializer: "\"cloudflare-module\""
|
|
3606
|
-
});
|
|
3607
|
-
if (!!!configObj.getProperty("customViteReactPlugin")) configObj.addPropertyAssignment({
|
|
3608
|
-
name: "customViteReactPlugin",
|
|
3609
|
-
initializer: "true"
|
|
3610
|
-
});
|
|
3611
|
-
needsReactPlugin = true;
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
});
|
|
3615
|
-
const hasReactPlugin = initializer.getElements().some((el) => Node.isCallExpression(el) && el.getExpression().getText() === reactPluginIdentifier);
|
|
3616
|
-
if (needsReactPlugin && !hasReactPlugin) initializer.addElement(`${reactPluginIdentifier}()`);
|
|
3547
|
+
if (!initializer.getElements().some((el) => el.getText().includes("alchemy("))) initializer.addElement("alchemy()");
|
|
3617
3548
|
}
|
|
3618
3549
|
} else configObject.addPropertyAssignment({
|
|
3619
3550
|
name: "plugins",
|
|
@@ -3624,16 +3555,6 @@ async function setupTanStackStartAlchemyDeploy(projectDir, _packageManager, opti
|
|
|
3624
3555
|
} catch (error) {
|
|
3625
3556
|
console.warn("Failed to update vite.config.ts:", error);
|
|
3626
3557
|
}
|
|
3627
|
-
const nitroConfigPath = path.join(webAppDir, "nitro.config.ts");
|
|
3628
|
-
await fs.writeFile(nitroConfigPath, `import { defineNitroConfig } from "nitropack/config";
|
|
3629
|
-
|
|
3630
|
-
export default defineNitroConfig({
|
|
3631
|
-
preset: "cloudflare-module",
|
|
3632
|
-
cloudflare: {
|
|
3633
|
-
nodeCompat: true,
|
|
3634
|
-
},
|
|
3635
|
-
});
|
|
3636
|
-
`, "utf-8");
|
|
3637
3558
|
}
|
|
3638
3559
|
|
|
3639
3560
|
//#endregion
|
|
@@ -3800,7 +3721,7 @@ async function setupTanstackStartWorkersDeploy(projectDir, packageManager) {
|
|
|
3800
3721
|
const webAppDir = path.join(projectDir, "apps/web");
|
|
3801
3722
|
if (!await fs.pathExists(webAppDir)) return;
|
|
3802
3723
|
await addPackageDependency({
|
|
3803
|
-
devDependencies: ["wrangler"],
|
|
3724
|
+
devDependencies: ["wrangler", "@cloudflare/vite-plugin"],
|
|
3804
3725
|
projectDir: webAppDir
|
|
3805
3726
|
});
|
|
3806
3727
|
const pkgPath = path.join(webAppDir, "package.json");
|
|
@@ -3817,6 +3738,12 @@ async function setupTanstackStartWorkersDeploy(projectDir, packageManager) {
|
|
|
3817
3738
|
if (!await fs.pathExists(viteConfigPath)) return;
|
|
3818
3739
|
const sourceFile = tsProject.addSourceFileAtPathIfExists(viteConfigPath);
|
|
3819
3740
|
if (!sourceFile) return;
|
|
3741
|
+
const cfImport = sourceFile.getImportDeclaration("@cloudflare/vite-plugin");
|
|
3742
|
+
if (!cfImport) sourceFile.addImportDeclaration({
|
|
3743
|
+
moduleSpecifier: "@cloudflare/vite-plugin",
|
|
3744
|
+
namedImports: [{ name: "cloudflare" }]
|
|
3745
|
+
});
|
|
3746
|
+
else if (!cfImport.getNamedImports().some((ni) => ni.getName() === "cloudflare")) cfImport.addNamedImport({ name: "cloudflare" });
|
|
3820
3747
|
const reactImport = sourceFile.getImportDeclaration("@vitejs/plugin-react");
|
|
3821
3748
|
let reactPluginIdentifier = "viteReact";
|
|
3822
3749
|
if (!reactImport) sourceFile.addImportDeclaration({
|
|
@@ -3836,10 +3763,7 @@ async function setupTanstackStartWorkersDeploy(projectDir, packageManager) {
|
|
|
3836
3763
|
const configObj = defineCall.getArguments()[0];
|
|
3837
3764
|
if (!configObj) return;
|
|
3838
3765
|
const pluginsArray = ensureArrayProperty(configObj, "plugins");
|
|
3839
|
-
|
|
3840
|
-
const tanstackPluginText = "tanstackStart({ target: \"cloudflare-module\", customViteReactPlugin: true })";
|
|
3841
|
-
if (tanstackPluginIndex === -1) pluginsArray.addElement(tanstackPluginText);
|
|
3842
|
-
else pluginsArray.getElements()[tanstackPluginIndex].replaceWithText(tanstackPluginText);
|
|
3766
|
+
if (!pluginsArray.getElements().some((el) => el.getText().includes("cloudflare("))) pluginsArray.insertElement(0, "cloudflare({ viteEnvironment: { name: 'ssr' } })");
|
|
3843
3767
|
if (!pluginsArray.getElements().some((el) => Node.isCallExpression(el) && el.getExpression().getText() === reactPluginIdentifier)) {
|
|
3844
3768
|
const nextIndex = pluginsArray.getElements().findIndex((el) => el.getText().includes("tanstackStart(")) + 1;
|
|
3845
3769
|
if (nextIndex > 0) pluginsArray.insertElement(nextIndex, `${reactPluginIdentifier}()`);
|
|
@@ -3985,10 +3909,10 @@ async function setupExamples(config) {
|
|
|
3985
3909
|
if (examples.includes("ai")) {
|
|
3986
3910
|
const webClientDir = path.join(projectDir, "apps/web");
|
|
3987
3911
|
const nativeClientDir = path.join(projectDir, "apps/native");
|
|
3988
|
-
const
|
|
3912
|
+
const serverDir = path.join(projectDir, "apps/server");
|
|
3989
3913
|
const webClientDirExists = await fs.pathExists(webClientDir);
|
|
3990
3914
|
const nativeClientDirExists = await fs.pathExists(nativeClientDir);
|
|
3991
|
-
const
|
|
3915
|
+
const serverDirExists = await fs.pathExists(serverDir);
|
|
3992
3916
|
const hasNuxt = frontend.includes("nuxt");
|
|
3993
3917
|
const hasSvelte = frontend.includes("svelte");
|
|
3994
3918
|
const hasReactWeb = frontend.includes("react-router") || frontend.includes("tanstack-router") || frontend.includes("next") || frontend.includes("tanstack-start");
|
|
@@ -4009,9 +3933,9 @@ async function setupExamples(config) {
|
|
|
4009
3933
|
dependencies: ["ai", "@ai-sdk/react"],
|
|
4010
3934
|
projectDir: nativeClientDir
|
|
4011
3935
|
});
|
|
4012
|
-
if (
|
|
3936
|
+
if (serverDirExists && backend !== "none") await addPackageDependency({
|
|
4013
3937
|
dependencies: ["ai", "@ai-sdk/google"],
|
|
4014
|
-
projectDir:
|
|
3938
|
+
projectDir: serverDir
|
|
4015
3939
|
});
|
|
4016
3940
|
}
|
|
4017
3941
|
}
|
|
@@ -4127,54 +4051,32 @@ function getConvexDependencies(frontend) {
|
|
|
4127
4051
|
return deps;
|
|
4128
4052
|
}
|
|
4129
4053
|
async function setupApi(config) {
|
|
4130
|
-
const { api, projectName, frontend, backend, packageManager, projectDir
|
|
4054
|
+
const { api, projectName, frontend, backend, packageManager, projectDir } = config;
|
|
4131
4055
|
const isConvex = backend === "convex";
|
|
4132
4056
|
const webDir = path.join(projectDir, "apps/web");
|
|
4133
4057
|
const nativeDir = path.join(projectDir, "apps/native");
|
|
4134
4058
|
const serverDir = path.join(projectDir, "apps/server");
|
|
4135
4059
|
const webDirExists = await fs.pathExists(webDir);
|
|
4136
4060
|
const nativeDirExists = await fs.pathExists(nativeDir);
|
|
4137
|
-
await fs.pathExists(serverDir);
|
|
4061
|
+
const serverDirExists = await fs.pathExists(serverDir);
|
|
4138
4062
|
const frontendType = getFrontendType(frontend);
|
|
4139
4063
|
if (!isConvex && api !== "none") {
|
|
4140
4064
|
const apiDeps = getApiDependencies(api, frontendType);
|
|
4141
|
-
|
|
4142
|
-
if (apiDeps.server) {
|
|
4065
|
+
if (serverDirExists && apiDeps.server) {
|
|
4143
4066
|
await addPackageDependency({
|
|
4144
4067
|
dependencies: apiDeps.server.dependencies,
|
|
4145
|
-
projectDir:
|
|
4146
|
-
});
|
|
4147
|
-
const frameworkDeps = [];
|
|
4148
|
-
if (backend === "hono") frameworkDeps.push("hono");
|
|
4149
|
-
else if (backend === "elysia") frameworkDeps.push("elysia");
|
|
4150
|
-
else if (backend === "express") frameworkDeps.push("express", "@types/express");
|
|
4151
|
-
else if (backend === "fastify") frameworkDeps.push("fastify");
|
|
4152
|
-
if (frameworkDeps.length > 0) await addPackageDependency({
|
|
4153
|
-
dependencies: frameworkDeps,
|
|
4154
|
-
projectDir: apiPackageDir
|
|
4068
|
+
projectDir: serverDir
|
|
4155
4069
|
});
|
|
4156
4070
|
if (api === "trpc") {
|
|
4157
4071
|
if (backend === "hono") await addPackageDependency({
|
|
4158
4072
|
dependencies: ["@hono/trpc-server"],
|
|
4159
|
-
projectDir:
|
|
4073
|
+
projectDir: serverDir
|
|
4160
4074
|
});
|
|
4161
4075
|
else if (backend === "elysia") await addPackageDependency({
|
|
4162
4076
|
dependencies: ["@elysiajs/trpc"],
|
|
4163
|
-
projectDir:
|
|
4164
|
-
});
|
|
4165
|
-
else if (backend === "express") await addPackageDependency({
|
|
4166
|
-
dependencies: ["@trpc/server"],
|
|
4167
|
-
projectDir: apiPackageDir
|
|
4168
|
-
});
|
|
4169
|
-
else if (backend === "fastify") await addPackageDependency({
|
|
4170
|
-
dependencies: ["@trpc/server"],
|
|
4171
|
-
projectDir: apiPackageDir
|
|
4077
|
+
projectDir: serverDir
|
|
4172
4078
|
});
|
|
4173
4079
|
}
|
|
4174
|
-
if (auth === "better-auth") await addPackageDependency({
|
|
4175
|
-
dependencies: ["better-auth"],
|
|
4176
|
-
projectDir: apiPackageDir
|
|
4177
|
-
});
|
|
4178
4080
|
}
|
|
4179
4081
|
if (webDirExists && apiDeps.web) await addPackageDependency({
|
|
4180
4082
|
dependencies: apiDeps.web.dependencies,
|
|
@@ -4218,7 +4120,7 @@ async function setupApi(config) {
|
|
|
4218
4120
|
//#endregion
|
|
4219
4121
|
//#region src/helpers/core/backend-setup.ts
|
|
4220
4122
|
async function setupBackendDependencies(config) {
|
|
4221
|
-
const { backend, runtime, api,
|
|
4123
|
+
const { backend, runtime, api, projectDir } = config;
|
|
4222
4124
|
if (backend === "convex") return;
|
|
4223
4125
|
const framework = backend;
|
|
4224
4126
|
const serverDir = path.join(projectDir, "apps/server");
|
|
@@ -4246,13 +4148,6 @@ async function setupBackendDependencies(config) {
|
|
|
4246
4148
|
dependencies.push("fastify", "@fastify/cors");
|
|
4247
4149
|
if (runtime === "node") devDependencies.push("tsx", "@types/node");
|
|
4248
4150
|
}
|
|
4249
|
-
if (api === "trpc") {
|
|
4250
|
-
if (framework === "express") dependencies.push("@trpc/server");
|
|
4251
|
-
else if (framework === "fastify") dependencies.push("@trpc/server");
|
|
4252
|
-
else if (runtime === "workers") dependencies.push("@trpc/server");
|
|
4253
|
-
} else if (api === "orpc") dependencies.push("@orpc/server", "@orpc/openapi", "@orpc/zod");
|
|
4254
|
-
if (auth === "better-auth") dependencies.push("better-auth");
|
|
4255
|
-
if (examples.includes("ai")) dependencies.push("ai", "@ai-sdk/google");
|
|
4256
4151
|
if (runtime === "bun") devDependencies.push("@types/bun");
|
|
4257
4152
|
if (dependencies.length > 0 || devDependencies.length > 0) await addPackageDependency({
|
|
4258
4153
|
dependencies,
|
|
@@ -4271,7 +4166,7 @@ async function setupAuth(config) {
|
|
|
4271
4166
|
const nativeDir = path.join(projectDir, "apps/native");
|
|
4272
4167
|
const clientDirExists = await fs.pathExists(clientDir);
|
|
4273
4168
|
const nativeDirExists = await fs.pathExists(nativeDir);
|
|
4274
|
-
await fs.pathExists(serverDir);
|
|
4169
|
+
const serverDirExists = await fs.pathExists(serverDir);
|
|
4275
4170
|
try {
|
|
4276
4171
|
if (backend === "convex") {
|
|
4277
4172
|
if (auth === "clerk" && clientDirExists) {
|
|
@@ -4327,11 +4222,9 @@ async function setupAuth(config) {
|
|
|
4327
4222
|
});
|
|
4328
4223
|
return;
|
|
4329
4224
|
}
|
|
4330
|
-
|
|
4331
|
-
const authPackageDirExists = await fs.pathExists(authPackageDir);
|
|
4332
|
-
if (authPackageDirExists && auth === "better-auth") await addPackageDependency({
|
|
4225
|
+
if (serverDirExists && auth === "better-auth") await addPackageDependency({
|
|
4333
4226
|
dependencies: ["better-auth"],
|
|
4334
|
-
projectDir:
|
|
4227
|
+
projectDir: serverDir
|
|
4335
4228
|
});
|
|
4336
4229
|
if (frontend.some((f) => [
|
|
4337
4230
|
"react-router",
|
|
@@ -4353,9 +4246,9 @@ async function setupAuth(config) {
|
|
|
4353
4246
|
dependencies: ["better-auth", "@better-auth/expo"],
|
|
4354
4247
|
projectDir: nativeDir
|
|
4355
4248
|
});
|
|
4356
|
-
if (
|
|
4249
|
+
if (serverDirExists) await addPackageDependency({
|
|
4357
4250
|
dependencies: ["@better-auth/expo"],
|
|
4358
|
-
projectDir:
|
|
4251
|
+
projectDir: serverDir
|
|
4359
4252
|
});
|
|
4360
4253
|
}
|
|
4361
4254
|
}
|
|
@@ -4538,6 +4431,8 @@ async function setupEnvironmentVariables(config) {
|
|
|
4538
4431
|
return;
|
|
4539
4432
|
}
|
|
4540
4433
|
const serverDir = path.join(projectDir, "apps/server");
|
|
4434
|
+
if (!await fs.pathExists(serverDir)) return;
|
|
4435
|
+
const envPath = path.join(serverDir, ".env");
|
|
4541
4436
|
let corsOrigin = "http://localhost:3001";
|
|
4542
4437
|
if (hasReactRouter || hasSvelte) corsOrigin = "http://localhost:5173";
|
|
4543
4438
|
let databaseUrl = null;
|
|
@@ -4553,50 +4448,47 @@ async function setupEnvironmentVariables(config) {
|
|
|
4553
4448
|
break;
|
|
4554
4449
|
case "sqlite":
|
|
4555
4450
|
if (config.runtime === "workers") databaseUrl = "http://127.0.0.1:8080";
|
|
4556
|
-
else databaseUrl =
|
|
4451
|
+
else databaseUrl = "file:./local.db";
|
|
4557
4452
|
break;
|
|
4558
4453
|
}
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
{
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
];
|
|
4598
|
-
await addEnvVariablesToFile(serverEnvPath, serverVars);
|
|
4599
|
-
}
|
|
4454
|
+
const serverVars = [
|
|
4455
|
+
{
|
|
4456
|
+
key: "CORS_ORIGIN",
|
|
4457
|
+
value: corsOrigin,
|
|
4458
|
+
condition: true
|
|
4459
|
+
},
|
|
4460
|
+
{
|
|
4461
|
+
key: "BETTER_AUTH_SECRET",
|
|
4462
|
+
value: generateAuthSecret(),
|
|
4463
|
+
condition: !!auth
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
key: "BETTER_AUTH_URL",
|
|
4467
|
+
value: "http://localhost:3000",
|
|
4468
|
+
condition: !!auth
|
|
4469
|
+
},
|
|
4470
|
+
{
|
|
4471
|
+
key: "DATABASE_URL",
|
|
4472
|
+
value: databaseUrl,
|
|
4473
|
+
condition: database !== "none" && dbSetup === "none"
|
|
4474
|
+
},
|
|
4475
|
+
{
|
|
4476
|
+
key: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
4477
|
+
value: "",
|
|
4478
|
+
condition: examples?.includes("ai") || false
|
|
4479
|
+
},
|
|
4480
|
+
{
|
|
4481
|
+
key: "POLAR_ACCESS_TOKEN",
|
|
4482
|
+
value: "",
|
|
4483
|
+
condition: config.payments === "polar"
|
|
4484
|
+
},
|
|
4485
|
+
{
|
|
4486
|
+
key: "POLAR_SUCCESS_URL",
|
|
4487
|
+
value: `${corsOrigin}/success?checkout_id={CHECKOUT_ID}`,
|
|
4488
|
+
condition: config.payments === "polar"
|
|
4489
|
+
}
|
|
4490
|
+
];
|
|
4491
|
+
await addEnvVariablesToFile(envPath, serverVars);
|
|
4600
4492
|
const isUnifiedAlchemy = webDeploy === "alchemy" && serverDeploy === "alchemy";
|
|
4601
4493
|
const isIndividualAlchemy = webDeploy === "alchemy" || serverDeploy === "alchemy";
|
|
4602
4494
|
if (isUnifiedAlchemy) {
|
|
@@ -4615,11 +4507,14 @@ async function setupEnvironmentVariables(config) {
|
|
|
4615
4507
|
condition: true
|
|
4616
4508
|
}]);
|
|
4617
4509
|
}
|
|
4618
|
-
if (serverDeploy === "alchemy")
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4510
|
+
if (serverDeploy === "alchemy") {
|
|
4511
|
+
const serverDir$1 = path.join(projectDir, "apps/server");
|
|
4512
|
+
if (await fs.pathExists(serverDir$1)) await addEnvVariablesToFile(path.join(serverDir$1, ".env"), [{
|
|
4513
|
+
key: "ALCHEMY_PASSWORD",
|
|
4514
|
+
value: "please-change-this",
|
|
4515
|
+
condition: true
|
|
4516
|
+
}]);
|
|
4517
|
+
}
|
|
4623
4518
|
}
|
|
4624
4519
|
}
|
|
4625
4520
|
|
|
@@ -4654,7 +4549,7 @@ async function setupCloudflareD1(config) {
|
|
|
4654
4549
|
const envPath = path.join(projectDir, "apps/server", ".env");
|
|
4655
4550
|
const variables = [{
|
|
4656
4551
|
key: "DATABASE_URL",
|
|
4657
|
-
value:
|
|
4552
|
+
value: "file:./local.db",
|
|
4658
4553
|
condition: true
|
|
4659
4554
|
}];
|
|
4660
4555
|
try {
|
|
@@ -5184,9 +5079,9 @@ async function writeEnvFile$1(projectDir, config) {
|
|
|
5184
5079
|
}
|
|
5185
5080
|
async function addDotenvImportToPrismaConfig(projectDir) {
|
|
5186
5081
|
try {
|
|
5187
|
-
const prismaConfigPath = path.join(projectDir, "
|
|
5082
|
+
const prismaConfigPath = path.join(projectDir, "apps/server/prisma.config.ts");
|
|
5188
5083
|
let content = await fs.readFile(prismaConfigPath, "utf8");
|
|
5189
|
-
content = `import
|
|
5084
|
+
content = `import "dotenv/config";\n${content}`;
|
|
5190
5085
|
await fs.writeFile(prismaConfigPath, content);
|
|
5191
5086
|
} catch (_error) {
|
|
5192
5087
|
consola$1.error("Failed to update prisma.config.ts");
|
|
@@ -5202,12 +5097,11 @@ function displayManualSetupInstructions$1() {
|
|
|
5202
5097
|
|
|
5203
5098
|
DATABASE_URL="your_database_url"`);
|
|
5204
5099
|
}
|
|
5205
|
-
async function addPrismaAccelerateExtension(
|
|
5100
|
+
async function addPrismaAccelerateExtension(serverDir) {
|
|
5206
5101
|
try {
|
|
5207
|
-
const dbPackageDir = path.join(projectDir, "packages/db");
|
|
5208
5102
|
await addPackageDependency({
|
|
5209
5103
|
dependencies: ["@prisma/extension-accelerate"],
|
|
5210
|
-
projectDir:
|
|
5104
|
+
projectDir: serverDir
|
|
5211
5105
|
});
|
|
5212
5106
|
return true;
|
|
5213
5107
|
} catch (_error) {
|
|
@@ -5268,7 +5162,7 @@ async function setupPrismaPostgres(config, cliInput) {
|
|
|
5268
5162
|
await writeEnvFile$1(projectDir, prismaConfig);
|
|
5269
5163
|
if (orm === "prisma") {
|
|
5270
5164
|
await addDotenvImportToPrismaConfig(projectDir);
|
|
5271
|
-
await addPrismaAccelerateExtension(
|
|
5165
|
+
await addPrismaAccelerateExtension(serverDir);
|
|
5272
5166
|
}
|
|
5273
5167
|
const connectionType = orm === "drizzle" ? "direct connection" : "Prisma Accelerate";
|
|
5274
5168
|
log.success(pc.green(`Prisma Postgres database configured successfully with ${connectionType}!`));
|
|
@@ -5368,18 +5262,18 @@ function displayManualSupabaseInstructions(output) {
|
|
|
5368
5262
|
log.info(`"Manual Supabase Setup Instructions:"
|
|
5369
5263
|
1. Ensure Docker is installed and running.
|
|
5370
5264
|
2. Install the Supabase CLI (e.g., \`npm install -g supabase\`).
|
|
5371
|
-
3. Run \`supabase init\` in your project's \`
|
|
5372
|
-
4. Run \`supabase start\` in your project's \`
|
|
5265
|
+
3. Run \`supabase init\` in your project's \`apps/server\` directory.
|
|
5266
|
+
4. Run \`supabase start\` in your project's \`apps/server\` directory.
|
|
5373
5267
|
5. Copy the 'DB URL' from the output.${output ? `
|
|
5374
5268
|
${pc.bold("Relevant output from `supabase start`:")}
|
|
5375
5269
|
${pc.dim(output)}` : ""}
|
|
5376
|
-
6. Add the DB URL to the .env file in \`
|
|
5270
|
+
6. Add the DB URL to the .env file in \`apps/server/.env\` as \`DATABASE_URL\`:
|
|
5377
5271
|
${pc.gray("DATABASE_URL=\"your_supabase_db_url\"")}`);
|
|
5378
5272
|
}
|
|
5379
5273
|
async function setupSupabase(config, cliInput) {
|
|
5380
5274
|
const { projectDir, packageManager } = config;
|
|
5381
5275
|
const manualDb = cliInput?.manualDb ?? false;
|
|
5382
|
-
const serverDir = path.join(projectDir, "
|
|
5276
|
+
const serverDir = path.join(projectDir, "apps", "server");
|
|
5383
5277
|
try {
|
|
5384
5278
|
await fs.ensureDir(serverDir);
|
|
5385
5279
|
if (manualDb) {
|
|
@@ -5662,15 +5556,15 @@ async function setupDatabase(config, cliInput) {
|
|
|
5662
5556
|
const { database, orm, dbSetup, backend, projectDir } = config;
|
|
5663
5557
|
if (backend === "convex" || database === "none") {
|
|
5664
5558
|
if (backend !== "convex") {
|
|
5665
|
-
const serverDir = path.join(projectDir, "apps/server");
|
|
5666
|
-
const serverDbDir = path.join(serverDir, "src/db");
|
|
5559
|
+
const serverDir$1 = path.join(projectDir, "apps/server");
|
|
5560
|
+
const serverDbDir = path.join(serverDir$1, "src/db");
|
|
5667
5561
|
if (await fs.pathExists(serverDbDir)) await fs.remove(serverDbDir);
|
|
5668
5562
|
}
|
|
5669
5563
|
return;
|
|
5670
5564
|
}
|
|
5671
5565
|
const s = spinner();
|
|
5672
|
-
const
|
|
5673
|
-
if (!await fs.pathExists(
|
|
5566
|
+
const serverDir = path.join(projectDir, "apps/server");
|
|
5567
|
+
if (!await fs.pathExists(serverDir)) return;
|
|
5674
5568
|
try {
|
|
5675
5569
|
if (orm === "prisma") if (database === "mysql" && dbSetup === "planetscale") await addPackageDependency({
|
|
5676
5570
|
dependencies: [
|
|
@@ -5679,27 +5573,23 @@ async function setupDatabase(config, cliInput) {
|
|
|
5679
5573
|
"@planetscale/database"
|
|
5680
5574
|
],
|
|
5681
5575
|
devDependencies: ["prisma"],
|
|
5682
|
-
projectDir:
|
|
5576
|
+
projectDir: serverDir
|
|
5683
5577
|
});
|
|
5684
5578
|
else if (database === "sqlite" && dbSetup === "turso") await addPackageDependency({
|
|
5685
5579
|
dependencies: ["@prisma/client", "@prisma/adapter-libsql"],
|
|
5686
5580
|
devDependencies: ["prisma"],
|
|
5687
|
-
projectDir:
|
|
5581
|
+
projectDir: serverDir
|
|
5688
5582
|
});
|
|
5689
5583
|
else await addPackageDependency({
|
|
5690
5584
|
dependencies: ["@prisma/client"],
|
|
5691
5585
|
devDependencies: ["prisma"],
|
|
5692
|
-
projectDir:
|
|
5586
|
+
projectDir: serverDir
|
|
5693
5587
|
});
|
|
5694
5588
|
else if (orm === "drizzle") {
|
|
5695
5589
|
if (database === "sqlite") await addPackageDependency({
|
|
5696
|
-
dependencies: [
|
|
5697
|
-
"drizzle-orm",
|
|
5698
|
-
"@libsql/client",
|
|
5699
|
-
"libsql"
|
|
5700
|
-
],
|
|
5590
|
+
dependencies: ["drizzle-orm", "@libsql/client"],
|
|
5701
5591
|
devDependencies: ["drizzle-kit"],
|
|
5702
|
-
projectDir:
|
|
5592
|
+
projectDir: serverDir
|
|
5703
5593
|
});
|
|
5704
5594
|
else if (database === "postgres") if (dbSetup === "neon") await addPackageDependency({
|
|
5705
5595
|
dependencies: [
|
|
@@ -5708,32 +5598,32 @@ async function setupDatabase(config, cliInput) {
|
|
|
5708
5598
|
"ws"
|
|
5709
5599
|
],
|
|
5710
5600
|
devDependencies: ["drizzle-kit", "@types/ws"],
|
|
5711
|
-
projectDir:
|
|
5601
|
+
projectDir: serverDir
|
|
5712
5602
|
});
|
|
5713
5603
|
else if (dbSetup === "planetscale") await addPackageDependency({
|
|
5714
5604
|
dependencies: ["drizzle-orm", "pg"],
|
|
5715
5605
|
devDependencies: ["drizzle-kit", "@types/pg"],
|
|
5716
|
-
projectDir:
|
|
5606
|
+
projectDir: serverDir
|
|
5717
5607
|
});
|
|
5718
5608
|
else await addPackageDependency({
|
|
5719
5609
|
dependencies: ["drizzle-orm", "pg"],
|
|
5720
5610
|
devDependencies: ["drizzle-kit", "@types/pg"],
|
|
5721
|
-
projectDir:
|
|
5611
|
+
projectDir: serverDir
|
|
5722
5612
|
});
|
|
5723
5613
|
else if (database === "mysql") if (dbSetup === "planetscale") await addPackageDependency({
|
|
5724
5614
|
dependencies: ["drizzle-orm", "@planetscale/database"],
|
|
5725
5615
|
devDependencies: ["drizzle-kit"],
|
|
5726
|
-
projectDir:
|
|
5616
|
+
projectDir: serverDir
|
|
5727
5617
|
});
|
|
5728
5618
|
else await addPackageDependency({
|
|
5729
5619
|
dependencies: ["drizzle-orm", "mysql2"],
|
|
5730
5620
|
devDependencies: ["drizzle-kit"],
|
|
5731
|
-
projectDir:
|
|
5621
|
+
projectDir: serverDir
|
|
5732
5622
|
});
|
|
5733
5623
|
} else if (orm === "mongoose") await addPackageDependency({
|
|
5734
5624
|
dependencies: ["mongoose"],
|
|
5735
5625
|
devDependencies: [],
|
|
5736
|
-
projectDir:
|
|
5626
|
+
projectDir: serverDir
|
|
5737
5627
|
});
|
|
5738
5628
|
if (dbSetup === "docker") await setupDockerCompose(config);
|
|
5739
5629
|
else if (database === "sqlite" && dbSetup === "turso") await setupTurso(config, cliInput);
|
|
@@ -6390,66 +6280,12 @@ function getAlchemyDeployInstructions(runCmd, webDeploy, serverDeploy) {
|
|
|
6390
6280
|
return instructions.length ? `\n${instructions.join("\n")}` : "";
|
|
6391
6281
|
}
|
|
6392
6282
|
|
|
6393
|
-
//#endregion
|
|
6394
|
-
//#region src/helpers/core/workspace-setup.ts
|
|
6395
|
-
async function setupWorkspaceDependencies(projectDir, options) {
|
|
6396
|
-
const projectName = options.projectName;
|
|
6397
|
-
const workspaceVersion = options.packageManager === "npm" ? "*" : "workspace:*";
|
|
6398
|
-
const commonDeps = ["dotenv", "zod"];
|
|
6399
|
-
const commonDevDeps = ["tsdown"];
|
|
6400
|
-
const dbPackageDir = path.join(projectDir, "packages/db");
|
|
6401
|
-
if (await fs.pathExists(dbPackageDir)) await addPackageDependency({
|
|
6402
|
-
dependencies: commonDeps,
|
|
6403
|
-
devDependencies: commonDevDeps,
|
|
6404
|
-
projectDir: dbPackageDir
|
|
6405
|
-
});
|
|
6406
|
-
const authPackageDir = path.join(projectDir, "packages/auth");
|
|
6407
|
-
if (await fs.pathExists(authPackageDir)) await addPackageDependency({
|
|
6408
|
-
dependencies: commonDeps,
|
|
6409
|
-
devDependencies: commonDevDeps,
|
|
6410
|
-
customDependencies: { [`@${projectName}/db`]: workspaceVersion },
|
|
6411
|
-
projectDir: authPackageDir
|
|
6412
|
-
});
|
|
6413
|
-
const apiPackageDir = path.join(projectDir, "packages/api");
|
|
6414
|
-
if (await fs.pathExists(apiPackageDir)) await addPackageDependency({
|
|
6415
|
-
dependencies: commonDeps,
|
|
6416
|
-
devDependencies: commonDevDeps,
|
|
6417
|
-
customDependencies: {
|
|
6418
|
-
[`@${projectName}/auth`]: workspaceVersion,
|
|
6419
|
-
[`@${projectName}/db`]: workspaceVersion
|
|
6420
|
-
},
|
|
6421
|
-
projectDir: apiPackageDir
|
|
6422
|
-
});
|
|
6423
|
-
const serverPackageDir = path.join(projectDir, "apps/server");
|
|
6424
|
-
if (await fs.pathExists(serverPackageDir)) await addPackageDependency({
|
|
6425
|
-
dependencies: commonDeps,
|
|
6426
|
-
devDependencies: commonDevDeps,
|
|
6427
|
-
customDependencies: {
|
|
6428
|
-
[`@${projectName}/api`]: workspaceVersion,
|
|
6429
|
-
[`@${projectName}/auth`]: workspaceVersion,
|
|
6430
|
-
[`@${projectName}/db`]: workspaceVersion
|
|
6431
|
-
},
|
|
6432
|
-
projectDir: serverPackageDir
|
|
6433
|
-
});
|
|
6434
|
-
if (options.api && options.api !== "none") {
|
|
6435
|
-
const webPackageDir = path.join(projectDir, "apps/web");
|
|
6436
|
-
if (await fs.pathExists(webPackageDir)) await addPackageDependency({
|
|
6437
|
-
customDependencies: { [`@${projectName}/api`]: workspaceVersion },
|
|
6438
|
-
projectDir: webPackageDir
|
|
6439
|
-
});
|
|
6440
|
-
}
|
|
6441
|
-
}
|
|
6442
|
-
|
|
6443
6283
|
//#endregion
|
|
6444
6284
|
//#region src/helpers/core/project-config.ts
|
|
6445
6285
|
async function updatePackageConfigurations(projectDir, options) {
|
|
6446
6286
|
await updateRootPackageJson(projectDir, options);
|
|
6447
|
-
if (options.backend !== "convex")
|
|
6448
|
-
|
|
6449
|
-
await updateAuthPackageJson(projectDir, options);
|
|
6450
|
-
await updateApiPackageJson(projectDir, options);
|
|
6451
|
-
await setupWorkspaceDependencies(projectDir, options);
|
|
6452
|
-
} else await updateConvexPackageJson(projectDir, options);
|
|
6287
|
+
if (options.backend !== "convex") await updateServerPackageJson(projectDir, options);
|
|
6288
|
+
else await updateConvexPackageJson(projectDir, options);
|
|
6453
6289
|
}
|
|
6454
6290
|
async function updateRootPackageJson(projectDir, options) {
|
|
6455
6291
|
const rootPackageJsonPath = path.join(projectDir, "package.json");
|
|
@@ -6459,7 +6295,6 @@ async function updateRootPackageJson(projectDir, options) {
|
|
|
6459
6295
|
if (!packageJson.scripts) packageJson.scripts = {};
|
|
6460
6296
|
const scripts = packageJson.scripts;
|
|
6461
6297
|
const backendPackageName = options.backend === "convex" ? `@${options.projectName}/backend` : "server";
|
|
6462
|
-
const dbPackageName = `@${options.projectName}/db`;
|
|
6463
6298
|
let serverDevScript = "";
|
|
6464
6299
|
if (options.addons.includes("turborepo")) serverDevScript = `turbo -F ${backendPackageName} dev`;
|
|
6465
6300
|
else if (options.packageManager === "bun") serverDevScript = `bun run --filter ${backendPackageName} dev`;
|
|
@@ -6479,14 +6314,14 @@ async function updateRootPackageJson(projectDir, options) {
|
|
|
6479
6314
|
scripts["dev:server"] = serverDevScript;
|
|
6480
6315
|
if (options.backend === "convex") scripts["dev:setup"] = `turbo -F ${backendPackageName} dev:setup`;
|
|
6481
6316
|
if (needsDbScripts) {
|
|
6482
|
-
scripts["db:push"] = `turbo -F ${
|
|
6483
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `turbo -F ${
|
|
6317
|
+
scripts["db:push"] = `turbo -F ${backendPackageName} db:push`;
|
|
6318
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `turbo -F ${backendPackageName} db:studio`;
|
|
6484
6319
|
if (options.orm === "prisma") {
|
|
6485
|
-
scripts["db:generate"] = `turbo -F ${
|
|
6486
|
-
scripts["db:migrate"] = `turbo -F ${
|
|
6320
|
+
scripts["db:generate"] = `turbo -F ${backendPackageName} db:generate`;
|
|
6321
|
+
scripts["db:migrate"] = `turbo -F ${backendPackageName} db:migrate`;
|
|
6487
6322
|
} else if (options.orm === "drizzle") {
|
|
6488
|
-
scripts["db:generate"] = `turbo -F ${
|
|
6489
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `turbo -F ${
|
|
6323
|
+
scripts["db:generate"] = `turbo -F ${backendPackageName} db:generate`;
|
|
6324
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `turbo -F ${backendPackageName} db:migrate`;
|
|
6490
6325
|
}
|
|
6491
6326
|
}
|
|
6492
6327
|
if (options.dbSetup === "docker") {
|
|
@@ -6504,14 +6339,14 @@ async function updateRootPackageJson(projectDir, options) {
|
|
|
6504
6339
|
scripts["dev:server"] = serverDevScript;
|
|
6505
6340
|
if (options.backend === "convex") scripts["dev:setup"] = `pnpm --filter ${backendPackageName} dev:setup`;
|
|
6506
6341
|
if (needsDbScripts) {
|
|
6507
|
-
scripts["db:push"] = `pnpm --filter ${
|
|
6508
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `pnpm --filter ${
|
|
6342
|
+
scripts["db:push"] = `pnpm --filter ${backendPackageName} db:push`;
|
|
6343
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `pnpm --filter ${backendPackageName} db:studio`;
|
|
6509
6344
|
if (options.orm === "prisma") {
|
|
6510
|
-
scripts["db:generate"] = `pnpm --filter ${
|
|
6511
|
-
scripts["db:migrate"] = `pnpm --filter ${
|
|
6345
|
+
scripts["db:generate"] = `pnpm --filter ${backendPackageName} db:generate`;
|
|
6346
|
+
scripts["db:migrate"] = `pnpm --filter ${backendPackageName} db:migrate`;
|
|
6512
6347
|
} else if (options.orm === "drizzle") {
|
|
6513
|
-
scripts["db:generate"] = `pnpm --filter ${
|
|
6514
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `pnpm --filter ${
|
|
6348
|
+
scripts["db:generate"] = `pnpm --filter ${backendPackageName} db:generate`;
|
|
6349
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `pnpm --filter ${backendPackageName} db:migrate`;
|
|
6515
6350
|
}
|
|
6516
6351
|
}
|
|
6517
6352
|
if (options.dbSetup === "docker") {
|
|
@@ -6529,14 +6364,14 @@ async function updateRootPackageJson(projectDir, options) {
|
|
|
6529
6364
|
scripts["dev:server"] = serverDevScript;
|
|
6530
6365
|
if (options.backend === "convex") scripts["dev:setup"] = `npm run dev:setup --workspace ${backendPackageName}`;
|
|
6531
6366
|
if (needsDbScripts) {
|
|
6532
|
-
scripts["db:push"] = `npm run db:push --workspace ${
|
|
6533
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `npm run db:studio --workspace ${
|
|
6367
|
+
scripts["db:push"] = `npm run db:push --workspace ${backendPackageName}`;
|
|
6368
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `npm run db:studio --workspace ${backendPackageName}`;
|
|
6534
6369
|
if (options.orm === "prisma") {
|
|
6535
|
-
scripts["db:generate"] = `npm run db:generate --workspace ${
|
|
6536
|
-
scripts["db:migrate"] = `npm run db:migrate --workspace ${
|
|
6370
|
+
scripts["db:generate"] = `npm run db:generate --workspace ${backendPackageName}`;
|
|
6371
|
+
scripts["db:migrate"] = `npm run db:migrate --workspace ${backendPackageName}`;
|
|
6537
6372
|
} else if (options.orm === "drizzle") {
|
|
6538
|
-
scripts["db:generate"] = `npm run db:generate --workspace ${
|
|
6539
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `npm run db:migrate --workspace ${
|
|
6373
|
+
scripts["db:generate"] = `npm run db:generate --workspace ${backendPackageName}`;
|
|
6374
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `npm run db:migrate --workspace ${backendPackageName}`;
|
|
6540
6375
|
}
|
|
6541
6376
|
}
|
|
6542
6377
|
if (options.dbSetup === "docker") {
|
|
@@ -6554,14 +6389,14 @@ async function updateRootPackageJson(projectDir, options) {
|
|
|
6554
6389
|
scripts["dev:server"] = serverDevScript;
|
|
6555
6390
|
if (options.backend === "convex") scripts["dev:setup"] = `bun run --filter ${backendPackageName} dev:setup`;
|
|
6556
6391
|
if (needsDbScripts) {
|
|
6557
|
-
scripts["db:push"] = `bun run --filter ${
|
|
6558
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `bun run --filter ${
|
|
6392
|
+
scripts["db:push"] = `bun run --filter ${backendPackageName} db:push`;
|
|
6393
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:studio"] = `bun run --filter ${backendPackageName} db:studio`;
|
|
6559
6394
|
if (options.orm === "prisma") {
|
|
6560
|
-
scripts["db:generate"] = `bun run --filter ${
|
|
6561
|
-
scripts["db:migrate"] = `bun run --filter ${
|
|
6395
|
+
scripts["db:generate"] = `bun run --filter ${backendPackageName} db:generate`;
|
|
6396
|
+
scripts["db:migrate"] = `bun run --filter ${backendPackageName} db:migrate`;
|
|
6562
6397
|
} else if (options.orm === "drizzle") {
|
|
6563
|
-
scripts["db:generate"] = `bun run --filter ${
|
|
6564
|
-
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `bun run --filter ${
|
|
6398
|
+
scripts["db:generate"] = `bun run --filter ${backendPackageName} db:generate`;
|
|
6399
|
+
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = `bun run --filter ${backendPackageName} db:migrate`;
|
|
6565
6400
|
}
|
|
6566
6401
|
}
|
|
6567
6402
|
if (options.dbSetup === "docker") {
|
|
@@ -6594,22 +6429,6 @@ async function updateServerPackageJson(projectDir, options) {
|
|
|
6594
6429
|
const serverPackageJson = await fs.readJson(serverPackageJsonPath);
|
|
6595
6430
|
if (!serverPackageJson.scripts) serverPackageJson.scripts = {};
|
|
6596
6431
|
const scripts = serverPackageJson.scripts;
|
|
6597
|
-
if (options.dbSetup === "docker") {
|
|
6598
|
-
scripts["db:start"] = "docker compose up -d";
|
|
6599
|
-
scripts["db:watch"] = "docker compose up";
|
|
6600
|
-
scripts["db:stop"] = "docker compose stop";
|
|
6601
|
-
scripts["db:down"] = "docker compose down";
|
|
6602
|
-
}
|
|
6603
|
-
await fs.writeJson(serverPackageJsonPath, serverPackageJson, { spaces: 2 });
|
|
6604
|
-
await updateDbPackageJson(projectDir, options);
|
|
6605
|
-
}
|
|
6606
|
-
async function updateDbPackageJson(projectDir, options) {
|
|
6607
|
-
const dbPackageJsonPath = path.join(projectDir, "packages/db/package.json");
|
|
6608
|
-
if (!await fs.pathExists(dbPackageJsonPath)) return;
|
|
6609
|
-
const dbPackageJson = await fs.readJson(dbPackageJsonPath);
|
|
6610
|
-
dbPackageJson.name = `@${options.projectName}/db`;
|
|
6611
|
-
if (!dbPackageJson.scripts) dbPackageJson.scripts = {};
|
|
6612
|
-
const scripts = dbPackageJson.scripts;
|
|
6613
6432
|
if (options.database !== "none") {
|
|
6614
6433
|
if (options.database === "sqlite" && options.orm === "drizzle" && options.dbSetup !== "d1") scripts["db:local"] = "turso dev --db-file local.db";
|
|
6615
6434
|
if (options.orm === "prisma") {
|
|
@@ -6624,21 +6443,13 @@ async function updateDbPackageJson(projectDir, options) {
|
|
|
6624
6443
|
if (!(options.dbSetup === "d1" && options.serverDeploy === "alchemy")) scripts["db:migrate"] = "drizzle-kit migrate";
|
|
6625
6444
|
}
|
|
6626
6445
|
}
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
await fs.writeJson(authPackageJsonPath, authPackageJson, { spaces: 2 });
|
|
6635
|
-
}
|
|
6636
|
-
async function updateApiPackageJson(projectDir, options) {
|
|
6637
|
-
const apiPackageJsonPath = path.join(projectDir, "packages/api/package.json");
|
|
6638
|
-
if (!await fs.pathExists(apiPackageJsonPath)) return;
|
|
6639
|
-
const apiPackageJson = await fs.readJson(apiPackageJsonPath);
|
|
6640
|
-
apiPackageJson.name = `@${options.projectName}/api`;
|
|
6641
|
-
await fs.writeJson(apiPackageJsonPath, apiPackageJson, { spaces: 2 });
|
|
6446
|
+
if (options.dbSetup === "docker") {
|
|
6447
|
+
scripts["db:start"] = "docker compose up -d";
|
|
6448
|
+
scripts["db:watch"] = "docker compose up";
|
|
6449
|
+
scripts["db:stop"] = "docker compose stop";
|
|
6450
|
+
scripts["db:down"] = "docker compose down";
|
|
6451
|
+
}
|
|
6452
|
+
await fs.writeJson(serverPackageJsonPath, serverPackageJson, { spaces: 2 });
|
|
6642
6453
|
}
|
|
6643
6454
|
async function updateConvexPackageJson(projectDir, options) {
|
|
6644
6455
|
const convexPackageJsonPath = path.join(projectDir, "packages/backend/package.json");
|
|
@@ -6659,7 +6470,10 @@ async function createProject(options, cliInput) {
|
|
|
6659
6470
|
await copyBaseTemplate(projectDir, options);
|
|
6660
6471
|
await setupFrontendTemplates(projectDir, options);
|
|
6661
6472
|
await setupBackendFramework(projectDir, options);
|
|
6662
|
-
if (!isConvex)
|
|
6473
|
+
if (!isConvex) {
|
|
6474
|
+
await setupDbOrmTemplates(projectDir, options);
|
|
6475
|
+
await setupDockerComposeTemplates(projectDir, options);
|
|
6476
|
+
}
|
|
6663
6477
|
await setupAuthTemplate(projectDir, options);
|
|
6664
6478
|
if (options.payments && options.payments !== "none") await setupPaymentsTemplate(projectDir, options);
|
|
6665
6479
|
if (options.examples.length > 0 && options.examples[0] !== "none") await setupExamplesTemplate(projectDir, options);
|