create-better-t-stack 3.22.3 → 3.23.0
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/README.md +34 -3
- package/dist/{chunk-C8ucw2H5.mjs → chunk-BtN16TXe.mjs} +12 -21
- package/dist/cli.mjs +289 -5
- package/dist/index.d.mts +710 -3
- package/dist/index.mjs +2 -206
- package/dist/{command-handlers-Dvaw7W_l.mjs → src-COTG6r9y.mjs} +1483 -729
- package/dist/virtual.d.mts +2 -1
- package/dist/virtual.mjs +3 -3
- package/package.json +14 -13
package/dist/index.mjs
CHANGED
|
@@ -1,207 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
3
|
-
|
|
4
|
-
import { Result, Result as Result$1 } from "better-result";
|
|
5
|
-
import { createCli } from "trpc-cli";
|
|
6
|
-
import z from "zod";
|
|
7
|
-
import { EMBEDDED_TEMPLATES, EMBEDDED_TEMPLATES as EMBEDDED_TEMPLATES$1, GeneratorError, GeneratorError as GeneratorError$1, TEMPLATE_COUNT, VirtualFileSystem, generate, generate as generate$1 } from "@better-t-stack/template-generator";
|
|
8
|
-
|
|
9
|
-
//#region src/index.ts
|
|
10
|
-
const router = os.router({
|
|
11
|
-
create: os.meta({
|
|
12
|
-
description: "Create a new Better-T-Stack project",
|
|
13
|
-
default: true,
|
|
14
|
-
negateBooleans: true
|
|
15
|
-
}).input(z.tuple([types_exports.ProjectNameSchema.optional(), z.object({
|
|
16
|
-
template: types_exports.TemplateSchema.optional().describe("Use a predefined template"),
|
|
17
|
-
yes: z.boolean().optional().default(false).describe("Use default configuration"),
|
|
18
|
-
yolo: z.boolean().optional().default(false).describe("(WARNING - NOT RECOMMENDED) Bypass validations and compatibility checks"),
|
|
19
|
-
verbose: z.boolean().optional().default(false).describe("Show detailed result information"),
|
|
20
|
-
database: types_exports.DatabaseSchema.optional(),
|
|
21
|
-
orm: types_exports.ORMSchema.optional(),
|
|
22
|
-
auth: types_exports.AuthSchema.optional(),
|
|
23
|
-
payments: types_exports.PaymentsSchema.optional(),
|
|
24
|
-
frontend: z.array(types_exports.FrontendSchema).optional(),
|
|
25
|
-
addons: z.array(types_exports.AddonsSchema).optional(),
|
|
26
|
-
examples: z.array(types_exports.ExamplesSchema).optional(),
|
|
27
|
-
git: z.boolean().optional(),
|
|
28
|
-
packageManager: types_exports.PackageManagerSchema.optional(),
|
|
29
|
-
install: z.boolean().optional(),
|
|
30
|
-
dbSetup: types_exports.DatabaseSetupSchema.optional(),
|
|
31
|
-
backend: types_exports.BackendSchema.optional(),
|
|
32
|
-
runtime: types_exports.RuntimeSchema.optional(),
|
|
33
|
-
api: types_exports.APISchema.optional(),
|
|
34
|
-
webDeploy: types_exports.WebDeploySchema.optional(),
|
|
35
|
-
serverDeploy: types_exports.ServerDeploySchema.optional(),
|
|
36
|
-
directoryConflict: types_exports.DirectoryConflictSchema.optional(),
|
|
37
|
-
renderTitle: z.boolean().optional(),
|
|
38
|
-
disableAnalytics: z.boolean().optional().default(false).describe("Disable analytics"),
|
|
39
|
-
manualDb: z.boolean().optional().default(false).describe("Skip automatic/manual database setup prompt and use manual setup")
|
|
40
|
-
})])).handler(async ({ input }) => {
|
|
41
|
-
const [projectName, options] = input;
|
|
42
|
-
const result = await createProjectHandler({
|
|
43
|
-
projectName,
|
|
44
|
-
...options
|
|
45
|
-
});
|
|
46
|
-
if (options.verbose) return result;
|
|
47
|
-
}),
|
|
48
|
-
sponsors: os.meta({ description: "Show Better-T-Stack sponsors" }).handler(showSponsorsCommand),
|
|
49
|
-
docs: os.meta({ description: "Open Better-T-Stack documentation" }).handler(openDocsCommand),
|
|
50
|
-
builder: os.meta({ description: "Open the web-based stack builder" }).handler(openBuilderCommand),
|
|
51
|
-
add: os.meta({ description: "Add addons to an existing Better-T-Stack project" }).input(z.object({
|
|
52
|
-
addons: z.array(types_exports.AddonsSchema).optional().describe("Addons to add"),
|
|
53
|
-
install: z.boolean().optional().default(false).describe("Install dependencies after adding"),
|
|
54
|
-
packageManager: types_exports.PackageManagerSchema.optional().describe("Package manager to use"),
|
|
55
|
-
projectDir: z.string().optional().describe("Project directory (defaults to current)")
|
|
56
|
-
})).handler(async ({ input }) => {
|
|
57
|
-
await addHandler(input);
|
|
58
|
-
}),
|
|
59
|
-
history: os.meta({ description: "Show project creation history" }).input(z.object({
|
|
60
|
-
limit: z.number().optional().default(10).describe("Number of entries to show"),
|
|
61
|
-
clear: z.boolean().optional().default(false).describe("Clear all history"),
|
|
62
|
-
json: z.boolean().optional().default(false).describe("Output as JSON")
|
|
63
|
-
})).handler(async ({ input }) => {
|
|
64
|
-
await historyHandler(input);
|
|
65
|
-
})
|
|
66
|
-
});
|
|
67
|
-
const caller = createRouterClient(router, { context: {} });
|
|
68
|
-
function createBtsCli() {
|
|
69
|
-
return createCli({
|
|
70
|
-
router,
|
|
71
|
-
name: "create-better-t-stack",
|
|
72
|
-
version: getLatestCLIVersion()
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Programmatic API to create a new Better-T-Stack project.
|
|
77
|
-
* Returns a Result type - no console output, no interactive prompts.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* ```typescript
|
|
81
|
-
* import { create, Result } from "create-better-t-stack";
|
|
82
|
-
*
|
|
83
|
-
* const result = await create("my-app", {
|
|
84
|
-
* frontend: ["tanstack-router"],
|
|
85
|
-
* backend: "hono",
|
|
86
|
-
* runtime: "bun",
|
|
87
|
-
* database: "sqlite",
|
|
88
|
-
* orm: "drizzle",
|
|
89
|
-
* });
|
|
90
|
-
*
|
|
91
|
-
* result.match({
|
|
92
|
-
* ok: (data) => console.log(`Project created at: ${data.projectDirectory}`),
|
|
93
|
-
* err: (error) => console.error(`Failed: ${error.message}`),
|
|
94
|
-
* });
|
|
95
|
-
*
|
|
96
|
-
* // Or use unwrapOr for a default value
|
|
97
|
-
* const data = result.unwrapOr(null);
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
async function create(projectName, options) {
|
|
101
|
-
const input = {
|
|
102
|
-
...options,
|
|
103
|
-
projectName,
|
|
104
|
-
renderTitle: false,
|
|
105
|
-
verbose: true,
|
|
106
|
-
disableAnalytics: options?.disableAnalytics ?? true,
|
|
107
|
-
directoryConflict: options?.directoryConflict ?? "error"
|
|
108
|
-
};
|
|
109
|
-
return Result$1.tryPromise({
|
|
110
|
-
try: async () => {
|
|
111
|
-
const result = await createProjectHandler(input, { silent: true });
|
|
112
|
-
if (!result) throw new UserCancelledError({ message: "Operation cancelled" });
|
|
113
|
-
if (!result.success) throw new CLIError({ message: result.error || "Unknown error occurred" });
|
|
114
|
-
return result;
|
|
115
|
-
},
|
|
116
|
-
catch: (e) => {
|
|
117
|
-
if (e instanceof UserCancelledError) return e;
|
|
118
|
-
if (e instanceof CLIError) return e;
|
|
119
|
-
if (e instanceof ProjectCreationError) return e;
|
|
120
|
-
return new CLIError({
|
|
121
|
-
message: e instanceof Error ? e.message : String(e),
|
|
122
|
-
cause: e
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
async function sponsors() {
|
|
128
|
-
return caller.sponsors();
|
|
129
|
-
}
|
|
130
|
-
async function docs() {
|
|
131
|
-
return caller.docs();
|
|
132
|
-
}
|
|
133
|
-
async function builder() {
|
|
134
|
-
return caller.builder();
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Programmatic API to generate a project in-memory (virtual filesystem).
|
|
138
|
-
* Returns a Result with a VirtualFileTree without writing to disk.
|
|
139
|
-
* Useful for web previews and testing.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```typescript
|
|
143
|
-
* import { createVirtual, EMBEDDED_TEMPLATES, Result } from "create-better-t-stack";
|
|
144
|
-
*
|
|
145
|
-
* const result = await createVirtual({
|
|
146
|
-
* frontend: ["tanstack-router"],
|
|
147
|
-
* backend: "hono",
|
|
148
|
-
* runtime: "bun",
|
|
149
|
-
* database: "sqlite",
|
|
150
|
-
* orm: "drizzle",
|
|
151
|
-
* });
|
|
152
|
-
*
|
|
153
|
-
* result.match({
|
|
154
|
-
* ok: (tree) => console.log(`Generated ${tree.fileCount} files`),
|
|
155
|
-
* err: (error) => console.error(`Failed: ${error.message}`),
|
|
156
|
-
* });
|
|
157
|
-
* ```
|
|
158
|
-
*/
|
|
159
|
-
async function createVirtual(options) {
|
|
160
|
-
return generate$1({
|
|
161
|
-
config: {
|
|
162
|
-
projectName: options.projectName || "my-project",
|
|
163
|
-
projectDir: "/virtual",
|
|
164
|
-
relativePath: "./virtual",
|
|
165
|
-
database: options.database || "none",
|
|
166
|
-
orm: options.orm || "none",
|
|
167
|
-
backend: options.backend || "hono",
|
|
168
|
-
runtime: options.runtime || "bun",
|
|
169
|
-
frontend: options.frontend || ["tanstack-router"],
|
|
170
|
-
addons: options.addons || [],
|
|
171
|
-
examples: options.examples || [],
|
|
172
|
-
auth: options.auth || "none",
|
|
173
|
-
payments: options.payments || "none",
|
|
174
|
-
git: options.git ?? false,
|
|
175
|
-
packageManager: options.packageManager || "bun",
|
|
176
|
-
install: false,
|
|
177
|
-
dbSetup: options.dbSetup || "none",
|
|
178
|
-
api: options.api || "trpc",
|
|
179
|
-
webDeploy: options.webDeploy || "none",
|
|
180
|
-
serverDeploy: options.serverDeploy || "none"
|
|
181
|
-
},
|
|
182
|
-
templates: EMBEDDED_TEMPLATES$1
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Programmatic API to add addons to an existing Better-T-Stack project.
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* ```typescript
|
|
190
|
-
* import { add } from "create-better-t-stack";
|
|
191
|
-
*
|
|
192
|
-
* const result = await add({
|
|
193
|
-
* addons: ["biome", "husky"],
|
|
194
|
-
* install: true,
|
|
195
|
-
* });
|
|
196
|
-
*
|
|
197
|
-
* if (result?.success) {
|
|
198
|
-
* console.log(`Added: ${result.addedAddons.join(", ")}`);
|
|
199
|
-
* }
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
async function add(options = {}) {
|
|
203
|
-
return addHandler(options, { silent: true });
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
export { CLIError, CompatibilityError, DatabaseSetupError, DirectoryConflictError, EMBEDDED_TEMPLATES, GeneratorError, ProjectCreationError, Result, TEMPLATE_COUNT, UserCancelledError, ValidationError, VirtualFileSystem, add, builder, create, createBtsCli, createVirtual, docs, generate, router, sponsors };
|
|
2
|
+
import { C as ProjectCreationError, S as DirectoryConflictError, T as ValidationError, a as TEMPLATE_COUNT, b as CompatibilityError, c as builder, d as createVirtual, f as docs, g as sponsors, h as router, i as SchemaNameSchema, l as create, m as getSchemaResult, n as GeneratorError, o as VirtualFileSystem, p as generate, r as Result, s as add, t as EMBEDDED_TEMPLATES, u as createBtsCli, w as UserCancelledError, x as DatabaseSetupError, y as CLIError } from "./src-COTG6r9y.mjs";
|
|
3
|
+
export { CLIError, CompatibilityError, DatabaseSetupError, DirectoryConflictError, EMBEDDED_TEMPLATES, GeneratorError, ProjectCreationError, Result, SchemaNameSchema, TEMPLATE_COUNT, UserCancelledError, ValidationError, VirtualFileSystem, add, builder, create, createBtsCli, createVirtual, docs, generate, getSchemaResult, router, sponsors };
|