()
| 14 | export type Orm = CliResults["orm"] |
| 15 | |
| 16 | export async function runCli(): Promise<CliResults | undefined> { |
| 17 | console.clear() |
| 18 | |
| 19 | // Parse command line arguments manually |
| 20 | const args = process.argv.slice(2) |
| 21 | const cliProvidedName = args[0]?.startsWith("--") ? undefined : args[0] |
| 22 | const noInstallFlag = args.includes("--noInstall") |
| 23 | |
| 24 | intro(color.bgCyan(" jStack CLI ")) |
| 25 | |
| 26 | const projectName = |
| 27 | cliProvidedName || |
| 28 | (await text({ |
| 29 | message: "What will your project be called?", |
| 30 | placeholder: "my-jstack-app", |
| 31 | validate: (value) => { |
| 32 | if (!value) return "Please enter a project name" |
| 33 | if (value.length > 50) return "Project name must be less than 50 characters" |
| 34 | return |
| 35 | }, |
| 36 | })) |
| 37 | |
| 38 | if (isCancel(projectName)) { |
| 39 | outro("Setup cancelled.") |
| 40 | return undefined |
| 41 | } |
| 42 | |
| 43 | const orm = await select<"none" | "drizzle">({ |
| 44 | message: "Which database ORM would you like to use?", |
| 45 | options: [ |
| 46 | { value: "none", label: "None" }, |
| 47 | { value: "drizzle", label: "Drizzle ORM" }, |
| 48 | ], |
| 49 | }) |
| 50 | |
| 51 | if (isCancel(orm)) { |
| 52 | outro("Setup cancelled.") |
| 53 | return undefined |
| 54 | } |
| 55 | |
| 56 | let dialect = undefined |
| 57 | let provider = undefined |
| 58 | if (orm === "drizzle") { |
| 59 | dialect = "postgres" as const // Only offering postgres |
| 60 | |
| 61 | provider = await select({ |
| 62 | message: "Which Postgres provider would you like to use?", |
| 63 | options: [ |
| 64 | { value: "postgres", label: "PostgreSQL" }, |
| 65 | { value: "neon", label: "Neon" }, |
| 66 | { value: "vercel-postgres", label: "Vercel Postgres" }, |
| 67 | ], |
| 68 | }) |
| 69 | |
| 70 | if (isCancel(provider)) { |
| 71 | outro("Setup cancelled.") |
| 72 | return undefined |
| 73 | } |
no test coverage detected