create-better-t-stack 3.7.3-canary.8e4d5716 → 3.7.3-canary.98ba1e7a
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.d.ts +1 -0
- package/dist/cli.js +8 -0
- package/dist/index.d.ts +347 -0
- package/dist/index.js +4 -0
- package/dist/src-yXf02Wox.js +7077 -0
- package/package.json +11 -7
- package/src/cli.ts +0 -3
- package/src/constants.ts +0 -188
- package/src/helpers/addons/addons-setup.ts +0 -226
- package/src/helpers/addons/examples-setup.ts +0 -104
- package/src/helpers/addons/fumadocs-setup.ts +0 -103
- package/src/helpers/addons/ruler-setup.ts +0 -139
- package/src/helpers/addons/starlight-setup.ts +0 -51
- package/src/helpers/addons/tauri-setup.ts +0 -96
- package/src/helpers/addons/ultracite-setup.ts +0 -232
- package/src/helpers/addons/vite-pwa-setup.ts +0 -59
- package/src/helpers/core/add-addons.ts +0 -85
- package/src/helpers/core/add-deployment.ts +0 -102
- package/src/helpers/core/api-setup.ts +0 -280
- package/src/helpers/core/auth-setup.ts +0 -203
- package/src/helpers/core/backend-setup.ts +0 -73
- package/src/helpers/core/command-handlers.ts +0 -354
- package/src/helpers/core/convex-codegen.ts +0 -14
- package/src/helpers/core/create-project.ts +0 -133
- package/src/helpers/core/create-readme.ts +0 -687
- package/src/helpers/core/db-setup.ts +0 -184
- package/src/helpers/core/detect-project-config.ts +0 -41
- package/src/helpers/core/env-setup.ts +0 -449
- package/src/helpers/core/git.ts +0 -31
- package/src/helpers/core/install-dependencies.ts +0 -32
- package/src/helpers/core/payments-setup.ts +0 -48
- package/src/helpers/core/post-installation.ts +0 -383
- package/src/helpers/core/project-config.ts +0 -246
- package/src/helpers/core/runtime-setup.ts +0 -76
- package/src/helpers/core/template-manager.ts +0 -917
- package/src/helpers/core/workspace-setup.ts +0 -184
- package/src/helpers/database-providers/d1-setup.ts +0 -28
- package/src/helpers/database-providers/docker-compose-setup.ts +0 -50
- package/src/helpers/database-providers/mongodb-atlas-setup.ts +0 -186
- package/src/helpers/database-providers/neon-setup.ts +0 -243
- package/src/helpers/database-providers/planetscale-setup.ts +0 -78
- package/src/helpers/database-providers/prisma-postgres-setup.ts +0 -196
- package/src/helpers/database-providers/supabase-setup.ts +0 -218
- package/src/helpers/database-providers/turso-setup.ts +0 -309
- package/src/helpers/deployment/alchemy/alchemy-combined-setup.ts +0 -80
- package/src/helpers/deployment/alchemy/alchemy-next-setup.ts +0 -51
- package/src/helpers/deployment/alchemy/alchemy-nuxt-setup.ts +0 -104
- package/src/helpers/deployment/alchemy/alchemy-react-router-setup.ts +0 -32
- package/src/helpers/deployment/alchemy/alchemy-solid-setup.ts +0 -32
- package/src/helpers/deployment/alchemy/alchemy-svelte-setup.ts +0 -98
- package/src/helpers/deployment/alchemy/alchemy-tanstack-router-setup.ts +0 -33
- package/src/helpers/deployment/alchemy/alchemy-tanstack-start-setup.ts +0 -98
- package/src/helpers/deployment/alchemy/env-dts-setup.ts +0 -76
- package/src/helpers/deployment/alchemy/index.ts +0 -7
- package/src/helpers/deployment/server-deploy-setup.ts +0 -55
- package/src/helpers/deployment/web-deploy-setup.ts +0 -58
- package/src/index.ts +0 -253
- package/src/prompts/addons.ts +0 -178
- package/src/prompts/api.ts +0 -49
- package/src/prompts/auth.ts +0 -84
- package/src/prompts/backend.ts +0 -83
- package/src/prompts/config-prompts.ts +0 -138
- package/src/prompts/database-setup.ts +0 -112
- package/src/prompts/database.ts +0 -57
- package/src/prompts/examples.ts +0 -64
- package/src/prompts/frontend.ts +0 -118
- package/src/prompts/git.ts +0 -16
- package/src/prompts/install.ts +0 -16
- package/src/prompts/orm.ts +0 -53
- package/src/prompts/package-manager.ts +0 -32
- package/src/prompts/payments.ts +0 -50
- package/src/prompts/project-name.ts +0 -86
- package/src/prompts/runtime.ts +0 -47
- package/src/prompts/server-deploy.ts +0 -91
- package/src/prompts/web-deploy.ts +0 -107
- package/src/types.ts +0 -2
- package/src/utils/add-package-deps.ts +0 -57
- package/src/utils/analytics.ts +0 -39
- package/src/utils/better-auth-plugin-setup.ts +0 -71
- package/src/utils/biome-formatter.ts +0 -82
- package/src/utils/bts-config.ts +0 -122
- package/src/utils/command-exists.ts +0 -16
- package/src/utils/compatibility-rules.ts +0 -319
- package/src/utils/compatibility.ts +0 -11
- package/src/utils/config-processing.ts +0 -130
- package/src/utils/config-validation.ts +0 -470
- package/src/utils/display-config.ts +0 -96
- package/src/utils/docker-utils.ts +0 -70
- package/src/utils/errors.ts +0 -32
- package/src/utils/generate-reproducible-command.ts +0 -53
- package/src/utils/get-latest-cli-version.ts +0 -11
- package/src/utils/get-package-manager.ts +0 -13
- package/src/utils/open-url.ts +0 -25
- package/src/utils/package-runner.ts +0 -23
- package/src/utils/project-directory.ts +0 -102
- package/src/utils/project-name-validation.ts +0 -43
- package/src/utils/render-title.ts +0 -48
- package/src/utils/setup-catalogs.ts +0 -192
- package/src/utils/sponsors.ts +0 -101
- package/src/utils/telemetry.ts +0 -19
- package/src/utils/template-processor.ts +0 -64
- package/src/utils/templates.ts +0 -94
- package/src/utils/ts-morph.ts +0 -26
- package/src/validation.ts +0 -117
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { intro, log, outro } from "@clack/prompts";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import fs from "fs-extra";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
import { getDefaultConfig } from "../../constants";
|
|
7
|
-
import { getAddonsToAdd } from "../../prompts/addons";
|
|
8
|
-
import { gatherConfig } from "../../prompts/config-prompts";
|
|
9
|
-
import { getProjectName } from "../../prompts/project-name";
|
|
10
|
-
import { getServerDeploymentToAdd } from "../../prompts/server-deploy";
|
|
11
|
-
import { getDeploymentToAdd } from "../../prompts/web-deploy";
|
|
12
|
-
import type { AddInput, CreateInput, DirectoryConflict, ProjectConfig } from "../../types";
|
|
13
|
-
import { trackProjectCreation } from "../../utils/analytics";
|
|
14
|
-
|
|
15
|
-
import { displayConfig } from "../../utils/display-config";
|
|
16
|
-
import { exitWithError, handleError } from "../../utils/errors";
|
|
17
|
-
import { generateReproducibleCommand } from "../../utils/generate-reproducible-command";
|
|
18
|
-
import { handleDirectoryConflict, setupProjectDirectory } from "../../utils/project-directory";
|
|
19
|
-
import { renderTitle } from "../../utils/render-title";
|
|
20
|
-
import { getTemplateConfig, getTemplateDescription } from "../../utils/templates";
|
|
21
|
-
import {
|
|
22
|
-
getProvidedFlags,
|
|
23
|
-
processAndValidateFlags,
|
|
24
|
-
processProvidedFlagsWithoutValidation,
|
|
25
|
-
validateConfigCompatibility,
|
|
26
|
-
} from "../../validation";
|
|
27
|
-
import { addAddonsToProject } from "./add-addons";
|
|
28
|
-
import { addDeploymentToProject } from "./add-deployment";
|
|
29
|
-
import { createProject } from "./create-project";
|
|
30
|
-
import { detectProjectConfig } from "./detect-project-config";
|
|
31
|
-
import { installDependencies } from "./install-dependencies";
|
|
32
|
-
|
|
33
|
-
export async function createProjectHandler(input: CreateInput & { projectName?: string }) {
|
|
34
|
-
const startTime = Date.now();
|
|
35
|
-
const timeScaffolded = new Date().toISOString();
|
|
36
|
-
|
|
37
|
-
if (input.renderTitle !== false) {
|
|
38
|
-
renderTitle();
|
|
39
|
-
}
|
|
40
|
-
intro(pc.magenta("Creating a new Better-T-Stack project"));
|
|
41
|
-
|
|
42
|
-
if (input.yolo) {
|
|
43
|
-
consola.fatal("YOLO mode enabled - skipping checks. Things may break!");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let currentPathInput: string;
|
|
47
|
-
if (input.yes && input.projectName) {
|
|
48
|
-
currentPathInput = input.projectName;
|
|
49
|
-
} else if (input.yes) {
|
|
50
|
-
const defaultConfig = getDefaultConfig();
|
|
51
|
-
let defaultName: string = defaultConfig.relativePath;
|
|
52
|
-
let counter = 1;
|
|
53
|
-
while (
|
|
54
|
-
(await fs.pathExists(path.resolve(process.cwd(), defaultName))) &&
|
|
55
|
-
(await fs.readdir(path.resolve(process.cwd(), defaultName))).length > 0
|
|
56
|
-
) {
|
|
57
|
-
defaultName = `${defaultConfig.projectName}-${counter}`;
|
|
58
|
-
counter++;
|
|
59
|
-
}
|
|
60
|
-
currentPathInput = defaultName;
|
|
61
|
-
} else {
|
|
62
|
-
currentPathInput = await getProjectName(input.projectName);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let finalPathInput: string;
|
|
66
|
-
let shouldClearDirectory: boolean;
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
if (input.directoryConflict) {
|
|
70
|
-
const result = await handleDirectoryConflictProgrammatically(
|
|
71
|
-
currentPathInput,
|
|
72
|
-
input.directoryConflict,
|
|
73
|
-
);
|
|
74
|
-
finalPathInput = result.finalPathInput;
|
|
75
|
-
shouldClearDirectory = result.shouldClearDirectory;
|
|
76
|
-
} else {
|
|
77
|
-
const result = await handleDirectoryConflict(currentPathInput);
|
|
78
|
-
finalPathInput = result.finalPathInput;
|
|
79
|
-
shouldClearDirectory = result.shouldClearDirectory;
|
|
80
|
-
}
|
|
81
|
-
} catch (error) {
|
|
82
|
-
const elapsedTimeMs = Date.now() - startTime;
|
|
83
|
-
return {
|
|
84
|
-
success: false,
|
|
85
|
-
projectConfig: {
|
|
86
|
-
projectName: "",
|
|
87
|
-
projectDir: "",
|
|
88
|
-
relativePath: "",
|
|
89
|
-
database: "none",
|
|
90
|
-
orm: "none",
|
|
91
|
-
backend: "none",
|
|
92
|
-
runtime: "none",
|
|
93
|
-
frontend: [],
|
|
94
|
-
addons: [],
|
|
95
|
-
examples: [],
|
|
96
|
-
auth: "none",
|
|
97
|
-
payments: "none",
|
|
98
|
-
git: false,
|
|
99
|
-
packageManager: "npm",
|
|
100
|
-
install: false,
|
|
101
|
-
dbSetup: "none",
|
|
102
|
-
api: "none",
|
|
103
|
-
webDeploy: "none",
|
|
104
|
-
serverDeploy: "none",
|
|
105
|
-
} satisfies ProjectConfig,
|
|
106
|
-
reproducibleCommand: "",
|
|
107
|
-
timeScaffolded,
|
|
108
|
-
elapsedTimeMs,
|
|
109
|
-
projectDirectory: "",
|
|
110
|
-
relativePath: "",
|
|
111
|
-
error: error instanceof Error ? error.message : String(error),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const { finalResolvedPath, finalBaseName } = await setupProjectDirectory(
|
|
116
|
-
finalPathInput,
|
|
117
|
-
shouldClearDirectory,
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const originalInput = {
|
|
121
|
-
...input,
|
|
122
|
-
projectDirectory: input.projectName,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const providedFlags = getProvidedFlags(originalInput);
|
|
126
|
-
|
|
127
|
-
let cliInput = originalInput;
|
|
128
|
-
|
|
129
|
-
if (input.template && input.template !== "none") {
|
|
130
|
-
const templateConfig = getTemplateConfig(input.template);
|
|
131
|
-
if (templateConfig) {
|
|
132
|
-
const templateName = input.template.toUpperCase();
|
|
133
|
-
const templateDescription = getTemplateDescription(input.template);
|
|
134
|
-
log.message(pc.bold(pc.cyan(`Using template: ${pc.white(templateName)}`)));
|
|
135
|
-
log.message(pc.dim(` ${templateDescription}`));
|
|
136
|
-
const userOverrides: Record<string, unknown> = {};
|
|
137
|
-
for (const [key, value] of Object.entries(originalInput)) {
|
|
138
|
-
if (value !== undefined) {
|
|
139
|
-
userOverrides[key] = value;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
cliInput = {
|
|
143
|
-
...templateConfig,
|
|
144
|
-
...userOverrides,
|
|
145
|
-
template: input.template,
|
|
146
|
-
projectDirectory: originalInput.projectDirectory,
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
let config: ProjectConfig;
|
|
152
|
-
if (cliInput.yes) {
|
|
153
|
-
const flagConfig = processProvidedFlagsWithoutValidation(cliInput, finalBaseName);
|
|
154
|
-
|
|
155
|
-
config = {
|
|
156
|
-
...getDefaultConfig(),
|
|
157
|
-
...flagConfig,
|
|
158
|
-
projectName: finalBaseName,
|
|
159
|
-
projectDir: finalResolvedPath,
|
|
160
|
-
relativePath: finalPathInput,
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
validateConfigCompatibility(config, providedFlags, cliInput);
|
|
164
|
-
|
|
165
|
-
log.info(pc.yellow("Using default/flag options (config prompts skipped):"));
|
|
166
|
-
log.message(displayConfig(config));
|
|
167
|
-
} else {
|
|
168
|
-
const flagConfig = processAndValidateFlags(cliInput, providedFlags, finalBaseName);
|
|
169
|
-
const { projectName: _projectNameFromFlags, ...otherFlags } = flagConfig;
|
|
170
|
-
|
|
171
|
-
if (Object.keys(otherFlags).length > 0) {
|
|
172
|
-
log.info(pc.yellow("Using these pre-selected options:"));
|
|
173
|
-
log.message(displayConfig(otherFlags));
|
|
174
|
-
log.message("");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
config = await gatherConfig(flagConfig, finalBaseName, finalResolvedPath, finalPathInput);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
await createProject(config, {
|
|
181
|
-
manualDb: cliInput.manualDb ?? input.manualDb,
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
const reproducibleCommand = generateReproducibleCommand(config);
|
|
185
|
-
log.success(
|
|
186
|
-
pc.blue(`You can reproduce this setup with the following command:\n${reproducibleCommand}`),
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
await trackProjectCreation(config, input.disableAnalytics);
|
|
190
|
-
|
|
191
|
-
const elapsedTimeMs = Date.now() - startTime;
|
|
192
|
-
const elapsedTimeInSeconds = (elapsedTimeMs / 1000).toFixed(2);
|
|
193
|
-
outro(pc.magenta(`Project created successfully in ${pc.bold(elapsedTimeInSeconds)} seconds!`));
|
|
194
|
-
|
|
195
|
-
return {
|
|
196
|
-
success: true,
|
|
197
|
-
projectConfig: config,
|
|
198
|
-
reproducibleCommand,
|
|
199
|
-
timeScaffolded,
|
|
200
|
-
elapsedTimeMs,
|
|
201
|
-
projectDirectory: config.projectDir,
|
|
202
|
-
relativePath: config.relativePath,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async function handleDirectoryConflictProgrammatically(
|
|
207
|
-
currentPathInput: string,
|
|
208
|
-
strategy: DirectoryConflict,
|
|
209
|
-
) {
|
|
210
|
-
const currentPath = path.resolve(process.cwd(), currentPathInput);
|
|
211
|
-
|
|
212
|
-
if (!(await fs.pathExists(currentPath))) {
|
|
213
|
-
return { finalPathInput: currentPathInput, shouldClearDirectory: false };
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const dirContents = await fs.readdir(currentPath);
|
|
217
|
-
const isNotEmpty = dirContents.length > 0;
|
|
218
|
-
|
|
219
|
-
if (!isNotEmpty) {
|
|
220
|
-
return { finalPathInput: currentPathInput, shouldClearDirectory: false };
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
switch (strategy) {
|
|
224
|
-
case "overwrite":
|
|
225
|
-
return { finalPathInput: currentPathInput, shouldClearDirectory: true };
|
|
226
|
-
|
|
227
|
-
case "merge":
|
|
228
|
-
return { finalPathInput: currentPathInput, shouldClearDirectory: false };
|
|
229
|
-
|
|
230
|
-
case "increment": {
|
|
231
|
-
let counter = 1;
|
|
232
|
-
const baseName = currentPathInput;
|
|
233
|
-
let finalPathInput = `${baseName}-${counter}`;
|
|
234
|
-
|
|
235
|
-
while (
|
|
236
|
-
(await fs.pathExists(path.resolve(process.cwd(), finalPathInput))) &&
|
|
237
|
-
(await fs.readdir(path.resolve(process.cwd(), finalPathInput))).length > 0
|
|
238
|
-
) {
|
|
239
|
-
counter++;
|
|
240
|
-
finalPathInput = `${baseName}-${counter}`;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return { finalPathInput, shouldClearDirectory: false };
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
case "error":
|
|
247
|
-
throw new Error(
|
|
248
|
-
`Directory "${currentPathInput}" already exists and is not empty. Use directoryConflict: "overwrite", "merge", or "increment" to handle this.`,
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
default:
|
|
252
|
-
throw new Error(`Unknown directory conflict strategy: ${strategy}`);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export async function addAddonsHandler(input: AddInput) {
|
|
257
|
-
try {
|
|
258
|
-
const projectDir = input.projectDir || process.cwd();
|
|
259
|
-
const detectedConfig = await detectProjectConfig(projectDir);
|
|
260
|
-
|
|
261
|
-
if (!detectedConfig) {
|
|
262
|
-
exitWithError(
|
|
263
|
-
"Could not detect project configuration. Please ensure this is a valid Better-T-Stack project.",
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (!input.addons || input.addons.length === 0) {
|
|
268
|
-
const addonsPrompt = await getAddonsToAdd(
|
|
269
|
-
detectedConfig.frontend || [],
|
|
270
|
-
detectedConfig.addons || [],
|
|
271
|
-
detectedConfig.auth,
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
if (addonsPrompt.length > 0) {
|
|
275
|
-
input.addons = addonsPrompt;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if (!input.webDeploy) {
|
|
280
|
-
const deploymentPrompt = await getDeploymentToAdd(
|
|
281
|
-
detectedConfig.frontend || [],
|
|
282
|
-
detectedConfig.webDeploy,
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
if (deploymentPrompt !== "none") {
|
|
286
|
-
input.webDeploy = deploymentPrompt;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (!input.serverDeploy) {
|
|
291
|
-
const serverDeploymentPrompt = await getServerDeploymentToAdd(
|
|
292
|
-
detectedConfig.runtime,
|
|
293
|
-
detectedConfig.serverDeploy,
|
|
294
|
-
detectedConfig.backend,
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
if (serverDeploymentPrompt !== "none") {
|
|
298
|
-
input.serverDeploy = serverDeploymentPrompt;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
const packageManager = input.packageManager || detectedConfig.packageManager || "npm";
|
|
303
|
-
|
|
304
|
-
let somethingAdded = false;
|
|
305
|
-
|
|
306
|
-
if (input.addons && input.addons.length > 0) {
|
|
307
|
-
await addAddonsToProject({
|
|
308
|
-
...input,
|
|
309
|
-
install: false,
|
|
310
|
-
suppressInstallMessage: true,
|
|
311
|
-
addons: input.addons,
|
|
312
|
-
});
|
|
313
|
-
somethingAdded = true;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
if (input.webDeploy && input.webDeploy !== "none") {
|
|
317
|
-
await addDeploymentToProject({
|
|
318
|
-
...input,
|
|
319
|
-
install: false,
|
|
320
|
-
suppressInstallMessage: true,
|
|
321
|
-
webDeploy: input.webDeploy,
|
|
322
|
-
});
|
|
323
|
-
somethingAdded = true;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if (input.serverDeploy && input.serverDeploy !== "none") {
|
|
327
|
-
await addDeploymentToProject({
|
|
328
|
-
...input,
|
|
329
|
-
install: false,
|
|
330
|
-
suppressInstallMessage: true,
|
|
331
|
-
serverDeploy: input.serverDeploy,
|
|
332
|
-
});
|
|
333
|
-
somethingAdded = true;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if (!somethingAdded) {
|
|
337
|
-
outro(pc.yellow("No addons or deployment configurations to add."));
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
if (input.install) {
|
|
342
|
-
await installDependencies({
|
|
343
|
-
projectDir,
|
|
344
|
-
packageManager,
|
|
345
|
-
});
|
|
346
|
-
} else {
|
|
347
|
-
log.info(`Run ${pc.bold(`${packageManager} install`)} to install dependencies`);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
outro("Add command completed successfully!");
|
|
351
|
-
} catch (error) {
|
|
352
|
-
handleError(error, "Failed to add addons or deployment");
|
|
353
|
-
}
|
|
354
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { execa } from "execa";
|
|
3
|
-
import type { PackageManager } from "../../types";
|
|
4
|
-
import { getPackageExecutionCommand } from "../../utils/package-runner";
|
|
5
|
-
|
|
6
|
-
// having problems running this in convex + better-auth
|
|
7
|
-
export async function runConvexCodegen(
|
|
8
|
-
projectDir: string,
|
|
9
|
-
packageManager: PackageManager | null | undefined,
|
|
10
|
-
) {
|
|
11
|
-
const backendDir = path.join(projectDir, "packages/backend");
|
|
12
|
-
const cmd = getPackageExecutionCommand(packageManager, "convex codegen");
|
|
13
|
-
await execa(cmd, { cwd: backendDir, shell: true });
|
|
14
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { log } from "@clack/prompts";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import type { ProjectConfig } from "../../types";
|
|
4
|
-
import { writeBtsConfig } from "../../utils/bts-config";
|
|
5
|
-
import { exitWithError } from "../../utils/errors";
|
|
6
|
-
import { setupCatalogs } from "../../utils/setup-catalogs";
|
|
7
|
-
import { setupAddons } from "../addons/addons-setup";
|
|
8
|
-
import { setupExamples } from "../addons/examples-setup";
|
|
9
|
-
import { setupApi } from "../core/api-setup";
|
|
10
|
-
import { setupBackendDependencies } from "../core/backend-setup";
|
|
11
|
-
import { setupDatabase } from "../core/db-setup";
|
|
12
|
-
import { setupRuntime } from "../core/runtime-setup";
|
|
13
|
-
import { setupServerDeploy } from "../deployment/server-deploy-setup";
|
|
14
|
-
import { setupWebDeploy } from "../deployment/web-deploy-setup";
|
|
15
|
-
import { setupAuth } from "./auth-setup";
|
|
16
|
-
import { createReadme } from "./create-readme";
|
|
17
|
-
import { setupEnvironmentVariables } from "./env-setup";
|
|
18
|
-
import { initializeGit } from "./git";
|
|
19
|
-
import { installDependencies } from "./install-dependencies";
|
|
20
|
-
import { setupPayments } from "./payments-setup";
|
|
21
|
-
import { displayPostInstallInstructions } from "./post-installation";
|
|
22
|
-
import { updatePackageConfigurations } from "./project-config";
|
|
23
|
-
import {
|
|
24
|
-
copyBaseTemplate,
|
|
25
|
-
handleExtras,
|
|
26
|
-
setupAddonsTemplate,
|
|
27
|
-
setupAuthTemplate,
|
|
28
|
-
setupBackendFramework,
|
|
29
|
-
setupDeploymentTemplates,
|
|
30
|
-
setupDockerComposeTemplates,
|
|
31
|
-
setupExamplesTemplate,
|
|
32
|
-
setupFrontendTemplates,
|
|
33
|
-
setupPaymentsTemplate,
|
|
34
|
-
} from "./template-manager";
|
|
35
|
-
|
|
36
|
-
export async function createProject(options: ProjectConfig, cliInput?: { manualDb?: boolean }) {
|
|
37
|
-
const projectDir = options.projectDir;
|
|
38
|
-
const isConvex = options.backend === "convex";
|
|
39
|
-
const isSelfBackend = options.backend === "self";
|
|
40
|
-
const needsServerSetup = !isConvex && !isSelfBackend;
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
await fs.ensureDir(projectDir);
|
|
44
|
-
|
|
45
|
-
await copyBaseTemplate(projectDir, options);
|
|
46
|
-
await setupFrontendTemplates(projectDir, options);
|
|
47
|
-
|
|
48
|
-
await setupBackendFramework(projectDir, options);
|
|
49
|
-
|
|
50
|
-
if (needsServerSetup || (isSelfBackend && options.dbSetup === "docker")) {
|
|
51
|
-
await setupDockerComposeTemplates(projectDir, options);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
await setupAuthTemplate(projectDir, options);
|
|
55
|
-
if (options.payments && options.payments !== "none") {
|
|
56
|
-
await setupPaymentsTemplate(projectDir, options);
|
|
57
|
-
}
|
|
58
|
-
if (options.examples.length > 0 && options.examples[0] !== "none") {
|
|
59
|
-
await setupExamplesTemplate(projectDir, options);
|
|
60
|
-
}
|
|
61
|
-
await setupAddonsTemplate(projectDir, options);
|
|
62
|
-
|
|
63
|
-
await setupDeploymentTemplates(projectDir, options);
|
|
64
|
-
|
|
65
|
-
await setupApi(options);
|
|
66
|
-
|
|
67
|
-
if (isConvex || needsServerSetup) {
|
|
68
|
-
await setupBackendDependencies(options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (!isConvex) {
|
|
72
|
-
if (needsServerSetup) {
|
|
73
|
-
await setupRuntime(options);
|
|
74
|
-
}
|
|
75
|
-
await setupDatabase(options, cliInput);
|
|
76
|
-
if (options.examples.length > 0 && options.examples[0] !== "none") {
|
|
77
|
-
await setupExamples(options);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (options.addons.length > 0 && options.addons[0] !== "none") {
|
|
82
|
-
await setupAddons(options);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (options.auth && options.auth !== "none") {
|
|
86
|
-
await setupAuth(options);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (options.payments && options.payments !== "none") {
|
|
90
|
-
await setupPayments(options);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
await handleExtras(projectDir, options);
|
|
94
|
-
|
|
95
|
-
await setupEnvironmentVariables(options);
|
|
96
|
-
await updatePackageConfigurations(projectDir, options);
|
|
97
|
-
|
|
98
|
-
await setupWebDeploy(options);
|
|
99
|
-
await setupServerDeploy(options);
|
|
100
|
-
|
|
101
|
-
await setupCatalogs(projectDir, options);
|
|
102
|
-
|
|
103
|
-
await createReadme(projectDir, options);
|
|
104
|
-
|
|
105
|
-
await writeBtsConfig(options);
|
|
106
|
-
|
|
107
|
-
log.success("Project template successfully scaffolded!");
|
|
108
|
-
|
|
109
|
-
if (options.install) {
|
|
110
|
-
await installDependencies({
|
|
111
|
-
projectDir,
|
|
112
|
-
packageManager: options.packageManager,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
await initializeGit(projectDir, options.git);
|
|
117
|
-
|
|
118
|
-
await displayPostInstallInstructions({
|
|
119
|
-
...options,
|
|
120
|
-
depsInstalled: options.install,
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return projectDir;
|
|
124
|
-
} catch (error) {
|
|
125
|
-
if (error instanceof Error) {
|
|
126
|
-
console.error(error.stack);
|
|
127
|
-
exitWithError(`Error during project creation: ${error.message}`);
|
|
128
|
-
} else {
|
|
129
|
-
console.error(error);
|
|
130
|
-
exitWithError(`An unexpected error occurred: ${String(error)}`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|