create-better-t-stack 3.7.3-canary.8e4d5716 → 3.7.3-canary.fe324be3

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.
Files changed (104) hide show
  1. package/dist/cli.d.ts +1 -0
  2. package/dist/cli.js +8 -0
  3. package/dist/index.d.ts +347 -0
  4. package/dist/index.js +4 -0
  5. package/dist/src-yXf02Wox.js +7077 -0
  6. package/package.json +11 -7
  7. package/src/cli.ts +0 -3
  8. package/src/constants.ts +0 -188
  9. package/src/helpers/addons/addons-setup.ts +0 -226
  10. package/src/helpers/addons/examples-setup.ts +0 -104
  11. package/src/helpers/addons/fumadocs-setup.ts +0 -103
  12. package/src/helpers/addons/ruler-setup.ts +0 -139
  13. package/src/helpers/addons/starlight-setup.ts +0 -51
  14. package/src/helpers/addons/tauri-setup.ts +0 -96
  15. package/src/helpers/addons/ultracite-setup.ts +0 -232
  16. package/src/helpers/addons/vite-pwa-setup.ts +0 -59
  17. package/src/helpers/core/add-addons.ts +0 -85
  18. package/src/helpers/core/add-deployment.ts +0 -102
  19. package/src/helpers/core/api-setup.ts +0 -280
  20. package/src/helpers/core/auth-setup.ts +0 -203
  21. package/src/helpers/core/backend-setup.ts +0 -73
  22. package/src/helpers/core/command-handlers.ts +0 -354
  23. package/src/helpers/core/convex-codegen.ts +0 -14
  24. package/src/helpers/core/create-project.ts +0 -133
  25. package/src/helpers/core/create-readme.ts +0 -687
  26. package/src/helpers/core/db-setup.ts +0 -184
  27. package/src/helpers/core/detect-project-config.ts +0 -41
  28. package/src/helpers/core/env-setup.ts +0 -449
  29. package/src/helpers/core/git.ts +0 -31
  30. package/src/helpers/core/install-dependencies.ts +0 -32
  31. package/src/helpers/core/payments-setup.ts +0 -48
  32. package/src/helpers/core/post-installation.ts +0 -383
  33. package/src/helpers/core/project-config.ts +0 -246
  34. package/src/helpers/core/runtime-setup.ts +0 -76
  35. package/src/helpers/core/template-manager.ts +0 -917
  36. package/src/helpers/core/workspace-setup.ts +0 -184
  37. package/src/helpers/database-providers/d1-setup.ts +0 -28
  38. package/src/helpers/database-providers/docker-compose-setup.ts +0 -50
  39. package/src/helpers/database-providers/mongodb-atlas-setup.ts +0 -186
  40. package/src/helpers/database-providers/neon-setup.ts +0 -243
  41. package/src/helpers/database-providers/planetscale-setup.ts +0 -78
  42. package/src/helpers/database-providers/prisma-postgres-setup.ts +0 -196
  43. package/src/helpers/database-providers/supabase-setup.ts +0 -218
  44. package/src/helpers/database-providers/turso-setup.ts +0 -309
  45. package/src/helpers/deployment/alchemy/alchemy-combined-setup.ts +0 -80
  46. package/src/helpers/deployment/alchemy/alchemy-next-setup.ts +0 -51
  47. package/src/helpers/deployment/alchemy/alchemy-nuxt-setup.ts +0 -104
  48. package/src/helpers/deployment/alchemy/alchemy-react-router-setup.ts +0 -32
  49. package/src/helpers/deployment/alchemy/alchemy-solid-setup.ts +0 -32
  50. package/src/helpers/deployment/alchemy/alchemy-svelte-setup.ts +0 -98
  51. package/src/helpers/deployment/alchemy/alchemy-tanstack-router-setup.ts +0 -33
  52. package/src/helpers/deployment/alchemy/alchemy-tanstack-start-setup.ts +0 -98
  53. package/src/helpers/deployment/alchemy/env-dts-setup.ts +0 -76
  54. package/src/helpers/deployment/alchemy/index.ts +0 -7
  55. package/src/helpers/deployment/server-deploy-setup.ts +0 -55
  56. package/src/helpers/deployment/web-deploy-setup.ts +0 -58
  57. package/src/index.ts +0 -253
  58. package/src/prompts/addons.ts +0 -178
  59. package/src/prompts/api.ts +0 -49
  60. package/src/prompts/auth.ts +0 -84
  61. package/src/prompts/backend.ts +0 -83
  62. package/src/prompts/config-prompts.ts +0 -138
  63. package/src/prompts/database-setup.ts +0 -112
  64. package/src/prompts/database.ts +0 -57
  65. package/src/prompts/examples.ts +0 -64
  66. package/src/prompts/frontend.ts +0 -118
  67. package/src/prompts/git.ts +0 -16
  68. package/src/prompts/install.ts +0 -16
  69. package/src/prompts/orm.ts +0 -53
  70. package/src/prompts/package-manager.ts +0 -32
  71. package/src/prompts/payments.ts +0 -50
  72. package/src/prompts/project-name.ts +0 -86
  73. package/src/prompts/runtime.ts +0 -47
  74. package/src/prompts/server-deploy.ts +0 -91
  75. package/src/prompts/web-deploy.ts +0 -107
  76. package/src/types.ts +0 -2
  77. package/src/utils/add-package-deps.ts +0 -57
  78. package/src/utils/analytics.ts +0 -39
  79. package/src/utils/better-auth-plugin-setup.ts +0 -71
  80. package/src/utils/biome-formatter.ts +0 -82
  81. package/src/utils/bts-config.ts +0 -122
  82. package/src/utils/command-exists.ts +0 -16
  83. package/src/utils/compatibility-rules.ts +0 -319
  84. package/src/utils/compatibility.ts +0 -11
  85. package/src/utils/config-processing.ts +0 -130
  86. package/src/utils/config-validation.ts +0 -470
  87. package/src/utils/display-config.ts +0 -96
  88. package/src/utils/docker-utils.ts +0 -70
  89. package/src/utils/errors.ts +0 -32
  90. package/src/utils/generate-reproducible-command.ts +0 -53
  91. package/src/utils/get-latest-cli-version.ts +0 -11
  92. package/src/utils/get-package-manager.ts +0 -13
  93. package/src/utils/open-url.ts +0 -25
  94. package/src/utils/package-runner.ts +0 -23
  95. package/src/utils/project-directory.ts +0 -102
  96. package/src/utils/project-name-validation.ts +0 -43
  97. package/src/utils/render-title.ts +0 -48
  98. package/src/utils/setup-catalogs.ts +0 -192
  99. package/src/utils/sponsors.ts +0 -101
  100. package/src/utils/telemetry.ts +0 -19
  101. package/src/utils/template-processor.ts +0 -64
  102. package/src/utils/templates.ts +0 -94
  103. package/src/utils/ts-morph.ts +0 -26
  104. package/src/validation.ts +0 -117
@@ -1,917 +0,0 @@
1
- import path from "node:path";
2
- import fs from "fs-extra";
3
- import { glob } from "tinyglobby";
4
- import { PKG_ROOT } from "../../constants";
5
- import type { ProjectConfig } from "../../types";
6
- import { processTemplate } from "../../utils/template-processor";
7
- import { setupEnvDtsImport } from "../deployment/alchemy/env-dts-setup";
8
-
9
- export async function processAndCopyFiles(
10
- sourcePattern: string | string[],
11
- baseSourceDir: string,
12
- destDir: string,
13
- context: ProjectConfig,
14
- overwrite = true,
15
- ignorePatterns?: string[],
16
- ) {
17
- const sourceFiles = await glob(sourcePattern, {
18
- cwd: baseSourceDir,
19
- dot: true,
20
- onlyFiles: true,
21
- absolute: false,
22
- ignore: ignorePatterns,
23
- });
24
-
25
- for (const relativeSrcPath of sourceFiles) {
26
- const srcPath = path.join(baseSourceDir, relativeSrcPath);
27
- let relativeDestPath = relativeSrcPath;
28
-
29
- if (relativeSrcPath.endsWith(".hbs")) {
30
- relativeDestPath = relativeSrcPath.slice(0, -4);
31
- }
32
-
33
- const basename = path.basename(relativeDestPath);
34
- if (basename === "_gitignore") {
35
- relativeDestPath = path.join(path.dirname(relativeDestPath), ".gitignore");
36
- } else if (basename === "_npmrc") {
37
- relativeDestPath = path.join(path.dirname(relativeDestPath), ".npmrc");
38
- }
39
-
40
- const destPath = path.join(destDir, relativeDestPath);
41
-
42
- await fs.ensureDir(path.dirname(destPath));
43
-
44
- if (!overwrite && (await fs.pathExists(destPath))) {
45
- continue;
46
- }
47
-
48
- await processTemplate(srcPath, destPath, context);
49
- }
50
- }
51
-
52
- export async function copyBaseTemplate(projectDir: string, context: ProjectConfig) {
53
- const templateDir = path.join(PKG_ROOT, "templates/base");
54
- await processAndCopyFiles(["**/*"], templateDir, projectDir, context);
55
- }
56
-
57
- export async function setupFrontendTemplates(projectDir: string, context: ProjectConfig) {
58
- const hasReactWeb = context.frontend.some((f) =>
59
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
60
- );
61
- const hasNuxtWeb = context.frontend.includes("nuxt");
62
- const hasSvelteWeb = context.frontend.includes("svelte");
63
- const hasSolidWeb = context.frontend.includes("solid");
64
- const hasNativeBare = context.frontend.includes("native-bare");
65
- const hasNativeUniwind = context.frontend.includes("native-uniwind");
66
- const hasUnistyles = context.frontend.includes("native-unistyles");
67
- const _hasNative = hasNativeBare || hasNativeUniwind || hasUnistyles;
68
- const isConvex = context.backend === "convex";
69
-
70
- if (hasReactWeb || hasNuxtWeb || hasSvelteWeb || hasSolidWeb) {
71
- const webAppDir = path.join(projectDir, "apps/web");
72
- await fs.ensureDir(webAppDir);
73
-
74
- if (hasReactWeb) {
75
- const webBaseDir = path.join(PKG_ROOT, "templates/frontend/react/web-base");
76
- if (await fs.pathExists(webBaseDir)) {
77
- await processAndCopyFiles("**/*", webBaseDir, webAppDir, context);
78
- } else {
79
- }
80
- const reactFramework = context.frontend.find((f) =>
81
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
82
- );
83
- if (reactFramework) {
84
- const frameworkSrcDir = path.join(PKG_ROOT, `templates/frontend/react/${reactFramework}`);
85
- if (await fs.pathExists(frameworkSrcDir)) {
86
- await processAndCopyFiles("**/*", frameworkSrcDir, webAppDir, context);
87
- } else {
88
- }
89
-
90
- if (!isConvex && context.api !== "none") {
91
- const apiWebBaseDir = path.join(PKG_ROOT, `templates/api/${context.api}/web/react/base`);
92
- if (await fs.pathExists(apiWebBaseDir)) {
93
- await processAndCopyFiles("**/*", apiWebBaseDir, webAppDir, context);
94
- } else {
95
- }
96
- }
97
-
98
- if (
99
- context.backend === "self" &&
100
- (reactFramework === "next" || reactFramework === "tanstack-start") &&
101
- context.api !== "none"
102
- ) {
103
- const apiFullstackDir = path.join(
104
- PKG_ROOT,
105
- `templates/api/${context.api}/fullstack/${reactFramework}`,
106
- );
107
- if (await fs.pathExists(apiFullstackDir)) {
108
- await processAndCopyFiles("**/*", apiFullstackDir, webAppDir, context);
109
- }
110
- }
111
- }
112
- } else if (hasNuxtWeb) {
113
- const nuxtBaseDir = path.join(PKG_ROOT, "templates/frontend/nuxt");
114
- if (await fs.pathExists(nuxtBaseDir)) {
115
- await processAndCopyFiles("**/*", nuxtBaseDir, webAppDir, context);
116
- } else {
117
- }
118
-
119
- if (!isConvex && context.api === "orpc") {
120
- const apiWebNuxtDir = path.join(PKG_ROOT, `templates/api/${context.api}/web/nuxt`);
121
- if (await fs.pathExists(apiWebNuxtDir)) {
122
- await processAndCopyFiles("**/*", apiWebNuxtDir, webAppDir, context);
123
- } else {
124
- }
125
- }
126
- } else if (hasSvelteWeb) {
127
- const svelteBaseDir = path.join(PKG_ROOT, "templates/frontend/svelte");
128
- if (await fs.pathExists(svelteBaseDir)) {
129
- await processAndCopyFiles("**/*", svelteBaseDir, webAppDir, context);
130
- } else {
131
- }
132
-
133
- if (!isConvex && context.api === "orpc") {
134
- const apiWebSvelteDir = path.join(PKG_ROOT, `templates/api/${context.api}/web/svelte`);
135
- if (await fs.pathExists(apiWebSvelteDir)) {
136
- await processAndCopyFiles("**/*", apiWebSvelteDir, webAppDir, context);
137
- } else {
138
- }
139
- }
140
- } else if (hasSolidWeb) {
141
- const solidBaseDir = path.join(PKG_ROOT, "templates/frontend/solid");
142
- if (await fs.pathExists(solidBaseDir)) {
143
- await processAndCopyFiles("**/*", solidBaseDir, webAppDir, context);
144
- } else {
145
- }
146
-
147
- if (!isConvex && context.api === "orpc") {
148
- const apiWebSolidDir = path.join(PKG_ROOT, `templates/api/${context.api}/web/solid`);
149
- if (await fs.pathExists(apiWebSolidDir)) {
150
- await processAndCopyFiles("**/*", apiWebSolidDir, webAppDir, context);
151
- } else {
152
- }
153
- }
154
- }
155
- }
156
-
157
- if (hasNativeBare || hasNativeUniwind || hasUnistyles) {
158
- const nativeAppDir = path.join(projectDir, "apps/native");
159
- await fs.ensureDir(nativeAppDir);
160
-
161
- const nativeBaseCommonDir = path.join(PKG_ROOT, "templates/frontend/native/base");
162
- if (await fs.pathExists(nativeBaseCommonDir)) {
163
- await processAndCopyFiles("**/*", nativeBaseCommonDir, nativeAppDir, context);
164
- } else {
165
- }
166
-
167
- let nativeFrameworkPath = "";
168
- if (hasNativeBare) {
169
- nativeFrameworkPath = "bare";
170
- } else if (hasNativeUniwind) {
171
- nativeFrameworkPath = "uniwind";
172
- } else if (hasUnistyles) {
173
- nativeFrameworkPath = "unistyles";
174
- }
175
-
176
- const nativeSpecificDir = path.join(
177
- PKG_ROOT,
178
- `templates/frontend/native/${nativeFrameworkPath}`,
179
- );
180
- if (await fs.pathExists(nativeSpecificDir)) {
181
- await processAndCopyFiles("**/*", nativeSpecificDir, nativeAppDir, context, true);
182
- }
183
-
184
- if (!isConvex && (context.api === "trpc" || context.api === "orpc")) {
185
- const apiNativeSrcDir = path.join(PKG_ROOT, `templates/api/${context.api}/native`);
186
- if (await fs.pathExists(apiNativeSrcDir)) {
187
- await processAndCopyFiles("**/*", apiNativeSrcDir, nativeAppDir, context);
188
- }
189
- }
190
- }
191
- }
192
-
193
- async function setupApiPackage(projectDir: string, context: ProjectConfig) {
194
- if (context.api === "none") return;
195
-
196
- const apiPackageDir = path.join(projectDir, "packages/api");
197
- await fs.ensureDir(apiPackageDir);
198
-
199
- const apiServerDir = path.join(PKG_ROOT, `templates/api/${context.api}/server`);
200
- if (await fs.pathExists(apiServerDir)) {
201
- await processAndCopyFiles("**/*", apiServerDir, apiPackageDir, context);
202
- }
203
- }
204
-
205
- async function setupConfigPackage(projectDir: string, context: ProjectConfig) {
206
- const configPackageDir = path.join(projectDir, "packages/config");
207
- await fs.ensureDir(configPackageDir);
208
-
209
- const configBaseDir = path.join(PKG_ROOT, "templates/packages/config");
210
- if (await fs.pathExists(configBaseDir)) {
211
- await processAndCopyFiles("**/*", configBaseDir, configPackageDir, context);
212
- }
213
- }
214
-
215
- async function setupDbPackage(projectDir: string, context: ProjectConfig) {
216
- if (context.database === "none" || context.orm === "none") return;
217
-
218
- const dbPackageDir = path.join(projectDir, "packages/db");
219
- await fs.ensureDir(dbPackageDir);
220
-
221
- const dbBaseDir = path.join(PKG_ROOT, "templates/db/base");
222
- if (await fs.pathExists(dbBaseDir)) {
223
- await processAndCopyFiles("**/*", dbBaseDir, dbPackageDir, context);
224
- }
225
-
226
- const dbOrmSrcDir = path.join(PKG_ROOT, `templates/db/${context.orm}/${context.database}`);
227
- if (await fs.pathExists(dbOrmSrcDir)) {
228
- await processAndCopyFiles("**/*", dbOrmSrcDir, dbPackageDir, context);
229
- }
230
- }
231
-
232
- async function setupConvexBackend(projectDir: string, context: ProjectConfig) {
233
- const serverAppDir = path.join(projectDir, "apps/server");
234
- if (await fs.pathExists(serverAppDir)) {
235
- await fs.remove(serverAppDir);
236
- }
237
-
238
- const convexBackendDestDir = path.join(projectDir, "packages/backend");
239
- const convexSrcDir = path.join(PKG_ROOT, "templates/backend/convex/packages/backend");
240
- await fs.ensureDir(convexBackendDestDir);
241
- if (await fs.pathExists(convexSrcDir)) {
242
- await processAndCopyFiles("**/*", convexSrcDir, convexBackendDestDir, context);
243
- }
244
- }
245
-
246
- async function setupServerApp(projectDir: string, context: ProjectConfig) {
247
- const serverAppDir = path.join(projectDir, "apps/server");
248
- await fs.ensureDir(serverAppDir);
249
-
250
- const serverBaseDir = path.join(PKG_ROOT, "templates/backend/server/base");
251
- if (await fs.pathExists(serverBaseDir)) {
252
- await processAndCopyFiles("**/*", serverBaseDir, serverAppDir, context);
253
- }
254
-
255
- const frameworkSrcDir = path.join(PKG_ROOT, `templates/backend/server/${context.backend}`);
256
- if (await fs.pathExists(frameworkSrcDir)) {
257
- await processAndCopyFiles("**/*", frameworkSrcDir, serverAppDir, context, true);
258
- }
259
- }
260
-
261
- export async function setupBackendFramework(projectDir: string, context: ProjectConfig) {
262
- await setupConfigPackage(projectDir, context);
263
-
264
- if (context.backend === "none") {
265
- return;
266
- }
267
-
268
- if (context.backend === "convex") {
269
- await setupConvexBackend(projectDir, context);
270
- return;
271
- }
272
-
273
- if (context.backend === "self") {
274
- await setupApiPackage(projectDir, context);
275
- await setupDbPackage(projectDir, context);
276
- return;
277
- }
278
-
279
- await setupServerApp(projectDir, context);
280
- await setupApiPackage(projectDir, context);
281
- await setupDbPackage(projectDir, context);
282
- }
283
-
284
- export async function setupAuthTemplate(projectDir: string, context: ProjectConfig) {
285
- if (!context.auth || context.auth === "none") return;
286
-
287
- const serverAppDir = path.join(projectDir, "apps/server");
288
- const webAppDir = path.join(projectDir, "apps/web");
289
- const nativeAppDir = path.join(projectDir, "apps/native");
290
-
291
- const serverAppDirExists = await fs.pathExists(serverAppDir);
292
- const webAppDirExists = await fs.pathExists(webAppDir);
293
- const nativeAppDirExists = await fs.pathExists(nativeAppDir);
294
-
295
- const hasReactWeb = context.frontend.some((f) =>
296
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
297
- );
298
- const hasNuxtWeb = context.frontend.includes("nuxt");
299
- const hasSvelteWeb = context.frontend.includes("svelte");
300
- const hasSolidWeb = context.frontend.includes("solid");
301
- const hasNativeBare = context.frontend.includes("native-bare");
302
- const hasUniwind = context.frontend.includes("native-uniwind");
303
- const hasUnistyles = context.frontend.includes("native-unistyles");
304
- const hasNative = hasNativeBare || hasUniwind || hasUnistyles;
305
-
306
- const authProvider = context.auth;
307
-
308
- if (context.backend === "convex" && authProvider === "clerk") {
309
- const convexBackendDestDir = path.join(projectDir, "packages/backend");
310
- const convexClerkBackendSrc = path.join(PKG_ROOT, "templates/auth/clerk/convex/backend");
311
- if (await fs.pathExists(convexClerkBackendSrc)) {
312
- await fs.ensureDir(convexBackendDestDir);
313
- await processAndCopyFiles("**/*", convexClerkBackendSrc, convexBackendDestDir, context);
314
- }
315
-
316
- if (webAppDirExists) {
317
- const reactFramework = context.frontend.find((f) =>
318
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
319
- );
320
- if (reactFramework) {
321
- const convexClerkWebSrc = path.join(
322
- PKG_ROOT,
323
- `templates/auth/clerk/convex/web/react/${reactFramework}`,
324
- );
325
- if (await fs.pathExists(convexClerkWebSrc)) {
326
- await processAndCopyFiles("**/*", convexClerkWebSrc, webAppDir, context);
327
- }
328
- }
329
- }
330
-
331
- if (nativeAppDirExists) {
332
- const convexClerkNativeBaseSrc = path.join(
333
- PKG_ROOT,
334
- "templates/auth/clerk/convex/native/base",
335
- );
336
- if (await fs.pathExists(convexClerkNativeBaseSrc)) {
337
- await processAndCopyFiles("**/*", convexClerkNativeBaseSrc, nativeAppDir, context);
338
- }
339
-
340
- let nativeFrameworkPath = "";
341
- if (hasNativeBare) nativeFrameworkPath = "bare";
342
- else if (hasUniwind) nativeFrameworkPath = "uniwind";
343
- else if (hasUnistyles) nativeFrameworkPath = "unistyles";
344
- if (nativeFrameworkPath) {
345
- const convexClerkNativeFrameworkSrc = path.join(
346
- PKG_ROOT,
347
- `templates/auth/clerk/convex/native/${nativeFrameworkPath}`,
348
- );
349
- if (await fs.pathExists(convexClerkNativeFrameworkSrc)) {
350
- await processAndCopyFiles("**/*", convexClerkNativeFrameworkSrc, nativeAppDir, context);
351
- }
352
- }
353
- }
354
- return;
355
- }
356
-
357
- if (context.backend === "convex" && authProvider === "better-auth") {
358
- const convexBackendDestDir = path.join(projectDir, "packages/backend");
359
- const convexBetterAuthBackendSrc = path.join(
360
- PKG_ROOT,
361
- "templates/auth/better-auth/convex/backend",
362
- );
363
- if (await fs.pathExists(convexBetterAuthBackendSrc)) {
364
- await fs.ensureDir(convexBackendDestDir);
365
- await processAndCopyFiles("**/*", convexBetterAuthBackendSrc, convexBackendDestDir, context);
366
- }
367
-
368
- if (webAppDirExists && hasReactWeb) {
369
- const convexBetterAuthWebBaseSrc = path.join(
370
- PKG_ROOT,
371
- "templates/auth/better-auth/convex/web/react/base",
372
- );
373
- if (await fs.pathExists(convexBetterAuthWebBaseSrc)) {
374
- await processAndCopyFiles("**/*", convexBetterAuthWebBaseSrc, webAppDir, context);
375
- }
376
-
377
- const reactFramework = context.frontend.find((f) =>
378
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
379
- );
380
- if (reactFramework) {
381
- const convexBetterAuthWebSrc = path.join(
382
- PKG_ROOT,
383
- `templates/auth/better-auth/convex/web/react/${reactFramework}`,
384
- );
385
- if (await fs.pathExists(convexBetterAuthWebSrc)) {
386
- await processAndCopyFiles("**/*", convexBetterAuthWebSrc, webAppDir, context);
387
- }
388
- }
389
- }
390
-
391
- if (nativeAppDirExists) {
392
- const convexBetterAuthNativeBaseSrc = path.join(
393
- PKG_ROOT,
394
- "templates/auth/better-auth/convex/native/base",
395
- );
396
- if (await fs.pathExists(convexBetterAuthNativeBaseSrc)) {
397
- await processAndCopyFiles("**/*", convexBetterAuthNativeBaseSrc, nativeAppDir, context);
398
- }
399
-
400
- let nativeFrameworkPath = "";
401
- if (hasNativeBare) nativeFrameworkPath = "bare";
402
- else if (hasUniwind) nativeFrameworkPath = "uniwind";
403
- else if (hasUnistyles) nativeFrameworkPath = "unistyles";
404
- if (nativeFrameworkPath) {
405
- const convexBetterAuthNativeFrameworkSrc = path.join(
406
- PKG_ROOT,
407
- `templates/auth/better-auth/convex/native/${nativeFrameworkPath}`,
408
- );
409
- if (await fs.pathExists(convexBetterAuthNativeFrameworkSrc)) {
410
- await processAndCopyFiles(
411
- "**/*",
412
- convexBetterAuthNativeFrameworkSrc,
413
- nativeAppDir,
414
- context,
415
- );
416
- }
417
- }
418
- }
419
- return;
420
- }
421
-
422
- if ((serverAppDirExists || context.backend === "self") && context.backend !== "convex") {
423
- const authPackageDir = path.join(projectDir, "packages/auth");
424
- await fs.ensureDir(authPackageDir);
425
-
426
- const authServerBaseSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/base`);
427
- if (await fs.pathExists(authServerBaseSrc)) {
428
- await processAndCopyFiles("**/*", authServerBaseSrc, authPackageDir, context);
429
- }
430
-
431
- if (context.orm !== "none" && context.database !== "none") {
432
- const dbPackageDir = path.join(projectDir, "packages/db");
433
- await fs.ensureDir(dbPackageDir);
434
-
435
- const orm = context.orm;
436
- const db = context.database;
437
- let authDbSrc = "";
438
- if (orm === "drizzle") {
439
- authDbSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/db/drizzle/${db}`);
440
- } else if (orm === "prisma") {
441
- authDbSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/db/prisma/${db}`);
442
- } else if (orm === "mongoose") {
443
- authDbSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/server/db/mongoose/${db}`);
444
- }
445
- if (authDbSrc && (await fs.pathExists(authDbSrc))) {
446
- await processAndCopyFiles("**/*", authDbSrc, dbPackageDir, context);
447
- }
448
- }
449
- }
450
-
451
- if ((hasReactWeb || hasNuxtWeb || hasSvelteWeb || hasSolidWeb) && webAppDirExists) {
452
- if (hasReactWeb) {
453
- const authWebBaseSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/web/react/base`);
454
- if (await fs.pathExists(authWebBaseSrc)) {
455
- await processAndCopyFiles("**/*", authWebBaseSrc, webAppDir, context);
456
- }
457
-
458
- const reactFramework = context.frontend.find((f) =>
459
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
460
- );
461
- if (reactFramework) {
462
- const authWebFrameworkSrc = path.join(
463
- PKG_ROOT,
464
- `templates/auth/${authProvider}/web/react/${reactFramework}`,
465
- );
466
- if (await fs.pathExists(authWebFrameworkSrc)) {
467
- await processAndCopyFiles("**/*", authWebFrameworkSrc, webAppDir, context);
468
- }
469
-
470
- if (
471
- context.backend === "self" &&
472
- (reactFramework === "next" || reactFramework === "tanstack-start")
473
- ) {
474
- const authFullstackSrc = path.join(
475
- PKG_ROOT,
476
- `templates/auth/${authProvider}/fullstack/${reactFramework}`,
477
- );
478
- if (await fs.pathExists(authFullstackSrc)) {
479
- await processAndCopyFiles("**/*", authFullstackSrc, webAppDir, context);
480
- }
481
- }
482
- }
483
- } else if (hasNuxtWeb) {
484
- const authWebNuxtSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/web/nuxt`);
485
- if (await fs.pathExists(authWebNuxtSrc)) {
486
- await processAndCopyFiles("**/*", authWebNuxtSrc, webAppDir, context);
487
- }
488
- } else if (hasSvelteWeb) {
489
- const authWebSvelteSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/web/svelte`);
490
- if (await fs.pathExists(authWebSvelteSrc)) {
491
- await processAndCopyFiles("**/*", authWebSvelteSrc, webAppDir, context);
492
- }
493
- } else if (hasSolidWeb) {
494
- const authWebSolidSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/web/solid`);
495
- if (await fs.pathExists(authWebSolidSrc)) {
496
- await processAndCopyFiles("**/*", authWebSolidSrc, webAppDir, context);
497
- }
498
- }
499
- }
500
-
501
- if (hasNative && nativeAppDirExists) {
502
- const authNativeBaseSrc = path.join(PKG_ROOT, `templates/auth/${authProvider}/native/base`);
503
- if (await fs.pathExists(authNativeBaseSrc)) {
504
- await processAndCopyFiles("**/*", authNativeBaseSrc, nativeAppDir, context);
505
- }
506
-
507
- let nativeFrameworkAuthPath = "";
508
- if (hasNativeBare) {
509
- nativeFrameworkAuthPath = "bare";
510
- } else if (hasUniwind) {
511
- nativeFrameworkAuthPath = "uniwind";
512
- } else if (hasUnistyles) {
513
- nativeFrameworkAuthPath = "unistyles";
514
- }
515
-
516
- if (nativeFrameworkAuthPath) {
517
- const authNativeFrameworkSrc = path.join(
518
- PKG_ROOT,
519
- `templates/auth/${authProvider}/native/${nativeFrameworkAuthPath}`,
520
- );
521
- if (await fs.pathExists(authNativeFrameworkSrc)) {
522
- await processAndCopyFiles("**/*", authNativeFrameworkSrc, nativeAppDir, context);
523
- }
524
- }
525
- }
526
- }
527
-
528
- export async function setupPaymentsTemplate(projectDir: string, context: ProjectConfig) {
529
- if (!context.payments || context.payments === "none") return;
530
-
531
- const serverAppDir = path.join(projectDir, "apps/server");
532
- const webAppDir = path.join(projectDir, "apps/web");
533
-
534
- const serverAppDirExists = await fs.pathExists(serverAppDir);
535
- const webAppDirExists = await fs.pathExists(webAppDir);
536
-
537
- if ((serverAppDirExists || context.backend === "self") && context.backend !== "convex") {
538
- const authPackageDir = path.join(projectDir, "packages/auth");
539
- await fs.ensureDir(authPackageDir);
540
-
541
- const paymentsServerSrc = path.join(
542
- PKG_ROOT,
543
- `templates/payments/${context.payments}/server/base`,
544
- );
545
- if (await fs.pathExists(paymentsServerSrc)) {
546
- await processAndCopyFiles("**/*", paymentsServerSrc, authPackageDir, context);
547
- }
548
- }
549
-
550
- const hasReactWeb = context.frontend.some((f) =>
551
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
552
- );
553
- const hasNuxtWeb = context.frontend.includes("nuxt");
554
- const hasSvelteWeb = context.frontend.includes("svelte");
555
- const hasSolidWeb = context.frontend.includes("solid");
556
-
557
- if (webAppDirExists && (hasReactWeb || hasNuxtWeb || hasSvelteWeb || hasSolidWeb)) {
558
- if (hasReactWeb) {
559
- const reactFramework = context.frontend.find((f) =>
560
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
561
- );
562
- if (reactFramework) {
563
- const paymentsWebSrc = path.join(
564
- PKG_ROOT,
565
- `templates/payments/${context.payments}/web/react/${reactFramework}`,
566
- );
567
- if (await fs.pathExists(paymentsWebSrc)) {
568
- await processAndCopyFiles("**/*", paymentsWebSrc, webAppDir, context);
569
- }
570
- }
571
- } else if (hasNuxtWeb) {
572
- const paymentsWebNuxtSrc = path.join(
573
- PKG_ROOT,
574
- `templates/payments/${context.payments}/web/nuxt`,
575
- );
576
- if (await fs.pathExists(paymentsWebNuxtSrc)) {
577
- await processAndCopyFiles("**/*", paymentsWebNuxtSrc, webAppDir, context);
578
- }
579
- } else if (hasSvelteWeb) {
580
- const paymentsWebSvelteSrc = path.join(
581
- PKG_ROOT,
582
- `templates/payments/${context.payments}/web/svelte`,
583
- );
584
- if (await fs.pathExists(paymentsWebSvelteSrc)) {
585
- await processAndCopyFiles("**/*", paymentsWebSvelteSrc, webAppDir, context);
586
- }
587
- } else if (hasSolidWeb) {
588
- const paymentsWebSolidSrc = path.join(
589
- PKG_ROOT,
590
- `templates/payments/${context.payments}/web/solid`,
591
- );
592
- if (await fs.pathExists(paymentsWebSolidSrc)) {
593
- await processAndCopyFiles("**/*", paymentsWebSolidSrc, webAppDir, context);
594
- }
595
- }
596
- }
597
- }
598
-
599
- export async function setupAddonsTemplate(projectDir: string, context: ProjectConfig) {
600
- if (!context.addons || context.addons.length === 0) return;
601
-
602
- for (const addon of context.addons) {
603
- if (addon === "none") continue;
604
-
605
- let addonSrcDir = path.join(PKG_ROOT, `templates/addons/${addon}`);
606
- let addonDestDir = projectDir;
607
-
608
- if (addon === "pwa") {
609
- const webAppDir = path.join(projectDir, "apps/web");
610
- if (!(await fs.pathExists(webAppDir))) {
611
- continue;
612
- }
613
- addonDestDir = webAppDir;
614
- if (context.frontend.includes("next")) {
615
- addonSrcDir = path.join(PKG_ROOT, "templates/addons/pwa/apps/web/next");
616
- } else if (
617
- context.frontend.some((f) => ["tanstack-router", "react-router", "solid"].includes(f))
618
- ) {
619
- addonSrcDir = path.join(PKG_ROOT, "templates/addons/pwa/apps/web/vite");
620
- } else {
621
- continue;
622
- }
623
- }
624
-
625
- if (await fs.pathExists(addonSrcDir)) {
626
- await processAndCopyFiles("**/*", addonSrcDir, addonDestDir, context);
627
- } else {
628
- }
629
- }
630
- }
631
-
632
- export async function setupExamplesTemplate(projectDir: string, context: ProjectConfig) {
633
- if (!context.examples || context.examples.length === 0 || context.examples[0] === "none") {
634
- return;
635
- }
636
-
637
- const serverAppDir = path.join(projectDir, "apps/server");
638
- const webAppDir = path.join(projectDir, "apps/web");
639
-
640
- const serverAppDirExists = await fs.pathExists(serverAppDir);
641
- const webAppDirExists = await fs.pathExists(webAppDir);
642
- const nativeAppDir = path.join(projectDir, "apps/native");
643
- const nativeAppDirExists = await fs.pathExists(nativeAppDir);
644
-
645
- const hasReactWeb = context.frontend.some((f) =>
646
- ["tanstack-router", "react-router", "tanstack-start", "next"].includes(f),
647
- );
648
- const hasNuxtWeb = context.frontend.includes("nuxt");
649
- const hasSvelteWeb = context.frontend.includes("svelte");
650
- const hasSolidWeb = context.frontend.includes("solid");
651
-
652
- for (const example of context.examples) {
653
- if (example === "none") continue;
654
-
655
- const exampleBaseDir = path.join(PKG_ROOT, `templates/examples/${example}`);
656
-
657
- if (
658
- (serverAppDirExists || context.backend === "self") &&
659
- context.backend !== "convex" &&
660
- context.backend !== "none"
661
- ) {
662
- const exampleServerSrc = path.join(exampleBaseDir, "server");
663
-
664
- if (context.api !== "none") {
665
- const apiPackageDir = path.join(projectDir, "packages/api");
666
- await fs.ensureDir(apiPackageDir);
667
-
668
- const exampleOrmBaseSrc = path.join(exampleServerSrc, context.orm, "base");
669
- if (await fs.pathExists(exampleOrmBaseSrc)) {
670
- await processAndCopyFiles("**/*", exampleOrmBaseSrc, apiPackageDir, context, false);
671
- }
672
- }
673
-
674
- if (context.orm !== "none" && context.database !== "none") {
675
- const dbPackageDir = path.join(projectDir, "packages/db");
676
- await fs.ensureDir(dbPackageDir);
677
-
678
- const exampleDbSchemaSrc = path.join(exampleServerSrc, context.orm, context.database);
679
- if (await fs.pathExists(exampleDbSchemaSrc)) {
680
- await processAndCopyFiles("**/*", exampleDbSchemaSrc, dbPackageDir, context, false);
681
- }
682
- }
683
- }
684
-
685
- if (webAppDirExists) {
686
- if (hasReactWeb) {
687
- const exampleWebSrc = path.join(exampleBaseDir, "web/react");
688
- if (await fs.pathExists(exampleWebSrc)) {
689
- if (example === "ai") {
690
- const exampleWebBaseSrc = path.join(exampleWebSrc, "base");
691
- if (await fs.pathExists(exampleWebBaseSrc)) {
692
- await processAndCopyFiles("**/*", exampleWebBaseSrc, webAppDir, context, false);
693
- }
694
- }
695
-
696
- const reactFramework = context.frontend.find((f) =>
697
- ["next", "react-router", "tanstack-router", "tanstack-start"].includes(f),
698
- );
699
- if (reactFramework) {
700
- const exampleWebFrameworkSrc = path.join(exampleWebSrc, reactFramework);
701
- if (await fs.pathExists(exampleWebFrameworkSrc)) {
702
- await processAndCopyFiles("**/*", exampleWebFrameworkSrc, webAppDir, context, false);
703
- } else {
704
- }
705
-
706
- if (
707
- context.backend === "self" &&
708
- (reactFramework === "next" || reactFramework === "tanstack-start")
709
- ) {
710
- const exampleFullstackSrc = path.join(exampleBaseDir, `fullstack/${reactFramework}`);
711
- if (await fs.pathExists(exampleFullstackSrc)) {
712
- await processAndCopyFiles("**/*", exampleFullstackSrc, webAppDir, context, false);
713
- }
714
- }
715
- }
716
- }
717
- } else if (hasNuxtWeb) {
718
- const exampleWebNuxtSrc = path.join(exampleBaseDir, "web/nuxt");
719
- if (await fs.pathExists(exampleWebNuxtSrc)) {
720
- await processAndCopyFiles("**/*", exampleWebNuxtSrc, webAppDir, context, false);
721
- } else {
722
- }
723
- } else if (hasSvelteWeb) {
724
- const exampleWebSvelteSrc = path.join(exampleBaseDir, "web/svelte");
725
- if (await fs.pathExists(exampleWebSvelteSrc)) {
726
- await processAndCopyFiles("**/*", exampleWebSvelteSrc, webAppDir, context, false);
727
- } else {
728
- }
729
- } else if (hasSolidWeb) {
730
- const exampleWebSolidSrc = path.join(exampleBaseDir, "web/solid");
731
- if (await fs.pathExists(exampleWebSolidSrc)) {
732
- await processAndCopyFiles("**/*", exampleWebSolidSrc, webAppDir, context, false);
733
- } else {
734
- }
735
- }
736
- }
737
-
738
- if (nativeAppDirExists) {
739
- const hasNativeBare = context.frontend.includes("native-bare");
740
- const hasUniwind = context.frontend.includes("native-uniwind");
741
- const hasUnistyles = context.frontend.includes("native-unistyles");
742
-
743
- if (hasNativeBare || hasUniwind || hasUnistyles) {
744
- let nativeFramework = "";
745
- if (hasNativeBare) {
746
- nativeFramework = "bare";
747
- } else if (hasUniwind) {
748
- nativeFramework = "uniwind";
749
- } else if (hasUnistyles) {
750
- nativeFramework = "unistyles";
751
- }
752
-
753
- const exampleNativeSrc = path.join(exampleBaseDir, `native/${nativeFramework}`);
754
- if (await fs.pathExists(exampleNativeSrc)) {
755
- await processAndCopyFiles("**/*", exampleNativeSrc, nativeAppDir, context, false);
756
- }
757
- }
758
- }
759
- }
760
- }
761
-
762
- export async function handleExtras(projectDir: string, context: ProjectConfig) {
763
- const extrasDir = path.join(PKG_ROOT, "templates/extras");
764
- const hasNativeBare = context.frontend.includes("native-bare");
765
- const hasUniwind = context.frontend.includes("native-uniwind");
766
- const hasUnistyles = context.frontend.includes("native-unistyles");
767
- const hasNative = hasNativeBare || hasUniwind || hasUnistyles;
768
-
769
- if (context.packageManager === "pnpm") {
770
- const pnpmWorkspaceSrc = path.join(extrasDir, "pnpm-workspace.yaml");
771
- const pnpmWorkspaceDest = path.join(projectDir, "pnpm-workspace.yaml");
772
- if (await fs.pathExists(pnpmWorkspaceSrc)) {
773
- await processTemplate(pnpmWorkspaceSrc, pnpmWorkspaceDest, context);
774
- }
775
- }
776
-
777
- if (context.packageManager === "bun") {
778
- const bunfigSrc = path.join(extrasDir, "bunfig.toml.hbs");
779
- if (await fs.pathExists(bunfigSrc)) {
780
- await processAndCopyFiles("bunfig.toml.hbs", extrasDir, projectDir, context);
781
- }
782
- }
783
-
784
- if (context.packageManager === "pnpm" && (hasNative || context.frontend.includes("nuxt"))) {
785
- const npmrcTemplateSrc = path.join(extrasDir, "_npmrc.hbs");
786
- if (await fs.pathExists(npmrcTemplateSrc)) {
787
- await processAndCopyFiles("_npmrc.hbs", extrasDir, projectDir, context);
788
- }
789
- }
790
- }
791
-
792
- export async function setupDockerComposeTemplates(projectDir: string, context: ProjectConfig) {
793
- if (context.dbSetup !== "docker" || context.database === "none") {
794
- return;
795
- }
796
-
797
- const dbPackageDir = path.join(projectDir, "packages/db");
798
- const dockerSrcDir = path.join(PKG_ROOT, `templates/db-setup/docker-compose/${context.database}`);
799
-
800
- if (await fs.pathExists(dockerSrcDir)) {
801
- await processAndCopyFiles("**/*", dockerSrcDir, dbPackageDir, context);
802
- }
803
- }
804
-
805
- export async function setupDeploymentTemplates(projectDir: string, context: ProjectConfig) {
806
- const isBackendSelf = context.backend === "self";
807
-
808
- if (context.webDeploy === "alchemy" || context.serverDeploy === "alchemy") {
809
- const alchemyTemplateSrc = path.join(PKG_ROOT, "templates/deploy/alchemy");
810
-
811
- if (context.webDeploy === "alchemy" && (context.serverDeploy === "alchemy" || isBackendSelf)) {
812
- if (await fs.pathExists(alchemyTemplateSrc)) {
813
- const webAppDir = path.join(projectDir, "apps/web");
814
- const destDir = isBackendSelf && (await fs.pathExists(webAppDir)) ? webAppDir : projectDir;
815
- await processAndCopyFiles("alchemy.run.ts.hbs", alchemyTemplateSrc, destDir, context);
816
-
817
- if (!isBackendSelf) {
818
- await addEnvDtsToPackages(projectDir, context, alchemyTemplateSrc);
819
- }
820
- }
821
- } else {
822
- if (context.webDeploy === "alchemy") {
823
- const webAppDir = path.join(projectDir, "apps/web");
824
- if ((await fs.pathExists(alchemyTemplateSrc)) && (await fs.pathExists(webAppDir))) {
825
- await processAndCopyFiles("alchemy.run.ts.hbs", alchemyTemplateSrc, webAppDir, context);
826
-
827
- if (!isBackendSelf) {
828
- await addEnvDtsToPackages(projectDir, context, alchemyTemplateSrc);
829
- }
830
- }
831
- }
832
-
833
- if (context.serverDeploy === "alchemy" && !isBackendSelf) {
834
- const serverAppDir = path.join(projectDir, "apps/server");
835
- if ((await fs.pathExists(alchemyTemplateSrc)) && (await fs.pathExists(serverAppDir))) {
836
- await processAndCopyFiles(
837
- "alchemy.run.ts.hbs",
838
- alchemyTemplateSrc,
839
- serverAppDir,
840
- context,
841
- );
842
- const envDtsPath = path.join(serverAppDir, "env.d.ts");
843
- await processTemplate(path.join(alchemyTemplateSrc, "env.d.ts.hbs"), envDtsPath, context);
844
- await setupEnvDtsImport(envDtsPath, projectDir, context);
845
-
846
- await addEnvDtsToPackages(projectDir, context, alchemyTemplateSrc);
847
- }
848
- }
849
- }
850
- }
851
-
852
- if (context.webDeploy !== "none" && context.webDeploy !== "alchemy") {
853
- const webAppDir = path.join(projectDir, "apps/web");
854
- if (await fs.pathExists(webAppDir)) {
855
- const frontends = context.frontend;
856
-
857
- const templateMap: Record<string, string> = {
858
- "tanstack-router": "react/tanstack-router",
859
- "tanstack-start": "react/tanstack-start",
860
- "react-router": "react/react-router",
861
- solid: "solid",
862
- next: "react/next",
863
- nuxt: "nuxt",
864
- svelte: "svelte",
865
- };
866
-
867
- for (const f of frontends) {
868
- if (templateMap[f]) {
869
- const deployTemplateSrc = path.join(
870
- PKG_ROOT,
871
- `templates/deploy/${context.webDeploy}/web/${templateMap[f]}`,
872
- );
873
- if (await fs.pathExists(deployTemplateSrc)) {
874
- await processAndCopyFiles("**/*", deployTemplateSrc, webAppDir, context);
875
- }
876
- }
877
- }
878
- }
879
- }
880
-
881
- if (context.serverDeploy !== "none" && context.serverDeploy !== "alchemy" && !isBackendSelf) {
882
- const serverAppDir = path.join(projectDir, "apps/server");
883
- if (await fs.pathExists(serverAppDir)) {
884
- const deployTemplateSrc = path.join(
885
- PKG_ROOT,
886
- `templates/deploy/${context.serverDeploy}/server`,
887
- );
888
- if (await fs.pathExists(deployTemplateSrc)) {
889
- await processAndCopyFiles("**/*", deployTemplateSrc, serverAppDir, context);
890
- }
891
- }
892
- }
893
- }
894
-
895
- async function addEnvDtsToPackages(
896
- projectDir: string,
897
- context: ProjectConfig,
898
- alchemyTemplateSrc: string,
899
- ) {
900
- const packages = ["packages/api", "packages/auth", "packages/db"];
901
-
902
- for (const packageName of packages) {
903
- const packageDir = path.join(projectDir, packageName);
904
- if (await fs.pathExists(packageDir)) {
905
- const envDtsPath = path.join(packageDir, "env.d.ts");
906
- await processTemplate(path.join(alchemyTemplateSrc, "env.d.ts.hbs"), envDtsPath, context);
907
- await setupEnvDtsImport(envDtsPath, projectDir, context);
908
- }
909
- }
910
-
911
- const serverAppDir = path.join(projectDir, "apps/server");
912
- if (await fs.pathExists(serverAppDir)) {
913
- const envDtsPath = path.join(serverAppDir, "env.d.ts");
914
- await processTemplate(path.join(alchemyTemplateSrc, "env.d.ts.hbs"), envDtsPath, context);
915
- await setupEnvDtsImport(envDtsPath, projectDir, context);
916
- }
917
- }