create-better-t-stack 2.35.3 → 2.35.5
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-dID--AYy.js → src-D3yNVHFj.js} +44 -21
- package/package.json +1 -1
- package/templates/backend/server/server-base/tsconfig.json.hbs +9 -14
- package/templates/frontend/react/tanstack-start/package.json.hbs +1 -1
- package/templates/frontend/react/tanstack-start/{vite.config.ts → vite.config.ts.hbs} +7 -1
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1080,7 +1080,8 @@ async function getServerDeploymentChoice(deployment, runtime, backend, webDeploy
|
|
|
1080
1080
|
if (backend === "none" || backend === "convex") return "none";
|
|
1081
1081
|
if (backend !== "hono") return "none";
|
|
1082
1082
|
const options = [];
|
|
1083
|
-
if (runtime
|
|
1083
|
+
if (runtime !== "workers") return "none";
|
|
1084
|
+
["alchemy", "wrangler"].forEach((deploy) => {
|
|
1084
1085
|
const { label, hint } = getDeploymentDisplay$1(deploy);
|
|
1085
1086
|
options.unshift({
|
|
1086
1087
|
value: deploy,
|
|
@@ -1088,11 +1089,6 @@ async function getServerDeploymentChoice(deployment, runtime, backend, webDeploy
|
|
|
1088
1089
|
hint
|
|
1089
1090
|
});
|
|
1090
1091
|
});
|
|
1091
|
-
else options.push({
|
|
1092
|
-
value: "none",
|
|
1093
|
-
label: "None",
|
|
1094
|
-
hint: "Manual setup"
|
|
1095
|
-
});
|
|
1096
1092
|
const response = await select({
|
|
1097
1093
|
message: "Select server deployment",
|
|
1098
1094
|
options,
|
|
@@ -1123,11 +1119,7 @@ async function getServerDeploymentToAdd(runtime, existingDeployment, backend) {
|
|
|
1123
1119
|
}
|
|
1124
1120
|
}
|
|
1125
1121
|
if (existingDeployment && existingDeployment !== "none") return "none";
|
|
1126
|
-
if (options.length > 0)
|
|
1127
|
-
value: "none",
|
|
1128
|
-
label: "None",
|
|
1129
|
-
hint: "Skip deployment setup"
|
|
1130
|
-
});
|
|
1122
|
+
if (options.length > 0) {}
|
|
1131
1123
|
if (options.length === 0) return "none";
|
|
1132
1124
|
const response = await select({
|
|
1133
1125
|
message: "Select server deployment",
|
|
@@ -1740,6 +1732,7 @@ function validateFullConfig(config, providedFlags, options) {
|
|
|
1740
1732
|
validateApiConstraints(config, options);
|
|
1741
1733
|
validateServerDeployRequiresBackend(config.serverDeploy, config.backend);
|
|
1742
1734
|
validateWorkersCompatibility(providedFlags, options, config);
|
|
1735
|
+
if (config.runtime === "workers" && config.serverDeploy === "none") exitWithError("Cloudflare Workers runtime requires a server deployment. Please choose 'wrangler' or 'alchemy' for --server-deploy.");
|
|
1743
1736
|
if (config.addons && config.addons.length > 0) {
|
|
1744
1737
|
validateAddonsAgainstFrontends(config.addons, config.frontend);
|
|
1745
1738
|
config.addons = [...new Set(config.addons)];
|
|
@@ -2983,11 +2976,7 @@ async function setupWorkersServerDeploy(serverDir, _packageManager) {
|
|
|
2983
2976
|
};
|
|
2984
2977
|
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
|
2985
2978
|
await addPackageDependency({
|
|
2986
|
-
devDependencies: [
|
|
2987
|
-
"wrangler",
|
|
2988
|
-
"@types/node",
|
|
2989
|
-
"@cloudflare/workers-types"
|
|
2990
|
-
],
|
|
2979
|
+
devDependencies: ["wrangler", "@types/node"],
|
|
2991
2980
|
projectDir: serverDir
|
|
2992
2981
|
});
|
|
2993
2982
|
}
|
|
@@ -3012,7 +3001,6 @@ async function setupAlchemyServerDeploy(serverDir, _packageManager) {
|
|
|
3012
3001
|
"alchemy",
|
|
3013
3002
|
"wrangler",
|
|
3014
3003
|
"@types/node",
|
|
3015
|
-
"@cloudflare/workers-types",
|
|
3016
3004
|
"dotenv"
|
|
3017
3005
|
],
|
|
3018
3006
|
projectDir: serverDir
|
|
@@ -3380,6 +3368,17 @@ async function setupTanStackStartAlchemyDeploy(projectDir, _packageManager) {
|
|
|
3380
3368
|
defaultImport: "alchemy"
|
|
3381
3369
|
});
|
|
3382
3370
|
else alchemyImport.setModuleSpecifier("alchemy/cloudflare/tanstack-start");
|
|
3371
|
+
const reactImport = sourceFile.getImportDeclaration("@vitejs/plugin-react");
|
|
3372
|
+
let reactPluginIdentifier = "viteReact";
|
|
3373
|
+
if (!reactImport) sourceFile.addImportDeclaration({
|
|
3374
|
+
moduleSpecifier: "@vitejs/plugin-react",
|
|
3375
|
+
defaultImport: "viteReact"
|
|
3376
|
+
});
|
|
3377
|
+
else {
|
|
3378
|
+
const defaultImport = reactImport.getDefaultImport();
|
|
3379
|
+
if (defaultImport) reactPluginIdentifier = defaultImport.getText();
|
|
3380
|
+
else reactImport.setDefaultImport("viteReact");
|
|
3381
|
+
}
|
|
3383
3382
|
const exportAssignment = sourceFile.getExportAssignment((d) => !d.isExportEquals());
|
|
3384
3383
|
if (!exportAssignment) return;
|
|
3385
3384
|
const defineConfigCall = exportAssignment.getExpression();
|
|
@@ -3403,26 +3402,33 @@ async function setupTanStackStartAlchemyDeploy(projectDir, _packageManager) {
|
|
|
3403
3402
|
const hasShim = initializer.getElements().some((el) => el.getText().includes("alchemy"));
|
|
3404
3403
|
if (!hasShim) initializer.addElement("alchemy()");
|
|
3405
3404
|
const tanstackElements = initializer.getElements().filter((el) => el.getText().includes("tanstackStart"));
|
|
3405
|
+
let needsReactPlugin = false;
|
|
3406
3406
|
tanstackElements.forEach((element) => {
|
|
3407
3407
|
if (Node.isCallExpression(element)) {
|
|
3408
3408
|
const args = element.getArguments();
|
|
3409
|
-
if (args.length === 0)
|
|
3409
|
+
if (args.length === 0) {
|
|
3410
|
+
element.addArgument(`{
|
|
3410
3411
|
target: "cloudflare-module",
|
|
3411
3412
|
customViteReactPlugin: true,
|
|
3412
3413
|
}`);
|
|
3413
|
-
|
|
3414
|
+
needsReactPlugin = true;
|
|
3415
|
+
} else if (args.length === 1 && Node.isObjectLiteralExpression(args[0])) {
|
|
3414
3416
|
const configObj = args[0];
|
|
3415
3417
|
if (!configObj.getProperty("target")) configObj.addPropertyAssignment({
|
|
3416
3418
|
name: "target",
|
|
3417
3419
|
initializer: "\"cloudflare-module\""
|
|
3418
3420
|
});
|
|
3419
|
-
|
|
3421
|
+
const hasCustomViteReactPlugin = !!configObj.getProperty("customViteReactPlugin");
|
|
3422
|
+
if (!hasCustomViteReactPlugin) configObj.addPropertyAssignment({
|
|
3420
3423
|
name: "customViteReactPlugin",
|
|
3421
3424
|
initializer: "true"
|
|
3422
3425
|
});
|
|
3426
|
+
needsReactPlugin = true;
|
|
3423
3427
|
}
|
|
3424
3428
|
}
|
|
3425
3429
|
});
|
|
3430
|
+
const hasReactPlugin = initializer.getElements().some((el) => Node.isCallExpression(el) && el.getExpression().getText() === reactPluginIdentifier);
|
|
3431
|
+
if (needsReactPlugin && !hasReactPlugin) initializer.addElement(`${reactPluginIdentifier}()`);
|
|
3426
3432
|
}
|
|
3427
3433
|
} else configObject.addPropertyAssignment({
|
|
3428
3434
|
name: "plugins",
|
|
@@ -3631,6 +3637,17 @@ async function setupTanstackStartWorkersDeploy(projectDir, packageManager) {
|
|
|
3631
3637
|
if (!await fs.pathExists(viteConfigPath)) return;
|
|
3632
3638
|
const sourceFile = tsProject.addSourceFileAtPathIfExists(viteConfigPath);
|
|
3633
3639
|
if (!sourceFile) return;
|
|
3640
|
+
const reactImport = sourceFile.getImportDeclaration("@vitejs/plugin-react");
|
|
3641
|
+
let reactPluginIdentifier = "viteReact";
|
|
3642
|
+
if (!reactImport) sourceFile.addImportDeclaration({
|
|
3643
|
+
moduleSpecifier: "@vitejs/plugin-react",
|
|
3644
|
+
defaultImport: "viteReact"
|
|
3645
|
+
});
|
|
3646
|
+
else {
|
|
3647
|
+
const defaultImport = reactImport.getDefaultImport();
|
|
3648
|
+
if (defaultImport) reactPluginIdentifier = defaultImport.getText();
|
|
3649
|
+
else reactImport.setDefaultImport("viteReact");
|
|
3650
|
+
}
|
|
3634
3651
|
const defineCall = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).find((expr) => {
|
|
3635
3652
|
const expression = expr.getExpression();
|
|
3636
3653
|
return Node.isIdentifier(expression) && expression.getText() === "defineConfig";
|
|
@@ -3640,9 +3657,15 @@ async function setupTanstackStartWorkersDeploy(projectDir, packageManager) {
|
|
|
3640
3657
|
if (!configObj) return;
|
|
3641
3658
|
const pluginsArray = ensureArrayProperty(configObj, "plugins");
|
|
3642
3659
|
const tanstackPluginIndex = pluginsArray.getElements().findIndex((el) => el.getText().includes("tanstackStart("));
|
|
3643
|
-
const tanstackPluginText = "tanstackStart({ target: \"cloudflare-module\" })";
|
|
3660
|
+
const tanstackPluginText = "tanstackStart({ target: \"cloudflare-module\", customViteReactPlugin: true })";
|
|
3644
3661
|
if (tanstackPluginIndex === -1) pluginsArray.addElement(tanstackPluginText);
|
|
3645
3662
|
else pluginsArray.getElements()[tanstackPluginIndex].replaceWithText(tanstackPluginText);
|
|
3663
|
+
const hasReactPlugin = pluginsArray.getElements().some((el) => Node.isCallExpression(el) && el.getExpression().getText() === reactPluginIdentifier);
|
|
3664
|
+
if (!hasReactPlugin) {
|
|
3665
|
+
const nextIndex = pluginsArray.getElements().findIndex((el) => el.getText().includes("tanstackStart(")) + 1;
|
|
3666
|
+
if (nextIndex > 0) pluginsArray.insertElement(nextIndex, `${reactPluginIdentifier}()`);
|
|
3667
|
+
else pluginsArray.addElement(`${reactPluginIdentifier}()`);
|
|
3668
|
+
}
|
|
3646
3669
|
await tsProject.save();
|
|
3647
3670
|
}
|
|
3648
3671
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "2.35.
|
|
3
|
+
"version": "2.35.5",
|
|
4
4
|
"description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,28 +8,23 @@
|
|
|
8
8
|
"skipLibCheck": true,
|
|
9
9
|
"baseUrl": "./",
|
|
10
10
|
"paths": {
|
|
11
|
-
"@/*": ["./src/*"]
|
|
12
|
-
|
|
13
|
-
"prisma": ["node_modules/prisma"]
|
|
14
|
-
{{/if}}
|
|
11
|
+
"@/*": ["./src/*"]{{#if (eq orm "prisma")}},
|
|
12
|
+
"prisma": ["node_modules/prisma"]{{/if}}
|
|
15
13
|
},
|
|
16
14
|
"outDir": "./dist",
|
|
17
15
|
"types": [
|
|
18
16
|
{{#if (eq runtime "node")}}
|
|
19
|
-
|
|
17
|
+
"node"
|
|
20
18
|
{{else if (eq runtime "bun")}}
|
|
21
|
-
|
|
19
|
+
"bun"
|
|
22
20
|
{{else if (eq runtime "workers")}}
|
|
23
|
-
|
|
24
|
-
"node"
|
|
21
|
+
"node"
|
|
25
22
|
{{else}}
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
"node",
|
|
24
|
+
"bun"
|
|
28
25
|
{{/if}}
|
|
29
|
-
],
|
|
30
|
-
{{
|
|
31
|
-
"composite": true,
|
|
32
|
-
{{/unless}}
|
|
26
|
+
]{{#unless (or (eq backend "convex") (eq backend "none"))}},
|
|
27
|
+
"composite": true{{/unless}},
|
|
33
28
|
"jsx": "react-jsx"{{#if (eq backend "hono")}},
|
|
34
29
|
"jsxImportSource": "hono/jsx"{{/if}}
|
|
35
30
|
}
|
|
@@ -2,7 +2,13 @@ import { defineConfig } from "vite";
|
|
|
2
2
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
3
3
|
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
4
4
|
import tailwindcss from "@tailwindcss/vite";
|
|
5
|
+
import viteReact from "@vitejs/plugin-react";
|
|
5
6
|
|
|
6
7
|
export default defineConfig({
|
|
7
|
-
plugins: [
|
|
8
|
+
plugins: [
|
|
9
|
+
tsconfigPaths(),
|
|
10
|
+
tailwindcss(),
|
|
11
|
+
tanstackStart({ customViteReactPlugin: true }),
|
|
12
|
+
viteReact(),
|
|
13
|
+
],
|
|
8
14
|
});
|