|
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"; |
0 commit comments