Skip to content

Commit 9032a59

Browse files
add flags and prompt for orm selection
1 parent 16e11cb commit 9032a59

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

apps/cli/src/consts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export const DEFAULT_CONFIG: ProjectConfig = {
1313
features: [],
1414
git: true,
1515
packageManager: "npm",
16+
orm: "drizzle",
1617
};

apps/cli/src/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type {
2121
ProjectConfig,
2222
ProjectDatabase,
2323
ProjectFeature,
24+
ProjectORM,
2425
} from "./types";
2526
import { generateReproducibleCommand } from "./utils/generate-reproducible-command";
2627
import { getUserPkgManager } from "./utils/get-package-manager";
@@ -101,6 +102,25 @@ async function gatherConfig(
101102
},
102103
],
103104
}),
105+
orm: () =>
106+
flags.orm !== undefined
107+
? Promise.resolve(flags.orm)
108+
: select<ProjectORM>({
109+
message: "Which ORM would you like to use?",
110+
options: [
111+
{
112+
value: "drizzle",
113+
label: "Drizzle",
114+
hint: "Type-safe, lightweight ORM (recommended)",
115+
},
116+
// {
117+
// value: "prisma",
118+
// label: "Prisma (coming soon)",
119+
// hint: "Feature-rich ORM with great DX",
120+
// },
121+
],
122+
initialValue: "drizzle",
123+
}),
104124
auth: () =>
105125
flags.auth !== undefined
106126
? Promise.resolve(flags.auth)
@@ -186,6 +206,7 @@ async function gatherConfig(
186206
return {
187207
projectName: result.projectName ?? DEFAULT_CONFIG.projectName,
188208
database: result.database ?? DEFAULT_CONFIG.database,
209+
orm: result.orm ?? DEFAULT_CONFIG.orm,
189210
auth: result.auth ?? DEFAULT_CONFIG.auth,
190211
features: result.features ?? DEFAULT_CONFIG.features,
191212
git: result.git ?? DEFAULT_CONFIG.git,
@@ -202,6 +223,9 @@ function displayConfig(config: Partial<ProjectConfig>) {
202223
if (config.database) {
203224
configDisplay.push(`${pc.blue("Database:")} ${config.database}`);
204225
}
226+
if (config.orm) {
227+
configDisplay.push(`${pc.blue("ORM:")} ${config.orm}`);
228+
}
205229
if (config.auth !== undefined) {
206230
configDisplay.push(`${pc.blue("Authentication:")} ${config.auth}`);
207231
}
@@ -245,6 +269,8 @@ async function main() {
245269
.option("--pnpm", "Use pnpm package manager")
246270
.option("--yarn", "Use yarn package manager")
247271
.option("--bun", "Use bun package manager")
272+
.option("--drizzle", "Use Drizzle ORM")
273+
.option("--prisma", "Use Prisma ORM (coming soon)")
248274
.parse();
249275

250276
const options = program.opts();
@@ -257,6 +283,7 @@ async function main() {
257283
: options.postgres
258284
? "postgres"
259285
: undefined,
286+
orm: options.drizzle ? "drizzle" : options.prisma ? "prisma" : undefined,
260287
auth: "auth" in options ? options.auth : undefined,
261288
packageManager: options.npm
262289
? "npm"
@@ -293,6 +320,11 @@ async function main() {
293320
yes: true,
294321
projectName: projectDirectory ?? DEFAULT_CONFIG.projectName,
295322
database: options.database ?? DEFAULT_CONFIG.database,
323+
orm: options.drizzle
324+
? "drizzle"
325+
: options.prisma
326+
? "prisma"
327+
: DEFAULT_CONFIG.orm, // Add this line
296328
auth: options.auth ?? DEFAULT_CONFIG.auth,
297329
git: options.git ?? DEFAULT_CONFIG.git,
298330
packageManager:

apps/cli/src/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export type ProjectDatabase = "sqlite" | "postgres";
44

55
export type PackageManager = "npm" | "yarn" | "pnpm" | "bun";
66

7+
export type ProjectORM = "drizzle" | "prisma";
8+
79
export type ProjectConfig = {
810
yes?: boolean;
911
projectName: string;
@@ -12,4 +14,5 @@ export type ProjectConfig = {
1214
auth: boolean;
1315
packageManager: PackageManager;
1416
features: ProjectFeature[];
17+
orm: ProjectORM;
1518
};

apps/cli/src/utils/generate-reproducible-command.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export function generateReproducibleCommand(config: ProjectConfig): string {
1818
flags.push(config.database === "sqlite" ? "--sqlite" : "--postgres");
1919
}
2020

21+
if (config.orm !== DEFAULT_CONFIG.orm) {
22+
flags.push(config.orm === "drizzle" ? "--drizzle" : "--prisma");
23+
}
24+
2125
if (config.auth !== DEFAULT_CONFIG.auth) {
2226
flags.push("--no-auth");
2327
}

0 commit comments

Comments
 (0)