create-better-t-stack
Version:
A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations
351 lines (350 loc) • 10.2 kB
TypeScript
import * as trpc_cli0 from "trpc-cli";
import { trpcServer } from "trpc-cli";
import z from "zod";
//#region src/types.d.ts
declare const DatabaseSchema: z.ZodEnum<{
none: "none";
sqlite: "sqlite";
postgres: "postgres";
mysql: "mysql";
mongodb: "mongodb";
}>;
type Database = z.infer<typeof DatabaseSchema>;
declare const ORMSchema: z.ZodEnum<{
none: "none";
drizzle: "drizzle";
prisma: "prisma";
mongoose: "mongoose";
}>;
type ORM = z.infer<typeof ORMSchema>;
declare const BackendSchema: z.ZodEnum<{
none: "none";
next: "next";
hono: "hono";
express: "express";
fastify: "fastify";
elysia: "elysia";
convex: "convex";
}>;
type Backend = z.infer<typeof BackendSchema>;
declare const RuntimeSchema: z.ZodEnum<{
none: "none";
bun: "bun";
node: "node";
workers: "workers";
}>;
type Runtime = z.infer<typeof RuntimeSchema>;
declare const FrontendSchema: z.ZodEnum<{
none: "none";
"tanstack-router": "tanstack-router";
"react-router": "react-router";
"tanstack-start": "tanstack-start";
next: "next";
nuxt: "nuxt";
"native-nativewind": "native-nativewind";
"native-unistyles": "native-unistyles";
svelte: "svelte";
solid: "solid";
}>;
type Frontend = z.infer<typeof FrontendSchema>;
declare const AddonsSchema: z.ZodEnum<{
none: "none";
pwa: "pwa";
tauri: "tauri";
starlight: "starlight";
biome: "biome";
husky: "husky";
ruler: "ruler";
turborepo: "turborepo";
fumadocs: "fumadocs";
ultracite: "ultracite";
oxlint: "oxlint";
}>;
type Addons = z.infer<typeof AddonsSchema>;
declare const ExamplesSchema: z.ZodEnum<{
none: "none";
todo: "todo";
ai: "ai";
}>;
type Examples = z.infer<typeof ExamplesSchema>;
declare const PackageManagerSchema: z.ZodEnum<{
npm: "npm";
pnpm: "pnpm";
bun: "bun";
}>;
type PackageManager = z.infer<typeof PackageManagerSchema>;
declare const DatabaseSetupSchema: z.ZodEnum<{
none: "none";
turso: "turso";
neon: "neon";
"prisma-postgres": "prisma-postgres";
planetscale: "planetscale";
"mongodb-atlas": "mongodb-atlas";
supabase: "supabase";
d1: "d1";
docker: "docker";
}>;
type DatabaseSetup = z.infer<typeof DatabaseSetupSchema>;
declare const APISchema: z.ZodEnum<{
none: "none";
trpc: "trpc";
orpc: "orpc";
}>;
type API = z.infer<typeof APISchema>;
declare const AuthSchema: z.ZodEnum<{
none: "none";
"better-auth": "better-auth";
clerk: "clerk";
}>;
type Auth = z.infer<typeof AuthSchema>;
declare const PaymentsSchema: z.ZodEnum<{
none: "none";
polar: "polar";
}>;
type Payments = z.infer<typeof PaymentsSchema>;
declare const WebDeploySchema: z.ZodEnum<{
none: "none";
wrangler: "wrangler";
alchemy: "alchemy";
}>;
type WebDeploy = z.infer<typeof WebDeploySchema>;
declare const ServerDeploySchema: z.ZodEnum<{
none: "none";
wrangler: "wrangler";
alchemy: "alchemy";
}>;
type ServerDeploy = z.infer<typeof ServerDeploySchema>;
declare const DirectoryConflictSchema: z.ZodEnum<{
error: "error";
merge: "merge";
overwrite: "overwrite";
increment: "increment";
}>;
type DirectoryConflict = z.infer<typeof DirectoryConflictSchema>;
type CreateInput = {
projectName?: string;
yes?: boolean;
yolo?: boolean;
verbose?: boolean;
database?: Database;
orm?: ORM;
auth?: Auth;
payments?: Payments;
frontend?: Frontend[];
addons?: Addons[];
examples?: Examples[];
git?: boolean;
packageManager?: PackageManager;
install?: boolean;
dbSetup?: DatabaseSetup;
backend?: Backend;
runtime?: Runtime;
api?: API;
webDeploy?: WebDeploy;
serverDeploy?: ServerDeploy;
directoryConflict?: DirectoryConflict;
renderTitle?: boolean;
disableAnalytics?: boolean;
manualDb?: boolean;
};
type AddInput = {
addons?: Addons[];
webDeploy?: WebDeploy;
serverDeploy?: ServerDeploy;
projectDir?: string;
install?: boolean;
packageManager?: PackageManager;
};
interface ProjectConfig {
projectName: string;
projectDir: string;
relativePath: string;
database: Database;
orm: ORM;
backend: Backend;
runtime: Runtime;
frontend: Frontend[];
addons: Addons[];
examples: Examples[];
auth: Auth;
payments: Payments;
git: boolean;
packageManager: PackageManager;
install: boolean;
dbSetup: DatabaseSetup;
api: API;
webDeploy: WebDeploy;
serverDeploy: ServerDeploy;
}
interface BetterTStackConfig {
version: string;
createdAt: string;
database: Database;
orm: ORM;
backend: Backend;
runtime: Runtime;
frontend: Frontend[];
addons: Addons[];
examples: Examples[];
auth: Auth;
payments: Payments;
packageManager: PackageManager;
dbSetup: DatabaseSetup;
api: API;
webDeploy: WebDeploy;
serverDeploy: ServerDeploy;
}
interface InitResult {
success: boolean;
projectConfig: ProjectConfig;
reproducibleCommand: string;
timeScaffolded: string;
elapsedTimeMs: number;
projectDirectory: string;
relativePath: string;
error?: string;
}
//#endregion
//#region src/index.d.ts
declare const router: trpcServer.TRPCBuiltRouter<{
ctx: object;
meta: object;
errorShape: trpcServer.TRPCDefaultErrorShape;
transformer: false;
}, trpcServer.TRPCDecorateCreateRouterOptions<{
init: trpcServer.TRPCMutationProcedure<{
input: [string | undefined, {
yes?: boolean | undefined;
yolo?: boolean | undefined;
verbose?: boolean | undefined;
database?: "none" | "sqlite" | "postgres" | "mysql" | "mongodb" | undefined;
orm?: "none" | "drizzle" | "prisma" | "mongoose" | undefined;
auth?: "none" | "better-auth" | "clerk" | undefined;
payments?: "none" | "polar" | undefined;
frontend?: ("none" | "tanstack-router" | "react-router" | "tanstack-start" | "next" | "nuxt" | "native-nativewind" | "native-unistyles" | "svelte" | "solid")[] | undefined;
addons?: ("none" | "pwa" | "tauri" | "starlight" | "biome" | "husky" | "ruler" | "turborepo" | "fumadocs" | "ultracite" | "oxlint")[] | undefined;
examples?: ("none" | "todo" | "ai")[] | undefined;
git?: boolean | undefined;
packageManager?: "npm" | "pnpm" | "bun" | undefined;
install?: boolean | undefined;
dbSetup?: "none" | "turso" | "neon" | "prisma-postgres" | "planetscale" | "mongodb-atlas" | "supabase" | "d1" | "docker" | undefined;
backend?: "none" | "next" | "hono" | "express" | "fastify" | "elysia" | "convex" | undefined;
runtime?: "none" | "bun" | "node" | "workers" | undefined;
api?: "none" | "trpc" | "orpc" | undefined;
webDeploy?: "none" | "wrangler" | "alchemy" | undefined;
serverDeploy?: "none" | "wrangler" | "alchemy" | undefined;
directoryConflict?: "error" | "merge" | "overwrite" | "increment" | undefined;
renderTitle?: boolean | undefined;
disableAnalytics?: boolean | undefined;
manualDb?: boolean | undefined;
}];
output: {
success: boolean;
projectConfig: {
projectName: string;
projectDir: string;
relativePath: string;
database: "none";
orm: "none";
backend: "none";
runtime: "none";
frontend: never[];
addons: never[];
examples: never[];
auth: "none";
payments: "none";
git: false;
packageManager: "npm";
install: false;
dbSetup: "none";
api: "none";
webDeploy: "none";
serverDeploy: "none";
};
reproducibleCommand: string;
timeScaffolded: string;
elapsedTimeMs: number;
projectDirectory: string;
relativePath: string;
error: string;
} | {
success: boolean;
projectConfig: ProjectConfig;
reproducibleCommand: string;
timeScaffolded: string;
elapsedTimeMs: number;
projectDirectory: string;
relativePath: string;
error?: undefined;
} | undefined;
meta: object;
}>;
add: trpcServer.TRPCMutationProcedure<{
input: [{
addons?: ("none" | "pwa" | "tauri" | "starlight" | "biome" | "husky" | "ruler" | "turborepo" | "fumadocs" | "ultracite" | "oxlint")[] | undefined;
webDeploy?: "none" | "wrangler" | "alchemy" | undefined;
serverDeploy?: "none" | "wrangler" | "alchemy" | undefined;
projectDir?: string | undefined;
install?: boolean | undefined;
packageManager?: "npm" | "pnpm" | "bun" | undefined;
}];
output: void;
meta: object;
}>;
sponsors: trpcServer.TRPCMutationProcedure<{
input: void;
output: void;
meta: object;
}>;
docs: trpcServer.TRPCMutationProcedure<{
input: void;
output: void;
meta: object;
}>;
builder: trpcServer.TRPCMutationProcedure<{
input: void;
output: void;
meta: object;
}>;
}>>;
declare function createBtsCli(): trpc_cli0.TrpcCli;
/**
* Initialize a new Better-T-Stack project
*
* @example CLI usage:
* ```bash
* npx create-better-t-stack my-app --yes
* ```
*
* @example Programmatic usage (always returns structured data):
* ```typescript
* import { init } from "create-better-t-stack";
*
* const result = await init("my-app", {
* yes: true,
* frontend: ["tanstack-router"],
* backend: "hono",
* database: "sqlite",
* orm: "drizzle",
* auth: "better-auth",
* addons: ["biome", "turborepo"],
* packageManager: "bun",
* install: false,
* directoryConflict: "increment", // auto-handle conflicts
* disableAnalytics: true, // disable analytics
* });
*
* if (result.success) {
* console.log(`Project created at: ${result.projectDirectory}`);
* console.log(`Reproducible command: ${result.reproducibleCommand}`);
* console.log(`Time taken: ${result.elapsedTimeMs}ms`);
* }
* ```
*/
declare function init(projectName?: string, options?: CreateInput): Promise<InitResult>;
declare function sponsors(): Promise<void>;
declare function docs(): Promise<void>;
declare function builder(): Promise<void>;
//#endregion
export { type API, type AddInput, type Addons, type Backend, type BetterTStackConfig, type CreateInput, type Database, type DatabaseSetup, type DirectoryConflict, type Examples, type Frontend, type InitResult, type ORM, type PackageManager, type ProjectConfig, type Runtime, type ServerDeploy, type WebDeploy, builder, createBtsCli, docs, init, router, sponsors };