create-better-t-stack 3.10.0 → 3.11.0-pr749.7e7198c
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/bin/create-better-t-stack +94 -0
- package/package.json +27 -31
- package/scripts/postinstall.mjs +129 -0
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +1 -1
- package/templates/backend/convex/packages/backend/convex/convex.config.ts.hbs +17 -0
- package/templates/examples/ai/convex/packages/backend/convex/agent.ts.hbs +9 -0
- package/templates/examples/ai/convex/packages/backend/convex/chat.ts.hbs +67 -0
- package/templates/examples/ai/native/bare/app/(drawer)/ai.tsx.hbs +301 -3
- package/templates/examples/ai/native/unistyles/app/(drawer)/ai.tsx.hbs +296 -10
- package/templates/examples/ai/native/uniwind/app/(drawer)/ai.tsx.hbs +180 -1
- package/templates/examples/ai/web/react/next/src/app/ai/page.tsx.hbs +172 -9
- package/templates/examples/ai/web/react/react-router/src/routes/ai.tsx.hbs +156 -6
- package/templates/examples/ai/web/react/tanstack-router/src/routes/ai.tsx.hbs +156 -4
- package/templates/examples/ai/web/react/tanstack-start/src/routes/ai.tsx.hbs +159 -6
- package/templates/frontend/react/web-base/src/index.css.hbs +1 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -8
- package/dist/index.d.mts +0 -347
- package/dist/index.mjs +0 -4
- package/dist/src-QkFdHtZE.mjs +0 -7072
- package/templates/auth/better-auth/convex/backend/convex/convex.config.ts.hbs +0 -7
- package/templates/examples/ai/web/react/base/src/components/response.tsx.hbs +0 -22
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bin stub for create-better-t-stack.
|
|
5
|
+
* Finds and runs the platform-specific compiled binary.
|
|
6
|
+
*
|
|
7
|
+
* The binary is installed as an optional dependency:
|
|
8
|
+
* @better-t-stack/cli-{platform}-{arch}
|
|
9
|
+
*
|
|
10
|
+
* This stub searches node_modules for the matching binary package.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const childProcess = require("child_process");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const os = require("os");
|
|
17
|
+
|
|
18
|
+
function run(target) {
|
|
19
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
20
|
+
stdio: "inherit",
|
|
21
|
+
});
|
|
22
|
+
if (result.error) {
|
|
23
|
+
console.error(result.error.message);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
const code = typeof result.status === "number" ? result.status : 0;
|
|
27
|
+
process.exit(code);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Allow override via environment variable
|
|
31
|
+
const envPath = process.env.CREATE_BETTER_T_STACK_BIN_PATH;
|
|
32
|
+
if (envPath) {
|
|
33
|
+
run(envPath);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const scriptPath = fs.realpathSync(__filename);
|
|
37
|
+
const scriptDir = path.dirname(scriptPath);
|
|
38
|
+
|
|
39
|
+
const platformMap = {
|
|
40
|
+
darwin: "darwin",
|
|
41
|
+
linux: "linux",
|
|
42
|
+
win32: "windows",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const archMap = {
|
|
46
|
+
x64: "x64",
|
|
47
|
+
arm64: "arm64",
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
let platform = platformMap[os.platform()];
|
|
51
|
+
if (!platform) {
|
|
52
|
+
platform = os.platform();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let arch = archMap[os.arch()];
|
|
56
|
+
if (!arch) {
|
|
57
|
+
arch = os.arch();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Scoped package name: @better-t-stack/cli-{platform}-{arch}
|
|
61
|
+
const scopedPackage = "@better-t-stack/cli-" + platform + "-" + arch;
|
|
62
|
+
const binary = platform === "windows" ? "create-better-t-stack.exe" : "create-better-t-stack";
|
|
63
|
+
|
|
64
|
+
function findBinary(startDir) {
|
|
65
|
+
let current = startDir;
|
|
66
|
+
for (; ;) {
|
|
67
|
+
const modules = path.join(current, "node_modules");
|
|
68
|
+
if (fs.existsSync(modules)) {
|
|
69
|
+
// Check for scoped package: node_modules/@better-t-stack/cli-{platform}-{arch}
|
|
70
|
+
const scopedPath = path.join(modules, "@better-t-stack", "cli-" + platform + "-" + arch);
|
|
71
|
+
const candidate = path.join(scopedPath, "bin", binary);
|
|
72
|
+
if (fs.existsSync(candidate)) {
|
|
73
|
+
return candidate;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const parent = path.dirname(current);
|
|
77
|
+
if (parent === current) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
current = parent;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const resolved = findBinary(scriptDir);
|
|
85
|
+
|
|
86
|
+
if (!resolved) {
|
|
87
|
+
console.error(
|
|
88
|
+
'No binary found for your platform (' + platform + '-' + arch + ').\n' +
|
|
89
|
+
'You can try manually installing the "' + scopedPackage + '" package.',
|
|
90
|
+
);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
run(resolved);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0-pr749.7e7198c",
|
|
4
4
|
"description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"better-auth",
|
|
@@ -37,59 +37,55 @@
|
|
|
37
37
|
"directory": "apps/cli"
|
|
38
38
|
},
|
|
39
39
|
"bin": {
|
|
40
|
-
"create-better-t-stack": "
|
|
40
|
+
"create-better-t-stack": "./bin/create-better-t-stack"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
|
-
"
|
|
44
|
-
"templates"
|
|
43
|
+
"bin",
|
|
44
|
+
"templates",
|
|
45
|
+
"scripts/postinstall.mjs"
|
|
45
46
|
],
|
|
46
47
|
"type": "module",
|
|
47
|
-
"exports": {
|
|
48
|
-
".": {
|
|
49
|
-
"types": "./dist/index.d.mts",
|
|
50
|
-
"import": "./dist/index.mjs"
|
|
51
|
-
},
|
|
52
|
-
"./cli": {
|
|
53
|
-
"import": "./dist/cli.mjs"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
48
|
"publishConfig": {
|
|
57
49
|
"access": "public"
|
|
58
50
|
},
|
|
59
51
|
"scripts": {
|
|
60
|
-
"build": "
|
|
61
|
-
"
|
|
52
|
+
"build": "bun run scripts/build.ts",
|
|
53
|
+
"build:local": "bun run scripts/build.ts --single",
|
|
54
|
+
"dev": "bun run src/cli.ts",
|
|
62
55
|
"check-types": "tsc --noEmit",
|
|
63
|
-
"test": "bun
|
|
64
|
-
"test:watch": "bun
|
|
65
|
-
"test:coverage": "bun
|
|
66
|
-
"test:ci": "
|
|
67
|
-
"prepublishOnly": "
|
|
56
|
+
"test": "bun test",
|
|
57
|
+
"test:watch": "bun test --watch",
|
|
58
|
+
"test:coverage": "bun test --coverage",
|
|
59
|
+
"test:ci": "AGENT=1 bun test --bail=5",
|
|
60
|
+
"prepublishOnly": "echo 'Build binaries separately before publishing'",
|
|
61
|
+
"postinstall": "node ./scripts/postinstall.mjs || true"
|
|
68
62
|
},
|
|
69
63
|
"dependencies": {
|
|
70
|
-
"@better-t-stack/types": "
|
|
64
|
+
"@better-t-stack/types": "3.11.0-pr749.7e7198c",
|
|
71
65
|
"@clack/prompts": "^1.0.0-alpha.8",
|
|
72
|
-
"
|
|
66
|
+
"commander": "^14.0.2",
|
|
73
67
|
"consola": "^3.4.2",
|
|
74
|
-
"
|
|
75
|
-
"fs-extra": "^11.3.2",
|
|
68
|
+
"fs-extra": "^11.3.3",
|
|
76
69
|
"gradient-string": "^3.0.0",
|
|
77
70
|
"handlebars": "^4.7.8",
|
|
78
71
|
"jsonc-parser": "^3.3.1",
|
|
79
|
-
"oxfmt": "^0.19.0",
|
|
80
72
|
"picocolors": "^1.1.1",
|
|
81
73
|
"tinyglobby": "^0.2.15",
|
|
82
|
-
"trpc-cli": "^0.12.1",
|
|
83
74
|
"ts-morph": "^27.0.2",
|
|
84
75
|
"yaml": "^2.8.2",
|
|
85
|
-
"zod": "^4.1
|
|
76
|
+
"zod": "^4.2.1"
|
|
86
77
|
},
|
|
87
78
|
"devDependencies": {
|
|
88
|
-
"@types/bun": "^1.
|
|
79
|
+
"@types/bun": "^1.3.5",
|
|
89
80
|
"@types/fs-extra": "^11.0.4",
|
|
90
|
-
"@types/node": "^
|
|
91
|
-
"publint": "^0.3.16",
|
|
92
|
-
"tsdown": "^0.17.2",
|
|
81
|
+
"@types/node": "^25.0.3",
|
|
93
82
|
"typescript": "^5.9.3"
|
|
83
|
+
},
|
|
84
|
+
"optionalDependencies": {
|
|
85
|
+
"@better-t-stack/cli-darwin-arm64": "3.11.0",
|
|
86
|
+
"@better-t-stack/cli-darwin-x64": "3.11.0",
|
|
87
|
+
"@better-t-stack/cli-linux-arm64": "3.11.0",
|
|
88
|
+
"@better-t-stack/cli-linux-x64": "3.11.0",
|
|
89
|
+
"@better-t-stack/cli-windows-x64": "3.11.0"
|
|
94
90
|
}
|
|
95
91
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall script for create-better-t-stack.
|
|
5
|
+
* Symlinks the platform-specific binary to the bin directory for convenience.
|
|
6
|
+
*
|
|
7
|
+
* This runs after npm install to set up the binary.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import os from "os";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
14
|
+
import { createRequire } from "module";
|
|
15
|
+
|
|
16
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
const require = createRequire(import.meta.url);
|
|
18
|
+
|
|
19
|
+
function detectPlatformAndArch() {
|
|
20
|
+
let platform;
|
|
21
|
+
switch (os.platform()) {
|
|
22
|
+
case "darwin":
|
|
23
|
+
platform = "darwin";
|
|
24
|
+
break;
|
|
25
|
+
case "linux":
|
|
26
|
+
platform = "linux";
|
|
27
|
+
break;
|
|
28
|
+
case "win32":
|
|
29
|
+
platform = "windows";
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
platform = os.platform();
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let arch;
|
|
37
|
+
switch (os.arch()) {
|
|
38
|
+
case "x64":
|
|
39
|
+
arch = "x64";
|
|
40
|
+
break;
|
|
41
|
+
case "arm64":
|
|
42
|
+
arch = "arm64";
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
arch = os.arch();
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { platform, arch };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function findBinary() {
|
|
53
|
+
const { platform, arch } = detectPlatformAndArch();
|
|
54
|
+
// Scoped package: @better-t-stack/cli-{platform}-{arch}
|
|
55
|
+
const packageName = `@better-t-stack/cli-${platform}-${arch}`;
|
|
56
|
+
const binaryName = platform === "windows" ? "create-better-t-stack.exe" : "create-better-t-stack";
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
// Use require.resolve to find the package
|
|
60
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
61
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
62
|
+
const binaryPath = path.join(packageDir, "bin", binaryName);
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(binaryPath)) {
|
|
65
|
+
throw new Error(`Binary not found at ${binaryPath}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { binaryPath, binaryName };
|
|
69
|
+
} catch (error) {
|
|
70
|
+
throw new Error(`Could not find package ${packageName}: ${error.message}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function prepareBinDirectory(binaryName) {
|
|
75
|
+
const binDir = path.join(__dirname, "..", "bin");
|
|
76
|
+
const targetPath = path.join(binDir, binaryName);
|
|
77
|
+
|
|
78
|
+
// Ensure bin directory exists
|
|
79
|
+
if (!fs.existsSync(binDir)) {
|
|
80
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Remove existing binary/symlink if it exists
|
|
84
|
+
try {
|
|
85
|
+
if (fs.existsSync(targetPath) || fs.lstatSync(targetPath).isSymbolicLink()) {
|
|
86
|
+
fs.unlinkSync(targetPath);
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
// File doesn't exist, that's fine
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { binDir, targetPath };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function symlinkBinary(sourcePath, binaryName) {
|
|
96
|
+
const { targetPath } = prepareBinDirectory(binaryName);
|
|
97
|
+
|
|
98
|
+
fs.symlinkSync(sourcePath, targetPath);
|
|
99
|
+
console.log(`create-better-t-stack binary symlinked: ${targetPath} -> ${sourcePath}`);
|
|
100
|
+
|
|
101
|
+
// Verify the file exists after operation
|
|
102
|
+
if (!fs.existsSync(targetPath)) {
|
|
103
|
+
throw new Error(`Failed to symlink binary to ${targetPath}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function main() {
|
|
108
|
+
try {
|
|
109
|
+
if (os.platform() === "win32") {
|
|
110
|
+
// On Windows, symlinks require admin privileges
|
|
111
|
+
// The bin stub will find the binary directly
|
|
112
|
+
console.log("Windows detected: skipping symlink (bin stub will find binary directly)");
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const { binaryPath, binaryName } = findBinary();
|
|
117
|
+
symlinkBinary(binaryPath, binaryName);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
// Don't fail the install if we can't symlink - the bin stub will still work
|
|
120
|
+
console.log(`Note: Could not symlink binary (${error.message}). The CLI will still work.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
main();
|
|
126
|
+
} catch (error) {
|
|
127
|
+
// Silently continue - postinstall failures shouldn't break the install
|
|
128
|
+
console.log("Postinstall completed with warnings.");
|
|
129
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineApp } from "convex/server";
|
|
2
|
+
{{#if (eq auth "better-auth")}}
|
|
3
|
+
import betterAuth from "@convex-dev/better-auth/convex.config";
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if (includes examples "ai")}}
|
|
6
|
+
import agent from "@convex-dev/agent/convex.config";
|
|
7
|
+
{{/if}}
|
|
8
|
+
|
|
9
|
+
const app = defineApp();
|
|
10
|
+
{{#if (eq auth "better-auth")}}
|
|
11
|
+
app.use(betterAuth);
|
|
12
|
+
{{/if}}
|
|
13
|
+
{{#if (includes examples "ai")}}
|
|
14
|
+
app.use(agent);
|
|
15
|
+
{{/if}}
|
|
16
|
+
|
|
17
|
+
export default app;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Agent } from "@convex-dev/agent";
|
|
2
|
+
import { google } from "@ai-sdk/google";
|
|
3
|
+
import { components } from "./_generated/api";
|
|
4
|
+
|
|
5
|
+
export const chatAgent = new Agent(components.agent, {
|
|
6
|
+
name: "Chat Agent",
|
|
7
|
+
languageModel: google("gemini-2.5-flash"),
|
|
8
|
+
instructions: "You are a helpful AI assistant. Be concise and friendly in your responses.",
|
|
9
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createThread,
|
|
3
|
+
listUIMessages,
|
|
4
|
+
saveMessage,
|
|
5
|
+
syncStreams,
|
|
6
|
+
vStreamArgs,
|
|
7
|
+
} from "@convex-dev/agent";
|
|
8
|
+
import { paginationOptsValidator } from "convex/server";
|
|
9
|
+
import { v } from "convex/values";
|
|
10
|
+
|
|
11
|
+
import { components, internal } from "./_generated/api";
|
|
12
|
+
import { internalAction, mutation, query } from "./_generated/server";
|
|
13
|
+
import { chatAgent } from "./agent";
|
|
14
|
+
|
|
15
|
+
export const createNewThread = mutation({
|
|
16
|
+
args: {},
|
|
17
|
+
handler: async (ctx) => {
|
|
18
|
+
const threadId = await createThread(ctx, components.agent, {});
|
|
19
|
+
return threadId;
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const listMessages = query({
|
|
24
|
+
args: {
|
|
25
|
+
threadId: v.string(),
|
|
26
|
+
paginationOpts: paginationOptsValidator,
|
|
27
|
+
streamArgs: vStreamArgs,
|
|
28
|
+
},
|
|
29
|
+
handler: async (ctx, args) => {
|
|
30
|
+
const paginated = await listUIMessages(ctx, components.agent, args);
|
|
31
|
+
const streams = await syncStreams(ctx, components.agent, args);
|
|
32
|
+
return { ...paginated, streams };
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const sendMessage = mutation({
|
|
37
|
+
args: {
|
|
38
|
+
threadId: v.string(),
|
|
39
|
+
prompt: v.string(),
|
|
40
|
+
},
|
|
41
|
+
handler: async (ctx, { threadId, prompt }) => {
|
|
42
|
+
const { messageId } = await saveMessage(ctx, components.agent, {
|
|
43
|
+
threadId,
|
|
44
|
+
prompt,
|
|
45
|
+
});
|
|
46
|
+
await ctx.scheduler.runAfter(0, internal.chat.generateResponseAsync, {
|
|
47
|
+
threadId,
|
|
48
|
+
promptMessageId: messageId,
|
|
49
|
+
});
|
|
50
|
+
return messageId;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const generateResponseAsync = internalAction({
|
|
55
|
+
args: {
|
|
56
|
+
threadId: v.string(),
|
|
57
|
+
promptMessageId: v.string(),
|
|
58
|
+
},
|
|
59
|
+
handler: async (ctx, { threadId, promptMessageId }) => {
|
|
60
|
+
await chatAgent.streamText(
|
|
61
|
+
ctx,
|
|
62
|
+
{ threadId },
|
|
63
|
+
{ promptMessageId },
|
|
64
|
+
{ saveStreamDeltas: true },
|
|
65
|
+
);
|
|
66
|
+
},
|
|
67
|
+
});
|