use zod for project name validation

This commit is contained in:
Aman Varshney
2025-06-11 18:54:07 +05:30
parent 82efc2bfc4
commit 1dc922233f
6 changed files with 93 additions and 68 deletions

View File

@@ -27,6 +27,7 @@ import {
FrontendSchema,
ORMSchema,
PackageManagerSchema,
ProjectNameSchema,
RuntimeSchema,
} from "./types";
import { trackProjectCreation } from "./utils/analytics";
@@ -36,10 +37,6 @@ import { getLatestCLIVersion } from "./utils/get-latest-cli-version";
import { renderTitle } from "./utils/render-title";
import { getProvidedFlags, processAndValidateFlags } from "./validation";
const exit = () => process.exit(0);
process.on("SIGINT", exit);
process.on("SIGTERM", exit);
const t = trpcServer.initTRPC.create();
async function handleDirectoryConflict(currentPathInput: string): Promise<{
@@ -268,32 +265,23 @@ const router = t.router({
})
.input(
z.tuple([
z.string().optional().describe("project-name"),
ProjectNameSchema.optional(),
z
.object({
yes: z
.boolean()
.optional()
.default(false)
.describe("Use default configuration and skip prompts"),
.describe("Use default configuration"),
database: DatabaseSchema.optional(),
orm: ORMSchema.optional(),
auth: z.boolean().optional().describe("Include authentication"),
frontend: z
.array(FrontendSchema)
.optional()
.describe("Frontend frameworks"),
addons: z
.array(AddonsSchema)
.optional()
.describe("Additional addons"),
examples: z
.array(ExamplesSchema)
.optional()
.describe("Examples to include"),
git: z.boolean().optional().describe("Initialize git repository"),
auth: z.boolean().optional(),
frontend: z.array(FrontendSchema).optional(),
addons: z.array(AddonsSchema).optional(),
examples: z.array(ExamplesSchema).optional(),
git: z.boolean().optional(),
packageManager: PackageManagerSchema.optional(),
install: z.boolean().optional().describe("Install dependencies"),
install: z.boolean().optional(),
dbSetup: DatabaseSetupSchema.optional(),
backend: BackendSchema.optional(),
runtime: RuntimeSchema.optional(),