@drzl/cli 4.14.0 → 4.14.2

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
@@ -13,7 +13,7 @@ import chalk2 from "chalk";
13
13
  import chokidar from "chokidar";
14
14
  import cliProgress from "cli-progress";
15
15
  import { Command } from "commander";
16
- import * as path3 from "path";
16
+ import * as path4 from "path";
17
17
  import ora from "ora";
18
18
 
19
19
  // src/validation-options.ts
@@ -103,6 +103,7 @@ var tips = [
103
103
  "Pair DRZL watch mode with drizzle-kit to keep schema & API synced.",
104
104
  "Templatize your ORPC routers to roll out new endpoints safely.",
105
105
  "Need typed validators? Enable the zod, valibot, arktype, or typebox generators.",
106
+ "Need JSON Schema or OpenAPI? The json-schema generator emits both, with no runtime dependency.",
106
107
  "Use output headers to track generated files and trim noisy diffs."
107
108
  ];
108
109
  var green = (msg) => chalk.hex("#6ee7b7")(msg);
@@ -159,9 +160,42 @@ function writeCache(payload) {
159
160
  writeFileSync(CACHE_FILE, JSON.stringify(payload, null, 2), "utf8");
160
161
  }
161
162
 
163
+ // src/version.ts
164
+ import { readFileSync as readFileSync2 } from "fs";
165
+ import * as path3 from "path";
166
+ import { fileURLToPath } from "url";
167
+ var PACKAGE_NAME = "@drzl/cli";
168
+ function moduleDir() {
169
+ return path3.dirname(fileURLToPath(import.meta.url));
170
+ }
171
+ function readVersionFrom(manifestPath) {
172
+ let raw;
173
+ try {
174
+ raw = readFileSync2(manifestPath, "utf8");
175
+ } catch (e) {
176
+ throw new Error(
177
+ `${PACKAGE_NAME} cannot read its own version: no manifest at ${manifestPath} (${e?.message ?? String(e)}).`
178
+ );
179
+ }
180
+ const manifest = JSON.parse(raw);
181
+ if (manifest.name !== PACKAGE_NAME) {
182
+ throw new Error(
183
+ `${PACKAGE_NAME} looked for its own version in ${manifestPath} and found ${JSON.stringify(manifest.name)}, so this build is not sitting where it thinks it is.`
184
+ );
185
+ }
186
+ if (typeof manifest.version !== "string" || manifest.version.length === 0) {
187
+ throw new Error(`${manifestPath} declares no version, so there is nothing to report.`);
188
+ }
189
+ return manifest.version;
190
+ }
191
+ function readCliVersion() {
192
+ return readVersionFrom(path3.join(moduleDir(), "..", "package.json"));
193
+ }
194
+ var CLI_VERSION = readCliVersion();
195
+
162
196
  // src/cli.ts
163
197
  var program = new Command();
164
- program.name("drzl").description("DRZL - Drizzle Developer Toolkit").version("0.0.1");
198
+ program.name("drzl").description("DRZL - Drizzle Developer Toolkit").version(CLI_VERSION);
165
199
  program.addHelpText(
166
200
  "afterAll",
167
201
  `
@@ -401,7 +435,7 @@ Generated output is out of date (${drift.length} file(s)):`));
401
435
  for (const d of drift) {
402
436
  const mark = d.status === "added" ? "+" : d.status === "removed" ? "-" : "~";
403
437
  console.error(
404
- ` ${mark} ${chalk2.yellow(d.status.padEnd(8))} ${path3.relative(process.cwd(), d.file)}`
438
+ ` ${mark} ${chalk2.yellow(d.status.padEnd(8))} ${path4.relative(process.cwd(), d.file)}`
405
439
  );
406
440
  }
407
441
  console.error(
@@ -453,10 +487,10 @@ program.command("watch").description("Watch schema and regenerate on changes").o
453
487
  process.exit(2);
454
488
  return;
455
489
  }
456
- const abs = (p) => path3.resolve(process.cwd(), p);
490
+ const abs = (p) => path4.resolve(process.cwd(), p);
457
491
  const isInside = (child, parent) => {
458
- const rel = path3.relative(parent, child);
459
- return !!rel && !rel.startsWith("..") && !path3.isAbsolute(rel);
492
+ const rel = path4.relative(parent, child);
493
+ return !!rel && !rel.startsWith("..") && !path4.isAbsolute(rel);
460
494
  };
461
495
  const ignoredOutDirs = new Set(computeGeneratorOutputDirs(cfg).map(abs));
462
496
  const currentTargets = new Set(computeWatchTargets(cfg).map(abs));
@@ -481,7 +515,7 @@ program.command("watch").description("Watch schema and regenerate on changes").o
481
515
  if (full === dir || isInside(full, dir)) return true;
482
516
  }
483
517
  if (stats?.isDirectory()) return false;
484
- const ext = path3.extname(full);
518
+ const ext = path4.extname(full);
485
519
  if (!ext) return false;
486
520
  return !WATCHED_EXTENSIONS.has(ext);
487
521
  };
@@ -716,7 +750,7 @@ program.command("watch").description("Watch schema and regenerate on changes").o
716
750
  } else {
717
751
  console.log(
718
752
  chalk2.gray(
719
- "Watching:\n " + Array.from(currentTargets).map((p) => path3.relative(process.cwd(), p)).join("\n ")
753
+ "Watching:\n " + Array.from(currentTargets).map((p) => path4.relative(process.cwd(), p)).join("\n ")
720
754
  )
721
755
  );
722
756
  }
@@ -725,8 +759,8 @@ program.command("watch").description("Watch schema and regenerate on changes").o
725
759
  });
726
760
  program.command("init").description("Scaffold a drzl.config.ts").option("-y, --yes", "accept defaults").action(async (_opts) => {
727
761
  const fs2 = await import("fs/promises");
728
- const path4 = await import("path");
729
- const target = path4.resolve(process.cwd(), "drzl.config.ts");
762
+ const path5 = await import("path");
763
+ const target = path5.resolve(process.cwd(), "drzl.config.ts");
730
764
  const template = `export default {
731
765
  schema: 'src/db/schema.ts',
732
766
  outDir: 'src/api',
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/validation-options.ts","../src/drift.ts","../src/sponsor.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { SchemaAnalyzer } from '@drzl/analyzer';\nimport { ORPCGenerator } from '@drzl/generator-orpc';\nimport chalk from 'chalk';\nimport chokidar from 'chokidar';\nimport cliProgress from 'cli-progress';\nimport { Command } from 'commander';\nimport * as path from 'node:path';\nimport ora from 'ora';\nimport { validationOptions } from './validation-options';\nimport {\n computeGeneratorOutputDirs,\n computeWatchTargets,\n DrzlConfig,\n filterTables,\n loadConfig,\n} from './config.js';\nimport { diffSnapshots, restoreSnapshot, snapshotAll } from './drift.js';\nimport { maybeShowSponsorMessage } from './sponsor.js';\n\nconst program = new Command();\nprogram.name('drzl').description('DRZL - Drizzle Developer Toolkit').version('0.0.1');\nprogram.addHelpText(\n 'afterAll',\n `\\nNeed a template, adapter, or generator DRZL doesn't ship yet?\\n→ DM @omardulaimidev on X: https://x.com/omardulaimidev\\n`\n);\n\nprogram\n .command('analyze')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('--relations', 'include relations', true)\n .option('--validate', 'validate constraints', true)\n .option('--out <file>', 'write analysis JSON to file')\n .option('--json', 'print JSON to stdout (overrides --out)', false)\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const spinner = !opts.json ? ora('Analyzing schema...').start() : null;\n const start = Date.now();\n const res = await analyzer.analyze({\n includeRelations: !!opts.relations,\n validateConstraints: !!opts.validate,\n });\n const ms = Date.now() - start;\n const json = JSON.stringify(res, null, 2);\n if (opts.json) {\n console.log(json);\n } else if (opts.out) {\n const fs = await import('node:fs/promises');\n await fs.writeFile(opts.out, json, 'utf8');\n spinner?.succeed(chalk.green(`Analysis written to ${opts.out} in ${ms}ms`));\n } else {\n spinner?.succeed(chalk.green(`Analyzed in ${ms}ms`));\n console.log(json);\n }\n process.exit(res.issues.some((i) => i.level === 'error') ? 2 : 0);\n } catch (e: any) {\n const msg = e?.message ?? String(e);\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', code: 'DRZL_CLI_ANALYZE', message: msg }));\n else\n console.error(\n chalk.red('Analyze failed (DRZL_CLI_ANALYZE):'),\n msg,\n '\\nTip: run with --json for structured output.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate')\n .description('Run configured generators (drzl.config.*)')\n .option('-c, --config <path>', 'path to drzl.config')\n .option(\n '--check',\n 'regenerate and fail if the result differs from what is on disk, without changing it'\n )\n .action(async (opts: any) => {\n try {\n const cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(\n chalk.red('No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.')\n );\n process.exit(2);\n return;\n }\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const spinner = ora('Analyzing...').start();\n const t0 = Date.now();\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations,\n });\n // Applied before any generator sees the analysis, so every one of them honours it without\n // needing to know the option exists.\n analysis.tables = filterTables(analysis.tables, cfg);\n spinner.succeed(`Analysis complete in ${Date.now() - t0}ms`);\n reportWideColumns(analysis.issues);\n // Under --check the existing output is captured before anything overwrites it, so the\n // regenerated result can be compared against it and the tree put back either way.\n const driftDirs = computeGeneratorOutputDirs(cfg);\n const driftBefore = opts.check ? await snapshotAll(driftDirs) : null;\n const progress = new cliProgress.SingleBar(\n { hideCursor: true },\n cliProgress.Presets.shades_classic\n );\n const total = analysis.tables.length || 1;\n progress.start(total, 0);\n // Where the service generator is actually writing, so a router template that imports\n // services spells a path that exists. Templates default this to 'src/services', and with\n // nothing passed that default was used no matter where the services really went, emitting\n // an import of a module that was never created. Must match the `g.path ?? 'src/services'`\n // used by the service branch below.\n const servicesDir =\n cfg.generators.find((x: { kind: string }) => x.kind === 'service')?.path ?? 'src/services';\n for (const g of cfg.generators) {\n if (g.kind === 'orpc') {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n templateOptions: g.templateOptions,\n importExtension: g.importExtension,\n validation: g.validation,\n servicesDir,\n onProgress: ({ index }) => progress.update(index),\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (${g.kind}): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await import('@drzl/generator-service');\n const gen = new ServiceGenerator(analysis);\n const target = g.path ?? 'src/services';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n dataAccess: g.dataAccess,\n dbImportPath: g.dbImportPath,\n schemaImportPath: g.schemaImportPath,\n importExtension: g.importExtension,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (service): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Service generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-service')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await import('@drzl/generator-zod');\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (zod): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Zod generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-zod')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await import('@drzl/generator-valibot');\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (valibot): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Valibot generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-valibot')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await import('@drzl/generator-arktype');\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: false }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (arktype): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('ArkType generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-arktype')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'json-schema') {\n try {\n const { JsonSchemaGenerator } = await import('@drzl/generator-json-schema');\n const gen = new JsonSchemaGenerator(analysis);\n const target = g.path ?? 'src/validators/json-schema';\n const files = await gen.generate({\n // JSON Schema is data, so nothing here references a type from the schema module.\n ...(validationOptions(g, cfg, target, { schemaTypes: false }) as object),\n target: g.target,\n components: g.components,\n } as never);\n progress.stop();\n ora().succeed(chalk.green(`Generated (json-schema): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('JSON Schema generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-json-schema'),\n // An optional dependency, unlike the other generators, until its npm trusted\n // publisher exists. A missing optional dependency is skipped rather than failing\n // the install, which is what keeps `npm i @drzl/cli` working meanwhile.\n ''\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'typebox') {\n try {\n const { TypeBoxGenerator } = await import('@drzl/generator-typebox');\n const gen = new TypeBoxGenerator(analysis);\n const target = g.path ?? 'src/validators/typebox';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (typebox): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('TypeBox generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-typebox')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n }\n }\n if (driftBefore) {\n const after = await snapshotAll(driftDirs);\n const drift = diffSnapshots(driftBefore, after);\n // Restored whether or not anything drifted, so `--check` never leaves the tree altered.\n await restoreSnapshot(driftBefore, after);\n\n if (drift.length) {\n console.error(chalk.red(`\\nGenerated output is out of date (${drift.length} file(s)):`));\n for (const d of drift) {\n const mark = d.status === 'added' ? '+' : d.status === 'removed' ? '-' : '~';\n console.error(\n ` ${mark} ${chalk.yellow(d.status.padEnd(8))} ${path.relative(process.cwd(), d.file)}`\n );\n }\n console.error(\n chalk.dim(\n '\\nRun `drzl generate` and commit the result. Nothing was written by this check.'\n )\n );\n process.exit(1);\n }\n console.log(chalk.green('Generated output is up to date.'));\n return;\n }\n\n if (cfg.generators.length) {\n maybeShowSponsorMessage({ reason: 'generate' });\n }\n } catch (e: any) {\n console.error(\n chalk.red('Generate failed (DRZL_GEN_001):'),\n e?.message ?? e,\n '\\nTip: check your drzl.config.ts and template path.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:orpc')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('-o, --outDir <dir>', 'output directory', 'src/api')\n .option('--template <name>', 'template name', 'standard')\n .option('--includeRelations', 'include relation endpoints')\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const analysis = await analyzer.analyze({\n includeRelations: !!opts.includeRelations,\n validateConstraints: true,\n });\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: opts.outDir,\n template: opts.template,\n includeRelations: !!opts.includeRelations,\n });\n console.log(chalk.green(`Generated:`), files.map((f) => chalk.cyan(f)).join(', '));\n maybeShowSponsorMessage({ reason: 'generate:orpc' });\n } catch (e: any) {\n console.error(chalk.red('Generate orpc failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\nprogram\n .command('watch')\n .description('Watch schema and regenerate on changes')\n .option('-c, --config <path>', 'path to drzl.config')\n .option('--pipeline <name>', 'all | analyze | generate-orpc', 'all')\n .option('--debounce <ms>', 'debounce ms', '200')\n .option('--json', 'emit JSON logs', false)\n .option('--poll', 'force polling (helps WSL/Docker/remote FS)', false)\n .action(async (opts: any) => {\n let cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(chalk.red('No config found. Create drzl.config.ts or pass --config.'));\n process.exit(2);\n return;\n }\n\n const abs = (p: string) => path.resolve(process.cwd(), p);\n const isInside = (child: string, parent: string) => {\n const rel = path.relative(parent, child);\n return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);\n };\n\n const ignoredOutDirs = new Set<string>(computeGeneratorOutputDirs(cfg).map(abs));\n const currentTargets = new Set<string>(computeWatchTargets(cfg).map(abs));\n\n const syncWatcherTargets = (watcher: import('chokidar').FSWatcher, next: Set<string>) => {\n const add: string[] = [];\n const del: string[] = [];\n for (const p of next) if (!currentTargets.has(p)) add.push(p);\n for (const p of currentTargets) if (!next.has(p)) del.push(p);\n if (add.length) watcher.add(add);\n if (del.length) watcher.unwatch(del);\n currentTargets.clear();\n next.forEach((p) => currentTargets.add(p));\n };\n\n const rebuildIgnoreDirsFrom = (cfgNow: DrzlConfig) => {\n ignoredOutDirs.clear();\n for (const d of computeGeneratorOutputDirs(cfgNow)) ignoredOutDirs.add(abs(d));\n };\n\n // Watch targets are directories now, because chokidar v4 dropped glob support. The\n // extensions the old `**/*.{ts,tsx,js}` glob selected therefore have to be filtered here\n // instead, or every unrelated file in the schema's directory would trigger a rebuild.\n const WATCHED_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.mjs', '.cjs']);\n\n const ignoredFn = (p: string, stats?: { isDirectory(): boolean }) => {\n const full = abs(p);\n for (const dir of ignoredOutDirs) {\n if (full === dir || isInside(full, dir)) return true;\n }\n // A directory is never ignored: chokidar has to descend into it to reach the files.\n if (stats?.isDirectory()) return false;\n const ext = path.extname(full);\n // Without stats chokidar is asking about a path it has not resolved yet. An extensionless\n // one is almost certainly a directory, so let it through and decide once it is known.\n if (!ext) return false;\n return !WATCHED_EXTENSIONS.has(ext);\n };\n\n const watcher = chokidar.watch(Array.from(currentTargets), {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 400, pollInterval: 50 },\n usePolling: !!opts.poll,\n ignored: ignoredFn,\n });\n\n const logTrigger = (type: 'add' | 'change' | 'unlink', file: string) => {\n if (opts.json) console.log(JSON.stringify({ event: 'trigger', type, file }));\n };\n\n watcher\n .on('add', (p) => {\n logTrigger('add', p);\n trigger(p);\n })\n .on('change', (p) => {\n logTrigger('change', p);\n trigger(p);\n })\n .on('unlink', (p) => {\n logTrigger('unlink', p);\n trigger(p);\n });\n\n let lastFiles: string[] = [];\n\n const run = async () => {\n try {\n const reloaded = await loadConfig(opts.config);\n if (!reloaded) throw new Error('Config disappeared during watch.');\n cfg = reloaded;\n\n rebuildIgnoreDirsFrom(cfg);\n const nextTargets = new Set<string>(computeWatchTargets(cfg).map(abs));\n syncWatcherTargets(watcher, nextTargets);\n\n if (!opts.json) console.clear();\n\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'watch_config_applied',\n targets: Array.from(currentTargets),\n ignored: Array.from(ignoredOutDirs),\n })\n );\n }\n\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations,\n });\n analysis.tables = filterTables(analysis.tables, cfg);\n if (!opts.json) reportWideColumns(analysis.issues);\n\n if (opts.pipeline === 'analyze') {\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'analyze_complete',\n issues: analysis.issues,\n tables: analysis.tables.length,\n })\n );\n } else {\n console.log(chalk.green('Analyze complete.'));\n }\n return;\n }\n\n const newFiles: string[] = [];\n\n for (const g of cfg.generators) {\n if (\n opts.pipeline !== 'all' &&\n !(opts.pipeline === 'generate-orpc' && g.kind === 'orpc')\n ) {\n continue;\n }\n\n if (g.kind === 'orpc') {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n templateOptions: g.templateOptions,\n importExtension: g.importExtension,\n validation: g.validation,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (${g.kind}):`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await import('@drzl/generator-service');\n const gen = new ServiceGenerator(analysis);\n const target = g.path ?? 'src/services';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n dataAccess: g.dataAccess,\n dbImportPath: g.dbImportPath,\n schemaImportPath: g.schemaImportPath,\n importExtension: g.importExtension,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (service): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('Service generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-service')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await import('@drzl/generator-zod');\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (zod): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('Zod generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-zod')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await import('@drzl/generator-valibot');\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (valibot): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('Valibot generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-valibot')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await import('@drzl/generator-arktype');\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (arktype): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('ArkType generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-arktype')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n }\n }\n\n const added = newFiles.filter((f) => !lastFiles.includes(f));\n const removed = lastFiles.filter((f) => !newFiles.includes(f));\n opts.json\n ? console.log(JSON.stringify({ event: 'diff', added, removed }))\n : (() => {\n if (added.length) console.log(chalk.blue(`Added: ${added.join(', ')}`));\n if (removed.length) console.log(chalk.yellow(`Removed: ${removed.join(', ')}`));\n })();\n if (newFiles.length && !opts.json) {\n const reason =\n opts.pipeline && opts.pipeline !== 'all' ? `watch:${opts.pipeline}` : 'watch';\n maybeShowSponsorMessage({ reason });\n }\n lastFiles = newFiles;\n } catch (e: any) {\n opts.json\n ? console.log(JSON.stringify({ event: 'error', message: String(e?.message ?? e) }))\n : console.error(chalk.red('Watch pipeline failed:'), e?.message ?? e);\n }\n };\n\n const debounced = Number(opts.debounce) || 200;\n let timer: NodeJS.Timeout | null = null;\n const trigger = (file?: string) => {\n if (file) {\n const full = abs(file);\n for (const dir of ignoredOutDirs) {\n if (full === dir || isInside(full, dir)) return;\n }\n }\n if (timer) clearTimeout(timer);\n timer = setTimeout(run, debounced);\n };\n\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'watching',\n targets: Array.from(currentTargets),\n ignored: Array.from(ignoredOutDirs),\n })\n );\n } else {\n console.log(\n chalk.gray(\n 'Watching:\\n ' +\n Array.from(currentTargets)\n .map((p) => path.relative(process.cwd(), p))\n .join('\\n ')\n )\n );\n }\n\n watcher\n .on('add', (p) => trigger(p))\n .on('change', (p) => trigger(p))\n .on('unlink', (p) => trigger(p))\n .on('error', (err) => console.error(chalk.red('Watcher error:'), err));\n\n await run();\n });\n\nprogram\n .command('init')\n .description('Scaffold a drzl.config.ts')\n .option('-y, --yes', 'accept defaults')\n .action(async (_opts: any) => {\n const fs = await import('node:fs/promises');\n const path = await import('node:path');\n const target = path.resolve(process.cwd(), 'drzl.config.ts');\n const template = `export default {\n schema: 'src/db/schema.ts',\n outDir: 'src/api',\n analyzer: { includeRelations: true, validateConstraints: true },\n generators: [\n { kind: 'orpc', template: 'standard', includeRelations: true }\n ]\n} as const\\n`;\n try {\n await fs.writeFile(target, template, { flag: 'wx' });\n console.log(chalk.green(`Created ${target}`));\n } catch (e: any) {\n console.error(chalk.red('Init failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\n/**\n * Tell the user which columns got a validator that accepts anything.\n *\n * This is the user-facing half of a check `verify-packed.sh` runs on this repository. Two real\n * bugs took exactly this shape, `.array()` and `pgEnum` columns coming back untyped on\n * drizzle-orm 0.4x, and the only way anyone noticed was reading the generated file. A user whose\n * schema uses a type nobody here has modelled gets the same silence, and no gate of ours helps\n * them.\n *\n * Printed once with a count rather than a line per column, so a schema with fifty custom types\n * stays readable.\n */\nfunction reportWideColumns(issues: Array<{ code?: string; message?: string; hint?: string }>) {\n const wide = issues.filter((i) => i.code === 'DRZL_ANL_UNKNOWN_COLUMN');\n if (!wide.length) return;\n console.warn(\n chalk.yellow(`\\n${wide.length} column${wide.length === 1 ? '' : 's'} could not be typed:`)\n );\n for (const i of wide.slice(0, 10)) console.warn(chalk.gray(` - ${i.message}`));\n if (wide.length > 10) console.warn(chalk.gray(` ... and ${wide.length - 10} more`));\n // One hint for the set, since they are almost always the same two.\n const hints = [...new Set(wide.map((i) => i.hint).filter(Boolean))];\n for (const h of hints) console.warn(chalk.gray(` ${h}`));\n}\n\nprogram.parseAsync(process.argv);\n","/**\n * The options every validation generator receives, built in one place.\n *\n * Each of the four branches used to assemble this by hand, and three documented options were\n * found silently dead as a result: `typedJson` never reached typebox, and `coerceDates` and\n * `applyDefaults` never reached anything but zod. The config parsed them, the CLI dropped them,\n * and the feature simply did nothing while nothing said so. Building it once removes the class\n * rather than fixing each instance.\n *\n * What stays per-generator is a real capability rather than an oversight, which is why it is\n * named as one.\n */\n\n/** A generator entry from the config, loosely typed because the config schema owns its shape. */\ntype GeneratorConfig = {\n outputHeader?: unknown;\n format?: unknown;\n schemaSuffix?: unknown;\n fileSuffix?: unknown;\n importExtension?: unknown;\n affix?: unknown;\n coerceDates?: unknown;\n applyDefaults?: unknown;\n typedJson?: unknown;\n typedColumns?: unknown;\n duplicateFinder?: unknown;\n};\n\nexport interface GeneratorCapabilities {\n /**\n * Whether the generator can reference a type from the schema module.\n *\n * `typedJson` and `typedColumns` both work by importing the table back and reading\n * `typeof table.$inferSelect['col']`, so a generator that cannot embed a TypeScript type in its\n * output cannot use either. ArkType is the case: it emits one string per field, and a type\n * reference has nowhere to live inside a string DSL.\n */\n schemaTypes?: boolean;\n}\n\nexport function validationOptions(\n g: GeneratorConfig,\n cfg: { schema?: unknown },\n outDir: string,\n caps: GeneratorCapabilities = {}\n): Record<string, unknown> {\n return {\n outDir,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n coerceDates: g.coerceDates,\n applyDefaults: g.applyDefaults,\n duplicateFinder: g.duplicateFinder,\n // Only where the generator can act on them, so an unsupported option is absent rather than\n // present and ignored.\n ...(caps.schemaTypes\n ? {\n // Needed by both: the reference is resolved relative to the emitted file.\n schemaPath: cfg.schema,\n typedJson: g.typedJson,\n typedColumns: g.typedColumns,\n }\n : {}),\n };\n}\n","/**\n * Drift detection for generated output.\n *\n * No runtime validator can offer this. `drizzle-orm/zod` and friends derive schemas in memory at\n * import time, so there is nothing on disk to have drifted and nothing for CI to compare. It is\n * only available to a code generator, which makes it one of the few things DRZL can do that the\n * first-party modules structurally cannot.\n *\n * The check is: regenerate, and require the result to equal what is committed. That catches the\n * two failures that actually happen, someone editing generated files by hand and someone\n * changing the schema without regenerating, and it catches them in CI rather than in review.\n *\n * Content-neutral by construction. Redirecting output to a temporary directory would not work:\n * generated files contain paths computed relative to their own location, so a different output\n * directory produces legitimately different bytes and every file would report as drifted. So the\n * real directories are snapshotted first, regeneration is allowed to overwrite them, and the\n * snapshot is put back if anything changed. Either way the tree ends as it began.\n */\nimport { promises as fs } from 'node:fs';\nimport path from 'node:path';\n\nexport interface DriftEntry {\n file: string;\n status: 'changed' | 'added' | 'removed';\n}\n\n/** Every file under `dir`, keyed by its path relative to `dir`. Missing directory means empty. */\nexport async function snapshotDir(dir: string): Promise<Map<string, string>> {\n const out = new Map<string, string>();\n async function walk(current: string) {\n let entries;\n try {\n entries = await fs.readdir(current, { withFileTypes: true });\n } catch {\n return; // Nothing generated there yet, which a first run should report as additions.\n }\n for (const e of entries) {\n const full = path.join(current, e.name);\n if (e.isDirectory()) await walk(full);\n else out.set(path.relative(dir, full), await fs.readFile(full, 'utf8'));\n }\n }\n await walk(dir);\n return out;\n}\n\n/** Snapshot several directories at once, keys prefixed by directory so they cannot collide. */\nexport async function snapshotAll(dirs: string[]): Promise<Map<string, string>> {\n const all = new Map<string, string>();\n for (const dir of dirs) {\n for (const [rel, content] of await snapshotDir(dir)) {\n all.set(path.join(dir, rel), content);\n }\n }\n return all;\n}\n\n/** What changed between two snapshots. */\nexport function diffSnapshots(\n before: Map<string, string>,\n after: Map<string, string>\n): DriftEntry[] {\n const out: DriftEntry[] = [];\n for (const [file, content] of after) {\n if (!before.has(file)) out.push({ file, status: 'added' });\n else if (before.get(file) !== content) out.push({ file, status: 'changed' });\n }\n for (const file of before.keys()) {\n if (!after.has(file)) out.push({ file, status: 'removed' });\n }\n return out.sort((a, b) => a.file.localeCompare(b.file));\n}\n\n/**\n * Put a snapshot back, so a failed check leaves the tree exactly as it found it.\n *\n * A file that regeneration created and the snapshot does not know about is deleted, since it was\n * not there before the check ran.\n */\nexport async function restoreSnapshot(\n before: Map<string, string>,\n after: Map<string, string>\n): Promise<void> {\n for (const [file, content] of before) {\n await fs.mkdir(path.dirname(file), { recursive: true });\n await fs.writeFile(file, content, 'utf8');\n }\n for (const file of after.keys()) {\n if (!before.has(file)) await fs.rm(file, { force: true });\n }\n}\n","import chalk from 'chalk';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport interface SponsorMessageOptions {\n reason?: string;\n minIntervalMs?: number;\n force?: boolean;\n}\n\ninterface SponsorCachePayload {\n runs: number;\n lastShownAt?: number;\n lastReason?: string;\n}\n\nconst CACHE_DIR = path.join(process.cwd(), 'node_modules', '.cache', '@drzl');\nconst CACHE_FILE = path.join(CACHE_DIR, 'sponsor-message.json');\nconst DEFAULT_INTERVAL_MS = 1000 * 60 * 15; // 15 minutes\nlet shownThisProcess = false;\n\nconst tips = [\n 'Pair DRZL watch mode with drizzle-kit to keep schema & API synced.',\n 'Templatize your ORPC routers to roll out new endpoints safely.',\n 'Need typed validators? Enable the zod, valibot, arktype, or typebox generators.',\n 'Use output headers to track generated files and trim noisy diffs.',\n];\n\nconst green = (msg: string) => chalk.hex('#6ee7b7')(msg);\nconst cyan = (msg: string) => chalk.cyan(msg);\nconst gray = (msg: string) => chalk.gray(msg);\n\nexport function maybeShowSponsorMessage({\n reason = 'generate',\n minIntervalMs = DEFAULT_INTERVAL_MS,\n force = false,\n}: SponsorMessageOptions = {}) {\n const hideViaEnv = process.env.DRZL_HIDE_SPONSOR?.toLowerCase();\n const hideRequested = hideViaEnv === '1' || hideViaEnv === 'true';\n if (hideRequested || (process.env.CI && !force) || (shownThisProcess && !force)) return;\n\n try {\n mkdirSync(CACHE_DIR, { recursive: true });\n const payload = readCache();\n payload.runs += 1;\n\n const now = Date.now();\n const shouldShow = force || now - (payload.lastShownAt ?? 0) >= minIntervalMs;\n\n if (shouldShow) {\n payload.lastShownAt = now;\n payload.lastReason = reason;\n }\n\n writeCache(payload);\n\n if (!shouldShow) return;\n\n shownThisProcess = true;\n const tip = tips[payload.runs % tips.length];\n\n console.log(\n `\\n${cyan(`🚀 DRZL finished a ${reason} run (#${payload.runs.toLocaleString()}).`)}\\n\\n` +\n `${green('✨ Sponsors keep DRZL shipping. Consider supporting ongoing dev:')}\\n` +\n ` ${green('GitHub Sponsors')} ${gray('→ https://github.com/sponsors/omar-dulaimi')}\\n\\n` +\n `${green('Pro tip:')} ${tip}\\n`\n );\n } catch {\n // Swallow to avoid impacting generator success paths\n }\n}\n\nfunction readCache(): SponsorCachePayload {\n if (!existsSync(CACHE_FILE)) {\n return { runs: 0 };\n }\n try {\n const data = JSON.parse(readFileSync(CACHE_FILE, 'utf8')) as SponsorCachePayload;\n if (typeof data.runs !== 'number') return { runs: 0 };\n return data;\n } catch {\n return { runs: 0 };\n }\n}\n\nfunction writeCache(payload: SponsorCachePayload) {\n writeFileSync(CACHE_F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AI,cAAc,GAAG,GAAG,WAAW,CAAC;AACxD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAcH,SAAS,kBAAkB,QAAmE;AAC5F,QAAM,OAAO,OAAO,OAAO,CAAC,MAAM,EAAE,SAAS,yBAAyB;AACtE,MAAI,CAAC,KAAK,OAAQ;AAClB,UAAQ;AAAA,IACNA,OAAM,OAAO;AAAA,EAAK,KAAK,MAAM,UAAU,KAAK,WAAW,IAAI,KAAK,GAAG,sBAAsB;AAAA,EAC3F;AACA,aAAW,KAAK,KAAK,MAAM,GAAG,EAAE,EAAG,SAAQ,KAAKA,OAAM,KAAK,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9E,MAAI,KAAK,SAAS,GAAI,SAAQ,KAAKA,OAAM,KAAK,aAAa,KAAK,SAAS,EAAE,OAAO,CAAC;AAEnF,QAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,OAAO,CAAC,CAAC;AAClE,aAAW,KAAK,MAAO,SAAQ,KAAKA,OAAM,KAAK,KAAK,CAAC,EAAE,CAAC;AAC1D;AAEA,QAAQ,WAAW,QAAQ,IAAI;","names":["chalk","path","path","fs","chalk","watcher","path"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/validation-options.ts","../src/drift.ts","../src/sponsor.ts","../src/version.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { SchemaAnalyzer } from '@drzl/analyzer';\nimport { ORPCGenerator } from '@drzl/generator-orpc';\nimport chalk from 'chalk';\nimport chokidar from 'chokidar';\nimport cliProgress from 'cli-progress';\nimport { Command } from 'commander';\nimport * as path from 'node:path';\nimport ora from 'ora';\nimport { validationOptions } from './validation-options';\nimport {\n computeGeneratorOutputDirs,\n computeWatchTargets,\n DrzlConfig,\n filterTables,\n loadConfig,\n} from './config.js';\nimport { diffSnapshots, restoreSnapshot, snapshotAll } from './drift.js';\nimport { maybeShowSponsorMessage } from './sponsor.js';\nimport { CLI_VERSION } from './version.js';\n\nconst program = new Command();\nprogram.name('drzl').description('DRZL - Drizzle Developer Toolkit').version(CLI_VERSION);\nprogram.addHelpText(\n 'afterAll',\n `\\nNeed a template, adapter, or generator DRZL doesn't ship yet?\\n→ DM @omardulaimidev on X: https://x.com/omardulaimidev\\n`\n);\n\nprogram\n .command('analyze')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('--relations', 'include relations', true)\n .option('--validate', 'validate constraints', true)\n .option('--out <file>', 'write analysis JSON to file')\n .option('--json', 'print JSON to stdout (overrides --out)', false)\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const spinner = !opts.json ? ora('Analyzing schema...').start() : null;\n const start = Date.now();\n const res = await analyzer.analyze({\n includeRelations: !!opts.relations,\n validateConstraints: !!opts.validate,\n });\n const ms = Date.now() - start;\n const json = JSON.stringify(res, null, 2);\n if (opts.json) {\n console.log(json);\n } else if (opts.out) {\n const fs = await import('node:fs/promises');\n await fs.writeFile(opts.out, json, 'utf8');\n spinner?.succeed(chalk.green(`Analysis written to ${opts.out} in ${ms}ms`));\n } else {\n spinner?.succeed(chalk.green(`Analyzed in ${ms}ms`));\n console.log(json);\n }\n process.exit(res.issues.some((i) => i.level === 'error') ? 2 : 0);\n } catch (e: any) {\n const msg = e?.message ?? String(e);\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', code: 'DRZL_CLI_ANALYZE', message: msg }));\n else\n console.error(\n chalk.red('Analyze failed (DRZL_CLI_ANALYZE):'),\n msg,\n '\\nTip: run with --json for structured output.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate')\n .description('Run configured generators (drzl.config.*)')\n .option('-c, --config <path>', 'path to drzl.config')\n .option(\n '--check',\n 'regenerate and fail if the result differs from what is on disk, without changing it'\n )\n .action(async (opts: any) => {\n try {\n const cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(\n chalk.red('No config found (DRZL_CFG_001). Create drzl.config.ts or pass --config.')\n );\n process.exit(2);\n return;\n }\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const spinner = ora('Analyzing...').start();\n const t0 = Date.now();\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations,\n });\n // Applied before any generator sees the analysis, so every one of them honours it without\n // needing to know the option exists.\n analysis.tables = filterTables(analysis.tables, cfg);\n spinner.succeed(`Analysis complete in ${Date.now() - t0}ms`);\n reportWideColumns(analysis.issues);\n // Under --check the existing output is captured before anything overwrites it, so the\n // regenerated result can be compared against it and the tree put back either way.\n const driftDirs = computeGeneratorOutputDirs(cfg);\n const driftBefore = opts.check ? await snapshotAll(driftDirs) : null;\n const progress = new cliProgress.SingleBar(\n { hideCursor: true },\n cliProgress.Presets.shades_classic\n );\n const total = analysis.tables.length || 1;\n progress.start(total, 0);\n // Where the service generator is actually writing, so a router template that imports\n // services spells a path that exists. Templates default this to 'src/services', and with\n // nothing passed that default was used no matter where the services really went, emitting\n // an import of a module that was never created. Must match the `g.path ?? 'src/services'`\n // used by the service branch below.\n const servicesDir =\n cfg.generators.find((x: { kind: string }) => x.kind === 'service')?.path ?? 'src/services';\n for (const g of cfg.generators) {\n if (g.kind === 'orpc') {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n templateOptions: g.templateOptions,\n importExtension: g.importExtension,\n validation: g.validation,\n servicesDir,\n onProgress: ({ index }) => progress.update(index),\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (${g.kind}): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await import('@drzl/generator-service');\n const gen = new ServiceGenerator(analysis);\n const target = g.path ?? 'src/services';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n dataAccess: g.dataAccess,\n dbImportPath: g.dbImportPath,\n schemaImportPath: g.schemaImportPath,\n importExtension: g.importExtension,\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (service): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Service generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-service')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await import('@drzl/generator-zod');\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (zod): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Zod generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-zod')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await import('@drzl/generator-valibot');\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (valibot): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('Valibot generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-valibot')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await import('@drzl/generator-arktype');\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: false }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (arktype): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('ArkType generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-arktype')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'json-schema') {\n try {\n const { JsonSchemaGenerator } = await import('@drzl/generator-json-schema');\n const gen = new JsonSchemaGenerator(analysis);\n const target = g.path ?? 'src/validators/json-schema';\n const files = await gen.generate({\n // JSON Schema is data, so nothing here references a type from the schema module.\n ...(validationOptions(g, cfg, target, { schemaTypes: false }) as object),\n target: g.target,\n components: g.components,\n } as never);\n progress.stop();\n ora().succeed(chalk.green(`Generated (json-schema): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('JSON Schema generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-json-schema'),\n // An optional dependency, unlike the other generators, until its npm trusted\n // publisher exists. A missing optional dependency is skipped rather than failing\n // the install, which is what keeps `npm i @drzl/cli` working meanwhile.\n ''\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n } else if (g.kind === 'typebox') {\n try {\n const { TypeBoxGenerator } = await import('@drzl/generator-typebox');\n const gen = new TypeBoxGenerator(analysis);\n const target = g.path ?? 'src/validators/typebox';\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n progress.stop();\n ora().succeed(chalk.green(`Generated (typebox): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n console.error(\n chalk.red('TypeBox generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-typebox')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n process.exit(1);\n }\n }\n }\n if (driftBefore) {\n const after = await snapshotAll(driftDirs);\n const drift = diffSnapshots(driftBefore, after);\n // Restored whether or not anything drifted, so `--check` never leaves the tree altered.\n await restoreSnapshot(driftBefore, after);\n\n if (drift.length) {\n console.error(chalk.red(`\\nGenerated output is out of date (${drift.length} file(s)):`));\n for (const d of drift) {\n const mark = d.status === 'added' ? '+' : d.status === 'removed' ? '-' : '~';\n console.error(\n ` ${mark} ${chalk.yellow(d.status.padEnd(8))} ${path.relative(process.cwd(), d.file)}`\n );\n }\n console.error(\n chalk.dim(\n '\\nRun `drzl generate` and commit the result. Nothing was written by this check.'\n )\n );\n process.exit(1);\n }\n console.log(chalk.green('Generated output is up to date.'));\n return;\n }\n\n if (cfg.generators.length) {\n maybeShowSponsorMessage({ reason: 'generate' });\n }\n } catch (e: any) {\n console.error(\n chalk.red('Generate failed (DRZL_GEN_001):'),\n e?.message ?? e,\n '\\nTip: check your drzl.config.ts and template path.'\n );\n process.exit(1);\n }\n });\n\nprogram\n .command('generate:orpc')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('-o, --outDir <dir>', 'output directory', 'src/api')\n .option('--template <name>', 'template name', 'standard')\n .option('--includeRelations', 'include relation endpoints')\n .action(async (schema: string, opts: any) => {\n try {\n const analyzer = new SchemaAnalyzer(schema);\n const analysis = await analyzer.analyze({\n includeRelations: !!opts.includeRelations,\n validateConstraints: true,\n });\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: opts.outDir,\n template: opts.template,\n includeRelations: !!opts.includeRelations,\n });\n console.log(chalk.green(`Generated:`), files.map((f) => chalk.cyan(f)).join(', '));\n maybeShowSponsorMessage({ reason: 'generate:orpc' });\n } catch (e: any) {\n console.error(chalk.red('Generate orpc failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\nprogram\n .command('watch')\n .description('Watch schema and regenerate on changes')\n .option('-c, --config <path>', 'path to drzl.config')\n .option('--pipeline <name>', 'all | analyze | generate-orpc', 'all')\n .option('--debounce <ms>', 'debounce ms', '200')\n .option('--json', 'emit JSON logs', false)\n .option('--poll', 'force polling (helps WSL/Docker/remote FS)', false)\n .action(async (opts: any) => {\n let cfg = await loadConfig(opts.config);\n if (!cfg) {\n console.error(chalk.red('No config found. Create drzl.config.ts or pass --config.'));\n process.exit(2);\n return;\n }\n\n const abs = (p: string) => path.resolve(process.cwd(), p);\n const isInside = (child: string, parent: string) => {\n const rel = path.relative(parent, child);\n return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);\n };\n\n const ignoredOutDirs = new Set<string>(computeGeneratorOutputDirs(cfg).map(abs));\n const currentTargets = new Set<string>(computeWatchTargets(cfg).map(abs));\n\n const syncWatcherTargets = (watcher: import('chokidar').FSWatcher, next: Set<string>) => {\n const add: string[] = [];\n const del: string[] = [];\n for (const p of next) if (!currentTargets.has(p)) add.push(p);\n for (const p of currentTargets) if (!next.has(p)) del.push(p);\n if (add.length) watcher.add(add);\n if (del.length) watcher.unwatch(del);\n currentTargets.clear();\n next.forEach((p) => currentTargets.add(p));\n };\n\n const rebuildIgnoreDirsFrom = (cfgNow: DrzlConfig) => {\n ignoredOutDirs.clear();\n for (const d of computeGeneratorOutputDirs(cfgNow)) ignoredOutDirs.add(abs(d));\n };\n\n // Watch targets are directories now, because chokidar v4 dropped glob support. The\n // extensions the old `**/*.{ts,tsx,js}` glob selected therefore have to be filtered here\n // instead, or every unrelated file in the schema's directory would trigger a rebuild.\n const WATCHED_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.mjs', '.cjs']);\n\n const ignoredFn = (p: string, stats?: { isDirectory(): boolean }) => {\n const full = abs(p);\n for (const dir of ignoredOutDirs) {\n if (full === dir || isInside(full, dir)) return true;\n }\n // A directory is never ignored: chokidar has to descend into it to reach the files.\n if (stats?.isDirectory()) return false;\n const ext = path.extname(full);\n // Without stats chokidar is asking about a path it has not resolved yet. An extensionless\n // one is almost certainly a directory, so let it through and decide once it is known.\n if (!ext) return false;\n return !WATCHED_EXTENSIONS.has(ext);\n };\n\n const watcher = chokidar.watch(Array.from(currentTargets), {\n ignoreInitial: true,\n awaitWriteFinish: { stabilityThreshold: 400, pollInterval: 50 },\n usePolling: !!opts.poll,\n ignored: ignoredFn,\n });\n\n const logTrigger = (type: 'add' | 'change' | 'unlink', file: string) => {\n if (opts.json) console.log(JSON.stringify({ event: 'trigger', type, file }));\n };\n\n watcher\n .on('add', (p) => {\n logTrigger('add', p);\n trigger(p);\n })\n .on('change', (p) => {\n logTrigger('change', p);\n trigger(p);\n })\n .on('unlink', (p) => {\n logTrigger('unlink', p);\n trigger(p);\n });\n\n let lastFiles: string[] = [];\n\n const run = async () => {\n try {\n const reloaded = await loadConfig(opts.config);\n if (!reloaded) throw new Error('Config disappeared during watch.');\n cfg = reloaded;\n\n rebuildIgnoreDirsFrom(cfg);\n const nextTargets = new Set<string>(computeWatchTargets(cfg).map(abs));\n syncWatcherTargets(watcher, nextTargets);\n\n if (!opts.json) console.clear();\n\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'watch_config_applied',\n targets: Array.from(currentTargets),\n ignored: Array.from(ignoredOutDirs),\n })\n );\n }\n\n const analyzer = new SchemaAnalyzer(cfg.schema);\n const analysis = await analyzer.analyze({\n includeRelations: cfg.analyzer.includeRelations,\n validateConstraints: cfg.analyzer.validateConstraints,\n includeHeuristicRelations: cfg.analyzer.includeHeuristicRelations,\n });\n analysis.tables = filterTables(analysis.tables, cfg);\n if (!opts.json) reportWideColumns(analysis.issues);\n\n if (opts.pipeline === 'analyze') {\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'analyze_complete',\n issues: analysis.issues,\n tables: analysis.tables.length,\n })\n );\n } else {\n console.log(chalk.green('Analyze complete.'));\n }\n return;\n }\n\n const newFiles: string[] = [];\n\n for (const g of cfg.generators) {\n if (\n opts.pipeline !== 'all' &&\n !(opts.pipeline === 'generate-orpc' && g.kind === 'orpc')\n ) {\n continue;\n }\n\n if (g.kind === 'orpc') {\n const gen = new ORPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: cfg.outDir,\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n templateOptions: g.templateOptions,\n importExtension: g.importExtension,\n validation: g.validation,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (${g.kind}):`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await import('@drzl/generator-service');\n const gen = new ServiceGenerator(analysis);\n const target = g.path ?? 'src/services';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n dataAccess: g.dataAccess,\n dbImportPath: g.dbImportPath,\n schemaImportPath: g.schemaImportPath,\n importExtension: g.importExtension,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (service): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('Service generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-service')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await import('@drzl/generator-zod');\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (zod): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('Zod generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-zod')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await import('@drzl/generator-valibot');\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (valibot): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('Valibot generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-valibot')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await import('@drzl/generator-arktype');\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n const files = await gen.generate({\n outDir: target,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n });\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (arktype): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n console.error(\n chalk.red('ArkType generator missing.'),\n chalk.yellow('\\nInstall with: npm install @drzl/generator-arktype')\n );\n console.error(chalk.gray('Error details:'), e?.message ?? e);\n return;\n }\n }\n }\n\n const added = newFiles.filter((f) => !lastFiles.includes(f));\n const removed = lastFiles.filter((f) => !newFiles.includes(f));\n opts.json\n ? console.log(JSON.stringify({ event: 'diff', added, removed }))\n : (() => {\n if (added.length) console.log(chalk.blue(`Added: ${added.join(', ')}`));\n if (removed.length) console.log(chalk.yellow(`Removed: ${removed.join(', ')}`));\n })();\n if (newFiles.length && !opts.json) {\n const reason =\n opts.pipeline && opts.pipeline !== 'all' ? `watch:${opts.pipeline}` : 'watch';\n maybeShowSponsorMessage({ reason });\n }\n lastFiles = newFiles;\n } catch (e: any) {\n opts.json\n ? console.log(JSON.stringify({ event: 'error', message: String(e?.message ?? e) }))\n : console.error(chalk.red('Watch pipeline failed:'), e?.message ?? e);\n }\n };\n\n const debounced = Number(opts.debounce) || 200;\n let timer: NodeJS.Timeout | null = null;\n const trigger = (file?: string) => {\n if (file) {\n const full = abs(file);\n for (const dir of ignoredOutDirs) {\n if (full === dir || isInside(full, dir)) return;\n }\n }\n if (timer) clearTimeout(timer);\n timer = setTimeout(run, debounced);\n };\n\n if (opts.json) {\n console.log(\n JSON.stringify({\n event: 'watching',\n targets: Array.from(currentTargets),\n ignored: Array.from(ignoredOutDirs),\n })\n );\n } else {\n console.log(\n chalk.gray(\n 'Watching:\\n ' +\n Array.from(currentTargets)\n .map((p) => path.relative(process.cwd(), p))\n .join('\\n ')\n )\n );\n }\n\n watcher\n .on('add', (p) => trigger(p))\n .on('change', (p) => trigger(p))\n .on('unlink', (p) => trigger(p))\n .on('error', (err) => console.error(chalk.red('Watcher error:'), err));\n\n await run();\n });\n\nprogram\n .command('init')\n .description('Scaffold a drzl.config.ts')\n .option('-y, --yes', 'accept defaults')\n .action(async (_opts: any) => {\n const fs = await import('node:fs/promises');\n const path = await import('node:path');\n const target = path.resolve(process.cwd(), 'drzl.config.ts');\n const template = `export default {\n schema: 'src/db/schema.ts',\n outDir: 'src/api',\n analyzer: { includeRelations: true, validateConstraints: true },\n generators: [\n { kind: 'orpc', template: 'standard', includeRelations: true }\n ]\n} as const\\n`;\n try {\n await fs.writeFile(target, template, { flag: 'wx' });\n console.log(chalk.green(`Created ${target}`));\n } catch (e: any) {\n console.error(chalk.red('Init failed:'), e?.message ?? e);\n process.exit(1);\n }\n });\n\n/**\n * Tell the user which columns got a validator that accepts anything.\n *\n * This is the user-facing half of a check `verify-packed.sh` runs on this repository. Two real\n * bugs took exactly this shape, `.array()` and `pgEnum` columns coming back untyped on\n * drizzle-orm 0.4x, and the only way anyone noticed was reading the generated file. A user whose\n * schema uses a type nobody here has modelled gets the same silence, and no gate of ours helps\n * them.\n *\n * Printed once with a count rather than a line per column, so a schema with fifty custom types\n * stays readable.\n */\nfunction reportWideColumns(issues: Array<{ code?: string; message?: string; hint?: string }>) {\n const wide = issues.filter((i) => i.code === 'DRZL_ANL_UNKNOWN_COLUMN');\n if (!wide.length) return;\n console.warn(\n chalk.yellow(`\\n${wide.length} column${wide.length === 1 ? '' : 's'} could not be typed:`)\n );\n for (const i of wide.slice(0, 10)) console.warn(chalk.gray(` - ${i.message}`));\n if (wide.length > 10) console.warn(chalk.gray(` ... and ${wide.length - 10} more`));\n // One hint for the set, since they are almost always the same two.\n const hints = [...new Set(wide.map((i) => i.hint).filter(Boolean))];\n for (const h of hints) console.warn(chalk.gray(` ${h}`));\n}\n\nprogram.parseAsync(process.argv);\n","/**\n * The options every validation generator receives, built in one place.\n *\n * Each of the four branches used to assemble this by hand, and three documented options were\n * found silently dead as a result: `typedJson` never reached typebox, and `coerceDates` and\n * `applyDefaults` never reached anything but zod. The config parsed them, the CLI dropped them,\n * and the feature simply did nothing while nothing said so. Building it once removes the class\n * rather than fixing each instance.\n *\n * What stays per-generator is a real capability rather than an oversight, which is why it is\n * named as one.\n */\n\n/** A generator entry from the config, loosely typed because the config schema owns its shape. */\ntype GeneratorConfig = {\n outputHeader?: unknown;\n format?: unknown;\n schemaSuffix?: unknown;\n fileSuffix?: unknown;\n importExtension?: unknown;\n affix?: unknown;\n coerceDates?: unknown;\n applyDefaults?: unknown;\n typedJson?: unknown;\n typedColumns?: unknown;\n duplicateFinder?: unknown;\n};\n\nexport interface GeneratorCapabilities {\n /**\n * Whether the generator can reference a type from the schema module.\n *\n * `typedJson` and `typedColumns` both work by importing the table back and reading\n * `typeof table.$inferSelect['col']`, so a generator that cannot embed a TypeScript type in its\n * output cannot use either. ArkType is the case: it emits one string per field, and a type\n * reference has nowhere to live inside a string DSL.\n */\n schemaTypes?: boolean;\n}\n\nexport function validationOptions(\n g: GeneratorConfig,\n cfg: { schema?: unknown },\n outDir: string,\n caps: GeneratorCapabilities = {}\n): Record<string, unknown> {\n return {\n outDir,\n outputHeader: g.outputHeader,\n format: g.format,\n schemaSuffix: g.schemaSuffix,\n fileSuffix: g.fileSuffix,\n importExtension: g.importExtension,\n affix: g.affix,\n coerceDates: g.coerceDates,\n applyDefaults: g.applyDefaults,\n duplicateFinder: g.duplicateFinder,\n // Only where the generator can act on them, so an unsupported option is absent rather than\n // present and ignored.\n ...(caps.schemaTypes\n ? {\n // Needed by both: the reference is resolved relative to the emitted file.\n schemaPath: cfg.schema,\n typedJson: g.typedJson,\n typedColumns: g.typedColumns,\n }\n : {}),\n };\n}\n","/**\n * Drift detection for generated output.\n *\n * No runtime validator can offer this. `drizzle-orm/zod` and friends derive schemas in memory at\n * import time, so there is nothing on disk to have drifted and nothing for CI to compare. It is\n * only available to a code generator, which makes it one of the few things DRZL can do that the\n * first-party modules structurally cannot.\n *\n * The check is: regenerate, and require the result to equal what is committed. That catches the\n * two failures that actually happen, someone editing generated files by hand and someone\n * changing the schema without regenerating, and it catches them in CI rather than in review.\n *\n * Content-neutral by construction. Redirecting output to a temporary directory would not work:\n * generated files contain paths computed relative to their own location, so a different output\n * directory produces legitimately different bytes and every file would report as drifted. So the\n * real directories are snapshotted first, regeneration is allowed to overwrite them, and the\n * snapshot is put back if anything changed. Either way the tree ends as it began.\n */\nimport { promises as fs } from 'node:fs';\nimport path from 'node:path';\n\nexport interface DriftEntry {\n file: string;\n status: 'changed' | 'added' | 'removed';\n}\n\n/** Every file under `dir`, keyed by its path relative to `dir`. Missing directory means empty. */\nexport async function snapshotDir(dir: string): Promise<Map<string, string>> {\n const out = new Map<string, string>();\n async function walk(current: string) {\n let entries;\n try {\n entries = await fs.readdir(current, { withFileTypes: true });\n } catch {\n return; // Nothing generated there yet, which a first run should report as additions.\n }\n for (const e of entries) {\n const full = path.join(current, e.name);\n if (e.isDirectory()) await walk(full);\n else out.set(path.relative(dir, full), await fs.readFile(full, 'utf8'));\n }\n }\n await walk(dir);\n return out;\n}\n\n/** Snapshot several directories at once, keys prefixed by directory so they cannot collide. */\nexport async function snapshotAll(dirs: string[]): Promise<Map<string, string>> {\n const all = new Map<string, string>();\n for (const dir of dirs) {\n for (const [rel, content] of await snapshotDir(dir)) {\n all.set(path.join(dir, rel), content);\n }\n }\n return all;\n}\n\n/** What changed between two snapshots. */\nexport function diffSnapshots(\n before: Map<string, string>,\n after: Map<string, string>\n): DriftEntry[] {\n const out: DriftEntry[] = [];\n for (const [file, content] of after) {\n if (!before.has(file)) out.push({ file, status: 'added' });\n else if (before.get(file) !== content) out.push({ file, status: 'changed' });\n }\n for (const file of before.keys()) {\n if (!after.has(file)) out.push({ file, status: 'removed' });\n }\n return out.sort((a, b) => a.file.localeCompare(b.file));\n}\n\n/**\n * Put a snapshot back, so a failed check leaves the tree exactly as it found it.\n *\n * A file that regeneration created and the snapshot does not know about is deleted, since it was\n * not there before the check ran.\n */\nexport async function restoreSnapshot(\n before: Map<string, string>,\n after: Map<string, string>\n): Promise<void> {\n for (const [file, content] of before) {\n await fs.mkdir(path.dirname(file), { recursive: true });\n await fs.writeFile(file, content, 'utf8');\n }\n for (const file of after.keys()) {\n if (!before.has(file)) await fs.rm(file, { force: true });\n }\n}\n","import chalk from 'chalk';\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\n\nexport interface SponsorMessageOptions {\n reason?: string;\n minIntervalMs?: number;\n force?: boolean;\n}\n\ninterface SponsorCachePayload {\n runs: number;\n lastShownAt?: number;\n lastReason?: string;\n}\n\nconst CACHE_DIR = path.join(process.cwd(), 'node_modules', '.cache', '@drzl');\nconst CACHE_FILE = path.join(CACHE_DIR, 'sponsor-message.json');\nconst DEFAULT_INTERVAL_MS = 1000 * 60 * 15; // 15 minutes\nlet shownThisProcess = false;\n\nconst tips = [\n 'Pair DRZL watch mode with drizzle-kit to keep schema & API synced.',\n 'Templatize your ORPC routers to roll out new endpoints safely.',\n 'Need typed validators? Enable the zod, valibot, arktype, or typebox generators.',\n 'Need JSON Schema or OpenAPI? The json-schema generator emits both, with no runtime dependency.',\n 'Use output headers to track generated files and trim noisy diffs.',\n];\n\nconst green = (msg: string) => chalk.hex('#6ee7b7')(msg);\nconst cyan = (msg: string) => chalk.cyan(msg);\nconst gray = (msg: string) => chalk.gray(msg);\n\nexport function maybeShowSponsorMessage({\n reason = 'generate',\n minIntervalMs = DEFAULT_INTERVAL_MS,\n force = false,\n}: SponsorMessageOptions = {}) {\n const hideViaEnv = process.env.DRZL_HIDE_SPONSOR?.toLowerCase();\n const hideRequested = hideViaEnv === '1' || hideViaEnv === 'true';\n if (hideRequested || (process.env.CI && !force) || (shownThisProcess && !force)) return;\n\n try {\n mkdirSync(CACHE_DIR, { recursive: true });\n const payload = readCache();\n payload.runs += 1;\n\n const now = Date.now();\n const shouldShow = force || now - (payload.lastShownAt ?? 0) >= minIntervalMs;\n\n if (shouldShow) {\n payload.lastShownAt = now;\n payload.lastReason = reason;\n }\n\n writeCache(payload);\n\n if (!shouldShow) return;\n\n shownThisProcess = true;\n const tip = tips[payload.runs % tips.length];\n\n console.log(\n `\\n${cyan(`🚀 DRZL finished a ${reason} run (#${payload.runs.toLocaleString()}).`)}\\n\\n` +\n `${green('✨ Sponsors keep DRZL shipping. Consider supporting ongoing dev:')}\\n` +\n ` ${green('GitHub Sponsors')} ${gray('→ https://github.com/sponsors/omar-dulaimi')}\\n\\n` +\n `${green('Pro tip:')} ${tip}\\n`\n );\n } catch {\n // Swallow to avoid impacting generator success paths\n }\n}\n\nfunction readCache(): SponsorCachePayload {\n if (!existsSync(CACHE_FILE)) {\n return { runs: 0 };\n }\n try {\n const data = JSON.parse(readFileSync(CACHE_FILE, 'utf8')) as SponsorCachePayload;\n if (typeof data.runs !== 'number') return { runs: 0 };\n return data;\n } catch {\n return { runs: 0 };\n }\n}\n\nfunction writeCache(payload: SponsorCachePayload) {\n writeFileSync(CACHE_FILE, JSON.stringify(payload, null, 2), 'utf8');\n}\n","/**\n * The version `drzl --version` prints, read from the manifest that ships beside the build.\n *\n * It used to be the literal `'0.0.1'`, passed to `program.version()` when the CLI was scaffolded\n * and never touched again. That was true of exactly one release, the first: the registry lists 29\n * versions of `@drzl/cli`, and the other 28 printed `0.0.1` as well. Reading the manifest is the\n * only form that cannot drift, because it is the same file the registry took the version from.\n *\n * Nothing here falls back. A build that cannot find its own manifest, or finds someone else's, has\n * resolved somewhere it did not intend to, and a placeholder standing in for that is how the\n * original defect stayed invisible for 28 releases.\n */\nimport { readFileSync } from 'node:fs';\nimport * as path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n/** The name the manifest beside this build must carry, which is what makes it ours. */\nconst PACKAGE_NAME = '@drzl/cli';\n\n/**\n * The directory holding the file this code ends up in, in every form it is reached.\n *\n * Three of them: `dist/cli.js`, `dist/cli.cjs`, and this file unbundled under ts-node, all three\n * run and checked. Only the CommonJS bundle has no `import.meta`; `tsup.config.ts` gives that\n * build a real value for `import.meta.url` rather than esbuild's empty one, so this needs no\n * branch. If that config is ever dropped, `fileURLToPath(undefined)` throws on load, so the\n * CommonJS bundle stops working loudly instead of reporting the wrong directory.\n */\nfunction moduleDir(): string {\n return path.dirname(fileURLToPath(import.meta.url));\n}\n\n/**\n * The `version` a named manifest declares, or a throw naming what was wrong with it.\n *\n * Split out from the caller below only so the three ways it refuses can be exercised without a\n * build. Nothing in the CLI passes a path.\n */\nexport function readVersionFrom(manifestPath: string): string {\n let raw: string;\n try {\n raw = readFileSync(manifestPath, 'utf8');\n } catch (e: any) {\n throw new Error(\n `${PACKAGE_NAME} cannot read its own version: no manifest at ${manifestPath} ` +\n `(${e?.message ?? String(e)}).`\n );\n }\n\n const manifest = JSON.parse(raw) as { name?: unknown; version?: unknown };\n\n if (manifest.name !== PACKAGE_NAME) {\n throw new Error(\n `${PACKAGE_NAME} looked for its own version in ${manifestPath} and found ` +\n `${JSON.stringify(manifest.name)}, so this build is not sitting where it thinks it is.`\n );\n }\n\n if (typeof manifest.version !== 'string' || manifest.version.length === 0) {\n throw new Error(`${manifestPath} declares no version, so there is nothing to report.`);\n }\n\n return manifest.version;\n}\n\n/**\n * The `version` field of this package's own manifest.\n *\n * Both bundles sit one level below it, in `dist/`, and so does `src/` when this file is run\n * unbundled, so one `..` covers every way it is reached. All three were run.\n */\nexport function readCliVersion(): string {\n return readVersionFrom(path.join(moduleDir(), '..', 'package.json'));\n}\n\nexport const CLI_VERSION = readCliVersion();\n"],"mappings":";;;;;;;;;AACA,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,OAAOA,YAAW;AAClB,OAAO,cAAc;AACrB,OAAO,iBAAiB;AACxB,SAAS,eAAe;AACxB,YAAYC,WAAU;AACtB,OAAO,SAAS;;;ACgCT,SAAS,kBACd,GACA,KACA,QACA,OAA8B,CAAC,GACN;AACzB,SAAO;AAAA,IACL;AAAA,IACA,cAAc,EAAE;AAAA,IAChB,QAAQ,EAAE;AAAA,IACV,cAAc,EAAE;AAAA,IAChB,YAAY,EAAE;AAAA,IACd,iBAAiB,EAAE;AAAA,IACnB,OAAO,EAAE;AAAA,IACT,aAAa,EAAE;AAAA,IACf,eAAe,EAAE;AAAA,IACjB,iBAAiB,EAAE;AAAA;AAAA;AAAA,IAGnB,GAAI,KAAK,cACL;AAAA;AAAA,MAEE,YAAY,IAAI;AAAA,MAChB,WAAW,EAAE;AAAA,MACb,cAAc,EAAE;AAAA,IAClB,IACA,CAAC;AAAA,EACP;AACF;;;AClDA,SAAS,YAAY,UAAU;AAC/B,OAAO,UAAU;AAQjB,eAAsB,YAAY,KAA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AAIC,OAAM,MAAM,WAAW,MAAM,EAAE,CAAC;AAAA,EAC9C,SAAS,GAAQ;AACf,YAAQ,MAAMA,OAAM,IAAI,cAAc,GAAG,GAAG,WAAW,CAAC;AACxD,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF,CAAC;AAcH,SAAS,kBAAkB,QAAmE;AAC5F,QAAM,OAAO,OAAO,OAAO,CAAC,MAAM,EAAE,SAAS,yBAAyB;AACtE,MAAI,CAAC,KAAK,OAAQ;AAClB,UAAQ;AAAA,IACNA,OAAM,OAAO;AAAA,EAAK,KAAK,MAAM,UAAU,KAAK,WAAW,IAAI,KAAK,GAAG,sBAAsB;AAAA,EAC3F;AACA,aAAW,KAAK,KAAK,MAAM,GAAG,EAAE,EAAG,SAAQ,KAAKA,OAAM,KAAK,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9E,MAAI,KAAK,SAAS,GAAI,SAAQ,KAAKA,OAAM,KAAK,aAAa,KAAK,SAAS,EAAE,OAAO,CAAC;AAEnF,QAAM,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,OAAO,CAAC,CAAC;AAClE,aAAW,KAAK,MAAO,SAAQ,KAAKA,OAAM,KAAK,KAAK,CAAC,EAAE,CAAC;AAC1D;AAEA,QAAQ,WAAW,QAAQ,IAAI;","names":["chalk","path","path","readFileSync","path","fs","chalk","watcher","path"]}
package/dist/config.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";var __drzlModuleUrl = require("node:url").pathToFileURL(__filename).href;
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { AffixOptions } from '@drzl/validation-core';\nimport {\n AFFIX_PROBE_TABLE,\n DEFAULT_IMPORT_EXTENSION,\n IMPORT_EXTENSIONS,\n NAME_MODES,\n resolveAffix,\n schemaName,\n validateAffix,\n} from '@drzl/validation-core';\nimport * as fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport { z } from 'zod';\n\nexport const NamingSchema = z\n .object({\n routerSuffix: z.string().default('Router'),\n procedureCase: z.enum(['camel', 'kebab', 'snake']).default('camel'),\n })\n .partial();\n\n/** One affix for every mode, or a per-mode map. Keys match drzl's internal mode names. */\nconst AffixValueSchema = z.union(\n [\n z.string(),\n z\n .object({\n insert: z.string().optional(),\n update: z.string().optional(),\n select: z.string().optional(),\n })\n .strict(),\n ],\n {\n error:\n 'Expected a string to use for every mode, or an object with any of the keys \"insert\", ' +\n '\"update\" and \"select\". Those keys are lowercase, matching the mode names drzl uses ' +\n 'everywhere else.',\n }\n);\n\nconst AffixPartSchema = z\n .object({\n prefix: AffixValueSchema.optional(),\n suffix: AffixValueSchema.optional(),\n })\n .strict();\n\nexport const AffixSchema = z\n .object({\n /**\n * `preserve` (default) keeps today's output: the Drizzle export name goes into the\n * identifier verbatim, so `export const users` yields `InsertusersSchema`. `pascal`\n * upper-camels it first, yielding `InsertUsersSchema`.\n */\n tableCase: z.enum(['preserve', 'pascal']).optional(),\n schema: AffixPartSchema.optional(),\n type: AffixPartSchema.optional(),\n })\n .strict();\n\n/**\n * How every relative specifier drzl invents spells its extension.\n *\n * The generated files land in the consumer's own source tree, so the consumer's\n * `moduleResolution` decides which forms resolve. `js` is the only one that resolves under\n * all of `bundler`, `node10`, `node16` and `nodenext` with no compiler flag, so it is the\n * default. See the `ImportExtension` docs in `@drzl/validation-core` for the measured grid.\n */\nexport const ImportExtensionSchema = z.enum(IMPORT_EXTENSIONS);\n\nexport const GeneratorSchema = z.object({\n kind: z.enum(['orpc', 'service', 'zod', 'valibot', 'arktype', 'typebox', 'json-schema']),\n /**\n * Overrides the top-level `importExtension` for this generator alone, for a project whose\n * generated directories are compiled by different tsconfigs.\n */\n importExtension: ImportExtensionSchema.optional(),\n template: z.string().optional(),\n includeRelations: z.boolean().optional(),\n /**\n * Type `json` and `jsonb` columns from the schema rather than leaving them wide.\n *\n * `.$type<T>()` is a compile-time cast, so no runtime-derived validator can see it and\n * `drizzle-orm/zod` types every json column as its generic `Json`. A generator can reference\n * `typeof <table>.$inferSelect['<column>']` instead, which is the declared type resolved by\n * TypeScript itself, so generics, unions and imported interfaces all work.\n *\n * Off by default because it makes the generated file import your schema module, as a\n * type-only import that disappears at build time.\n */\n // What a date column accepts. Documented on the zod generator and, until now, accepted by the\n // config parser and then dropped on the floor: the generators default it to 'input' themselves,\n // so setting it here changed nothing.\n coerceDates: z.enum(['input', 'all', 'none']).optional(),\n typedJson: z.boolean().optional(),\n // The wider form: every column's static type comes from Drizzle, not just the untyped ones.\n typedColumns: z.boolean().optional(),\n // Reproduce literal column defaults in the insert schema, so parsing fills them in.\n applyDefaults: z.boolean().optional(),\n /**\n * Emit `findDuplicate<Table>` beside the schemas: the rows in a batch that collide with an\n * earlier row on a unique constraint.\n *\n * Uniqueness is the one constraint a per-row validator structurally cannot see, since it is a\n * fact about the table rather than the row. This checks the half that needs no database.\n */\n duplicateFinder: z.boolean().optional(),\n naming: NamingSchema.optional(),\n outputHeader: z\n .object({\n enabled: z.boolean().default(true).optional(),\n text: z.string().optional(),\n })\n .optional(),\n format: z\n .object({\n enabled: z.boolean().default(true).optional(),\n engine: z.enum(['auto', 'prettier', 'biome']).default('auto').optional(),\n configPath: z.string().optional(),\n })\n .optional(),\n /**\n * Which spelling of JSON Schema the `json-schema` generator emits.\n *\n * OpenAPI 3.0 is not an older superset of the 2020-12 draft, it is a different dialect: a\n * nullable type is `nullable: true` rather than a type array, and an exclusive bound is a\n * boolean flag beside the bound rather than its own keyword. An unknown keyword is not an error\n * in JSON Schema, it is ignored, so emitting the wrong dialect produces a document that\n * validates and then accepts the values the constraints exist to reject.\n */\n target: z.enum(['draft-2020-12', 'openapi-3.1', 'openapi-3.0']).optional(),\n /** Also emit `components.ts` for the `json-schema` generator, ready for an OpenAPI document. */\n components: z.boolean().optional(),\n // service generator specific options\n path: z.string().optional(),\n dataAccess: z.enum(['stub', 'drizzle']).default('stub').optional(),\n dbImportPath: z.string().optional(),\n schemaImportPath: z.string().optional(),\n // zod/valibot/arktype generator specific options\n schemaSuffix: z.string().optional(),\n fileSuffix: z.string().optional(),\n /**\n * Prefixes, suffixes and table casing for generated identifiers (zod/valibot/arktype).\n * Omitting it reproduces the output of every previous release exactly.\n */\n affix: AffixSchema.optional(),\n // orpc validation sharing\n validation: z\n .object({\n useShared: z.boolean().default(false).optional(),\n library: z.enum(['zod', 'valibot', 'arktype']).default('zod').optional(),\n importPath: z.string().optional(),\n schemaSuffix: z.string().optional(),\n /**\n * How the validation generator named its exports. Usually left unset: the CLI copies\n * it from the sibling generator whose `kind` matches `library`.\n */\n affix: AffixSchema.optional(),\n })\n .optional(),\n // template options\n templateOptions: z.record(z.string(), z.any()).optional(),\n});\n\nexport const AnalyzerSchema = z.object({\n includeRelations: z.boolean().default(true),\n validateConstraints: z.boolean().default(true),\n includeHeuristicRelations: z.boolean().default(false),\n});\n\nexport const ConfigSchema = z\n .object({\n schema: z.string(),\n outDir: z.string().default('src/api'),\n /**\n * Which tables to generate for, matched against the database table name.\n *\n * There was no way to say this, and every generator loops over every table it finds, so\n * DRZL emitted unauthenticated CRUD over whatever shared the schema file. That is noise for\n * a migrations table and a genuine leak for an auth one: Better Auth puts `user`, `session`,\n * `account` and `verification` alongside your own tables, and `account` holds\n * `accessToken`, `refreshToken`, `idToken` and `password`.\n *\n * Deliberately name-based and explicit rather than detecting any particular library. Auth\n * table names are all renameable, so a built-in list would miss renamed tables and, worse,\n * silently skip an ordinary table that happened to be called `user`, which is usually the\n * application's main entity.\n *\n * `exclude` wins over `include`. Patterns support `*`, matching within a name.\n */\n include: z.array(z.string()).optional(),\n exclude: z.array(z.string()).optional(),\n /**\n * How every relative specifier drzl invents spells its extension, for every generator.\n * A generator may override it. Defaults to `js`, which is the only form that resolves\n * under every `moduleResolution` without a compiler flag.\n */\n importExtension: ImportExtensionSchema.default(DEFAULT_IMPORT_EXTENSION),\n analyzer: AnalyzerSchema.default({\n includeRelations: true,\n validateConstraints: true,\n includeHeuristicRelations: false,\n }),\n generators: z\n .array(GeneratorSchema)\n .min(1)\n .default([{ kind: 'orpc' } as any]),\n })\n // Reject an affix before anything is written, rather than emitting a file that cannot\n // compile. Only `affix` is inspected; the legacy flat `schemaSuffix` is left alone so\n // configs that parse today keep parsing.\n .superRefine((cfg, ctx) => {\n cfg.generators.forEach((g, i) => {\n const report = (base: (string | number)[], affix?: AffixOptions, schemaSuffix?: string) => {\n for (const issue of validateAffix(affix, schemaSuffix)) {\n ctx.addIssue({\n code: 'custom',\n path: ['generators', i, ...base, ...issue.path],\n message: issue.message,\n });\n }\n };\n report(['affix'], g.affix as AffixOptions | undefined, g.schemaSuffix);\n report(\n ['validation', 'affix'],\n g.validation?.affix as AffixOptions | undefined,\n g.validation?.schemaSuffix\n );\n });\n });\n\n// ✨ Separate input vs output types\nexport type DrzlConfigInput = z.input<typeof ConfigSchema>;\nexport type DrzlConfig = z.output<typeof ConfigSchema>;\n\nexport function defineConfig<T extends DrzlConfigInput>(cfg: T): T {\n return cfg;\n}\n\ntype GeneratorConfig = DrzlConfig['generators'][number];\n\nfunction sharedSchemaNames(opts: { affix?: AffixOptions; schemaSuffix?: string }): string[] {\n const resolved = resolveAffix(opts);\n return NAME_MODES.map((mode) => schemaName(mode, AFFIX_PROBE_TABLE, resolved));\n}\n\n/**\n * Fill in cross-generator defaults and refuse configs whose generators would disagree.\n *\n * An oRPC router that imports shared schemas has to spell the exact names the validation\n * generator exported. Both sides used to be configured independently, so they could silently\n * drift into a router that does not compile. When an oRPC generator uses shared validation\n * and exactly one sibling generator produces that library, its `affix` is copied across.\n *\n * Deliberately conservative about the pre-existing flat `schemaSuffix`: a disagreement there\n * is only reported, never repaired, because repairing it would change the bytes an existing\n * config emits.\n *\n * `importExtension` is pushed down here too. A consumer compiles the whole generated tree\n * with one tsconfig, so the setting that has to hold is the same for every generator, and\n * every call site downstream can then read it off the generator without knowing about the\n * top-level default.\n */\nexport function resolveConfig(cfg: DrzlConfig): { config: DrzlConfig; warnings: string[] } {\n const warnings: string[] = [];\n const generators: GeneratorConfig[] = cfg.generators.map((g) => ({\n ...g,\n importExtension: g.importExtension ?? cfg.importExtension,\n }));\n\n for (const g of generators) {\n if (g.kind !== 'orpc') continue;\n const v = g.validation;\n if (!v?.useShared) continue;\n\n const library = v.library ?? 'zod';\n const siblings = generators.filter((s) => s.kind === library);\n // Zero siblings means the user points at a barrel drzl does not generate; more than one\n // means there is no single source of truth. Either way, leave the config alone.\n if (siblings.length !== 1) continue;\n const sibling = siblings[0];\n\n const theirs = sharedSchemaNames({\n affix: sibling.affix as AffixOptions | undefined,\n schemaSuffix: sibling.schemaSuffix,\n });\n\n if (!v.affix) {\n if (sibling.affix) {\n // Bake the sibling's fully resolved naming in, so its own schemaSuffix fallback\n // travels with it and cannot be re-interpreted on the oRPC side.\n g.validation = {\n ...v,\n affix: resolveAffix({\n affix: sibling.affix as AffixOptions,\n schemaSuffix: sibling.schemaSuffix,\n }),\n };\n continue;\n }\n const mine = sharedSchemaNames({ schemaSuffix: v.schemaSuffix });\n if (mine.join(',') !== theirs.join(',')) {\n warnings.push(\n `drzl config: the \"orpc\" generator's validation.schemaSuffix ` +\n `(${JSON.stringify(v.schemaSuffix ?? 'Schema')}) does not match the \"${library}\" ` +\n `generator's schemaSuffix (${JSON.stringify(sibling.schemaSuffix ?? 'Schema')}). ` +\n `The router will import ${mine.join(', ')} but the \"${library}\" generator exports ` +\n `${theirs.join(', ')}, so the generated router will not compile. Set both to the ` +\n `same value, or move to \"affix\", which is inherited automatically.`\n );\n }\n continue;\n }\n\n const mine = sharedSchemaNames({\n affix: v.affix as AffixOptions,\n schemaSuffix: v.schemaSuffix,\n });\n if (mine.join(',') !== theirs.join(',')) {\n throw new Error(\n `drzl config: the \"orpc\" generator imports shared ${library} schemas, but its ` +\n `validation.affix disagrees with the \"${library}\" generator's own naming. The router ` +\n `would import ${mine.join(', ')} while the \"${library}\" generator exports ` +\n `${theirs.join(', ')}. Make them match, or drop validation.affix and let it be ` +\n `inherited from the \"${library}\" generator.`\n );\n }\n }\n\n return { config: { ...cfg, generators }, warnings };\n}\n\n/**\n * Parse, then resolve cross-generator defaults. Both `generate` and `watch` go through\n * loadConfig, so putting the resolution here is what keeps the two duplicated generator\n * dispatch blocks in cli.ts from needing the logic twice.\n */\nfunction finalize(raw: unknown): DrzlConfig {\n const { config, warnings } = resolveConfig(ConfigSchema.parse(raw));\n for (const w of warnings) console.warn(w);\n return config;\n}\n\nexport async function loadConfig(customPath?: string): Promise<DrzlConfig | null> {\n const fsp = await import('node:fs/promises');\n\n const candidates = customPath\n ? [customPath]\n : [\n 'drzl.config.ts',\n 'drzl.config.mjs',\n 'drzl.config.js',\n 'drzl.config.cjs',\n 'drzl.config.json',\n ];\n\n for (const c of candidates) {\n const p = path.resolve(process.cwd(), c);\n try {\n await fsp.access(p);\n } catch {\n continue;\n }\n\n const ext = path.extname(p).toLowerCase();\n\n // JSON: read directly\n if (ext === '.json') {\n const raw = JSON.parse(await fsp.readFile(p, 'utf8'));\n return finalize(raw);\n }\n\n // Everything else (TS/JS/MJS/CJS) -> Jiti with cache-busting\n const { createJiti } = await import('jiti');\n const stat = await fsp.stat(p);\n\n // Passing __filename is safe in CJS; fallback to cwd if not defined.\n const base =\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js');\n\n const jiti = createJiti(base, {\n moduleCache: false, // re-evaluate each time\n fsCache: true, // keep transform cache\n cacheVersion: String(stat.mtimeMs), // bump on edit\n interopDefault: true,\n tryNative: false, // <-- prevent native import of .ts\n // debug: true,\n }) as any;\n\n const mod = await jiti.import(p);\n const raw = mod?.default ?? mod;\n return finalize(raw);\n }\n\n return null;\n}\n\n/** Absolute output dirs for all generators (to ignore in watcher). */\nexport function computeGeneratorOutputDirs(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const dirs = new Set<string>();\n dirs.add(abs(cfg.outDir)); // orpc\n for (const g of cfg.generators) {\n if (g.kind === 'service') dirs.add(abs(g.path ?? 'src/services'));\n if (g.kind === 'zod') dirs.add(abs(g.path ?? 'src/validators/zod'));\n if (g.kind === 'valibot') dirs.add(abs(g.path ?? 'src/validators/valibot'));\n if (g.kind === 'arktype') dirs.add(abs(g.path ?? 'src/validators/arktype'));\n if (g.kind === 'typebox') dirs.add(abs(g.path ?? 'src/validators/typebox'));\n if (g.kind === 'json-schema') dirs.add(abs(g.path ?? 'src/validators/json-schema'));\n }\n return [...dirs];\n}\n\n/** Resolve custom template directories (local path or installed package). */\nexport function resolveTemplateDirsSync(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const results: string[] = [];\n const req = createRequire(\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js')\n );\n\n for (const g of cfg.generators) {\n const t = g.template;\n if (!t || t === 'standard' || t === 'minimal') continue;\n\n // Try package resolution relative to cwd\n let pkgDir: string | null = null;\n try {\n const pkg = req.resolve(`${t}/package.json`, { paths: [cwd] as any });\n pkgDir = path.dirname(pkg);\n } catch {}\n\n if (pkgDir) {\n results.push(pkgDir);\n continue;\n }\n\n // Local path-like template\n if (/[./\\\\]/.test(t)) {\n const abs = path.resolve(cwd, t);\n if (fs.existsSync(abs)) results.push(abs);\n }\n }\n\n return Array.from(new Set(results));\n}\n\n/** Build watch targets (exclude output dirs; watcher will ignore those). */\n/**\n * Narrow an analysis's tables to the ones the config asked for.\n *\n * Matching is on the database table name, anchored, with `*` as the only metacharacter. Anchored\n * matters: `user` must not also drop `users`, and a substring match would. `exclude` is applied\n * after `include`, so the safer direction wins when both name the same table.\n */\nexport function filterTables<T extends { name: string }>(\n tables: T[],\n opts: { include?: string[]; exclude?: string[] }\n): T[] {\n const toRegExp = (pattern: string) =>\n new RegExp(\n '^' +\n pattern\n .split('*')\n .map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*') +\n '$'\n );\n\n const matches = (patterns: string[], name: string) =>\n patterns.some((p) => toRegExp(p).test(name));\n\n let out = tables;\n if (opts.include?.length) out = out.filter((t) => matches(opts.include!, t.name));\n if (opts.exclude?.length) out = out.filter((t) => !matches(opts.exclude!, t.name));\n return out;\n}\n\nexport function computeWatchTargets(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const schemaAbs = abs(cfg.schema);\n // The schema's directory, not a glob under it. Chokidar removed glob support in v4 and treats\n // `<dir>/**/*.{ts,tsx,js}` as a literal path, so it watched a directory named `**` that does\n // not exist: no event ever fired and `drzl watch` did its initial build and then sat inert.\n // A directory is watched recursively by chokidar itself, and the extension filtering that the\n // glob was doing now happens on the event instead.\n const targets = new Set<string>([\n path.dirname(schemaAbs),\n abs('drzl.config.ts'),\n abs('drzl.config.js'),\n abs('drzl.config.mjs'),\n abs('drzl.config.cjs'),\n ]);\n for (const t of resolveTemplateDirsSync(cfg, cwd)) targets.add(t);\n return [...targets];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAQO;AACP,SAAoB;AACpB,yBAA8B;AAC9B,WAAsB;AACtB,iBAAkB;AAEX,IAAM,eAAe,aACzB,OAAO;AAAA,EACN,cAAc,aAAE,OAAO,EAAE,QAAQ,QAAQ;AAAA,EACzC,eAAe,aAAE,KAAK,CAAC,SAAS,SAAS,OAAO,CAAC,EAAE,QAAQ,OAAO;AACpE,CAAC,EACA,QAAQ;AAGX,IAAM,mBAAmB,aAAE;AAAA,EACzB;AAAA,IACE,aAAE,OAAO;AAAA,IACT,aACG,OAAO;AAAA,MACN,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,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ChF,MAAI,KAAK,SAAS,OAAQ,OAAM,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAU,EAAE,IAAI,CAAC;AACjF,SAAO;AACT;AAEO,SAAS,oBAAoB,KAAiB,MAAM,QAAQ,IAAI,GAAa;AAClF,QAAM,MAAM,CAAC,MAAmB,aAAQ,KAAK,CAAC;AAC9C,QAAM,YAAY,IAAI,IAAI,MAAM;AAMhC,QAAM,UAAU,oBAAI,IAAY;AAAA,IACzB,aAAQ,SAAS;AAAA,IACtB,IAAI,gBAAgB;AAAA,IACpB,IAAI,gBAAgB;AAAA,IACpB,IAAI,iBAAiB;AAAA,IACrB,IAAI,iBAAiB;AAAA,EACvB,CAAC;AACD,aAAW,KAAK,wBAAwB,KAAK,GAAG,EAAG,SAAQ,IAAI,CAAC;AAChE,SAAO,CAAC,GAAG,OAAO;AACpB;","names":["mine","raw"]}
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { AffixOptions } from '@drzl/validation-core';\nimport {\n AFFIX_PROBE_TABLE,\n DEFAULT_IMPORT_EXTENSION,\n IMPORT_EXTENSIONS,\n NAME_MODES,\n resolveAffix,\n schemaName,\n validateAffix,\n} from '@drzl/validation-core';\nimport * as fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport * as path from 'node:path';\nimport { z } from 'zod';\n\nexport const NamingSchema = z\n .object({\n routerSuffix: z.string().default('Router'),\n procedureCase: z.enum(['camel', 'kebab', 'snake']).default('camel'),\n })\n .partial();\n\n/** One affix for every mode, or a per-mode map. Keys match drzl's internal mode names. */\nconst AffixValueSchema = z.union(\n [\n z.string(),\n z\n .object({\n insert: z.string().optional(),\n update: z.string().optional(),\n select: z.string().optional(),\n })\n .strict(),\n ],\n {\n error:\n 'Expected a string to use for every mode, or an object with any of the keys \"insert\", ' +\n '\"update\" and \"select\". Those keys are lowercase, matching the mode names drzl uses ' +\n 'everywhere else.',\n }\n);\n\nconst AffixPartSchema = z\n .object({\n prefix: AffixValueSchema.optional(),\n suffix: AffixValueSchema.optional(),\n })\n .strict();\n\nexport const AffixSchema = z\n .object({\n /**\n * `preserve` (default) keeps today's output: the Drizzle export name goes into the\n * identifier verbatim, so `export const users` yields `InsertusersSchema`. `pascal`\n * upper-camels it first, yielding `InsertUsersSchema`.\n */\n tableCase: z.enum(['preserve', 'pascal']).optional(),\n schema: AffixPartSchema.optional(),\n type: AffixPartSchema.optional(),\n })\n .strict();\n\n/**\n * How every relative specifier drzl invents spells its extension.\n *\n * The generated files land in the consumer's own source tree, so the consumer's\n * `moduleResolution` decides which forms resolve. `js` is the only one that resolves under\n * all of `bundler`, `node10`, `node16` and `nodenext` with no compiler flag, so it is the\n * default. See the `ImportExtension` docs in `@drzl/validation-core` for the measured grid.\n */\nexport const ImportExtensionSchema = z.enum(IMPORT_EXTENSIONS);\n\nexport const GeneratorSchema = z.object({\n kind: z.enum(['orpc', 'service', 'zod', 'valibot', 'arktype', 'typebox', 'json-schema']),\n /**\n * Overrides the top-level `importExtension` for this generator alone, for a project whose\n * generated directories are compiled by different tsconfigs.\n */\n importExtension: ImportExtensionSchema.optional(),\n template: z.string().optional(),\n includeRelations: z.boolean().optional(),\n /**\n * Type `json` and `jsonb` columns from the schema rather than leaving them wide.\n *\n * `.$type<T>()` is a compile-time cast, so no runtime-derived validator can see it and\n * `drizzle-orm/zod` types every json column as its generic `Json`. A generator can reference\n * `typeof <table>.$inferSelect['<column>']` instead, which is the declared type resolved by\n * TypeScript itself, so generics, unions and imported interfaces all work.\n *\n * Off by default because it makes the generated file import your schema module, as a\n * type-only import that disappears at build time.\n */\n // What a date column accepts. Documented on the zod generator and, until now, accepted by the\n // config parser and then dropped on the floor: the generators default it to 'input' themselves,\n // so setting it here changed nothing.\n coerceDates: z.enum(['input', 'all', 'none']).optional(),\n typedJson: z.boolean().optional(),\n // The wider form: every column's static type comes from Drizzle, not just the untyped ones.\n typedColumns: z.boolean().optional(),\n // Reproduce literal column defaults in the insert schema, so parsing fills them in.\n applyDefaults: z.boolean().optional(),\n /**\n * Emit `findDuplicate<Table>` beside the schemas: the rows in a batch that collide with an\n * earlier row on a unique constraint.\n *\n * Uniqueness is the one constraint a per-row validator structurally cannot see, since it is a\n * fact about the table rather than the row. This checks the half that needs no database.\n */\n duplicateFinder: z.boolean().optional(),\n naming: NamingSchema.optional(),\n outputHeader: z\n .object({\n enabled: z.boolean().default(true).optional(),\n text: z.string().optional(),\n })\n .optional(),\n format: z\n .object({\n enabled: z.boolean().default(true).optional(),\n engine: z.enum(['auto', 'prettier', 'biome']).default('auto').optional(),\n configPath: z.string().optional(),\n })\n .optional(),\n /**\n * Which spelling of JSON Schema the `json-schema` generator emits.\n *\n * OpenAPI 3.0 is not an older superset of the 2020-12 draft, it is a different dialect: a\n * nullable type is `nullable: true` rather than a type array, and an exclusive bound is a\n * boolean flag beside the bound rather than its own keyword. An unknown keyword is not an error\n * in JSON Schema, it is ignored, so emitting the wrong dialect produces a document that\n * validates and then accepts the values the constraints exist to reject.\n */\n target: z.enum(['draft-2020-12', 'openapi-3.1', 'openapi-3.0']).optional(),\n /** Also emit `components.ts` for the `json-schema` generator, ready for an OpenAPI document. */\n components: z.boolean().optional(),\n // service generator specific options\n path: z.string().optional(),\n dataAccess: z.enum(['stub', 'drizzle']).default('stub').optional(),\n dbImportPath: z.string().optional(),\n schemaImportPath: z.string().optional(),\n // zod/valibot/arktype generator specific options\n schemaSuffix: z.string().optional(),\n fileSuffix: z.string().optional(),\n /**\n * Prefixes, suffixes and table casing for generated identifiers (zod/valibot/arktype).\n * Omitting it reproduces the output of every previous release exactly.\n */\n affix: AffixSchema.optional(),\n // orpc validation sharing\n validation: z\n .object({\n useShared: z.boolean().default(false).optional(),\n library: z.enum(['zod', 'valibot', 'arktype']).default('zod').optional(),\n importPath: z.string().optional(),\n schemaSuffix: z.string().optional(),\n /**\n * How the validation generator named its exports. Usually left unset: the CLI copies\n * it from the sibling generator whose `kind` matches `library`.\n */\n affix: AffixSchema.optional(),\n })\n .optional(),\n // template options\n templateOptions: z.record(z.string(), z.any()).optional(),\n});\n\nexport const AnalyzerSchema = z.object({\n includeRelations: z.boolean().default(true),\n validateConstraints: z.boolean().default(true),\n includeHeuristicRelations: z.boolean().default(false),\n});\n\nexport const ConfigSchema = z\n .object({\n schema: z.string(),\n outDir: z.string().default('src/api'),\n /**\n * Which tables to generate for, matched against the database table name.\n *\n * There was no way to say this, and every generator loops over every table it finds, so\n * DRZL emitted unauthenticated CRUD over whatever shared the schema file. That is noise for\n * a migrations table and a genuine leak for an auth one: Better Auth puts `user`, `session`,\n * `account` and `verification` alongside your own tables, and `account` holds\n * `accessToken`, `refreshToken`, `idToken` and `password`.\n *\n * Deliberately name-based and explicit rather than detecting any particular library. Auth\n * table names are all renameable, so a built-in list would miss renamed tables and, worse,\n * silently skip an ordinary table that happened to be called `user`, which is usually the\n * application's main entity.\n *\n * `exclude` wins over `include`. Patterns support `*`, matching within a name.\n */\n include: z.array(z.string()).optional(),\n exclude: z.array(z.string()).optional(),\n /**\n * How every relative specifier drzl invents spells its extension, for every generator.\n * A generator may override it. Defaults to `js`, which is the only form that resolves\n * under every `moduleResolution` without a compiler flag.\n */\n importExtension: ImportExtensionSchema.default(DEFAULT_IMPORT_EXTENSION),\n analyzer: AnalyzerSchema.default({\n includeRelations: true,\n validateConstraints: true,\n includeHeuristicRelations: false,\n }),\n generators: z\n .array(GeneratorSchema)\n .min(1)\n .default([{ kind: 'orpc' } as any]),\n })\n // Reject an affix before anything is written, rather than emitting a file that cannot\n // compile. Only `affix` is inspected; the legacy flat `schemaSuffix` is left alone so\n // configs that parse today keep parsing.\n .superRefine((cfg, ctx) => {\n cfg.generators.forEach((g, i) => {\n const report = (base: (string | number)[], affix?: AffixOptions, schemaSuffix?: string) => {\n for (const issue of validateAffix(affix, schemaSuffix)) {\n ctx.addIssue({\n code: 'custom',\n path: ['generators', i, ...base, ...issue.path],\n message: issue.message,\n });\n }\n };\n report(['affix'], g.affix as AffixOptions | undefined, g.schemaSuffix);\n report(\n ['validation', 'affix'],\n g.validation?.affix as AffixOptions | undefined,\n g.validation?.schemaSuffix\n );\n });\n });\n\n// ✨ Separate input vs output types\nexport type DrzlConfigInput = z.input<typeof ConfigSchema>;\nexport type DrzlConfig = z.output<typeof ConfigSchema>;\n\nexport function defineConfig<T extends DrzlConfigInput>(cfg: T): T {\n return cfg;\n}\n\ntype GeneratorConfig = DrzlConfig['generators'][number];\n\nfunction sharedSchemaNames(opts: { affix?: AffixOptions; schemaSuffix?: string }): string[] {\n const resolved = resolveAffix(opts);\n return NAME_MODES.map((mode) => schemaName(mode, AFFIX_PROBE_TABLE, resolved));\n}\n\n/**\n * Fill in cross-generator defaults and refuse configs whose generators would disagree.\n *\n * An oRPC router that imports shared schemas has to spell the exact names the validation\n * generator exported. Both sides used to be configured independently, so they could silently\n * drift into a router that does not compile. When an oRPC generator uses shared validation\n * and exactly one sibling generator produces that library, its `affix` is copied across.\n *\n * Deliberately conservative about the pre-existing flat `schemaSuffix`: a disagreement there\n * is only reported, never repaired, because repairing it would change the bytes an existing\n * config emits.\n *\n * `importExtension` is pushed down here too. A consumer compiles the whole generated tree\n * with one tsconfig, so the setting that has to hold is the same for every generator, and\n * every call site downstream can then read it off the generator without knowing about the\n * top-level default.\n */\nexport function resolveConfig(cfg: DrzlConfig): { config: DrzlConfig; warnings: string[] } {\n const warnings: string[] = [];\n const generators: GeneratorConfig[] = cfg.generators.map((g) => ({\n ...g,\n importExtension: g.importExtension ?? cfg.importExtension,\n }));\n\n for (const g of generators) {\n if (g.kind !== 'orpc') continue;\n const v = g.validation;\n if (!v?.useShared) continue;\n\n const library = v.library ?? 'zod';\n const siblings = generators.filter((s) => s.kind === library);\n // Zero siblings means the user points at a barrel drzl does not generate; more than one\n // means there is no single source of truth. Either way, leave the config alone.\n if (siblings.length !== 1) continue;\n const sibling = siblings[0];\n\n const theirs = sharedSchemaNames({\n affix: sibling.affix as AffixOptions | undefined,\n schemaSuffix: sibling.schemaSuffix,\n });\n\n if (!v.affix) {\n if (sibling.affix) {\n // Bake the sibling's fully resolved naming in, so its own schemaSuffix fallback\n // travels with it and cannot be re-interpreted on the oRPC side.\n g.validation = {\n ...v,\n affix: resolveAffix({\n affix: sibling.affix as AffixOptions,\n schemaSuffix: sibling.schemaSuffix,\n }),\n };\n continue;\n }\n const mine = sharedSchemaNames({ schemaSuffix: v.schemaSuffix });\n if (mine.join(',') !== theirs.join(',')) {\n warnings.push(\n `drzl config: the \"orpc\" generator's validation.schemaSuffix ` +\n `(${JSON.stringify(v.schemaSuffix ?? 'Schema')}) does not match the \"${library}\" ` +\n `generator's schemaSuffix (${JSON.stringify(sibling.schemaSuffix ?? 'Schema')}). ` +\n `The router will import ${mine.join(', ')} but the \"${library}\" generator exports ` +\n `${theirs.join(', ')}, so the generated router will not compile. Set both to the ` +\n `same value, or move to \"affix\", which is inherited automatically.`\n );\n }\n continue;\n }\n\n const mine = sharedSchemaNames({\n affix: v.affix as AffixOptions,\n schemaSuffix: v.schemaSuffix,\n });\n if (mine.join(',') !== theirs.join(',')) {\n throw new Error(\n `drzl config: the \"orpc\" generator imports shared ${library} schemas, but its ` +\n `validation.affix disagrees with the \"${library}\" generator's own naming. The router ` +\n `would import ${mine.join(', ')} while the \"${library}\" generator exports ` +\n `${theirs.join(', ')}. Make them match, or drop validation.affix and let it be ` +\n `inherited from the \"${library}\" generator.`\n );\n }\n }\n\n return { config: { ...cfg, generators }, warnings };\n}\n\n/**\n * Parse, then resolve cross-generator defaults. Both `generate` and `watch` go through\n * loadConfig, so putting the resolution here is what keeps the two duplicated generator\n * dispatch blocks in cli.ts from needing the logic twice.\n */\nfunction finalize(raw: unknown): DrzlConfig {\n const { config, warnings } = resolveConfig(ConfigSchema.parse(raw));\n for (const w of warnings) console.warn(w);\n return config;\n}\n\nexport async function loadConfig(customPath?: string): Promise<DrzlConfig | null> {\n const fsp = await import('node:fs/promises');\n\n const candidates = customPath\n ? [customPath]\n : [\n 'drzl.config.ts',\n 'drzl.config.mjs',\n 'drzl.config.js',\n 'drzl.config.cjs',\n 'drzl.config.json',\n ];\n\n for (const c of candidates) {\n const p = path.resolve(process.cwd(), c);\n try {\n await fsp.access(p);\n } catch {\n continue;\n }\n\n const ext = path.extname(p).toLowerCase();\n\n // JSON: read directly\n if (ext === '.json') {\n const raw = JSON.parse(await fsp.readFile(p, 'utf8'));\n return finalize(raw);\n }\n\n // Everything else (TS/JS/MJS/CJS) -> Jiti with cache-busting\n const { createJiti } = await import('jiti');\n const stat = await fsp.stat(p);\n\n // Passing __filename is safe in CJS; fallback to cwd if not defined.\n const base =\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js');\n\n const jiti = createJiti(base, {\n moduleCache: false, // re-evaluate each time\n fsCache: true, // keep transform cache\n cacheVersion: String(stat.mtimeMs), // bump on edit\n interopDefault: true,\n tryNative: false, // <-- prevent native import of .ts\n // debug: true,\n }) as any;\n\n const mod = await jiti.import(p);\n const raw = mod?.default ?? mod;\n return finalize(raw);\n }\n\n return null;\n}\n\n/** Absolute output dirs for all generators (to ignore in watcher). */\nexport function computeGeneratorOutputDirs(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const dirs = new Set<string>();\n dirs.add(abs(cfg.outDir)); // orpc\n for (const g of cfg.generators) {\n if (g.kind === 'service') dirs.add(abs(g.path ?? 'src/services'));\n if (g.kind === 'zod') dirs.add(abs(g.path ?? 'src/validators/zod'));\n if (g.kind === 'valibot') dirs.add(abs(g.path ?? 'src/validators/valibot'));\n if (g.kind === 'arktype') dirs.add(abs(g.path ?? 'src/validators/arktype'));\n if (g.kind === 'typebox') dirs.add(abs(g.path ?? 'src/validators/typebox'));\n if (g.kind === 'json-schema') dirs.add(abs(g.path ?? 'src/validators/json-schema'));\n }\n return [...dirs];\n}\n\n/** Resolve custom template directories (local path or installed package). */\nexport function resolveTemplateDirsSync(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const results: string[] = [];\n const req = createRequire(\n typeof __filename !== 'undefined' ? __filename : path.join(process.cwd(), 'index.js')\n );\n\n for (const g of cfg.generators) {\n const t = g.template;\n if (!t || t === 'standard' || t === 'minimal') continue;\n\n // Try package resolution relative to cwd\n let pkgDir: string | null = null;\n try {\n const pkg = req.resolve(`${t}/package.json`, { paths: [cwd] as any });\n pkgDir = path.dirname(pkg);\n } catch {}\n\n if (pkgDir) {\n results.push(pkgDir);\n continue;\n }\n\n // Local path-like template\n if (/[./\\\\]/.test(t)) {\n const abs = path.resolve(cwd, t);\n if (fs.existsSync(abs)) results.push(abs);\n }\n }\n\n return Array.from(new Set(results));\n}\n\n/** Build watch targets (exclude output dirs; watcher will ignore those). */\n/**\n * Narrow an analysis's tables to the ones the config asked for.\n *\n * Matching is on the database table name, anchored, with `*` as the only metacharacter. Anchored\n * matters: `user` must not also drop `users`, and a substring match would. `exclude` is applied\n * after `include`, so the safer direction wins when both name the same table.\n */\nexport function filterTables<T extends { name: string }>(\n tables: T[],\n opts: { include?: string[]; exclude?: string[] }\n): T[] {\n const toRegExp = (pattern: string) =>\n new RegExp(\n '^' +\n pattern\n .split('*')\n .map((part) => part.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'))\n .join('.*') +\n '$'\n );\n\n const matches = (patterns: string[], name: string) =>\n patterns.some((p) => toRegExp(p).test(name));\n\n let out = tables;\n if (opts.include?.length) out = out.filter((t) => matches(opts.include!, t.name));\n if (opts.exclude?.length) out = out.filter((t) => !matches(opts.exclude!, t.name));\n return out;\n}\n\nexport function computeWatchTargets(cfg: DrzlConfig, cwd = process.cwd()): string[] {\n const abs = (p: string) => path.resolve(cwd, p);\n const schemaAbs = abs(cfg.schema);\n // The schema's directory, not a glob under it. Chokidar removed glob support in v4 and treats\n // `<dir>/**/*.{ts,tsx,js}` as a literal path, so it watched a directory named `**` that does\n // not exist: no event ever fired and `drzl watch` did its initial build and then sat inert.\n // A directory is watched recursively by chokidar itself, and the extension filtering that the\n // glob was doing now happens on the event instead.\n const targets = new Set<string>([\n path.dirname(schemaAbs),\n abs('drzl.config.ts'),\n abs('drzl.config.js'),\n abs('drzl.config.mjs'),\n abs('drzl.config.cjs'),\n ]);\n for (const t of resolveTemplateDirsSync(cfg, cwd)) targets.add(t);\n return [...targets];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,6BAQO;AACP,SAAoB;AACpB,yBAA8B;AAC9B,WAAsB;AACtB,iBAAkB;AAEX,IAAM,eAAe,aACzB,OAAO;AAAA,EACN,cAAc,aAAE,OAAO,EAAE,QAAQ,QAAQ;AAAA,EACzC,eAAe,aAAE,KAAK,CAAC,SAAS,SAAS,OAAO,CAAC,EAAE,QAAQ,OAAO;AACpE,CAAC,EACA,QAAQ;AAGX,IAAM,mBAAmB,aAAE;AAAA,EACzB;AAAA,IACE,aAAE,OAAO;AAAA,IACT,aACG,OAAO;AAAA,MACN,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,MAC5B,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,IAC9B,CAAC,EACA,OAAO;AAAA,EACZ;AAAA,EACA;AAAA,IACE,OACE;AAAA,EAGJ;AACF;AAEA,IAAM,kBAAkB,aACrB,OAAO;AAAA,EACN,QAAQ,iBAAiB,SAAS;AAAA,EAClC,QAAQ,iBAAiB,SAAS;AACpC,CAAC,EACA,OAAO;AAEH,IAAM,cAAc,aACxB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMN,WAAW,aAAE,KAAK,CAAC,YAAY,QAAQ,CAAC,EAAE,SAAS;AAAA,EACnD,QAAQ,gBAAgB,SAAS;AAAA,EACjC,MAAM,gBAAgB,SAAS;AACjC,CAAC,EACA,OAAO;AAUH,IAAM,wBAAwB,aAAE,KAAK,wCAAi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AQ,IAAI,CAAC;AAChE,SAAO,CAAC,GAAG,OAAO;AACpB;","names":["mine","raw"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drzl/cli",
3
- "version": "4.14.0",
3
+ "version": "4.14.2",
4
4
  "private": false,
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -29,14 +29,14 @@
29
29
  "jiti": "^2.7.0",
30
30
  "ora": "^9.4.1",
31
31
  "zod": "^4.4.3",
32
- "@drzl/analyzer": "^1.14.0",
33
- "@drzl/generator-arktype": "^3.10.0",
34
- "@drzl/generator-orpc": "^2.5.0",
35
- "@drzl/generator-service": "^2.1.2",
36
- "@drzl/generator-typebox": "^0.8.0",
37
- "@drzl/generator-valibot": "^3.14.0",
38
- "@drzl/generator-zod": "^3.15.0",
39
- "@drzl/validation-core": "^3.14.0"
32
+ "@drzl/analyzer": "^1.15.0",
33
+ "@drzl/generator-orpc": "^2.7.0",
34
+ "@drzl/generator-service": "^2.3.0",
35
+ "@drzl/generator-typebox": "^0.9.0",
36
+ "@drzl/generator-arktype": "^3.12.0",
37
+ "@drzl/generator-valibot": "^3.15.0",
38
+ "@drzl/validation-core": "^3.15.0",
39
+ "@drzl/generator-zod": "^3.16.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "drizzle-orm": "^0.45.2",
@@ -62,10 +62,10 @@
62
62
  "url": "https://github.com/sponsors/omar-dulaimi"
63
63
  },
64
64
  "optionalDependencies": {
65
- "@drzl/generator-json-schema": "^0.3.0"
65
+ "@drzl/generator-json-schema": "^0.4.0"
66
66
  },
67
67
  "scripts": {
68
- "build": "tsup src/cli.ts src/config.ts --format esm,cjs --sourcemap --dts",
68
+ "build": "tsup src/cli.ts src/config.ts --format esm,cjs --sourcemap --dts --clean",
69
69
  "dev": "node --loader ts-node/esm src/cli.ts --help",
70
70
  "lint": "eslint . --ext .ts",
71
71
  "test": "vitest run --testTimeout=20000"