create-better-t-stack 3.5.0 → 3.5.2
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
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as router, i as init, n as createBtsCli, o as sponsors, r as docs, t as builder } from "./src-
|
|
2
|
+
import { a as router, i as init, n as createBtsCli, o as sponsors, r as docs, t as builder } from "./src-C_MeUxmG.js";
|
|
3
3
|
|
|
4
4
|
export { builder, createBtsCli, docs, init, router, sponsors };
|
|
@@ -2689,6 +2689,38 @@ handlebars.registerHelper("or", (...args) => {
|
|
|
2689
2689
|
});
|
|
2690
2690
|
handlebars.registerHelper("includes", (array, value) => Array.isArray(array) && array.includes(value));
|
|
2691
2691
|
|
|
2692
|
+
//#endregion
|
|
2693
|
+
//#region src/helpers/deployment/alchemy/env-dts-setup.ts
|
|
2694
|
+
const tsProject$1 = new Project({
|
|
2695
|
+
useInMemoryFileSystem: false,
|
|
2696
|
+
skipAddingFilesFromTsConfig: true
|
|
2697
|
+
});
|
|
2698
|
+
function determineImportPath(envDtsPath, projectDir, config) {
|
|
2699
|
+
const { webDeploy, serverDeploy, backend } = config;
|
|
2700
|
+
const isBackendSelf = backend === "self";
|
|
2701
|
+
let alchemyRunPath;
|
|
2702
|
+
if (webDeploy === "alchemy" && (serverDeploy === "alchemy" || isBackendSelf)) if (isBackendSelf) alchemyRunPath = path.join(projectDir, "apps/web/alchemy.run.ts");
|
|
2703
|
+
else alchemyRunPath = path.join(projectDir, "alchemy.run.ts");
|
|
2704
|
+
else if (webDeploy === "alchemy") alchemyRunPath = path.join(projectDir, "apps/web/alchemy.run.ts");
|
|
2705
|
+
else if (serverDeploy === "alchemy") alchemyRunPath = path.join(projectDir, "apps/server/alchemy.run.ts");
|
|
2706
|
+
else alchemyRunPath = path.join(projectDir, "alchemy.run.ts");
|
|
2707
|
+
const relativePath = path.relative(path.dirname(envDtsPath), alchemyRunPath.replace(/\.ts$/, ""));
|
|
2708
|
+
return (relativePath.startsWith(".") ? relativePath : `./${relativePath}`).replace(/\\/g, "/");
|
|
2709
|
+
}
|
|
2710
|
+
async function setupEnvDtsImport(envDtsPath, projectDir, config) {
|
|
2711
|
+
if (!await fs.pathExists(envDtsPath)) return;
|
|
2712
|
+
const importPath = determineImportPath(envDtsPath, projectDir, config);
|
|
2713
|
+
const sourceFile = tsProject$1.addSourceFileAtPath(envDtsPath);
|
|
2714
|
+
if (!sourceFile.getImportDeclarations().some((imp) => imp.getModuleSpecifierValue() === importPath && imp.getNamedImports().some((named) => named.getName() === "server"))) sourceFile.insertImportDeclaration(0, {
|
|
2715
|
+
moduleSpecifier: importPath,
|
|
2716
|
+
namedImports: [{
|
|
2717
|
+
name: "server",
|
|
2718
|
+
isTypeOnly: true
|
|
2719
|
+
}]
|
|
2720
|
+
});
|
|
2721
|
+
await sourceFile.save();
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2692
2724
|
//#endregion
|
|
2693
2725
|
//#region src/helpers/core/template-manager.ts
|
|
2694
2726
|
async function processAndCopyFiles(sourcePattern, baseSourceDir, destDir, context, overwrite = true, ignorePatterns) {
|
|
@@ -3194,7 +3226,9 @@ async function setupDeploymentTemplates(projectDir, context) {
|
|
|
3194
3226
|
const serverAppDir = path.join(projectDir, "apps/server");
|
|
3195
3227
|
if (await fs.pathExists(alchemyTemplateSrc) && await fs.pathExists(serverAppDir)) {
|
|
3196
3228
|
await processAndCopyFiles("alchemy.run.ts.hbs", alchemyTemplateSrc, serverAppDir, context);
|
|
3197
|
-
|
|
3229
|
+
const envDtsPath = path.join(serverAppDir, "env.d.ts");
|
|
3230
|
+
await processTemplate(path.join(alchemyTemplateSrc, "env.d.ts.hbs"), envDtsPath, context);
|
|
3231
|
+
await setupEnvDtsImport(envDtsPath, projectDir, context);
|
|
3198
3232
|
await addEnvDtsToPackages(projectDir, context, alchemyTemplateSrc);
|
|
3199
3233
|
}
|
|
3200
3234
|
}
|
|
@@ -3234,10 +3268,18 @@ async function addEnvDtsToPackages(projectDir, context, alchemyTemplateSrc) {
|
|
|
3234
3268
|
"packages/db"
|
|
3235
3269
|
]) {
|
|
3236
3270
|
const packageDir = path.join(projectDir, packageName);
|
|
3237
|
-
if (await fs.pathExists(packageDir))
|
|
3271
|
+
if (await fs.pathExists(packageDir)) {
|
|
3272
|
+
const envDtsPath = path.join(packageDir, "env.d.ts");
|
|
3273
|
+
await processTemplate(path.join(alchemyTemplateSrc, "env.d.ts.hbs"), envDtsPath, context);
|
|
3274
|
+
await setupEnvDtsImport(envDtsPath, projectDir, context);
|
|
3275
|
+
}
|
|
3238
3276
|
}
|
|
3239
3277
|
const serverAppDir = path.join(projectDir, "apps/server");
|
|
3240
|
-
if (await fs.pathExists(serverAppDir))
|
|
3278
|
+
if (await fs.pathExists(serverAppDir)) {
|
|
3279
|
+
const envDtsPath = path.join(serverAppDir, "env.d.ts");
|
|
3280
|
+
await processTemplate(path.join(alchemyTemplateSrc, "env.d.ts.hbs"), envDtsPath, context);
|
|
3281
|
+
await setupEnvDtsImport(envDtsPath, projectDir, context);
|
|
3282
|
+
}
|
|
3241
3283
|
}
|
|
3242
3284
|
|
|
3243
3285
|
//#endregion
|
|
@@ -5987,7 +6029,7 @@ function generateDatabaseSetup(database, _auth, packageManagerRunCmd, orm, dbSet
|
|
|
5987
6029
|
if (database === "none") return "";
|
|
5988
6030
|
const isBackendSelf = backend === "self";
|
|
5989
6031
|
const envPath = isBackendSelf ? "apps/web/.env" : "apps/server/.env";
|
|
5990
|
-
const dbLocalPath =
|
|
6032
|
+
const dbLocalPath = "packages/db";
|
|
5991
6033
|
let setup = "## Database Setup\n\n";
|
|
5992
6034
|
if (database === "sqlite") setup += `This project uses SQLite${orm === "drizzle" ? " with Drizzle ORM" : orm === "prisma" ? " with Prisma" : ` with ${orm}`}.
|
|
5993
6035
|
|
|
@@ -6049,7 +6091,7 @@ function generateScriptsList(packageManagerRunCmd, database, orm, _auth, hasNati
|
|
|
6049
6091
|
- \`${packageManagerRunCmd} db:push\`: Push schema changes to database
|
|
6050
6092
|
- \`${packageManagerRunCmd} db:studio\`: Open database studio UI`;
|
|
6051
6093
|
if (database === "sqlite" && orm === "drizzle") scripts += `
|
|
6052
|
-
- \`cd
|
|
6094
|
+
- \`cd packages/db && ${packageManagerRunCmd} db:local\`: Start the local SQLite database`;
|
|
6053
6095
|
}
|
|
6054
6096
|
if (addons.includes("biome")) scripts += `
|
|
6055
6097
|
- \`${packageManagerRunCmd} check\`: Run Biome formatting and linting`;
|
|
@@ -6292,9 +6334,9 @@ async function getDatabaseInstructions(database, orm, runCmd, _runtime, dbSetup,
|
|
|
6292
6334
|
}
|
|
6293
6335
|
}
|
|
6294
6336
|
if (dbSetup === "d1" && serverDeploy === "alchemy") {
|
|
6295
|
-
if (orm === "drizzle") instructions.push(`${pc.
|
|
6337
|
+
if (orm === "drizzle") instructions.push(`${pc.cyan("•")} Generate migrations: ${`${runCmd} db:generate`}`);
|
|
6296
6338
|
else if (orm === "prisma") {
|
|
6297
|
-
instructions.push(`${pc.cyan("•")} Generate
|
|
6339
|
+
instructions.push(`${pc.cyan("•")} Generate Prisma client: ${`${runCmd} db:generate`}`);
|
|
6298
6340
|
instructions.push(`${pc.cyan("•")} Apply migrations: ${`${runCmd} db:migrate`}`);
|
|
6299
6341
|
}
|
|
6300
6342
|
}
|
package/package.json
CHANGED
|
@@ -21,7 +21,6 @@ import { Worker } from "alchemy/cloudflare";
|
|
|
21
21
|
{{/if}}
|
|
22
22
|
{{#if (and (or (eq serverDeploy "alchemy") (and (eq webDeploy "alchemy") (eq backend "self"))) (eq dbSetup "d1"))}}
|
|
23
23
|
import { D1Database } from "alchemy/cloudflare";
|
|
24
|
-
import { Exec } from "alchemy/os";
|
|
25
24
|
{{/if}}
|
|
26
25
|
import { config } from "dotenv";
|
|
27
26
|
|
|
@@ -36,11 +35,6 @@ config({ path: "./.env" });
|
|
|
36
35
|
const app = await alchemy("{{projectName}}");
|
|
37
36
|
|
|
38
37
|
{{#if (and (or (eq serverDeploy "alchemy") (and (eq webDeploy "alchemy") (eq backend "self"))) (eq dbSetup "d1"))}}
|
|
39
|
-
await Exec("db-generate", {
|
|
40
|
-
{{#if (and (eq webDeploy "alchemy") (eq serverDeploy "alchemy"))}}cwd: "packages/db",{{/if}}
|
|
41
|
-
command: "{{packageManager}} run db:generate",
|
|
42
|
-
});
|
|
43
|
-
|
|
44
38
|
const db = await D1Database("database", {
|
|
45
39
|
{{#if (eq orm "prisma")}}
|
|
46
40
|
migrationsDir: "packages/db/prisma/migrations",
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
// This file infers types for the cloudflare:workers environment from your Alchemy Worker.
|
|
2
2
|
// @see https://alchemy.run/concepts/bindings/#type-safe-bindings
|
|
3
3
|
|
|
4
|
-
{{#if (eq webDeploy "alchemy")}}
|
|
5
|
-
import type { server } from "../../alchemy.run";
|
|
6
|
-
{{else}}
|
|
7
|
-
import type { server } from "./alchemy.run";
|
|
8
|
-
{{/if}}
|
|
9
|
-
|
|
10
4
|
export type CloudflareEnv = typeof server.Env;
|
|
11
5
|
|
|
12
6
|
declare global {
|