@drzl/cli 4.17.0 → 4.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/validation-options.ts","../src/json-schema-options.ts","../src/trpc-options.ts","../src/drift.ts","../src/generator-loader.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 { jsonSchemaOptions } from './json-schema-options.js';\nimport { trpcOptions } from './trpc-options.js';\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 { GeneratorNotInstalledError, loadGenerator } from './generator-loader.js';\nimport { maybeShowSponsorMessage } from './sponsor.js';\nimport { CLI_VERSION } from './version.js';\n\n/**\n * Say what went wrong with a generator, distinguishing the two things that can.\n *\n * Every branch below used to print \"<name> generator missing. Install with: npm install\n * @drzl/generator-<name>\" for anything at all that threw, with the real reason on a trailing\n * \"Error details\" line. A generator that was installed and merely failed therefore sent its user\n * to reinstall a package they already had, and the sentence that would have told them what\n * actually happened was the one written as a footnote.\n *\n * `loadGenerator` marks the one case that is an install problem, so the package name comes off the\n * error rather than being repeated here beside the `import()` that already spells it.\n */\nfunction reportGeneratorFailure(kind: string, e: unknown): void {\n if (e instanceof GeneratorNotInstalledError) {\n console.error(\n chalk.red(`The ${kind} generator is not installed.`),\n chalk.yellow(`\\nInstall with: npm install ${e.specifier}`)\n );\n return;\n }\n console.error(chalk.red(`The ${kind} generator failed:`), (e as any)?.message ?? e);\n}\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 // Documented on this generator since it was added and never reachable from a config\n // file, because the config schema had no such key and zod stripped it in silence.\n databaseInjection: g.databaseInjection,\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 === 'trpc') {\n try {\n // An optional dependency, like the json-schema generator and unlike oRPC. A package\n // that has never been published cannot publish through npm's trusted-publisher OIDC\n // flow, so its first version has to go out by hand; naming it as a hard dependency of\n // the CLI in the same release breaks `npm i @drzl/cli` for everyone until it exists.\n // A missing optional dependency is skipped by the installer rather than failing it,\n // which is why this one really can be absent on an ordinary install.\n const { TRPCGenerator } = await loadGenerator(\n '@drzl/generator-trpc',\n () => import('@drzl/generator-trpc')\n );\n const gen = new TRPCGenerator(analysis);\n const { files } = await gen.generate({\n ...trpcOptions(g, cfg, servicesDir),\n onProgress: ({ index }: { index: number }) => progress.update(index),\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (trpc): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await loadGenerator(\n '@drzl/generator-service',\n () => import('@drzl/generator-service')\n );\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 // The other half of `databaseInjection`. A router generator in injection mode\n // emits `Service.getById(ctx.db, id)`, and only a service generated in the same\n // mode has a `db` parameter to receive it. This branch never passed the option, so\n // the two halves of one generated project disagreed about the signature.\n databaseInjection: g.databaseInjection,\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await loadGenerator(\n '@drzl/generator-zod',\n () => import('@drzl/generator-zod')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await loadGenerator(\n '@drzl/generator-valibot',\n () => import('@drzl/generator-valibot')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await loadGenerator(\n '@drzl/generator-arktype',\n () => import('@drzl/generator-arktype')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'json-schema') {\n try {\n // An optional dependency, unlike the other generators, until its npm trusted publisher\n // exists. A missing optional dependency is skipped rather than failing the install,\n // which is what keeps `npm i @drzl/cli` working meanwhile, and is why this one really\n // can be absent on a normal install.\n const { JsonSchemaGenerator } = await loadGenerator(\n '@drzl/generator-json-schema',\n () => import('@drzl/generator-json-schema')\n );\n const gen = new JsonSchemaGenerator(analysis);\n const target = g.path ?? 'src/validators/json-schema';\n const files = await gen.generate(jsonSchemaOptions(g, cfg, target) 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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'typebox') {\n try {\n const { TypeBoxGenerator } = await loadGenerator(\n '@drzl/generator-typebox',\n () => import('@drzl/generator-typebox')\n );\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 reportGeneratorFailure(g.kind, 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('generate:trpc')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('-o, --outDir <dir>', 'output directory', 'src/api')\n .option('--template <name>', 'standard | service', 'standard')\n .option('--includeRelations', 'include relation endpoints')\n .option('--servicesDir <dir>', 'where the service generator writes', 'src/services')\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 { TRPCGenerator } = await loadGenerator(\n '@drzl/generator-trpc',\n () => import('@drzl/generator-trpc')\n );\n const gen = new TRPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: opts.outDir,\n template: opts.template,\n includeRelations: !!opts.includeRelations,\n // Only consulted by `--template service`, and passed unconditionally so this command\n // cannot become the branch that forgets it.\n servicesDir: opts.servicesDir,\n });\n console.log(chalk.green(`Generated:`), files.map((f: string) => chalk.cyan(f)).join(', '));\n maybeShowSponsorMessage({ reason: 'generate:trpc' });\n } catch (e: any) {\n reportGeneratorFailure('trpc', 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 | generate-trpc', '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 // Must match the `g.path ?? 'src/services'` the service branch below uses, or a router\n // template that imports services spells a path nothing ever wrote. `generate` has always\n // computed this; `watch` did not, so a rebuild silently emitted the default.\n const servicesDir =\n cfg.generators.find((x: { kind: string }) => x.kind === 'service')?.path ??\n 'src/services';\n\n const PIPELINE_KINDS: Record<string, string> = {\n 'generate-orpc': 'orpc',\n 'generate-trpc': 'trpc',\n };\n\n for (const g of cfg.generators) {\n if (opts.pipeline !== 'all' && PIPELINE_KINDS[opts.pipeline] !== g.kind) {\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 databaseInjection: g.databaseInjection,\n servicesDir,\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 === 'trpc') {\n try {\n const { TRPCGenerator } = await loadGenerator(\n '@drzl/generator-trpc',\n () => import('@drzl/generator-trpc')\n );\n const gen = new TRPCGenerator(analysis);\n // The same builder `generate` uses, so the two dispatch loops cannot disagree\n // about what this generator is given.\n const { files } = await gen.generate(trpcOptions(g, cfg, servicesDir));\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (trpc): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await loadGenerator(\n '@drzl/generator-service',\n () => import('@drzl/generator-service')\n );\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 databaseInjection: g.databaseInjection,\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await loadGenerator(\n '@drzl/generator-zod',\n () => import('@drzl/generator-zod')\n );\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await loadGenerator(\n '@drzl/generator-valibot',\n () => import('@drzl/generator-valibot')\n );\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await loadGenerator(\n '@drzl/generator-arktype',\n () => import('@drzl/generator-arktype')\n );\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: false }) as never\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'typebox') {\n try {\n const { TypeBoxGenerator } = await loadGenerator(\n '@drzl/generator-typebox',\n () => import('@drzl/generator-typebox')\n );\n const gen = new TypeBoxGenerator(analysis);\n const target = g.path ?? 'src/validators/typebox';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (typebox): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'json-schema') {\n try {\n const { JsonSchemaGenerator } = await loadGenerator(\n '@drzl/generator-json-schema',\n () => import('@drzl/generator-json-schema')\n );\n const gen = new JsonSchemaGenerator(analysis);\n const target = g.path ?? 'src/validators/json-schema';\n // The same builder `generate` uses, so the two dispatch loops cannot disagree about\n // what this generator is given.\n const files = await gen.generate(jsonSchemaOptions(g, cfg, target) as never);\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (json-schema): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, 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 // One router generator, not both: they default to the same `outDir` and would each write an\n // `index.ts` there, so a scaffold naming both would emit a config whose second generator\n // silently overwrote the first. Swapping the kind is a one-word edit; running both needs a\n // `path` on one of them, which is what the comment says.\n const template = `export default {\n schema: 'src/db/schema.ts',\n outDir: 'src/api',\n analyzer: { includeRelations: true, validateConstraints: true },\n generators: [\n // For tRPC instead: { kind: 'trpc', template: 'standard', includeRelations: true }\n // To run both, give one of them its own \\`path\\`; they share \\`outDir\\` otherwise.\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/**\n * A generator entry from the config, loosely typed because the config schema owns its shape.\n *\n * Exported so a builder that wraps this one names the same keys rather than restating them: every\n * key listed in two places is a key the two can drift on, which is the failure this file exists to\n * remove.\n */\nexport type ValidationGeneratorConfig = {\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 nestedSchemas?: unknown;\n nestedDepth?: 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: ValidationGeneratorConfig,\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 nestedSchemas: g.nestedSchemas,\n nestedDepth: g.nestedDepth,\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 * The options `@drzl/generator-json-schema` receives, built in one place.\n *\n * `generate` and `watch` each dispatch over `cfg.generators` in their own loop, and the json-schema\n * branch was assembled by hand in both. That arrangement has already dropped options silently more\n * than once here: five validation options never reached a watch rebuild, and `watch` had no\n * json-schema branch at all for a while, so that directory went stale from the first save onward.\n * None of it is visible in the wiring, because the option parses, the generator defaults it, and\n * the feature simply does nothing.\n *\n * One builder makes the two call sites the same object by construction rather than by review, and\n * `packages/cli/test/openapi-branch-parity.e2e.spec.ts` runs both commands and compares the bytes.\n */\nimport { validationOptions, type ValidationGeneratorConfig } from './validation-options.js';\n\n/** A generator entry from the config, loosely typed because the config schema owns its shape. */\ntype GeneratorConfig = ValidationGeneratorConfig & {\n path?: string;\n target?: unknown;\n components?: unknown;\n document?: unknown;\n includeRelations?: unknown;\n};\n\nexport function jsonSchemaOptions(\n g: GeneratorConfig,\n cfg: { schema?: unknown },\n outDir: string\n): Record<string, unknown> {\n return {\n // JSON Schema is data, so nothing it emits references a type from the schema module.\n ...validationOptions(g, cfg, outDir, { schemaTypes: false }),\n target: g.target,\n components: g.components,\n document: g.document,\n // Read only while emitting a document, where it adds `/users/{id}/posts`. The per-table\n // schemas are flat whatever it says.\n includeRelations: g.includeRelations,\n };\n}\n","/**\n * The options `@drzl/generator-trpc` receives, built in one place.\n *\n * `generate` and `watch` each dispatch over `cfg.generators` in their own loop, and every branch\n * in both assembles its own options object by hand. Three documented options have already been\n * found dead that way: `typedJson` never reached typebox, `coerceDates` and `applyDefaults`\n * reached nothing but zod, and `servicesDir` is passed by `generate`'s oRPC branch and not by\n * `watch`'s, so a watch rebuild emits a service import pointing at the default directory whatever\n * the config says. None of those is visible in the wiring: the option parses, the generator\n * defaults it, and the feature simply does nothing.\n *\n * One builder means the two call sites are the same object by construction rather than by review.\n * It also gives the drift something to be asserted against, which is what\n * `packages/cli/test/trpc-branch-parity.spec.ts` does by running both commands and comparing the\n * bytes they wrote.\n */\nimport { trpcOutDir } from './config.js';\n\n/** A generator entry from the config, loosely typed because the config schema owns its shape. */\ntype GeneratorConfig = {\n path?: string;\n template?: unknown;\n includeRelations?: unknown;\n naming?: unknown;\n outputHeader?: unknown;\n format?: unknown;\n importExtension?: unknown;\n validation?: unknown;\n databaseInjection?: unknown;\n};\n\nexport function trpcOptions(\n g: GeneratorConfig,\n cfg: { outDir: string },\n servicesDir: string\n): Record<string, unknown> {\n return {\n outputDir: trpcOutDir(g, cfg),\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n importExtension: g.importExtension,\n validation: g.validation,\n databaseInjection: g.databaseInjection,\n // Where the service generator is actually writing, so `template: 'service'` emits an import\n // of a module that exists. The generator defaults this to `src/services`, which is right only\n // by coincidence for a config that puts them elsewhere.\n servicesDir,\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","/**\n * Loading an optional generator package, and telling absence apart from failure.\n *\n * Every validation generator is loaded on demand, because a project that only wants zod should not\n * have to install five. That makes \"the package is not installed\" a real, expected outcome worth a\n * helpful message. It does not make it the only outcome: a generator that is installed and running\n * can throw for any reason a program can throw, and the CLI reported all of those as a missing npm\n * package too, with the true reason printed underneath as a detail.\n *\n * Node reports an unresolvable import as `ERR_MODULE_NOT_FOUND`, and reports the same code when\n * the module resolved and something *it* imported did not. The code alone therefore does not\n * separate the two; the message does, because it names the specifier that failed to resolve.\n */\n\n/** A generator package that is not installed. Everything else is somebody's real error. */\nexport class GeneratorNotInstalledError extends Error {\n constructor(\n readonly specifier: string,\n /** What Node threw, kept so nothing is discarded on the way to the message. */\n readonly reason: unknown\n ) {\n super(`${specifier} is not installed`);\n this.name = 'GeneratorNotInstalledError';\n }\n}\n\n/**\n * Whether `err` is Node refusing to resolve `specifier` itself.\n *\n * Measured on Node 22, from an ESM entry and from a CJS one, since the CLI ships both builds and\n * the bundler leaves `import()` as `import()` in each:\n *\n * absent package ERR_MODULE_NOT_FOUND, `Cannot find package '<specifier>' imported…`\n * present, inner dep absent ERR_MODULE_NOT_FOUND, naming the *inner* specifier instead\n * present, main file gone ERR_MODULE_NOT_FOUND, naming the resolved file path\n * throws while evaluating no `code` at all, and whatever message the generator threw\n *\n * Only the first is an install problem, and only the first quotes the specifier that was asked\n * for, which is what this matches on.\n */\nexport function isPackageMissing(err: unknown, specifier: string): boolean {\n const code = (err as { code?: unknown } | null | undefined)?.code;\n if (code !== 'ERR_MODULE_NOT_FOUND') return false;\n const message = (err as { message?: unknown } | null | undefined)?.message;\n return typeof message === 'string' && message.includes(`'${specifier}'`);\n}\n\n/**\n * Run `load` and re-throw a missing package as `GeneratorNotInstalledError`.\n *\n * `load` is a thunk rather than a specifier so the caller keeps a literal `import('@drzl/…')` in\n * its own source, which is what lets the bundler see the dependency. Anything it throws that is\n * not this package's own absence comes out unchanged.\n */\nexport async function loadGenerator<T>(specifier: string, load: () => Promise<T>): Promise<T> {\n try {\n return await load();\n } catch (e) {\n if (isPackageMissing(e, specifier)) throw new GeneratorNotInstalledError(specifier, e);\n throw e;\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;;;ACwCT,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,IACnB,eAAe,EAAE;AAAA,IACjB,aAAa,EAAE;AAAA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K,CAAC,EAAE,CAAC;AAC1D;AAEA,QAAQ,WAAW,QAAQ,IAAI;","names":["chalk","path","path","readFileSync","path","chalk","fs","watcher","path"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/validation-options.ts","../src/json-schema-options.ts","../src/trpc-options.ts","../src/doctor.ts","../src/drift.ts","../src/generator-loader.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 { jsonSchemaOptions } from './json-schema-options.js';\nimport { trpcOptions } from './trpc-options.js';\nimport { validationOptions } from './validation-options';\nimport {\n computeGeneratorOutputDirs,\n computeWatchTargets,\n DrzlConfig,\n filterTables,\n loadConfig,\n} from './config.js';\nimport { buildDoctorReport, renderDoctorReport } from './doctor.js';\nimport { diffSnapshots, restoreSnapshot, snapshotAll } from './drift.js';\nimport { GeneratorNotInstalledError, loadGenerator } from './generator-loader.js';\nimport { maybeShowSponsorMessage } from './sponsor.js';\nimport { CLI_VERSION } from './version.js';\n\n/**\n * Say what went wrong with a generator, distinguishing the two things that can.\n *\n * Every branch below used to print \"<name> generator missing. Install with: npm install\n * @drzl/generator-<name>\" for anything at all that threw, with the real reason on a trailing\n * \"Error details\" line. A generator that was installed and merely failed therefore sent its user\n * to reinstall a package they already had, and the sentence that would have told them what\n * actually happened was the one written as a footnote.\n *\n * `loadGenerator` marks the one case that is an install problem, so the package name comes off the\n * error rather than being repeated here beside the `import()` that already spells it.\n */\nfunction reportGeneratorFailure(kind: string, e: unknown): void {\n if (e instanceof GeneratorNotInstalledError) {\n console.error(\n chalk.red(`The ${kind} generator is not installed.`),\n chalk.yellow(`\\nInstall with: npm install ${e.specifier}`)\n );\n return;\n }\n console.error(chalk.red(`The ${kind} generator failed:`), (e as any)?.message ?? e);\n}\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('doctor')\n .description('Report what DRZL cannot type or enforce in your schema, and why')\n .argument('[schema]', 'path to drizzle schema (TS); defaults to the schema in drzl.config')\n .option('-c, --config <path>', 'path to drzl.config, read when no schema argument is given')\n .option('--json', 'print the report as JSON instead of prose', false)\n .option('--strict', 'exit 2 when anything is reported', false)\n .action(async (schema: string | undefined, opts: any) => {\n try {\n // A schema path argument, like `analyze`, or the one already named in the config, since a\n // user who has a config should not have to retype the path they put in it.\n let target = schema;\n if (!target) {\n const cfg = await loadConfig(opts.config);\n target = cfg?.schema;\n }\n if (!target) {\n const msg = 'No schema given. Pass a path, or run from a directory with a drzl.config.';\n if (opts.json)\n console.log(JSON.stringify({ event: 'error', code: 'DRZL_CLI_DOCTOR', message: msg }));\n else console.error(chalk.red('Doctor failed (DRZL_CLI_DOCTOR):'), msg);\n process.exit(1);\n return;\n }\n\n const analyzer = new SchemaAnalyzer(target);\n // Both on, unconditionally. Doctor's job is to look at everything, and a warning that only\n // appears when relations are read would be hidden by a flag turning them off.\n const analysis = await analyzer.analyze({\n includeRelations: true,\n validateConstraints: true,\n });\n const report = buildDoctorReport(analysis, target);\n\n if (opts.json) console.log(JSON.stringify(report, null, 2));\n else console.log(renderDoctorReport(report));\n\n // An error-level issue means the schema was never read: the file is missing, or importing it\n // threw. There is no report to act on, so this exits like `analyze`'s failure path rather\n // than pretending the empty analysis was a clean bill of health.\n if (report.findings.some((f) => f.level === 'error')) {\n process.exit(1);\n return;\n }\n // Zero by default, and that is the whole point. A schema carrying a customType or a CHECK\n // this parser will not guess at is normal and usable, and a doctor that failed every\n // pipeline reading one would be switched off within a week. `--strict` is the opt-in.\n process.exit(opts.strict && report.findings.length ? 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_DOCTOR', message: msg }));\n else\n console.error(\n chalk.red('Doctor failed (DRZL_CLI_DOCTOR):'),\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 // Documented on this generator since it was added and never reachable from a config\n // file, because the config schema had no such key and zod stripped it in silence.\n databaseInjection: g.databaseInjection,\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 === 'trpc') {\n try {\n // An optional dependency, like the json-schema generator and unlike oRPC. A package\n // that has never been published cannot publish through npm's trusted-publisher OIDC\n // flow, so its first version has to go out by hand; naming it as a hard dependency of\n // the CLI in the same release breaks `npm i @drzl/cli` for everyone until it exists.\n // A missing optional dependency is skipped by the installer rather than failing it,\n // which is why this one really can be absent on an ordinary install.\n const { TRPCGenerator } = await loadGenerator(\n '@drzl/generator-trpc',\n () => import('@drzl/generator-trpc')\n );\n const gen = new TRPCGenerator(analysis);\n const { files } = await gen.generate({\n ...trpcOptions(g, cfg, servicesDir),\n onProgress: ({ index }: { index: number }) => progress.update(index),\n });\n progress.stop();\n ora().succeed(chalk.green(`Generated (trpc): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await loadGenerator(\n '@drzl/generator-service',\n () => import('@drzl/generator-service')\n );\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 // The other half of `databaseInjection`. A router generator in injection mode\n // emits `Service.getById(ctx.db, id)`, and only a service generated in the same\n // mode has a `db` parameter to receive it. This branch never passed the option, so\n // the two halves of one generated project disagreed about the signature.\n databaseInjection: g.databaseInjection,\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await loadGenerator(\n '@drzl/generator-zod',\n () => import('@drzl/generator-zod')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await loadGenerator(\n '@drzl/generator-valibot',\n () => import('@drzl/generator-valibot')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await loadGenerator(\n '@drzl/generator-arktype',\n () => import('@drzl/generator-arktype')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'json-schema') {\n try {\n // An optional dependency, unlike the other generators, until its npm trusted publisher\n // exists. A missing optional dependency is skipped rather than failing the install,\n // which is what keeps `npm i @drzl/cli` working meanwhile, and is why this one really\n // can be absent on a normal install.\n const { JsonSchemaGenerator } = await loadGenerator(\n '@drzl/generator-json-schema',\n () => import('@drzl/generator-json-schema')\n );\n const gen = new JsonSchemaGenerator(analysis);\n const target = g.path ?? 'src/validators/json-schema';\n const files = await gen.generate(jsonSchemaOptions(g, cfg, target) 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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'typebox') {\n try {\n const { TypeBoxGenerator } = await loadGenerator(\n '@drzl/generator-typebox',\n () => import('@drzl/generator-typebox')\n );\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 reportGeneratorFailure(g.kind, e);\n process.exit(1);\n }\n } else if (g.kind === 'effect') {\n try {\n const { EffectGenerator } = await loadGenerator(\n '@drzl/generator-effect',\n () => import('@drzl/generator-effect')\n );\n const gen = new EffectGenerator(analysis);\n const target = g.path ?? 'src/validators/effect';\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 (effect): ${files.length} files`));\n files.forEach((f: string) => console.log(' -', chalk.cyan(f)));\n } catch (e: any) {\n progress.stop();\n reportGeneratorFailure(g.kind, 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('generate:trpc')\n .argument('<schema>', 'path to drizzle schema (TS)')\n .option('-o, --outDir <dir>', 'output directory', 'src/api')\n .option('--template <name>', 'standard | service', 'standard')\n .option('--includeRelations', 'include relation endpoints')\n .option('--servicesDir <dir>', 'where the service generator writes', 'src/services')\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 { TRPCGenerator } = await loadGenerator(\n '@drzl/generator-trpc',\n () => import('@drzl/generator-trpc')\n );\n const gen = new TRPCGenerator(analysis);\n const { files } = await gen.generate({\n outputDir: opts.outDir,\n template: opts.template,\n includeRelations: !!opts.includeRelations,\n // Only consulted by `--template service`, and passed unconditionally so this command\n // cannot become the branch that forgets it.\n servicesDir: opts.servicesDir,\n });\n console.log(chalk.green(`Generated:`), files.map((f: string) => chalk.cyan(f)).join(', '));\n maybeShowSponsorMessage({ reason: 'generate:trpc' });\n } catch (e: any) {\n reportGeneratorFailure('trpc', 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 | generate-trpc', '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 // Must match the `g.path ?? 'src/services'` the service branch below uses, or a router\n // template that imports services spells a path nothing ever wrote. `generate` has always\n // computed this; `watch` did not, so a rebuild silently emitted the default.\n const servicesDir =\n cfg.generators.find((x: { kind: string }) => x.kind === 'service')?.path ??\n 'src/services';\n\n const PIPELINE_KINDS: Record<string, string> = {\n 'generate-orpc': 'orpc',\n 'generate-trpc': 'trpc',\n };\n\n for (const g of cfg.generators) {\n if (opts.pipeline !== 'all' && PIPELINE_KINDS[opts.pipeline] !== g.kind) {\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 databaseInjection: g.databaseInjection,\n servicesDir,\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 === 'trpc') {\n try {\n const { TRPCGenerator } = await loadGenerator(\n '@drzl/generator-trpc',\n () => import('@drzl/generator-trpc')\n );\n const gen = new TRPCGenerator(analysis);\n // The same builder `generate` uses, so the two dispatch loops cannot disagree\n // about what this generator is given.\n const { files } = await gen.generate(trpcOptions(g, cfg, servicesDir));\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (trpc): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'service') {\n try {\n const { ServiceGenerator } = await loadGenerator(\n '@drzl/generator-service',\n () => import('@drzl/generator-service')\n );\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 databaseInjection: g.databaseInjection,\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'zod') {\n try {\n const { ZodGenerator } = await loadGenerator(\n '@drzl/generator-zod',\n () => import('@drzl/generator-zod')\n );\n const gen = new ZodGenerator(analysis);\n const target = g.path ?? 'src/validators/zod';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'valibot') {\n try {\n const { ValibotGenerator } = await loadGenerator(\n '@drzl/generator-valibot',\n () => import('@drzl/generator-valibot')\n );\n const gen = new ValibotGenerator(analysis);\n const target = g.path ?? 'src/validators/valibot';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'arktype') {\n try {\n const { ArkTypeGenerator } = await loadGenerator(\n '@drzl/generator-arktype',\n () => import('@drzl/generator-arktype')\n );\n const gen = new ArkTypeGenerator(analysis);\n const target = g.path ?? 'src/validators/arktype';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: false }) as never\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 reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'typebox') {\n try {\n const { TypeBoxGenerator } = await loadGenerator(\n '@drzl/generator-typebox',\n () => import('@drzl/generator-typebox')\n );\n const gen = new TypeBoxGenerator(analysis);\n const target = g.path ?? 'src/validators/typebox';\n // The same builder `generate` uses. Assembled by hand here until now, and every\n // option added since the builder existed was therefore absent from a watch rebuild:\n // `coerceDates`, `applyDefaults`, `typedJson`, `typedColumns` and `duplicateFinder`\n // were all dropped, so the first save after starting `drzl watch` silently replaced\n // correct output with output generated from defaults.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (typebox): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'effect') {\n try {\n const { EffectGenerator } = await loadGenerator(\n '@drzl/generator-effect',\n () => import('@drzl/generator-effect')\n );\n const gen = new EffectGenerator(analysis);\n const target = g.path ?? 'src/validators/effect';\n // The same builder `generate` uses, and the same default path, which is also the one\n // `computeGeneratorOutputDirs` has to spell: a watcher that does not ignore this\n // directory regenerates on its own output forever.\n const files = await gen.generate(\n validationOptions(g, cfg, target, { schemaTypes: true }) as never\n );\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (effect): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, e);\n return;\n }\n } else if (g.kind === 'json-schema') {\n try {\n const { JsonSchemaGenerator } = await loadGenerator(\n '@drzl/generator-json-schema',\n () => import('@drzl/generator-json-schema')\n );\n const gen = new JsonSchemaGenerator(analysis);\n const target = g.path ?? 'src/validators/json-schema';\n // The same builder `generate` uses, so the two dispatch loops cannot disagree about\n // what this generator is given.\n const files = await gen.generate(jsonSchemaOptions(g, cfg, target) as never);\n opts.json\n ? console.log(JSON.stringify({ event: 'generate_complete', kind: g.kind, files }))\n : console.log(\n chalk.green(`Generated (json-schema): ${files.length} files`),\n files.map((f: string) => chalk.cyan(f)).join(', ')\n );\n newFiles.push(...files);\n } catch (e: any) {\n reportGeneratorFailure(g.kind, 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 // One router generator, not both: they default to the same `outDir` and would each write an\n // `index.ts` there, so a scaffold naming both would emit a config whose second generator\n // silently overwrote the first. Swapping the kind is a one-word edit; running both needs a\n // `path` on one of them, which is what the comment says.\n const template = `export default {\n schema: 'src/db/schema.ts',\n outDir: 'src/api',\n analyzer: { includeRelations: true, validateConstraints: true },\n generators: [\n // For tRPC instead: { kind: 'trpc', template: 'standard', includeRelations: true }\n // To run both, give one of them its own \\`path\\`; they share \\`outDir\\` otherwise.\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 // Untypeable columns are the only thing this line can see. A CHECK constraint the generators\n // decline produces no output at all and so cannot be counted here without parsing every one of\n // them on the generate path, which is what `doctor` is for.\n console.warn(chalk.gray(' Run `drzl doctor` for the full report.'));\n}\n\nprogram.parseAsync(process.argv);\n","/**\n * The options every validation generator receives, built in one place.\n *\n * Each generator branch 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/**\n * A generator entry from the config, loosely typed because the config schema owns its shape.\n *\n * Exported so a builder that wraps this one names the same keys rather than restating them: every\n * key listed in two places is a key the two can drift on, which is the failure this file exists to\n * remove.\n */\nexport type ValidationGeneratorConfig = {\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 nestedSchemas?: unknown;\n nestedDepth?: 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: ValidationGeneratorConfig,\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 nestedSchemas: g.nestedSchemas,\n nestedDepth: g.nestedDepth,\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 * The options `@drzl/generator-json-schema` receives, built in one place.\n *\n * `generate` and `watch` each dispatch over `cfg.generators` in their own loop, and the json-schema\n * branch was assembled by hand in both. That arrangement has already dropped options silently more\n * than once here: five validation options never reached a watch rebuild, and `watch` had no\n * json-schema branch at all for a while, so that directory went stale from the first save onward.\n * None of it is visible in the wiring, because the option parses, the generator defaults it, and\n * the feature simply does nothing.\n *\n * One builder makes the two call sites the same object by construction rather than by review, and\n * `packages/cli/test/openapi-branch-parity.e2e.spec.ts` runs both commands and compares the bytes.\n */\nimport { validationOptions, type ValidationGeneratorConfig } from './validation-options.js';\n\n/** A generator entry from the config, loosely typed because the config schema owns its shape. */\ntype GeneratorConfig = ValidationGeneratorConfig & {\n path?: string;\n target?: unknown;\n components?: unknown;\n document?: unknown;\n includeRelations?: unknown;\n};\n\nexport function jsonSchemaOptions(\n g: GeneratorConfig,\n cfg: { schema?: unknown },\n outDir: string\n): Record<string, unknown> {\n return {\n // JSON Schema is data, so nothing it emits references a type from the schema module.\n ...validationOptions(g, cfg, outDir, { schemaTypes: false }),\n target: g.target,\n components: g.components,\n document: g.document,\n // Read only while emitting a document, where it adds `/users/{id}/posts`. The per-table\n // schemas are flat whatever it says.\n includeRelations: g.includeRelations,\n };\n}\n","/**\n * The options `@drzl/generator-trpc` receives, built in one place.\n *\n * `generate` and `watch` each dispatch over `cfg.generators` in their own loop, and every branch\n * in both assembles its own options object by hand. Three documented options have already been\n * found dead that way: `typedJson` never reached typebox, `coerceDates` and `applyDefaults`\n * reached nothing but zod, and `servicesDir` is passed by `generate`'s oRPC branch and not by\n * `watch`'s, so a watch rebuild emits a service import pointing at the default directory whatever\n * the config says. None of those is visible in the wiring: the option parses, the generator\n * defaults it, and the feature simply does nothing.\n *\n * One builder means the two call sites are the same object by construction rather than by review.\n * It also gives the drift something to be asserted against, which is what\n * `packages/cli/test/trpc-branch-parity.spec.ts` does by running both commands and comparing the\n * bytes they wrote.\n */\nimport { trpcOutDir } from './config.js';\n\n/** A generator entry from the config, loosely typed because the config schema owns its shape. */\ntype GeneratorConfig = {\n path?: string;\n template?: unknown;\n includeRelations?: unknown;\n naming?: unknown;\n outputHeader?: unknown;\n format?: unknown;\n importExtension?: unknown;\n validation?: unknown;\n databaseInjection?: unknown;\n};\n\nexport function trpcOptions(\n g: GeneratorConfig,\n cfg: { outDir: string },\n servicesDir: string\n): Record<string, unknown> {\n return {\n outputDir: trpcOutDir(g, cfg),\n template: g.template,\n includeRelations: g.includeRelations,\n naming: g.naming,\n outputHeader: g.outputHeader,\n format: g.format,\n importExtension: g.importExtension,\n validation: g.validation,\n databaseInjection: g.databaseInjection,\n // Where the service generator is actually writing, so `template: 'service'` emits an import\n // of a module that exists. The generator defaults this to `src/services`, which is right only\n // by coincidence for a config that puts them elsewhere.\n servicesDir,\n };\n}\n","/**\n * The report behind `drzl doctor`: what DRZL will not check for you, and why.\n *\n * `drzl analyze` already prints the whole `Analysis` as JSON. This is not that. The analysis is a\n * description of the schema and the reader has to know which fields mean trouble; this is the list\n * of things that will silently not work, each with the sentence that says what to do about it.\n *\n * The point of the command is the *silent* half. A generator that cannot type a column emits a\n * validator accepting any value, and a CHECK the parser declines is simply absent from the output:\n * both produce a file that looks finished. `drzl generate` prints a one-line count for the first\n * and says nothing at all about the second.\n *\n * Two of the sections here read something the analyzer does not know:\n *\n * - **CHECK constraints.** `parseCheck` lives in `@drzl/validation-core` and every validation\n * generator calls it; the analyzer never does. It carries the raw expression through and has no\n * opinion on whether anything can be made of it. So the only way to say \"this constraint is in\n * your schema and nothing DRZL emits enforces it\" is to run the generators' own parser, which is\n * what this file does.\n * - **Primary keys.** The service generator keys `getById`, `update` and `delete` on\n * `table.primaryKey?.columns[0] ?? 'id'`, and the router templates take an `id` input to match.\n * A table with no primary key therefore gets a service referencing a column that may not exist,\n * and a composite key gets one keyed on half of it. The analysis states the key correctly; the\n * consequence is the generator's.\n *\n * Deliberately *not* reported, and each for a measured reason:\n *\n * - A CHECK that DRZL does translate. `age >= 18` folds into `.gte(18)` and `start < end` becomes\n * an object-level refinement; listing them as findings would drown the ones that matter.\n * - `length(col)` and `cardinality(col)` landing on a column that cannot take them. Some of the\n * validation generators drop those and some emit something for them, so no single sentence here\n * is true of all of them. It is also unreachable from a working schema: Postgres has no\n * `length(anyarray)` and no `cardinality(integer)`, so the DDL is refused before DRZL sees it.\n */\nimport type { Analysis, Column, Issue, Table } from '@drzl/analyzer';\nimport { parseCheck } from '@drzl/validation-core';\nimport chalk from 'chalk';\n\nexport type DoctorFindingKind =\n /** A column whose validator will accept any value. */\n | 'unknown-column'\n /** A CHECK the shared parser refused to translate. */\n | 'check-declined'\n /** A CHECK naming a column the table does not have. */\n | 'check-unknown-column'\n /** A CHECK comparing an array or structured column against a scalar literal. */\n | 'check-not-scalar'\n /** A table the generators cannot key. */\n | 'no-primary-key'\n /** A table keyed on more columns than the generators use. */\n | 'partial-primary-key'\n /** Anything else the analyzer said, passed through rather than dropped. */\n | 'analyzer';\n\nexport interface DoctorFinding {\n kind: DoctorFindingKind;\n level: 'warn' | 'error';\n /** Table this is about, as the analysis names it. Absent for a finding about the whole schema. */\n table?: string;\n column?: string;\n /** Constraint name, where the finding is about a CHECK. */\n constraint?: string;\n message: string;\n hint?: string;\n}\n\nexport interface DoctorReport {\n /** The schema path as the user spelled it, so the report names the file they asked about. */\n schema: string;\n dialect: string;\n /** True only when there is nothing at all to say. */\n ok: boolean;\n counts: { tables: number; columns: number; checks: number; findings: number };\n findings: DoctorFinding[];\n}\n\n/** Issue codes with a section of their own, so the catch-all does not print them twice. */\nconst HANDLED_CODES = new Set(['DRZL_ANL_UNKNOWN_COLUMN']);\n\n/**\n * Split an issue `path` into its table and column halves.\n *\n * The analyzer writes `table.column` for a column issue and a bare table name otherwise. Table\n * names are JavaScript identifiers, so the last dot is the separator and there is no ambiguity.\n */\nfunction splitPath(path: string | undefined): { table?: string; column?: string } {\n if (!path) return {};\n const dot = path.lastIndexOf('.');\n if (dot <= 0) return { table: path };\n return { table: path.slice(0, dot), column: path.slice(dot + 1) };\n}\n\n/** Every column name a parsed CHECK talks about, paired with the kind of constraint it came from. */\nfunction namedColumns(parsed: Extract<ReturnType<typeof parseCheck>, { ok: true }>) {\n const out: Array<{ column: string; scalar: boolean }> = [];\n // A comparison against a literal and an `IN` list are both statements about a scalar value, so\n // neither describes an array or a structured column. The other three kinds are not: a length or\n // a cardinality is a statement about a count, and a row check is a comparison of two columns.\n for (const c of parsed.checks) out.push({ column: c.column, scalar: true });\n for (const s of parsed.sets ?? []) out.push({ column: s.column, scalar: true });\n for (const l of parsed.lengths ?? []) out.push({ column: l.column, scalar: false });\n for (const c of parsed.cardinalities ?? []) out.push({ column: c.column, scalar: false });\n for (const r of parsed.rows ?? []) {\n out.push({ column: r.left, scalar: false });\n out.push({ column: r.right, scalar: false });\n }\n return out;\n}\n\n/**\n * What a column is, for a sentence about a constraint that does not fit it.\n *\n * Every `ColumnShape` kind has an arm, so a shape added later reads as \"a structured column\" rather\n * than as a wrong noun. `arrayDimensions` is checked first because an array carries its element's\n * shape and it is the array the constraint failed to describe.\n */\nfunction describeShape(c: Column): string {\n if (c.arrayDimensions) return 'an array';\n switch (c.shape?.kind) {\n case 'json':\n return 'a JSON';\n case 'buffer':\n return 'a binary';\n case 'tuple':\n case 'numberObject':\n return 'a structured';\n case 'numberVector':\n return 'a vector';\n case 'bitstring':\n return 'a bit-string';\n case 'byteString':\n return 'a byte-string';\n case 'custom':\n return 'a customType';\n default:\n return 'a structured';\n }\n}\n\nfunction checkFindings(table: Table): DoctorFinding[] {\n const out: DoctorFinding[] = [];\n const byName = new Map(table.columns.map((c) => [c.name, c]));\n for (const k of table.checks ?? []) {\n const label = k.name ? `\"${k.name}\"` : 'an unnamed constraint';\n const raw = k.expression ?? '';\n // A constraint whose expression the analyzer could not render at all is the one case where\n // printing the expression verbatim says nothing, and a line ending in \"Expression:\" reads\n // like the report itself is broken.\n const expr = raw.trim() ? raw : '(empty)';\n const parsed = parseCheck(raw, k.name);\n if (!parsed.ok) {\n out.push({\n kind: 'check-declined',\n level: 'warn',\n table: table.tsName,\n constraint: k.name,\n message: `CHECK ${label} on \"${table.tsName}\" is not translated: ${parsed.reason}. Expression: ${expr}`,\n hint:\n 'Only constraints whose meaning is unambiguous are translated, because a validator ' +\n 'enforcing a guess rejects rows the database accepts. Your database still enforces ' +\n 'this one; nothing DRZL emits does.',\n });\n continue;\n }\n\n // Reported once per column rather than once per clause, so `a >= 1 AND a <= 9` on a missing\n // column is one line and not two.\n const seen = new Set<string>();\n for (const { column, scalar } of namedColumns(parsed)) {\n if (seen.has(column)) continue;\n seen.add(column);\n const col = byName.get(column);\n if (!col) {\n out.push({\n kind: 'check-unknown-column',\n level: 'warn',\n table: table.tsName,\n column,\n constraint: k.name,\n message: `CHECK ${label} on \"${table.tsName}\" names \"${column}\", which is not a column of that table, so nothing enforces it. Expression: ${expr}`,\n hint:\n 'A constraint is attached to the field it names. Check the spelling, or move a ' +\n 'constraint spanning two tables out of the schema.',\n });\n continue;\n }\n if (scalar && (col.arrayDimensions || col.shape)) {\n out.push({\n kind: 'check-not-scalar',\n level: 'warn',\n table: table.tsName,\n column,\n constraint: k.name,\n message: `CHECK ${label} on \"${table.tsName}\" compares ${describeShape(col)} column \"${column}\" against a scalar literal, which does not describe it, so it is not translated. Expression: ${expr}`,\n hint:\n 'On an array column only cardinality(col) is read, since it is the one comparison ' +\n 'that is about the array rather than about an element.',\n });\n }\n }\n }\n return out;\n}\n\nfunction primaryKeyFindings(table: Table): DoctorFinding[] {\n // A read-only relation takes no writes and gets no keyed route, so it needs no key.\n if (table.readOnly) return [];\n const pk = table.primaryKey?.columns ?? [];\n if (!pk.length) {\n const hasId = table.columns.some((c) => c.name === 'id');\n return [\n {\n kind: 'no-primary-key',\n level: 'warn',\n table: table.tsName,\n message: hasId\n ? `Table \"${table.tsName}\" declares no primary key. The service and router generators fall back to a column named \"id\", which this table happens to have, so they work by coincidence.`\n : `Table \"${table.tsName}\" declares no primary key. The service and router generators fall back to a column named \"id\", which this table does not have, so the generated service will not compile.`,\n hint: 'Declare a primary key, or leave this table out with the config table filter.',\n },\n ];\n }\n if (pk.length > 1) {\n return [\n {\n kind: 'partial-primary-key',\n level: 'warn',\n table: table.tsName,\n message: `Table \"${table.tsName}\" has a composite primary key (${pk.join(', ')}). The service and router generators key getById, update and delete on \"${pk[0]}\" alone, so those operations match on part of the key.`,\n hint: 'Treat the generated service as a starting point for this table and widen the key by hand.',\n },\n ];\n }\n return [];\n}\n\n/**\n * Everything worth saying about one analysis, in the order it should be read.\n *\n * Ordered worst-first, and within that silent-first. A schema that could not be analyzed comes\n * first because nothing after it is trustworthy. Untypeable columns and dropped constraints come\n * next because they are invisible: the generated file exists, compiles and validates nothing. The\n * primary-key findings come after because one half of that pair announces itself as a compile\n * error. The catch-all is last.\n */\nexport function buildDoctorReport(analysis: Analysis, schemaPath: string): DoctorReport {\n const findings: DoctorFinding[] = [];\n\n const errors = analysis.issues.filter((i: Issue) => i.level === 'error');\n for (const i of errors) {\n findings.push({\n kind: 'analyzer',\n level: 'error',\n ...splitPath(i.path),\n message: i.message,\n hint: i.hint,\n });\n }\n\n for (const i of analysis.issues) {\n if (i.code !== 'DRZL_ANL_UNKNOWN_COLUMN') continue;\n findings.push({\n kind: 'unknown-column',\n level: 'warn',\n ...splitPath(i.path),\n message: i.message,\n hint: i.hint,\n });\n }\n\n for (const t of analysis.tables) findings.push(...checkFindings(t));\n for (const t of analysis.tables) findings.push(...primaryKeyFindings(t));\n\n for (const i of analysis.issues) {\n if (i.level === 'error' || HANDLED_CODES.has(i.code)) continue;\n findings.push({\n kind: 'analyzer',\n level: 'warn',\n ...splitPath(i.path),\n message: i.message,\n hint: i.hint,\n });\n }\n\n const columns = analysis.tables.reduce((n, t) => n + t.columns.length, 0);\n const checks = analysis.tables.reduce((n, t) => n + (t.checks?.length ?? 0), 0);\n return {\n schema: schemaPath,\n dialect: analysis.dialect,\n ok: findings.length === 0,\n counts: { tables: analysis.tables.length, columns, checks, findings: findings.length },\n findings,\n };\n}\n\n/** Sections, in report order, each with the sentence that says why its contents matter. */\nconst SECTIONS: Array<{ kinds: DoctorFindingKind[]; title: string; why: string }> = [\n {\n kinds: ['unknown-column'],\n title: 'Columns DRZL cannot type',\n why: 'These get a validator that accepts any value.',\n },\n {\n kinds: ['check-declined', 'check-unknown-column', 'check-not-scalar'],\n title: 'CHECK constraints DRZL does not enforce',\n why: 'Your database still enforces these. Nothing DRZL generates does.',\n },\n {\n kinds: ['no-primary-key', 'partial-primary-key'],\n title: 'Primary keys the generators cannot use',\n why: 'The generated getById, update and delete are keyed on one column.',\n },\n {\n kinds: ['analyzer'],\n title: 'Other findings',\n why: 'Reported by the analyzer while reading the schema.',\n },\n];\n\n/**\n * Wrap a sentence under a fixed indent, so it does not run off a narrow terminal.\n *\n * `first` is the prefix the opening line carries instead of the indent, which is what gives a\n * finding its bullet and its continuation lines a hanging indent under the text rather than under\n * the bullet.\n */\nfunction wrap(text: string, indent: string, first = indent, width = 96): string {\n const lines: string[] = [];\n let line = '';\n for (const word of text.split(/\\s+/)) {\n if (line && `${line} ${word}`.length + indent.length > width) {\n lines.push(line);\n line = word;\n } else {\n line = line ? `${line} ${word}` : word;\n }\n }\n if (line) lines.push(line);\n return lines.map((l, i) => (i === 0 ? first : indent) + l).join('\\n');\n}\n\n/**\n * The human-readable report.\n *\n * A clean schema prints what was looked at rather than nothing, because an empty page cannot be\n * told apart from a command that failed to run.\n */\nexport function renderDoctorReport(report: DoctorReport): string {\n const out: string[] = [];\n const plural = (n: number, one: string) => `${n} ${one}${n === 1 ? '' : 's'}`;\n\n out.push(chalk.bold(`DRZL doctor ${report.schema}`));\n out.push(\n chalk.dim(\n `${report.dialect}, ${plural(report.counts.tables, 'table')}, ` +\n `${plural(report.counts.columns, 'column')}, ${plural(report.counts.checks, 'CHECK constraint')}`\n )\n );\n out.push('');\n\n if (report.ok) {\n out.push(chalk.green('Nothing to report.'));\n out.push(chalk.dim(' Every column has a type DRZL can describe.'));\n out.push(chalk.dim(' Every CHECK constraint is translated into the generated validators.'));\n out.push(chalk.dim(' Every table has a primary key the generators can use.'));\n return out.join('\\n');\n }\n\n // Ahead of the sections rather than inside one. An error means the schema was never read, so\n // every count above is zero and every section below is empty, and printing that under \"Other\n // findings\" at the foot of the page buries the only sentence that matters.\n const fatal = report.findings.filter((f) => f.level === 'error');\n if (fatal.length) {\n out.push(chalk.red('DRZL could not read this schema'));\n out.push(chalk.dim(' Nothing else could be checked.'));\n out.push('');\n for (const f of fatal) {\n out.push(wrap(f.message, ' ', ` ${chalk.dim('-')} `));\n if (f.hint) out.push(chalk.dim(wrap(f.hint, ' ')));\n }\n out.push('');\n }\n\n for (const section of SECTIONS) {\n const mine = report.findings.filter(\n (f) => f.level !== 'error' && section.kinds.includes(f.kind)\n );\n if (!mine.length) continue;\n out.push(chalk.yellow(`${section.title} (${mine.length})`));\n out.push(chalk.dim(` ${section.why}`));\n out.push('');\n // One hint per distinct sentence, under the findings that share it: the same advice repeated\n // under twenty columns is the thing that makes a report unreadable.\n const groups = new Map<string, DoctorFinding[]>();\n for (const f of mine) {\n const key = f.hint ?? '';\n groups.set(key, [...(groups.get(key) ?? []), f]);\n }\n for (const [hint, items] of groups) {\n for (const f of items) out.push(wrap(f.message, ' ', ` ${chalk.dim('-')} `));\n if (hint) out.push(chalk.dim(wrap(hint, ' ')));\n out.push('');\n }\n }\n\n out.push(\n chalk.bold(`${plural(report.counts.findings, 'finding')} in ${report.schema}.`) +\n chalk.dim(\n fatal.length\n ? ' Fix the error above and run this again.'\n : ' None of these stop DRZL generating; they are what it will not check for you.'\n )\n );\n return out.join('\\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","/**\n * Loading an optional generator package, and telling absence apart from failure.\n *\n * Every validation generator is loaded on demand, because a project that only wants zod should not\n * have to install five. That makes \"the package is not installed\" a real, expected outcome worth a\n * helpful message. It does not make it the only outcome: a generator that is installed and running\n * can throw for any reason a program can throw, and the CLI reported all of those as a missing npm\n * package too, with the true reason printed underneath as a detail.\n *\n * Node reports an unresolvable import as `ERR_MODULE_NOT_FOUND`, and reports the same code when\n * the module resolved and something *it* imported did not. The code alone therefore does not\n * separate the two; the message does, because it names the specifier that failed to resolve.\n */\n\n/** A generator package that is not installed. Everything else is somebody's real error. */\nexport class GeneratorNotInstalledError extends Error {\n constructor(\n readonly specifier: string,\n /** What Node threw, kept so nothing is discarded on the way to the message. */\n readonly reason: unknown\n ) {\n super(`${specifier} is not installed`);\n this.name = 'GeneratorNotInstalledError';\n }\n}\n\n/**\n * Whether `err` is Node refusing to resolve `specifier` itself.\n *\n * Measured on Node 22, from an ESM entry and from a CJS one, since the CLI ships both builds and\n * the bundler leaves `import()` as `import()` in each:\n *\n * absent package ERR_MODULE_NOT_FOUND, `Cannot find package '<specifier>' imported…`\n * present, inner dep absent ERR_MODULE_NOT_FOUND, naming the *inner* specifier instead\n * present, main file gone ERR_MODULE_NOT_FOUND, naming the resolved file path\n * throws while evaluating no `code` at all, and whatever message the generator threw\n *\n * Only the first is an install problem, and only the first quotes the specifier that was asked\n * for, which is what this matches on.\n */\nexport function isPackageMissing(err: unknown, specifier: string): boolean {\n const code = (err as { code?: unknown } | null | undefined)?.code;\n if (code !== 'ERR_MODULE_NOT_FOUND') return false;\n const message = (err as { message?: unknown } | null | undefined)?.message;\n return typeof message === 'string' && message.includes(`'${specifier}'`);\n}\n\n/**\n * Run `load` and re-throw a missing package as `GeneratorNotInstalledError`.\n *\n * `load` is a thunk rather than a specifier so the caller keeps a literal `import('@drzl/…')` in\n * its own source, which is what lets the bundler see the dependency. Anything it throws that is\n * not this package's own absence comes out unchanged.\n */\nexport async function loadGenerator<T>(specifier: string, load: () => Promise<T>): Promise<T> {\n try {\n return await load();\n } catch (e) {\n if (isPackageMissing(e, specifier)) throw new GeneratorNotInstalledError(specifier, e);\n throw e;\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, typebox, or effect 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;;;ACwCT,SAAS,kBACd,GACA,KACA,QACA,OAA8B,CAAC,GACN;AACzB,SAAO;AAAA,IACL;AAAA,IACA,cAA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,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;AAIxD,UAAQ,KAAKA,OAAM,KAAK,0CAA0C,CAAC;AACrE;AAEA,QAAQ,WAAW,QAAQ,IAAI;","names":["chalk","path","path","chalk","path","readFileSync","path","chalk","fs","watcher","path"]}
package/dist/config.cjs CHANGED
@@ -85,7 +85,17 @@ var AffixSchema = import_zod.z.object({
85
85
  }).strict();
86
86
  var ImportExtensionSchema = import_zod.z.enum(import_validation_core.IMPORT_EXTENSIONS);
87
87
  var GeneratorSchema = import_zod.z.object({
88
- kind: import_zod.z.enum(["orpc", "trpc", "service", "zod", "valibot", "arktype", "typebox", "json-schema"]),
88
+ kind: import_zod.z.enum([
89
+ "orpc",
90
+ "trpc",
91
+ "service",
92
+ "zod",
93
+ "valibot",
94
+ "arktype",
95
+ "typebox",
96
+ "effect",
97
+ "json-schema"
98
+ ]),
89
99
  /**
90
100
  * Overrides the top-level `importExtension` for this generator alone, for a project whose
91
101
  * generated directories are compiled by different tsconfigs.
@@ -422,6 +432,7 @@ function computeGeneratorOutputDirs(cfg, cwd = process.cwd()) {
422
432
  if (g.kind === "valibot") dirs.add(abs(g.path ?? "src/validators/valibot"));
423
433
  if (g.kind === "arktype") dirs.add(abs(g.path ?? "src/validators/arktype"));
424
434
  if (g.kind === "typebox") dirs.add(abs(g.path ?? "src/validators/typebox"));
435
+ if (g.kind === "effect") dirs.add(abs(g.path ?? "src/validators/effect"));
425
436
  if (g.kind === "json-schema") dirs.add(abs(g.path ?? "src/validators/json-schema"));
426
437
  }
427
438
  return [...dirs];