@drzl/cli 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -3,19 +3,96 @@ import {
3
3
  computeGeneratorOutputDirs,
4
4
  computeWatchTargets,
5
5
  loadConfig
6
- } from "./chunk-MEPFGJIF.js";
6
+ } from "./chunk-HHT7INUJ.js";
7
7
 
8
8
  // src/cli.ts
9
9
  import { SchemaAnalyzer } from "@drzl/analyzer";
10
10
  import { ORPCGenerator } from "@drzl/generator-orpc";
11
- import chalk from "chalk";
11
+ import chalk2 from "chalk";
12
12
  import chokidar from "chokidar";
13
13
  import cliProgress from "cli-progress";
14
14
  import { Command } from "commander";
15
- import * as path from "path";
15
+ import * as path2 from "path";
16
16
  import ora from "ora";
17
+
18
+ // src/sponsor.ts
19
+ import chalk from "chalk";
20
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
21
+ import path from "path";
22
+ var CACHE_DIR = path.join(process.cwd(), "node_modules", ".cache", "@drzl");
23
+ var CACHE_FILE = path.join(CACHE_DIR, "sponsor-message.json");
24
+ var DEFAULT_INTERVAL_MS = 1e3 * 60 * 15;
25
+ var shownThisProcess = false;
26
+ var tips = [
27
+ "Pair DRZL watch mode with drizzle-kit to keep schema & API synced.",
28
+ "Templatize your ORPC routers to roll out new endpoints safely.",
29
+ "Need typed validators? Enable the zod, valibot, or arktype generators.",
30
+ "Use output headers to track generated files and trim noisy diffs."
31
+ ];
32
+ var green = (msg) => chalk.hex("#6ee7b7")(msg);
33
+ var cyan = (msg) => chalk.cyan(msg);
34
+ var gray = (msg) => chalk.gray(msg);
35
+ function maybeShowSponsorMessage({
36
+ reason = "generate",
37
+ minIntervalMs = DEFAULT_INTERVAL_MS,
38
+ force = false
39
+ } = {}) {
40
+ const hideViaEnv = process.env.DRZL_HIDE_SPONSOR?.toLowerCase();
41
+ const hideRequested = hideViaEnv === "1" || hideViaEnv === "true";
42
+ if (hideRequested || process.env.CI && !force || shownThisProcess && !force) return;
43
+ try {
44
+ mkdirSync(CACHE_DIR, { recursive: true });
45
+ const payload = readCache();
46
+ payload.runs += 1;
47
+ const now = Date.now();
48
+ const shouldShow = force || now - (payload.lastShownAt ?? 0) >= minIntervalMs;
49
+ if (shouldShow) {
50
+ payload.lastShownAt = now;
51
+ payload.lastReason = reason;
52
+ }
53
+ writeCache(payload);
54
+ if (!shouldShow) return;
55
+ shownThisProcess = true;
56
+ const tip = tips[payload.runs % tips.length];
57
+ console.log(
58
+ `
59
+ ${cyan(`\u{1F680} DRZL finished a ${reason} run (#${payload.runs.toLocaleString()}).`)}
60
+
61
+ ${green("\u2728 Sponsors keep DRZL shipping. Consider supporting ongoing dev:")}
62
+ ${green("GitHub Sponsors")} ${gray("\u2192 https://github.com/sponsors/omar-dulaimi")}
63
+
64
+ ${green("Pro tip:")} ${tip}
65
+ `
66
+ );
67
+ } catch {
68
+ }
69
+ }
70
+ function readCache() {
71
+ if (!existsSync(CACHE_FILE)) {
72
+ return { runs: 0 };
73
+ }
74
+ try {
75
+ const data = JSON.parse(readFileSync(CACHE_FILE, "utf8"));
76
+ if (typeof data.runs !== "number") return { runs: 0 };
77
+ return data;
78
+ } catch {
79
+ return { runs: 0 };
80
+ }
81
+ }
82
+ function writeCache(payload) {
83
+ writeFileSync(CACHE_FILE, JSON.stringify(payload, null, 2), "utf8");
84
+ }
85
+
86
+ // src/cli.ts
17
87
  var program = new Command();
18
88
  program.name("drzl").description("DRZL - Drizzle Developer Toolkit").version("0.0.1");
89
+ program.addHelpText(
90
+ "afterAll",
91
+ `
92
+ Need a template, adapter, or generator DRZL doesn't ship yet?
93
+ \u2192 DM @omardulaimidev on X: https://x.com/omardulaimidev
94
+ `
95
+ );
19
96
  program.command("analyze").argument("<schema>", "path to drizzle schema (TS)").option("--relations", "include relations", true).option("--validate", "validate constraints", true).option("--out <file>", "write analysis JSON to file").option("--json", "print JSON to stdout (overrides --out)", false).action(async (schema, opts) => {
20
97
  try {
21
98
  const analyzer = new SchemaAnalyzer(schema);
@@ -32,9 +109,9 @@ program.command("analyze").argument("<schema>", "path to drizzle schema (TS)").o
32
109
  } else if (opts.out) {
33
110
  const fs = await import("fs/promises");
34
111
  await fs.writeFile(opts.out, json, "utf8");
35
- spinner?.succeed(chalk.green(`Analysis written to ${opts.out} in ${ms}ms`));
112
+ spinner?.succeed(chalk2.green(`Analysis written to ${opts.out} in ${ms}ms`));
36
113
  } else {
37
- spinner?.succeed(chalk.green(`Analyzed in ${ms}ms`));
114
+ spinner?.succeed(chalk2.green(`Analyzed in ${ms}ms`));
38
115
  console.log(json);
39
116
  }
40
117
  process.exit(res.issues.some((i) => i.level === "error") ? 2 : 0);
@@ -44,7 +121,7 @@ program.command("analyze").argument("<schema>", "path to drizzle schema (TS)").o
44
121
  console.log(JSON.stringify({ event: "error", code: "DRZL_CLI_ANALYZE", message: msg }));
45
122
  else
46
123
  console.error(
47
- chalk.red("Analyze failed (DRZL_CLI_ANALYZE):"),
124
+ chalk2.red("Analyze failed (DRZL_CLI_ANALYZE):"),
48
125
  msg,
49
126
  "\nTip: run with --json for structured output."
50
127
  );
@@ -56,7 +133,7 @@ program.command("generate").description("Run configured generators (drzl.config.
56
133
  const cfg = await loadConfig(opts.config);
57
134
  if (!cfg) {
58
135
  console.error(
59
- chalk.red("No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.")
136
+ chalk2.red("No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.")
60
137
  );
61
138
  process.exit(2);
62
139
  return;
@@ -87,12 +164,13 @@ program.command("generate").description("Run configured generators (drzl.config.
87
164
  outputHeader: g.outputHeader,
88
165
  format: g.format,
89
166
  templateOptions: g.templateOptions,
167
+ importExtension: g.importExtension,
90
168
  validation: g.validation,
91
169
  onProgress: ({ index }) => progress.update(index)
92
170
  });
93
171
  progress.stop();
94
- ora().succeed(chalk.green(`Generated (${g.kind}): ${files.length} files`));
95
- files.forEach((f) => console.log(" -", chalk.cyan(f)));
172
+ ora().succeed(chalk2.green(`Generated (${g.kind}): ${files.length} files`));
173
+ files.forEach((f) => console.log(" -", chalk2.cyan(f)));
96
174
  } else if (g.kind === "service") {
97
175
  try {
98
176
  const { ServiceGenerator } = await import("@drzl/generator-service");
@@ -104,18 +182,19 @@ program.command("generate").description("Run configured generators (drzl.config.
104
182
  format: g.format,
105
183
  dataAccess: g.dataAccess,
106
184
  dbImportPath: g.dbImportPath,
107
- schemaImportPath: g.schemaImportPath
185
+ schemaImportPath: g.schemaImportPath,
186
+ importExtension: g.importExtension
108
187
  });
109
188
  progress.stop();
110
- ora().succeed(chalk.green(`Generated (service): ${files.length} files`));
111
- files.forEach((f) => console.log(" -", chalk.cyan(f)));
189
+ ora().succeed(chalk2.green(`Generated (service): ${files.length} files`));
190
+ files.forEach((f) => console.log(" -", chalk2.cyan(f)));
112
191
  } catch (e) {
113
192
  progress.stop();
114
193
  console.error(
115
- chalk.red("Service generator missing."),
116
- chalk.yellow("\nInstall with: npm install @drzl/generator-service")
194
+ chalk2.red("Service generator missing."),
195
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-service")
117
196
  );
118
- console.error(chalk.gray("Error details:"), e?.message ?? e);
197
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
119
198
  process.exit(1);
120
199
  }
121
200
  } else if (g.kind === "zod") {
@@ -128,18 +207,20 @@ program.command("generate").description("Run configured generators (drzl.config.
128
207
  outputHeader: g.outputHeader,
129
208
  format: g.format,
130
209
  schemaSuffix: g.schemaSuffix,
131
- fileSuffix: g.fileSuffix
210
+ fileSuffix: g.fileSuffix,
211
+ importExtension: g.importExtension,
212
+ affix: g.affix
132
213
  });
133
214
  progress.stop();
134
- ora().succeed(chalk.green(`Generated (zod): ${files.length} files`));
135
- files.forEach((f) => console.log(" -", chalk.cyan(f)));
215
+ ora().succeed(chalk2.green(`Generated (zod): ${files.length} files`));
216
+ files.forEach((f) => console.log(" -", chalk2.cyan(f)));
136
217
  } catch (e) {
137
218
  progress.stop();
138
219
  console.error(
139
- chalk.red("Zod generator missing."),
140
- chalk.yellow("\nInstall with: npm install @drzl/generator-zod")
220
+ chalk2.red("Zod generator missing."),
221
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-zod")
141
222
  );
142
- console.error(chalk.gray("Error details:"), e?.message ?? e);
223
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
143
224
  process.exit(1);
144
225
  }
145
226
  } else if (g.kind === "valibot") {
@@ -152,18 +233,20 @@ program.command("generate").description("Run configured generators (drzl.config.
152
233
  outputHeader: g.outputHeader,
153
234
  format: g.format,
154
235
  schemaSuffix: g.schemaSuffix,
155
- fileSuffix: g.fileSuffix
236
+ fileSuffix: g.fileSuffix,
237
+ importExtension: g.importExtension,
238
+ affix: g.affix
156
239
  });
157
240
  progress.stop();
158
- ora().succeed(chalk.green(`Generated (valibot): ${files.length} files`));
159
- files.forEach((f) => console.log(" -", chalk.cyan(f)));
241
+ ora().succeed(chalk2.green(`Generated (valibot): ${files.length} files`));
242
+ files.forEach((f) => console.log(" -", chalk2.cyan(f)));
160
243
  } catch (e) {
161
244
  progress.stop();
162
245
  console.error(
163
- chalk.red("Valibot generator missing."),
164
- chalk.yellow("\nInstall with: npm install @drzl/generator-valibot")
246
+ chalk2.red("Valibot generator missing."),
247
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-valibot")
165
248
  );
166
- console.error(chalk.gray("Error details:"), e?.message ?? e);
249
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
167
250
  process.exit(1);
168
251
  }
169
252
  } else if (g.kind === "arktype") {
@@ -176,25 +259,30 @@ program.command("generate").description("Run configured generators (drzl.config.
176
259
  outputHeader: g.outputHeader,
177
260
  format: g.format,
178
261
  schemaSuffix: g.schemaSuffix,
179
- fileSuffix: g.fileSuffix
262
+ fileSuffix: g.fileSuffix,
263
+ importExtension: g.importExtension,
264
+ affix: g.affix
180
265
  });
181
266
  progress.stop();
182
- ora().succeed(chalk.green(`Generated (arktype): ${files.length} files`));
183
- files.forEach((f) => console.log(" -", chalk.cyan(f)));
267
+ ora().succeed(chalk2.green(`Generated (arktype): ${files.length} files`));
268
+ files.forEach((f) => console.log(" -", chalk2.cyan(f)));
184
269
  } catch (e) {
185
270
  progress.stop();
186
271
  console.error(
187
- chalk.red("ArkType generator missing."),
188
- chalk.yellow("\nInstall with: npm install @drzl/generator-arktype")
272
+ chalk2.red("ArkType generator missing."),
273
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-arktype")
189
274
  );
190
- console.error(chalk.gray("Error details:"), e?.message ?? e);
275
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
191
276
  process.exit(1);
192
277
  }
193
278
  }
194
279
  }
280
+ if (cfg.generators.length) {
281
+ maybeShowSponsorMessage({ reason: "generate" });
282
+ }
195
283
  } catch (e) {
196
284
  console.error(
197
- chalk.red("Generate failed (DRZL_GEN_001):"),
285
+ chalk2.red("Generate failed (DRZL_GEN_001):"),
198
286
  e?.message ?? e,
199
287
  "\nTip: check your drzl.config.ts and template path."
200
288
  );
@@ -214,23 +302,24 @@ program.command("generate:orpc").argument("<schema>", "path to drizzle schema (T
214
302
  template: opts.template,
215
303
  includeRelations: !!opts.includeRelations
216
304
  });
217
- console.log(chalk.green(`Generated:`), files.map((f) => chalk.cyan(f)).join(", "));
305
+ console.log(chalk2.green(`Generated:`), files.map((f) => chalk2.cyan(f)).join(", "));
306
+ maybeShowSponsorMessage({ reason: "generate:orpc" });
218
307
  } catch (e) {
219
- console.error(chalk.red("Generate orpc failed:"), e?.message ?? e);
308
+ console.error(chalk2.red("Generate orpc failed:"), e?.message ?? e);
220
309
  process.exit(1);
221
310
  }
222
311
  });
223
312
  program.command("watch").description("Watch schema and regenerate on changes").option("-c, --config <path>", "path to drzl.config").option("--pipeline <name>", "all | analyze | generate-orpc", "all").option("--debounce <ms>", "debounce ms", "200").option("--json", "emit JSON logs", false).option("--poll", "force polling (helps WSL/Docker/remote FS)", false).action(async (opts) => {
224
313
  let cfg = await loadConfig(opts.config);
225
314
  if (!cfg) {
226
- console.error(chalk.red("No config found. Create drzl.config.ts or pass --config."));
315
+ console.error(chalk2.red("No config found. Create drzl.config.ts or pass --config."));
227
316
  process.exit(2);
228
317
  return;
229
318
  }
230
- const abs = (p) => path.resolve(process.cwd(), p);
319
+ const abs = (p) => path2.resolve(process.cwd(), p);
231
320
  const isInside = (child, parent) => {
232
- const rel = path.relative(parent, child);
233
- return !!rel && !rel.startsWith("..") && !path.isAbsolute(rel);
321
+ const rel = path2.relative(parent, child);
322
+ return !!rel && !rel.startsWith("..") && !path2.isAbsolute(rel);
234
323
  };
235
324
  const ignoredOutDirs = new Set(computeGeneratorOutputDirs(cfg).map(abs));
236
325
  const currentTargets = new Set(computeWatchTargets(cfg).map(abs));
@@ -309,7 +398,7 @@ program.command("watch").description("Watch schema and regenerate on changes").o
309
398
  })
310
399
  );
311
400
  } else {
312
- console.log(chalk.green("Analyze complete."));
401
+ console.log(chalk2.green("Analyze complete."));
313
402
  }
314
403
  return;
315
404
  }
@@ -328,11 +417,12 @@ program.command("watch").description("Watch schema and regenerate on changes").o
328
417
  outputHeader: g.outputHeader,
329
418
  format: g.format,
330
419
  templateOptions: g.templateOptions,
420
+ importExtension: g.importExtension,
331
421
  validation: g.validation
332
422
  });
333
423
  opts.json ? console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files })) : console.log(
334
- chalk.green(`Generated (${g.kind}):`),
335
- files.map((f) => chalk.cyan(f)).join(", ")
424
+ chalk2.green(`Generated (${g.kind}):`),
425
+ files.map((f) => chalk2.cyan(f)).join(", ")
336
426
  );
337
427
  newFiles.push(...files);
338
428
  } else if (g.kind === "service") {
@@ -346,19 +436,20 @@ program.command("watch").description("Watch schema and regenerate on changes").o
346
436
  format: g.format,
347
437
  dataAccess: g.dataAccess,
348
438
  dbImportPath: g.dbImportPath,
349
- schemaImportPath: g.schemaImportPath
439
+ schemaImportPath: g.schemaImportPath,
440
+ importExtension: g.importExtension
350
441
  });
351
442
  opts.json ? console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files })) : console.log(
352
- chalk.green(`Generated (service): ${files.length} files`),
353
- files.map((f) => chalk.cyan(f)).join(", ")
443
+ chalk2.green(`Generated (service): ${files.length} files`),
444
+ files.map((f) => chalk2.cyan(f)).join(", ")
354
445
  );
355
446
  newFiles.push(...files);
356
447
  } catch (e) {
357
448
  console.error(
358
- chalk.red("Service generator missing."),
359
- chalk.yellow("\nInstall with: npm install @drzl/generator-service")
449
+ chalk2.red("Service generator missing."),
450
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-service")
360
451
  );
361
- console.error(chalk.gray("Error details:"), e?.message ?? e);
452
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
362
453
  return;
363
454
  }
364
455
  } else if (g.kind === "zod") {
@@ -371,19 +462,21 @@ program.command("watch").description("Watch schema and regenerate on changes").o
371
462
  outputHeader: g.outputHeader,
372
463
  format: g.format,
373
464
  schemaSuffix: g.schemaSuffix,
374
- fileSuffix: g.fileSuffix
465
+ fileSuffix: g.fileSuffix,
466
+ importExtension: g.importExtension,
467
+ affix: g.affix
375
468
  });
376
469
  opts.json ? console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files })) : console.log(
377
- chalk.green(`Generated (zod): ${files.length} files`),
378
- files.map((f) => chalk.cyan(f)).join(", ")
470
+ chalk2.green(`Generated (zod): ${files.length} files`),
471
+ files.map((f) => chalk2.cyan(f)).join(", ")
379
472
  );
380
473
  newFiles.push(...files);
381
474
  } catch (e) {
382
475
  console.error(
383
- chalk.red("Zod generator missing."),
384
- chalk.yellow("\nInstall with: npm install @drzl/generator-zod")
476
+ chalk2.red("Zod generator missing."),
477
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-zod")
385
478
  );
386
- console.error(chalk.gray("Error details:"), e?.message ?? e);
479
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
387
480
  return;
388
481
  }
389
482
  } else if (g.kind === "valibot") {
@@ -396,19 +489,21 @@ program.command("watch").description("Watch schema and regenerate on changes").o
396
489
  outputHeader: g.outputHeader,
397
490
  format: g.format,
398
491
  schemaSuffix: g.schemaSuffix,
399
- fileSuffix: g.fileSuffix
492
+ fileSuffix: g.fileSuffix,
493
+ importExtension: g.importExtension,
494
+ affix: g.affix
400
495
  });
401
496
  opts.json ? console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files })) : console.log(
402
- chalk.green(`Generated (valibot): ${files.length} files`),
403
- files.map((f) => chalk.cyan(f)).join(", ")
497
+ chalk2.green(`Generated (valibot): ${files.length} files`),
498
+ files.map((f) => chalk2.cyan(f)).join(", ")
404
499
  );
405
500
  newFiles.push(...files);
406
501
  } catch (e) {
407
502
  console.error(
408
- chalk.red("Valibot generator missing."),
409
- chalk.yellow("\nInstall with: npm install @drzl/generator-valibot")
503
+ chalk2.red("Valibot generator missing."),
504
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-valibot")
410
505
  );
411
- console.error(chalk.gray("Error details:"), e?.message ?? e);
506
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
412
507
  return;
413
508
  }
414
509
  } else if (g.kind === "arktype") {
@@ -421,19 +516,21 @@ program.command("watch").description("Watch schema and regenerate on changes").o
421
516
  outputHeader: g.outputHeader,
422
517
  format: g.format,
423
518
  schemaSuffix: g.schemaSuffix,
424
- fileSuffix: g.fileSuffix
519
+ fileSuffix: g.fileSuffix,
520
+ importExtension: g.importExtension,
521
+ affix: g.affix
425
522
  });
426
523
  opts.json ? console.log(JSON.stringify({ event: "generate_complete", kind: g.kind, files })) : console.log(
427
- chalk.green(`Generated (arktype): ${files.length} files`),
428
- files.map((f) => chalk.cyan(f)).join(", ")
524
+ chalk2.green(`Generated (arktype): ${files.length} files`),
525
+ files.map((f) => chalk2.cyan(f)).join(", ")
429
526
  );
430
527
  newFiles.push(...files);
431
528
  } catch (e) {
432
529
  console.error(
433
- chalk.red("ArkType generator missing."),
434
- chalk.yellow("\nInstall with: npm install @drzl/generator-arktype")
530
+ chalk2.red("ArkType generator missing."),
531
+ chalk2.yellow("\nInstall with: npm install @drzl/generator-arktype")
435
532
  );
436
- console.error(chalk.gray("Error details:"), e?.message ?? e);
533
+ console.error(chalk2.gray("Error details:"), e?.message ?? e);
437
534
  return;
438
535
  }
439
536
  }
@@ -441,12 +538,16 @@ program.command("watch").description("Watch schema and regenerate on changes").o
441
538
  const added = newFiles.filter((f) => !lastFiles.includes(f));
442
539
  const removed = lastFiles.filter((f) => !newFiles.includes(f));
443
540
  opts.json ? console.log(JSON.stringify({ event: "diff", added, removed })) : (() => {
444
- if (added.length) console.log(chalk.blue(`Added: ${added.join(", ")}`));
445
- if (removed.length) console.log(chalk.yellow(`Removed: ${removed.join(", ")}`));
541
+ if (added.length) console.log(chalk2.blue(`Added: ${added.join(", ")}`));
542
+ if (removed.length) console.log(chalk2.yellow(`Removed: ${removed.join(", ")}`));
446
543
  })();
544
+ if (newFiles.length && !opts.json) {
545
+ const reason = opts.pipeline && opts.pipeline !== "all" ? `watch:${opts.pipeline}` : "watch";
546
+ maybeShowSponsorMessage({ reason });
547
+ }
447
548
  lastFiles = newFiles;
448
549
  } catch (e) {
449
- opts.json ? console.log(JSON.stringify({ event: "error", message: String(e?.message ?? e) })) : console.error(chalk.red("Watch pipeline failed:"), e?.message ?? e);
550
+ opts.json ? console.log(JSON.stringify({ event: "error", message: String(e?.message ?? e) })) : console.error(chalk2.red("Watch pipeline failed:"), e?.message ?? e);
450
551
  }
451
552
  };
452
553
  const debounced = Number(opts.debounce) || 200;
@@ -471,18 +572,18 @@ program.command("watch").description("Watch schema and regenerate on changes").o
471
572
  );
472
573
  } else {
473
574
  console.log(
474
- chalk.gray(
475
- "Watching:\n " + Array.from(currentTargets).map((p) => path.relative(process.cwd(), p)).join("\n ")
575
+ chalk2.gray(
576
+ "Watching:\n " + Array.from(currentTargets).map((p) => path2.relative(process.cwd(), p)).join("\n ")
476
577
  )
477
578
  );
478
579
  }
479
- watcher.on("add", (p) => trigger(p)).on("change", (p) => trigger(p)).on("unlink", (p) => trigger(p)).on("error", (err) => console.error(chalk.red("Watcher error:"), err));
580
+ watcher.on("add", (p) => trigger(p)).on("change", (p) => trigger(p)).on("unlink", (p) => trigger(p)).on("error", (err) => console.error(chalk2.red("Watcher error:"), err));
480
581
  await run();
481
582
  });
482
583
  program.command("init").description("Scaffold a drzl.config.ts").option("-y, --yes", "accept defaults").action(async (_opts) => {
483
584
  const fs = await import("fs/promises");
484
- const path2 = await import("path");
485
- const target = path2.resolve(process.cwd(), "drzl.config.ts");
585
+ const path3 = await import("path");
586
+ const target = path3.resolve(process.cwd(), "drzl.config.ts");
486
587
  const template = `export default {
487
588
  schema: 'src/db/schema.ts',
488
589
  outDir: 'src/api',
@@ -494,9 +595,9 @@ program.command("init").description("Scaffold a drzl.config.ts").option("-y, --y
494
595
  `;
495
596
  try {
496
597
  await fs.writeFile(target, template, { flag: "wx" });
497
- console.log(chalk.green(`Created ${target}`));
598
+ console.log(chalk2.green(`Created ${target}`));
498
599
  } catch (e) {
499
- console.error(chalk.red("Init failed:"), e?.message ?? e);
600
+ console.error(chalk2.red("Init failed:"), e?.message ?? e);
500
601
  process.exit(1);
501
602
  }
502
603
  });