create-better-t-stack 3.17.1 → 3.19.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/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { o as createBtsCli } from "./src-D5L84uxt.mjs";
2
+ import { l as createBtsCli } from "./src-_XtvURoM.mjs";
3
3
 
4
4
  //#region src/cli.ts
5
5
  createBtsCli().run();
package/dist/index.d.mts CHANGED
@@ -1,13 +1,129 @@
1
1
  #!/usr/bin/env node
2
2
  import * as _orpc_server0 from "@orpc/server";
3
+ import * as better_result0 from "better-result";
4
+ import { Result, Result as Result$1 } from "better-result";
3
5
  import * as trpc_cli0 from "trpc-cli";
4
6
  import z from "zod";
5
- import { EMBEDDED_TEMPLATES, GeneratorOptions, GeneratorResult, TEMPLATE_COUNT, VirtualDirectory, VirtualFile, VirtualFileSystem, VirtualFileTree, VirtualFileTree as VirtualFileTree$1, VirtualNode, generateVirtualProject } from "@better-t-stack/template-generator";
7
+ import { EMBEDDED_TEMPLATES, GeneratorError, GeneratorError as GeneratorError$1, GeneratorOptions, TEMPLATE_COUNT, VirtualDirectory, VirtualFile, VirtualFileSystem, VirtualFileTree, VirtualFileTree as VirtualFileTree$1, VirtualNode, generate } from "@better-t-stack/template-generator";
6
8
 
7
9
  //#region src/types.d.ts
8
10
 
9
11
  import * as import__better_t_stack_types from "@better-t-stack/types";
10
12
  //#endregion
13
+ //#region src/helpers/core/command-handlers.d.ts
14
+ /**
15
+ * Result type for project creation
16
+ */
17
+ interface CreateProjectResult {
18
+ success: boolean;
19
+ projectConfig: types_d_exports.ProjectConfig;
20
+ reproducibleCommand: string;
21
+ timeScaffolded: string;
22
+ elapsedTimeMs: number;
23
+ projectDirectory: string;
24
+ relativePath: string;
25
+ error?: string;
26
+ }
27
+ //#endregion
28
+ //#region src/helpers/core/add-handler.d.ts
29
+ interface AddResult {
30
+ success: boolean;
31
+ addedAddons: types_d_exports.Addons[];
32
+ projectDir: string;
33
+ error?: string;
34
+ }
35
+ //#endregion
36
+ //#region src/utils/errors.d.ts
37
+ declare const UserCancelledError_base: better_result0.TaggedErrorClass<"UserCancelledError", {
38
+ message: string;
39
+ }>;
40
+ /**
41
+ * User cancelled the operation (e.g., Ctrl+C in prompts)
42
+ */
43
+ declare class UserCancelledError extends UserCancelledError_base {
44
+ constructor(args?: {
45
+ message?: string;
46
+ });
47
+ }
48
+ declare const CLIError_base: better_result0.TaggedErrorClass<"CLIError", {
49
+ message: string;
50
+ cause?: unknown;
51
+ }>;
52
+ /**
53
+ * General CLI error for validation failures, invalid flags, etc.
54
+ */
55
+ declare class CLIError extends CLIError_base {}
56
+ declare const ValidationError_base: better_result0.TaggedErrorClass<"ValidationError", {
57
+ field?: string;
58
+ value?: unknown;
59
+ message: string;
60
+ }>;
61
+ /**
62
+ * Validation error for config/flag validation failures
63
+ */
64
+ declare class ValidationError extends ValidationError_base {
65
+ constructor(args: {
66
+ field?: string;
67
+ value?: unknown;
68
+ message: string;
69
+ });
70
+ }
71
+ declare const CompatibilityError_base: better_result0.TaggedErrorClass<"CompatibilityError", {
72
+ options: string[];
73
+ message: string;
74
+ }>;
75
+ /**
76
+ * Compatibility error for incompatible option combinations
77
+ */
78
+ declare class CompatibilityError extends CompatibilityError_base {
79
+ constructor(args: {
80
+ options: string[];
81
+ message: string;
82
+ });
83
+ }
84
+ declare const DirectoryConflictError_base: better_result0.TaggedErrorClass<"DirectoryConflictError", {
85
+ directory: string;
86
+ message: string;
87
+ }>;
88
+ /**
89
+ * Directory conflict error when target directory exists and is not empty
90
+ */
91
+ declare class DirectoryConflictError extends DirectoryConflictError_base {
92
+ constructor(args: {
93
+ directory: string;
94
+ });
95
+ }
96
+ declare const ProjectCreationError_base: better_result0.TaggedErrorClass<"ProjectCreationError", {
97
+ phase: string;
98
+ message: string;
99
+ cause?: unknown;
100
+ }>;
101
+ /**
102
+ * Project creation error for failures during scaffolding
103
+ */
104
+ declare class ProjectCreationError extends ProjectCreationError_base {
105
+ constructor(args: {
106
+ phase: string;
107
+ message: string;
108
+ cause?: unknown;
109
+ });
110
+ }
111
+ declare const DatabaseSetupError_base: better_result0.TaggedErrorClass<"DatabaseSetupError", {
112
+ provider: string;
113
+ message: string;
114
+ cause?: unknown;
115
+ }>;
116
+ /**
117
+ * Database setup error for failures during database configuration
118
+ */
119
+ declare class DatabaseSetupError extends DatabaseSetupError_base {
120
+ constructor(args: {
121
+ provider: string;
122
+ message: string;
123
+ cause?: unknown;
124
+ });
125
+ }
126
+ //#endregion
11
127
  //#region src/index.d.ts
12
128
  declare const router: {
13
129
  create: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, z.ZodTuple<[z.ZodOptional<z.ZodString>, z.ZodObject<{
@@ -72,6 +188,7 @@ declare const router: {
72
188
  oxlint: "oxlint";
73
189
  opentui: "opentui";
74
190
  wxt: "wxt";
191
+ skills: "skills";
75
192
  }>>>;
76
193
  examples: z.ZodOptional<z.ZodArray<z.ZodEnum<{
77
194
  none: "none";
@@ -133,95 +250,54 @@ declare const router: {
133
250
  renderTitle: z.ZodOptional<z.ZodBoolean>;
134
251
  disableAnalytics: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
135
252
  manualDb: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
136
- }, z.core.$strip>], null>, _orpc_server0.Schema<{
137
- success: boolean;
138
- projectConfig: {
139
- projectName: string;
140
- projectDir: string;
141
- relativePath: string;
142
- database: "none" | "sqlite" | "postgres" | "mysql" | "mongodb";
143
- orm: "none" | "drizzle" | "prisma" | "mongoose";
144
- backend: "none" | "hono" | "express" | "fastify" | "elysia" | "convex" | "self";
145
- runtime: "none" | "bun" | "node" | "workers";
146
- frontend: ("none" | "tanstack-router" | "react-router" | "tanstack-start" | "next" | "nuxt" | "native-bare" | "native-uniwind" | "native-unistyles" | "svelte" | "solid" | "astro")[];
147
- addons: ("none" | "pwa" | "tauri" | "starlight" | "biome" | "lefthook" | "husky" | "ruler" | "turborepo" | "fumadocs" | "ultracite" | "oxlint" | "opentui" | "wxt")[];
148
- examples: ("none" | "todo" | "ai")[];
149
- auth: "none" | "better-auth" | "clerk";
150
- payments: "none" | "polar";
151
- git: boolean;
152
- packageManager: "bun" | "npm" | "pnpm";
153
- install: boolean;
154
- dbSetup: "none" | "turso" | "neon" | "prisma-postgres" | "planetscale" | "mongodb-atlas" | "supabase" | "d1" | "docker";
155
- api: "none" | "trpc" | "orpc";
156
- webDeploy: "none" | "cloudflare";
157
- serverDeploy: "none" | "cloudflare";
158
- };
159
- reproducibleCommand: string;
160
- timeScaffolded: string;
161
- elapsedTimeMs: number;
162
- projectDirectory: string;
163
- relativePath: string;
164
- error?: undefined;
165
- } | {
166
- success: boolean;
167
- error: string;
168
- projectConfig: types_d_exports.ProjectConfig;
169
- reproducibleCommand: string;
170
- timeScaffolded: string;
171
- elapsedTimeMs: number;
172
- projectDirectory: string;
173
- relativePath: string;
174
- } | undefined, {
175
- success: boolean;
176
- projectConfig: {
177
- projectName: string;
178
- projectDir: string;
179
- relativePath: string;
180
- database: "none" | "sqlite" | "postgres" | "mysql" | "mongodb";
181
- orm: "none" | "drizzle" | "prisma" | "mongoose";
182
- backend: "none" | "hono" | "express" | "fastify" | "elysia" | "convex" | "self";
183
- runtime: "none" | "bun" | "node" | "workers";
184
- frontend: ("none" | "tanstack-router" | "react-router" | "tanstack-start" | "next" | "nuxt" | "native-bare" | "native-uniwind" | "native-unistyles" | "svelte" | "solid" | "astro")[];
185
- addons: ("none" | "pwa" | "tauri" | "starlight" | "biome" | "lefthook" | "husky" | "ruler" | "turborepo" | "fumadocs" | "ultracite" | "oxlint" | "opentui" | "wxt")[];
186
- examples: ("none" | "todo" | "ai")[];
187
- auth: "none" | "better-auth" | "clerk";
188
- payments: "none" | "polar";
189
- git: boolean;
190
- packageManager: "bun" | "npm" | "pnpm";
191
- install: boolean;
192
- dbSetup: "none" | "turso" | "neon" | "prisma-postgres" | "planetscale" | "mongodb-atlas" | "supabase" | "d1" | "docker";
193
- api: "none" | "trpc" | "orpc";
194
- webDeploy: "none" | "cloudflare";
195
- serverDeploy: "none" | "cloudflare";
196
- };
197
- reproducibleCommand: string;
198
- timeScaffolded: string;
199
- elapsedTimeMs: number;
200
- projectDirectory: string;
201
- relativePath: string;
202
- error?: undefined;
203
- } | {
204
- success: boolean;
205
- error: string;
206
- projectConfig: types_d_exports.ProjectConfig;
207
- reproducibleCommand: string;
208
- timeScaffolded: string;
209
- elapsedTimeMs: number;
210
- projectDirectory: string;
211
- relativePath: string;
212
- } | undefined>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
253
+ }, z.core.$strip>], null>, _orpc_server0.Schema<CreateProjectResult | undefined, CreateProjectResult | undefined>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
213
254
  sponsors: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, _orpc_server0.Schema<unknown, unknown>, _orpc_server0.Schema<void, void>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
214
255
  docs: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, _orpc_server0.Schema<unknown, unknown>, _orpc_server0.Schema<void, void>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
215
256
  builder: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, _orpc_server0.Schema<unknown, unknown>, _orpc_server0.Schema<void, void>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
257
+ add: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, z.ZodObject<{
258
+ addons: z.ZodOptional<z.ZodArray<z.ZodEnum<{
259
+ none: "none";
260
+ pwa: "pwa";
261
+ tauri: "tauri";
262
+ starlight: "starlight";
263
+ biome: "biome";
264
+ lefthook: "lefthook";
265
+ husky: "husky";
266
+ ruler: "ruler";
267
+ turborepo: "turborepo";
268
+ fumadocs: "fumadocs";
269
+ ultracite: "ultracite";
270
+ oxlint: "oxlint";
271
+ opentui: "opentui";
272
+ wxt: "wxt";
273
+ skills: "skills";
274
+ }>>>;
275
+ install: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
276
+ packageManager: z.ZodOptional<z.ZodEnum<{
277
+ bun: "bun";
278
+ npm: "npm";
279
+ pnpm: "pnpm";
280
+ }>>;
281
+ projectDir: z.ZodOptional<z.ZodString>;
282
+ }, z.core.$strip>, _orpc_server0.Schema<void, void>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
283
+ history: _orpc_server0.Procedure<_orpc_server0.MergedInitialContext<Record<never, never>, Record<never, never>, Record<never, never>>, Record<never, never>, z.ZodObject<{
284
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
285
+ clear: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
286
+ json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
287
+ }, z.core.$strip>, _orpc_server0.Schema<void, void>, _orpc_server0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
216
288
  };
217
289
  declare function createBtsCli(): trpc_cli0.TrpcCli;
290
+ /**
291
+ * Error types that can be returned from create/createVirtual
292
+ */
293
+ type CreateError = UserCancelledError | CLIError | ProjectCreationError;
218
294
  /**
219
295
  * Programmatic API to create a new Better-T-Stack project.
220
- * Returns pure JSON - no console output, no interactive prompts.
296
+ * Returns a Result type - no console output, no interactive prompts.
221
297
  *
222
298
  * @example
223
299
  * ```typescript
224
- * import { create } from "create-better-t-stack";
300
+ * import { create, Result } from "create-better-t-stack";
225
301
  *
226
302
  * const result = await create("my-app", {
227
303
  * frontend: ["tanstack-router"],
@@ -231,23 +307,27 @@ declare function createBtsCli(): trpc_cli0.TrpcCli;
231
307
  * orm: "drizzle",
232
308
  * });
233
309
  *
234
- * if (result.success) {
235
- * console.log(`Project created at: ${result.projectDirectory}`);
236
- * }
310
+ * result.match({
311
+ * ok: (data) => console.log(`Project created at: ${data.projectDirectory}`),
312
+ * err: (error) => console.error(`Failed: ${error.message}`),
313
+ * });
314
+ *
315
+ * // Or use unwrapOr for a default value
316
+ * const data = result.unwrapOr(null);
237
317
  * ```
238
318
  */
239
- declare function create(projectName?: string, options?: Partial<types_d_exports.CreateInput>): Promise<types_d_exports.InitResult>;
319
+ declare function create(projectName?: string, options?: Partial<types_d_exports.CreateInput>): Promise<Result$1<types_d_exports.InitResult, CreateError>>;
240
320
  declare function sponsors(): Promise<void>;
241
321
  declare function docs(): Promise<void>;
242
322
  declare function builder(): Promise<void>;
243
323
  /**
244
324
  * Programmatic API to generate a project in-memory (virtual filesystem).
245
- * Returns a VirtualFileTree without writing to disk.
325
+ * Returns a Result with a VirtualFileTree without writing to disk.
246
326
  * Useful for web previews and testing.
247
327
  *
248
328
  * @example
249
329
  * ```typescript
250
- * import { createVirtual, EMBEDDED_TEMPLATES } from "create-better-t-stack";
330
+ * import { createVirtual, EMBEDDED_TEMPLATES, Result } from "create-better-t-stack";
251
331
  *
252
332
  * const result = await createVirtual({
253
333
  * frontend: ["tanstack-router"],
@@ -257,16 +337,36 @@ declare function builder(): Promise<void>;
257
337
  * orm: "drizzle",
258
338
  * });
259
339
  *
260
- * if (result.success) {
261
- * console.log(`Generated ${result.tree.fileCount} files`);
340
+ * result.match({
341
+ * ok: (tree) => console.log(`Generated ${tree.fileCount} files`),
342
+ * err: (error) => console.error(`Failed: ${error.message}`),
343
+ * });
344
+ * ```
345
+ */
346
+ declare function createVirtual(options: Partial<Omit<types_d_exports.ProjectConfig, "projectDir" | "relativePath">>): Promise<Result$1<VirtualFileTree$1, GeneratorError$1>>;
347
+ /**
348
+ * Programmatic API to add addons to an existing Better-T-Stack project.
349
+ *
350
+ * @example
351
+ * ```typescript
352
+ * import { add } from "create-better-t-stack";
353
+ *
354
+ * const result = await add({
355
+ * addons: ["biome", "husky"],
356
+ * install: true,
357
+ * });
358
+ *
359
+ * if (result?.success) {
360
+ * console.log(`Added: ${result.addedAddons.join(", ")}`);
262
361
  * }
263
362
  * ```
264
363
  */
265
- declare function createVirtual(options: Partial<Omit<types_d_exports.ProjectConfig, "projectDir" | "relativePath">>): Promise<{
266
- success: boolean;
267
- tree?: VirtualFileTree$1;
268
- error?: string;
269
- }>;
364
+ declare function add(options?: {
365
+ addons?: types_d_exports.Addons[];
366
+ install?: boolean;
367
+ packageManager?: types_d_exports.PackageManager;
368
+ projectDir?: string;
369
+ }): Promise<AddResult | undefined>;
270
370
  type API = import__better_t_stack_types.API;
271
371
  type Addons = import__better_t_stack_types.Addons;
272
372
  type Auth = import__better_t_stack_types.Auth;
@@ -286,4 +386,4 @@ type Runtime = import__better_t_stack_types.Runtime;
286
386
  type ServerDeploy = import__better_t_stack_types.ServerDeploy;
287
387
  type Template = import__better_t_stack_types.Template;
288
388
  type WebDeploy = import__better_t_stack_types.WebDeploy;
289
- export { type API, type Addons, type Auth, type Backend, type BetterTStackConfig, type CreateInput, type Database, type DatabaseSetup, type DirectoryConflict, EMBEDDED_TEMPLATES, type Examples, type Frontend, type GeneratorOptions, type GeneratorResult, type InitResult, type ORM, type PackageManager, type Payments, type Runtime, type ServerDeploy, TEMPLATE_COUNT, type Template, type VirtualDirectory, type VirtualFile, VirtualFileSystem, type VirtualFileTree, type VirtualNode, type WebDeploy, builder, create, createBtsCli, createVirtual, docs, generateVirtualProject, router, sponsors };
389
+ export { type API, type AddResult, type Addons, type Auth, type Backend, type BetterTStackConfig, CLIError, CompatibilityError, CreateError, type CreateInput, type Database, type DatabaseSetup, DatabaseSetupError, type DirectoryConflict, DirectoryConflictError, EMBEDDED_TEMPLATES, type Examples, type Frontend, GeneratorError, type GeneratorOptions, type InitResult, type ORM, type PackageManager, type Payments, ProjectCreationError, Result, type Runtime, type ServerDeploy, TEMPLATE_COUNT, type Template, UserCancelledError, ValidationError, type VirtualDirectory, type VirtualFile, VirtualFileSystem, type VirtualFileTree, type VirtualNode, type WebDeploy, add, builder, create, createBtsCli, createVirtual, docs, generate, router, sponsors };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { a as create, c as docs, d as sponsors, i as builder, l as generateVirtualProject, n as TEMPLATE_COUNT, o as createBtsCli, r as VirtualFileSystem, s as createVirtual, t as EMBEDDED_TEMPLATES, u as router } from "./src-D5L84uxt.mjs";
2
+ import { _ as DatabaseSetupError, a as VirtualFileSystem, b as UserCancelledError, c as create, d as docs, f as generate, g as CompatibilityError, h as CLIError, i as TEMPLATE_COUNT, l as createBtsCli, m as sponsors, n as GeneratorError, o as add, p as router, r as Result, s as builder, t as EMBEDDED_TEMPLATES, u as createVirtual, v as DirectoryConflictError, x as ValidationError, y as ProjectCreationError } from "./src-_XtvURoM.mjs";
3
3
 
4
- export { EMBEDDED_TEMPLATES, TEMPLATE_COUNT, VirtualFileSystem, builder, create, createBtsCli, createVirtual, docs, generateVirtualProject, router, sponsors };
4
+ export { CLIError, CompatibilityError, DatabaseSetupError, DirectoryConflictError, EMBEDDED_TEMPLATES, GeneratorError, ProjectCreationError, Result, TEMPLATE_COUNT, UserCancelledError, ValidationError, VirtualFileSystem, add, builder, create, createBtsCli, createVirtual, docs, generate, router, sponsors };