Skip to content

Commit 19b625c

Browse files
feat: add @better-t-stack/types package
1 parent f650774 commit 19b625c

File tree

8 files changed

+270
-197
lines changed

8 files changed

+270
-197
lines changed

apps/cli/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"prepublishOnly": "npm run build"
5454
},
5555
"dependencies": {
56+
"@better-t-stack/types": "workspace:*",
5657
"@clack/prompts": "^0.11.0",
5758
"consola": "^3.4.2",
5859
"execa": "^9.6.0",
@@ -62,15 +63,15 @@
6263
"handlebars": "^4.7.8",
6364
"jsonc-parser": "^3.3.1",
6465
"picocolors": "^1.1.1",
65-
"posthog-node": "^5.5.0",
66-
"trpc-cli": "^0.10.0",
66+
"posthog-node": "^5.6.0",
67+
"trpc-cli": "^0.10.2",
6768
"ts-morph": "^26.0.0",
68-
"zod": "^4.0.5"
69+
"zod": "^4.0.14"
6970
},
7071
"devDependencies": {
7172
"@types/fs-extra": "^11.0.4",
72-
"@types/node": "^24.0.13",
73-
"tsdown": "^0.12.9",
74-
"typescript": "^5.8.3"
73+
"@types/node": "^24.2.0",
74+
"tsdown": "^0.13.3",
75+
"typescript": "^5.9.2"
7576
}
7677
}

apps/cli/src/types.ts

Lines changed: 1 addition & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -1,180 +1 @@
1-
import z from "zod";
2-
3-
export const DatabaseSchema = z
4-
.enum(["none", "sqlite", "postgres", "mysql", "mongodb"])
5-
.describe("Database type");
6-
export type Database = z.infer<typeof DatabaseSchema>;
7-
8-
export const ORMSchema = z
9-
.enum(["drizzle", "prisma", "mongoose", "none"])
10-
.describe("ORM type");
11-
export type ORM = z.infer<typeof ORMSchema>;
12-
13-
export const BackendSchema = z
14-
.enum(["hono", "express", "fastify", "next", "elysia", "convex", "none"])
15-
.describe("Backend framework");
16-
export type Backend = z.infer<typeof BackendSchema>;
17-
18-
export const RuntimeSchema = z
19-
.enum(["bun", "node", "workers", "none"])
20-
.describe(
21-
"Runtime environment (workers only available with hono backend and drizzle orm)",
22-
);
23-
export type Runtime = z.infer<typeof RuntimeSchema>;
24-
25-
export const FrontendSchema = z
26-
.enum([
27-
"tanstack-router",
28-
"react-router",
29-
"tanstack-start",
30-
"next",
31-
"nuxt",
32-
"native-nativewind",
33-
"native-unistyles",
34-
"svelte",
35-
"solid",
36-
"none",
37-
])
38-
.describe("Frontend framework");
39-
export type Frontend = z.infer<typeof FrontendSchema>;
40-
41-
export const AddonsSchema = z
42-
.enum([
43-
"pwa",
44-
"tauri",
45-
"starlight",
46-
"biome",
47-
"husky",
48-
"turborepo",
49-
"fumadocs",
50-
"ultracite",
51-
"oxlint",
52-
"none",
53-
])
54-
.describe("Additional addons");
55-
export type Addons = z.infer<typeof AddonsSchema>;
56-
57-
export const ExamplesSchema = z
58-
.enum(["todo", "ai", "none"])
59-
.describe("Example templates to include");
60-
export type Examples = z.infer<typeof ExamplesSchema>;
61-
62-
export const PackageManagerSchema = z
63-
.enum(["npm", "pnpm", "bun"])
64-
.describe("Package manager");
65-
export type PackageManager = z.infer<typeof PackageManagerSchema>;
66-
67-
export const DatabaseSetupSchema = z
68-
.enum([
69-
"turso",
70-
"neon",
71-
"prisma-postgres",
72-
"mongodb-atlas",
73-
"supabase",
74-
"d1",
75-
"docker",
76-
"none",
77-
])
78-
.describe("Database hosting setup");
79-
export type DatabaseSetup = z.infer<typeof DatabaseSetupSchema>;
80-
81-
export const APISchema = z.enum(["trpc", "orpc", "none"]).describe("API type");
82-
export type API = z.infer<typeof APISchema>;
83-
84-
export const ProjectNameSchema = z
85-
.string()
86-
.min(1, "Project name cannot be empty")
87-
.max(255, "Project name must be less than 255 characters")
88-
.refine(
89-
(name) => name === "." || !name.startsWith("."),
90-
"Project name cannot start with a dot (except for '.')",
91-
)
92-
.refine(
93-
(name) => name === "." || !name.startsWith("-"),
94-
"Project name cannot start with a dash",
95-
)
96-
.refine((name) => {
97-
const invalidChars = ["<", ">", ":", '"', "|", "?", "*"];
98-
return !invalidChars.some((char) => name.includes(char));
99-
}, "Project name contains invalid characters")
100-
.refine(
101-
(name) => name.toLowerCase() !== "node_modules",
102-
"Project name is reserved",
103-
)
104-
.describe("Project name or path");
105-
export type ProjectName = z.infer<typeof ProjectNameSchema>;
106-
107-
export const WebDeploySchema = z
108-
.enum(["workers", "none"])
109-
.describe("Web deployment");
110-
export type WebDeploy = z.infer<typeof WebDeploySchema>;
111-
112-
export type CreateInput = {
113-
projectName?: string;
114-
yes?: boolean;
115-
database?: Database;
116-
orm?: ORM;
117-
auth?: boolean;
118-
frontend?: Frontend[];
119-
addons?: Addons[];
120-
examples?: Examples[];
121-
git?: boolean;
122-
packageManager?: PackageManager;
123-
install?: boolean;
124-
dbSetup?: DatabaseSetup;
125-
backend?: Backend;
126-
runtime?: Runtime;
127-
api?: API;
128-
webDeploy?: WebDeploy;
129-
};
130-
131-
export type AddInput = {
132-
addons?: Addons[];
133-
webDeploy?: WebDeploy;
134-
projectDir?: string;
135-
install?: boolean;
136-
packageManager?: PackageManager;
137-
};
138-
139-
export type CLIInput = CreateInput & {
140-
projectDirectory?: string;
141-
};
142-
143-
export interface ProjectConfig {
144-
projectName: string;
145-
projectDir: string;
146-
relativePath: string;
147-
database: Database;
148-
orm: ORM;
149-
backend: Backend;
150-
runtime: Runtime;
151-
frontend: Frontend[];
152-
addons: Addons[];
153-
examples: Examples[];
154-
auth: boolean;
155-
git: boolean;
156-
packageManager: PackageManager;
157-
install: boolean;
158-
dbSetup: DatabaseSetup;
159-
api: API;
160-
webDeploy: WebDeploy;
161-
}
162-
163-
export interface BetterTStackConfig {
164-
version: string;
165-
createdAt: string;
166-
database: Database;
167-
orm: ORM;
168-
backend: Backend;
169-
runtime: Runtime;
170-
frontend: Frontend[];
171-
addons: Addons[];
172-
examples: Examples[];
173-
auth: boolean;
174-
packageManager: PackageManager;
175-
dbSetup: DatabaseSetup;
176-
api: API;
177-
webDeploy: WebDeploy;
178-
}
179-
180-
export type AvailablePackageManagers = "npm" | "pnpm" | "bun";
1+
export * from "@better-t-stack/types";

apps/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
},
1717
"dependencies": {
1818
"@better-t-stack/backend": "workspace:*",
19+
"@better-t-stack/types": "workspace:*",
1920
"@erquhart/convex-oss-stats": "^0.8.1",
2021
"@number-flow/react": "^0.5.10",
2122
"@opennextjs/cloudflare": "^1.6.3",

apps/web/scripts/generate-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
PackageManagerSchema,
1515
RuntimeSchema,
1616
WebDeploySchema,
17-
} from "../../cli/src/types";
17+
} from "@better-t-stack/types";
1818

1919
const DATABASE_VALUES = DatabaseSchema.options;
2020
const ORM_VALUES = ORMSchema.options;

0 commit comments

Comments
 (0)