create-better-t-stack 3.22.0 → 3.22.3
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.
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//#region
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __exportAll = (all, no_symbols) => {
|
|
8
|
+
let target = {};
|
|
9
|
+
for (var name in all) {
|
|
10
|
+
__defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (!no_symbols) {
|
|
16
|
+
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
7
20
|
var __copyProps = (to, from, except, desc) => {
|
|
8
21
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
22
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -21,4 +34,4 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
34
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
22
35
|
|
|
23
36
|
//#endregion
|
|
24
|
-
export { __reExport as t };
|
|
37
|
+
export { __reExport as n, __exportAll as t };
|
package/dist/cli.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Result, Result as Result$1, TaggedError } from "better-result";
|
|
5
|
-
import { createCli } from "trpc-cli";
|
|
2
|
+
import { n as __reExport, t as __exportAll } from "./chunk-C8ucw2H5.mjs";
|
|
3
|
+
import { Result, TaggedError } from "better-result";
|
|
6
4
|
import z from "zod";
|
|
7
5
|
import { autocompleteMultiselect, cancel, confirm, group, intro, isCancel, log, multiselect, outro, select, spinner, text } from "@clack/prompts";
|
|
8
6
|
import pc from "picocolors";
|
|
@@ -10,7 +8,7 @@ import envPaths from "env-paths";
|
|
|
10
8
|
import fs from "fs-extra";
|
|
11
9
|
import path from "node:path";
|
|
12
10
|
import { fileURLToPath } from "node:url";
|
|
13
|
-
import { EMBEDDED_TEMPLATES,
|
|
11
|
+
import { EMBEDDED_TEMPLATES, VirtualFileSystem, dependencyVersionMap, generate, generateReproducibleCommand, processAddonTemplates, processAddonsDeps } from "@better-t-stack/template-generator";
|
|
14
12
|
import consola, { consola as consola$1 } from "consola";
|
|
15
13
|
import gradient from "gradient-string";
|
|
16
14
|
import { $, execa } from "execa";
|
|
@@ -18,7 +16,7 @@ import { writeTree } from "@better-t-stack/template-generator/fs-writer";
|
|
|
18
16
|
import { ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, SelectPrompt, isCancel as isCancel$1 } from "@clack/core";
|
|
19
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
20
18
|
import { applyEdits, modify, parse } from "jsonc-parser";
|
|
21
|
-
import os
|
|
19
|
+
import os from "node:os";
|
|
22
20
|
import { format } from "oxfmt";
|
|
23
21
|
|
|
24
22
|
//#region src/utils/get-package-manager.ts
|
|
@@ -622,7 +620,7 @@ async function openBuilderCommand() {
|
|
|
622
620
|
|
|
623
621
|
//#endregion
|
|
624
622
|
//#region src/types.ts
|
|
625
|
-
var types_exports = {};
|
|
623
|
+
var types_exports = /* @__PURE__ */ __exportAll({});
|
|
626
624
|
import * as import__better_t_stack_types from "@better-t-stack/types";
|
|
627
625
|
__reExport(types_exports, import__better_t_stack_types);
|
|
628
626
|
|
|
@@ -5410,7 +5408,7 @@ async function setupTurso(config, cliInput) {
|
|
|
5410
5408
|
return Result.ok(void 0);
|
|
5411
5409
|
}
|
|
5412
5410
|
setupSpinner.start("Checking Turso CLI availability...");
|
|
5413
|
-
const platform = os
|
|
5411
|
+
const platform = os.platform();
|
|
5414
5412
|
const isMac = platform === "darwin";
|
|
5415
5413
|
if (platform === "win32") {
|
|
5416
5414
|
setupSpinner.stop(pc.yellow("Turso setup not supported on Windows"));
|
|
@@ -5587,7 +5585,7 @@ function getDockerInstallInstructions(platform, database) {
|
|
|
5587
5585
|
return `${pc.yellow("IMPORTANT:")} Docker required for ${databaseName}. Install for ${platformName}:\n${pc.blue(installUrl)}`;
|
|
5588
5586
|
}
|
|
5589
5587
|
async function getDockerStatus(database) {
|
|
5590
|
-
const platform = os
|
|
5588
|
+
const platform = os.platform();
|
|
5591
5589
|
if (!await isDockerInstalled()) return {
|
|
5592
5590
|
installed: false,
|
|
5593
5591
|
running: false,
|
|
@@ -5853,7 +5851,7 @@ async function setPackageManagerVersion(projectDir, packageManager) {
|
|
|
5853
5851
|
if (!await fs.pathExists(pkgJsonPath)) return Result.ok(void 0);
|
|
5854
5852
|
const versionResult = await Result.tryPromise({
|
|
5855
5853
|
try: async () => {
|
|
5856
|
-
const { stdout } = await $({ cwd: os
|
|
5854
|
+
const { stdout } = await $({ cwd: os.tmpdir() })`${packageManager} -v`;
|
|
5857
5855
|
return stdout.trim();
|
|
5858
5856
|
},
|
|
5859
5857
|
catch: () => null
|
|
@@ -6134,202 +6132,4 @@ async function handleDirectoryConflictProgrammatically(currentPathInput, strateg
|
|
|
6134
6132
|
}
|
|
6135
6133
|
|
|
6136
6134
|
//#endregion
|
|
6137
|
-
|
|
6138
|
-
const router = os.router({
|
|
6139
|
-
create: os.meta({
|
|
6140
|
-
description: "Create a new Better-T-Stack project",
|
|
6141
|
-
default: true,
|
|
6142
|
-
negateBooleans: true
|
|
6143
|
-
}).input(z.tuple([types_exports.ProjectNameSchema.optional(), z.object({
|
|
6144
|
-
template: types_exports.TemplateSchema.optional().describe("Use a predefined template"),
|
|
6145
|
-
yes: z.boolean().optional().default(false).describe("Use default configuration"),
|
|
6146
|
-
yolo: z.boolean().optional().default(false).describe("(WARNING - NOT RECOMMENDED) Bypass validations and compatibility checks"),
|
|
6147
|
-
verbose: z.boolean().optional().default(false).describe("Show detailed result information"),
|
|
6148
|
-
database: types_exports.DatabaseSchema.optional(),
|
|
6149
|
-
orm: types_exports.ORMSchema.optional(),
|
|
6150
|
-
auth: types_exports.AuthSchema.optional(),
|
|
6151
|
-
payments: types_exports.PaymentsSchema.optional(),
|
|
6152
|
-
frontend: z.array(types_exports.FrontendSchema).optional(),
|
|
6153
|
-
addons: z.array(types_exports.AddonsSchema).optional(),
|
|
6154
|
-
examples: z.array(types_exports.ExamplesSchema).optional(),
|
|
6155
|
-
git: z.boolean().optional(),
|
|
6156
|
-
packageManager: types_exports.PackageManagerSchema.optional(),
|
|
6157
|
-
install: z.boolean().optional(),
|
|
6158
|
-
dbSetup: types_exports.DatabaseSetupSchema.optional(),
|
|
6159
|
-
backend: types_exports.BackendSchema.optional(),
|
|
6160
|
-
runtime: types_exports.RuntimeSchema.optional(),
|
|
6161
|
-
api: types_exports.APISchema.optional(),
|
|
6162
|
-
webDeploy: types_exports.WebDeploySchema.optional(),
|
|
6163
|
-
serverDeploy: types_exports.ServerDeploySchema.optional(),
|
|
6164
|
-
directoryConflict: types_exports.DirectoryConflictSchema.optional(),
|
|
6165
|
-
renderTitle: z.boolean().optional(),
|
|
6166
|
-
disableAnalytics: z.boolean().optional().default(false).describe("Disable analytics"),
|
|
6167
|
-
manualDb: z.boolean().optional().default(false).describe("Skip automatic/manual database setup prompt and use manual setup")
|
|
6168
|
-
})])).handler(async ({ input }) => {
|
|
6169
|
-
const [projectName, options] = input;
|
|
6170
|
-
const result = await createProjectHandler({
|
|
6171
|
-
projectName,
|
|
6172
|
-
...options
|
|
6173
|
-
});
|
|
6174
|
-
if (options.verbose) return result;
|
|
6175
|
-
}),
|
|
6176
|
-
sponsors: os.meta({ description: "Show Better-T-Stack sponsors" }).handler(showSponsorsCommand),
|
|
6177
|
-
docs: os.meta({ description: "Open Better-T-Stack documentation" }).handler(openDocsCommand),
|
|
6178
|
-
builder: os.meta({ description: "Open the web-based stack builder" }).handler(openBuilderCommand),
|
|
6179
|
-
add: os.meta({ description: "Add addons to an existing Better-T-Stack project" }).input(z.object({
|
|
6180
|
-
addons: z.array(types_exports.AddonsSchema).optional().describe("Addons to add"),
|
|
6181
|
-
install: z.boolean().optional().default(false).describe("Install dependencies after adding"),
|
|
6182
|
-
packageManager: types_exports.PackageManagerSchema.optional().describe("Package manager to use"),
|
|
6183
|
-
projectDir: z.string().optional().describe("Project directory (defaults to current)")
|
|
6184
|
-
})).handler(async ({ input }) => {
|
|
6185
|
-
await addHandler(input);
|
|
6186
|
-
}),
|
|
6187
|
-
history: os.meta({ description: "Show project creation history" }).input(z.object({
|
|
6188
|
-
limit: z.number().optional().default(10).describe("Number of entries to show"),
|
|
6189
|
-
clear: z.boolean().optional().default(false).describe("Clear all history"),
|
|
6190
|
-
json: z.boolean().optional().default(false).describe("Output as JSON")
|
|
6191
|
-
})).handler(async ({ input }) => {
|
|
6192
|
-
await historyHandler(input);
|
|
6193
|
-
})
|
|
6194
|
-
});
|
|
6195
|
-
const caller = createRouterClient(router, { context: {} });
|
|
6196
|
-
function createBtsCli() {
|
|
6197
|
-
return createCli({
|
|
6198
|
-
router,
|
|
6199
|
-
name: "create-better-t-stack",
|
|
6200
|
-
version: getLatestCLIVersion()
|
|
6201
|
-
});
|
|
6202
|
-
}
|
|
6203
|
-
/**
|
|
6204
|
-
* Programmatic API to create a new Better-T-Stack project.
|
|
6205
|
-
* Returns a Result type - no console output, no interactive prompts.
|
|
6206
|
-
*
|
|
6207
|
-
* @example
|
|
6208
|
-
* ```typescript
|
|
6209
|
-
* import { create, Result } from "create-better-t-stack";
|
|
6210
|
-
*
|
|
6211
|
-
* const result = await create("my-app", {
|
|
6212
|
-
* frontend: ["tanstack-router"],
|
|
6213
|
-
* backend: "hono",
|
|
6214
|
-
* runtime: "bun",
|
|
6215
|
-
* database: "sqlite",
|
|
6216
|
-
* orm: "drizzle",
|
|
6217
|
-
* });
|
|
6218
|
-
*
|
|
6219
|
-
* result.match({
|
|
6220
|
-
* ok: (data) => console.log(`Project created at: ${data.projectDirectory}`),
|
|
6221
|
-
* err: (error) => console.error(`Failed: ${error.message}`),
|
|
6222
|
-
* });
|
|
6223
|
-
*
|
|
6224
|
-
* // Or use unwrapOr for a default value
|
|
6225
|
-
* const data = result.unwrapOr(null);
|
|
6226
|
-
* ```
|
|
6227
|
-
*/
|
|
6228
|
-
async function create(projectName, options) {
|
|
6229
|
-
const input = {
|
|
6230
|
-
...options,
|
|
6231
|
-
projectName,
|
|
6232
|
-
renderTitle: false,
|
|
6233
|
-
verbose: true,
|
|
6234
|
-
disableAnalytics: options?.disableAnalytics ?? true,
|
|
6235
|
-
directoryConflict: options?.directoryConflict ?? "error"
|
|
6236
|
-
};
|
|
6237
|
-
return Result.tryPromise({
|
|
6238
|
-
try: async () => {
|
|
6239
|
-
const result = await createProjectHandler(input, { silent: true });
|
|
6240
|
-
if (!result) throw new UserCancelledError({ message: "Operation cancelled" });
|
|
6241
|
-
if (!result.success) throw new CLIError({ message: result.error || "Unknown error occurred" });
|
|
6242
|
-
return result;
|
|
6243
|
-
},
|
|
6244
|
-
catch: (e) => {
|
|
6245
|
-
if (e instanceof UserCancelledError) return e;
|
|
6246
|
-
if (e instanceof CLIError) return e;
|
|
6247
|
-
if (e instanceof ProjectCreationError) return e;
|
|
6248
|
-
return new CLIError({
|
|
6249
|
-
message: e instanceof Error ? e.message : String(e),
|
|
6250
|
-
cause: e
|
|
6251
|
-
});
|
|
6252
|
-
}
|
|
6253
|
-
});
|
|
6254
|
-
}
|
|
6255
|
-
async function sponsors() {
|
|
6256
|
-
return caller.sponsors();
|
|
6257
|
-
}
|
|
6258
|
-
async function docs() {
|
|
6259
|
-
return caller.docs();
|
|
6260
|
-
}
|
|
6261
|
-
async function builder() {
|
|
6262
|
-
return caller.builder();
|
|
6263
|
-
}
|
|
6264
|
-
/**
|
|
6265
|
-
* Programmatic API to generate a project in-memory (virtual filesystem).
|
|
6266
|
-
* Returns a Result with a VirtualFileTree without writing to disk.
|
|
6267
|
-
* Useful for web previews and testing.
|
|
6268
|
-
*
|
|
6269
|
-
* @example
|
|
6270
|
-
* ```typescript
|
|
6271
|
-
* import { createVirtual, EMBEDDED_TEMPLATES, Result } from "create-better-t-stack";
|
|
6272
|
-
*
|
|
6273
|
-
* const result = await createVirtual({
|
|
6274
|
-
* frontend: ["tanstack-router"],
|
|
6275
|
-
* backend: "hono",
|
|
6276
|
-
* runtime: "bun",
|
|
6277
|
-
* database: "sqlite",
|
|
6278
|
-
* orm: "drizzle",
|
|
6279
|
-
* });
|
|
6280
|
-
*
|
|
6281
|
-
* result.match({
|
|
6282
|
-
* ok: (tree) => console.log(`Generated ${tree.fileCount} files`),
|
|
6283
|
-
* err: (error) => console.error(`Failed: ${error.message}`),
|
|
6284
|
-
* });
|
|
6285
|
-
* ```
|
|
6286
|
-
*/
|
|
6287
|
-
async function createVirtual(options) {
|
|
6288
|
-
return generate({
|
|
6289
|
-
config: {
|
|
6290
|
-
projectName: options.projectName || "my-project",
|
|
6291
|
-
projectDir: "/virtual",
|
|
6292
|
-
relativePath: "./virtual",
|
|
6293
|
-
database: options.database || "none",
|
|
6294
|
-
orm: options.orm || "none",
|
|
6295
|
-
backend: options.backend || "hono",
|
|
6296
|
-
runtime: options.runtime || "bun",
|
|
6297
|
-
frontend: options.frontend || ["tanstack-router"],
|
|
6298
|
-
addons: options.addons || [],
|
|
6299
|
-
examples: options.examples || [],
|
|
6300
|
-
auth: options.auth || "none",
|
|
6301
|
-
payments: options.payments || "none",
|
|
6302
|
-
git: options.git ?? false,
|
|
6303
|
-
packageManager: options.packageManager || "bun",
|
|
6304
|
-
install: false,
|
|
6305
|
-
dbSetup: options.dbSetup || "none",
|
|
6306
|
-
api: options.api || "trpc",
|
|
6307
|
-
webDeploy: options.webDeploy || "none",
|
|
6308
|
-
serverDeploy: options.serverDeploy || "none"
|
|
6309
|
-
},
|
|
6310
|
-
templates: EMBEDDED_TEMPLATES
|
|
6311
|
-
});
|
|
6312
|
-
}
|
|
6313
|
-
/**
|
|
6314
|
-
* Programmatic API to add addons to an existing Better-T-Stack project.
|
|
6315
|
-
*
|
|
6316
|
-
* @example
|
|
6317
|
-
* ```typescript
|
|
6318
|
-
* import { add } from "create-better-t-stack";
|
|
6319
|
-
*
|
|
6320
|
-
* const result = await add({
|
|
6321
|
-
* addons: ["biome", "husky"],
|
|
6322
|
-
* install: true,
|
|
6323
|
-
* });
|
|
6324
|
-
*
|
|
6325
|
-
* if (result?.success) {
|
|
6326
|
-
* console.log(`Added: ${result.addedAddons.join(", ")}`);
|
|
6327
|
-
* }
|
|
6328
|
-
* ```
|
|
6329
|
-
*/
|
|
6330
|
-
async function add(options = {}) {
|
|
6331
|
-
return addHandler(options, { silent: true });
|
|
6332
|
-
}
|
|
6333
|
-
|
|
6334
|
-
//#endregion
|
|
6335
|
-
export { DatabaseSetupError as _, VirtualFileSystem$1 as a, UserCancelledError as b, create as c, docs as d, generate$1 as f, CompatibilityError as g, CLIError as h, TEMPLATE_COUNT as i, createBtsCli as l, sponsors as m, GeneratorError$1 as n, add as o, router as p, Result$1 as r, builder as s, EMBEDDED_TEMPLATES$1 as t, createVirtual as u, DirectoryConflictError as v, ValidationError as x, ProjectCreationError as y };
|
|
6135
|
+
export { openDocsCommand as a, getLatestCLIVersion as c, DatabaseSetupError as d, DirectoryConflictError as f, ValidationError as h, openBuilderCommand as i, CLIError as l, UserCancelledError as m, addHandler as n, showSponsorsCommand as o, ProjectCreationError as p, types_exports as r, historyHandler as s, createProjectHandler as t, CompatibilityError as u };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,207 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { a as openDocsCommand, c as getLatestCLIVersion, d as DatabaseSetupError, f as DirectoryConflictError, h as ValidationError, i as openBuilderCommand, l as CLIError, m as UserCancelledError, n as addHandler, o as showSponsorsCommand, p as ProjectCreationError, r as types_exports, s as historyHandler, t as createProjectHandler, u as CompatibilityError } from "./command-handlers-Dvaw7W_l.mjs";
|
|
3
|
+
import { createRouterClient, os } from "@orpc/server";
|
|
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";
|
|
3
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
|
|
4
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-better-t-stack",
|
|
3
|
-
"version": "3.22.
|
|
3
|
+
"version": "3.22.3",
|
|
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",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"prepublishOnly": "npm run build"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@better-t-stack/template-generator": "^3.22.
|
|
74
|
-
"@better-t-stack/types": "^3.22.
|
|
73
|
+
"@better-t-stack/template-generator": "^3.22.3",
|
|
74
|
+
"@better-t-stack/types": "^3.22.3",
|
|
75
75
|
"@clack/core": "^1.0.0",
|
|
76
76
|
"@clack/prompts": "^1.0.0",
|
|
77
77
|
"@orpc/server": "^1.13.4",
|