@prisma-next/cli 0.10.0-dev.9 → 0.11.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.
Files changed (145) hide show
  1. package/README.md +1 -1
  2. package/dist/{cli-errors-CF60g2cG.mjs → cli-errors-Djtz98Vm.mjs} +3 -3
  3. package/dist/cli-errors-Djtz98Vm.mjs.map +1 -0
  4. package/dist/cli.mjs +46 -51
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/{client-Brv4qlfB.mjs → client-oXO2WCPD.mjs} +6 -5
  7. package/dist/client-oXO2WCPD.mjs.map +1 -0
  8. package/dist/{command-helpers-Dvgul7UA.mjs → command-helpers-BSb0tRC8.mjs} +103 -9
  9. package/dist/command-helpers-BSb0tRC8.mjs.map +1 -0
  10. package/dist/commands/contract-emit.mjs +1 -1
  11. package/dist/commands/contract-infer.mjs +1 -1
  12. package/dist/commands/db-init.d.mts.map +1 -1
  13. package/dist/commands/db-init.mjs +19 -20
  14. package/dist/commands/db-init.mjs.map +1 -1
  15. package/dist/commands/db-schema.mjs +6 -10
  16. package/dist/commands/db-schema.mjs.map +1 -1
  17. package/dist/commands/db-sign.mjs +7 -11
  18. package/dist/commands/db-sign.mjs.map +1 -1
  19. package/dist/commands/db-update.d.mts.map +1 -1
  20. package/dist/commands/db-update.mjs +16 -17
  21. package/dist/commands/db-update.mjs.map +1 -1
  22. package/dist/commands/db-verify.mjs +1 -1
  23. package/dist/commands/migrate.d.mts +1 -1
  24. package/dist/commands/migrate.mjs +7 -11
  25. package/dist/commands/migrate.mjs.map +1 -1
  26. package/dist/commands/migration-check.mjs +4 -7
  27. package/dist/commands/migration-check.mjs.map +1 -1
  28. package/dist/commands/migration-graph.d.mts +1 -1
  29. package/dist/commands/migration-graph.mjs +6 -10
  30. package/dist/commands/migration-graph.mjs.map +1 -1
  31. package/dist/commands/migration-list.mjs +5 -9
  32. package/dist/commands/migration-list.mjs.map +1 -1
  33. package/dist/commands/migration-log.d.mts.map +1 -1
  34. package/dist/commands/migration-log.mjs +7 -10
  35. package/dist/commands/migration-log.mjs.map +1 -1
  36. package/dist/commands/migration-new.mjs +6 -10
  37. package/dist/commands/migration-new.mjs.map +1 -1
  38. package/dist/commands/migration-plan.d.mts +1 -1
  39. package/dist/commands/migration-plan.mjs +1 -1
  40. package/dist/commands/migration-show.d.mts +1 -1
  41. package/dist/commands/migration-show.mjs +8 -12
  42. package/dist/commands/migration-show.mjs.map +1 -1
  43. package/dist/commands/migration-status.d.mts +1 -1
  44. package/dist/commands/migration-status.d.mts.map +1 -1
  45. package/dist/commands/migration-status.mjs +36 -14
  46. package/dist/commands/migration-status.mjs.map +1 -1
  47. package/dist/commands/ref.d.mts +1 -1
  48. package/dist/commands/ref.mjs +9 -19
  49. package/dist/commands/ref.mjs.map +1 -1
  50. package/dist/{contract-emit-iynA3BCA.mjs → contract-emit-bcrpT-wD.mjs} +3 -3
  51. package/dist/{contract-emit-iynA3BCA.mjs.map → contract-emit-bcrpT-wD.mjs.map} +1 -1
  52. package/dist/{contract-emit-BDBzHlaC.mjs → contract-emit-r4y8Zhf1.mjs} +7 -12
  53. package/dist/contract-emit-r4y8Zhf1.mjs.map +1 -0
  54. package/dist/{contract-infer-Dm8pBZMR.mjs → contract-infer-BmySmqVT.mjs} +8 -13
  55. package/dist/contract-infer-BmySmqVT.mjs.map +1 -0
  56. package/dist/{contract-space-aggregate-loader-pAc8CDfY.mjs → contract-space-aggregate-loader-BmNQwlws.mjs} +2 -2
  57. package/dist/{contract-space-aggregate-loader-pAc8CDfY.mjs.map → contract-space-aggregate-loader-BmNQwlws.mjs.map} +1 -1
  58. package/dist/{db-verify-CW8DR5Ei.mjs → db-verify-BClPs3ph.mjs} +9 -13
  59. package/dist/db-verify-BClPs3ph.mjs.map +1 -0
  60. package/dist/exports/control-api.d.mts +1 -1
  61. package/dist/exports/control-api.mjs +2 -2
  62. package/dist/exports/index.mjs +1 -1
  63. package/dist/exports/init-output.mjs +1 -1
  64. package/dist/{framework-components-xFLFpZUO.mjs → framework-components-65gOHkHB.mjs} +2 -2
  65. package/dist/{framework-components-xFLFpZUO.mjs.map → framework-components-65gOHkHB.mjs.map} +1 -1
  66. package/dist/{global-flags-DGmw6Kqg.d.mts → global-flags-CdE7M0d9.d.mts} +4 -1
  67. package/dist/global-flags-CdE7M0d9.d.mts.map +1 -0
  68. package/dist/{graph-render-eJDcLWny.mjs → graph-render-DJVv0_uf.mjs} +1 -1
  69. package/dist/{graph-render-eJDcLWny.mjs.map → graph-render-DJVv0_uf.mjs.map} +1 -1
  70. package/dist/{init-CxS9eqbQ.mjs → init-BCJZPWE1.mjs} +141 -55
  71. package/dist/init-BCJZPWE1.mjs.map +1 -0
  72. package/dist/{inspect-live-schema-iETRZ_59.mjs → inspect-live-schema-DSRbFoOL.mjs} +4 -4
  73. package/dist/{inspect-live-schema-iETRZ_59.mjs.map → inspect-live-schema-DSRbFoOL.mjs.map} +1 -1
  74. package/dist/{migration-command-scaffold-BlgVj_Pn.mjs → migration-command-scaffold-Bzd9La5c.mjs} +4 -4
  75. package/dist/{migration-command-scaffold-BlgVj_Pn.mjs.map → migration-command-scaffold-Bzd9La5c.mjs.map} +1 -1
  76. package/dist/{migration-plan-BSzcWsvm.mjs → migration-plan-CFwqw3Gk.mjs} +8 -12
  77. package/dist/migration-plan-CFwqw3Gk.mjs.map +1 -0
  78. package/dist/{migration-types-D2FW63pr.d.mts → migration-types-BXWvz12q.d.mts} +1 -1
  79. package/dist/{migration-types-D2FW63pr.d.mts.map → migration-types-BXWvz12q.d.mts.map} +1 -1
  80. package/dist/{migrations-CgANWI0w.mjs → migrations-CwZMa1Ck.mjs} +2 -2
  81. package/dist/{migrations-CgANWI0w.mjs.map → migrations-CwZMa1Ck.mjs.map} +1 -1
  82. package/dist/{output-B60Gw5fu.mjs → output-BlsrGMEF.mjs} +1 -1
  83. package/dist/{output-B60Gw5fu.mjs.map → output-BlsrGMEF.mjs.map} +1 -1
  84. package/dist/readme-mongo.md +35 -0
  85. package/dist/readme-postgres.md +34 -0
  86. package/dist/{terminal-ui-XtOQsqe9.mjs → terminal-ui-BiB_8KNo.mjs} +131 -24
  87. package/dist/terminal-ui-BiB_8KNo.mjs.map +1 -0
  88. package/dist/{types-0aS865QN.d.mts → types--CqjMdk0.d.mts} +2 -2
  89. package/dist/{types-0aS865QN.d.mts.map → types--CqjMdk0.d.mts.map} +1 -1
  90. package/dist/{verify-nlzO0uIY.mjs → verify-Bom75OYI.mjs} +2 -2
  91. package/dist/{verify-nlzO0uIY.mjs.map → verify-Bom75OYI.mjs.map} +1 -1
  92. package/package.json +18 -18
  93. package/src/cli.ts +36 -9
  94. package/src/commands/contract-emit.ts +4 -4
  95. package/src/commands/contract-infer.ts +6 -6
  96. package/src/commands/db-init.ts +13 -5
  97. package/src/commands/db-schema.ts +4 -4
  98. package/src/commands/db-sign.ts +4 -4
  99. package/src/commands/db-update.ts +13 -5
  100. package/src/commands/db-verify.ts +5 -5
  101. package/src/commands/init/detect-package-manager.ts +15 -0
  102. package/src/commands/init/errors.ts +31 -0
  103. package/src/commands/init/index.ts +2 -2
  104. package/src/commands/init/init.ts +33 -17
  105. package/src/commands/init/inputs.ts +6 -4
  106. package/src/commands/init/output.ts +1 -1
  107. package/src/commands/init/skill-install.ts +37 -26
  108. package/src/commands/init/templates/code-templates.ts +4 -12
  109. package/src/commands/init/templates/env.ts +8 -1
  110. package/src/commands/init/templates/readme-mongo.md +35 -0
  111. package/src/commands/init/templates/readme-postgres.md +34 -0
  112. package/src/commands/init/templates/readme.ts +62 -0
  113. package/src/commands/migrate.ts +4 -7
  114. package/src/commands/migration-check.ts +4 -4
  115. package/src/commands/migration-graph.ts +4 -4
  116. package/src/commands/migration-list.ts +4 -4
  117. package/src/commands/migration-log.ts +6 -5
  118. package/src/commands/migration-new.ts +4 -4
  119. package/src/commands/migration-plan.ts +4 -4
  120. package/src/commands/migration-show.ts +4 -4
  121. package/src/commands/migration-status.ts +49 -6
  122. package/src/commands/ref.ts +8 -8
  123. package/src/control-api/operations/apply-aggregate.ts +1 -0
  124. package/src/utils/cli-errors.ts +4 -0
  125. package/src/utils/command-helpers.ts +6 -2
  126. package/src/utils/global-flags.ts +102 -17
  127. package/src/utils/telemetry.ts +27 -52
  128. package/src/utils/terminal-ui.ts +44 -23
  129. package/dist/cli-errors-CF60g2cG.mjs.map +0 -1
  130. package/dist/client-Brv4qlfB.mjs.map +0 -1
  131. package/dist/command-helpers-Dvgul7UA.mjs.map +0 -1
  132. package/dist/contract-emit-BDBzHlaC.mjs.map +0 -1
  133. package/dist/contract-infer-Dm8pBZMR.mjs.map +0 -1
  134. package/dist/db-verify-CW8DR5Ei.mjs.map +0 -1
  135. package/dist/errors-BYAXmyRJ.mjs +0 -56
  136. package/dist/errors-BYAXmyRJ.mjs.map +0 -1
  137. package/dist/global-flags-DGmw6Kqg.d.mts.map +0 -1
  138. package/dist/init-CxS9eqbQ.mjs.map +0 -1
  139. package/dist/is-ci-YyvQBBke.mjs +0 -44
  140. package/dist/is-ci-YyvQBBke.mjs.map +0 -1
  141. package/dist/migration-plan-BSzcWsvm.mjs.map +0 -1
  142. package/dist/result-handler-CG3vVoKf.mjs +0 -25
  143. package/dist/result-handler-CG3vVoKf.mjs.map +0 -1
  144. package/dist/terminal-ui-XtOQsqe9.mjs.map +0 -1
  145. /package/dist/{cli-errors-DdcjVLJV.d.mts → cli-errors-Czmx92Zy.d.mts} +0 -0
package/README.md CHANGED
@@ -1060,7 +1060,7 @@ run `migration.ts` directly with Node to produce `ops.json` and attest
1060
1060
  node migrations/<dir>/migration.ts
1061
1061
  ```
1062
1062
 
1063
- The scaffolded `migration.ts` calls `MigrationCLI.run(import.meta.url, ...)` from `@prisma-next/cli/migration-cli` when invoked as the entrypoint. (Postgres scaffolds re-export `MigrationCLI` through `@prisma-next/target-postgres/migration` so a Postgres `migration.ts` only needs the single facade import; Mongo scaffolds still pull from `@prisma-next/cli/migration-cli` directly.) The CLI entrypoint loads `prisma-next.config.ts`, assembles a `ControlStack`, instantiates the migration with that stack (so `dataTransform` and other adapter-aware helpers can materialize a real adapter), and serializes operations to `ops.json` while writing the content-addressed `migrationHash` into `migration.json`. If `migration.ts` contains unfilled `placeholder()` slots, the script exits with `PN-MIG-2001` and reports the slot to fill in.
1063
+ The scaffolded `migration.ts` calls `MigrationCLI.run(import.meta.url, ...)` from `@prisma-next/cli/migration-cli` when invoked as the entrypoint. (Postgres and SQLite scaffolds re-export `MigrationCLI` through `@prisma-next/postgres/migration` or `@prisma-next/sqlite/migration` so a `migration.ts` only needs the single facade import; Mongo scaffolds still pull from `@prisma-next/cli/migration-cli` directly.) The CLI entrypoint loads `prisma-next.config.ts`, assembles a `ControlStack`, instantiates the migration with that stack (so `dataTransform` and other adapter-aware helpers can materialize a real adapter), and serializes operations to `ops.json` while writing the content-addressed `migrationHash` into `migration.json`. If `migration.ts` contains unfilled `placeholder()` slots, the script exits with `PN-MIG-2001` and reports the slot to fill in.
1064
1064
 
1065
1065
  `MigrationCLI.run` accepts an optional third argument `{ argv?, stdout?, stderr? }` for in-process testability (default: `process.argv` / `process.stdout` / `process.stderr`) and returns the exit code as a `Promise<number>`. The flag surface is `--help` / `--dry-run` / `--config <path>`, parsed by [`clipanion`](https://github.com/arcanis/clipanion). The main multi-command surface (`prisma-next contract emit`, `db verify`, etc.) uses Commander; the per-migration `MigrationCLI.run` entrypoint uses clipanion to keep authored migration files lightweight and in-process testable.
1066
1066
 
@@ -1,4 +1,4 @@
1
- import { CliStructuredError as CliStructuredError$1, errorConfigValidation as errorConfigValidation$1, errorContractConfigMissing as errorContractConfigMissing$1, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorMigrationPlanningFailed, errorTargetMigrationNotSupported, errorUnexpected as errorUnexpected$1 } from "@prisma-next/errors/control";
1
+ import { CliStructuredError as CliStructuredError$1, errorConfigValidation as errorConfigValidation$1, errorContractConfigMissing as errorContractConfigMissing$1, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorInvalidOutputFormat, errorMigrationPlanningFailed, errorOutputFormatMutex, errorTargetMigrationNotSupported, errorUnexpected as errorUnexpected$1 } from "@prisma-next/errors/control";
2
2
  import { ERROR_CODE_DESTRUCTIVE_CHANGES, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorRunnerFailed, errorRuntime, errorRuntime as errorRuntime$1, errorTargetMismatch } from "@prisma-next/errors/execution";
3
3
  import "@prisma-next/errors/migration";
4
4
  //#region src/utils/cli-errors.ts
@@ -66,6 +66,6 @@ function mapRefResolutionError(error) {
66
66
  }
67
67
  }
68
68
  //#endregion
69
- export { errorUnexpected$1 as _, errorContractValidationFailed as a, errorDriverRequired as c, errorMarkerMissing as d, errorMigrationPlanningFailed as f, errorTargetMismatch as g, errorTargetMigrationNotSupported as h, errorContractConfigMissing$1 as i, errorFileNotFound as l, errorRuntime$1 as m, ERROR_CODE_DESTRUCTIVE_CHANGES as n, errorDatabaseConnectionRequired as o, errorRunnerFailed as p, errorConfigValidation$1 as r, errorDestructiveChanges as s, CliStructuredError$1 as t, errorHashMismatch as u, mapMigrationToolsError as v, mapRefResolutionError as y };
69
+ export { errorTargetMigrationNotSupported as _, errorContractValidationFailed as a, mapMigrationToolsError as b, errorDriverRequired as c, errorInvalidOutputFormat as d, errorMarkerMissing as f, errorRuntime$1 as g, errorRunnerFailed as h, errorContractConfigMissing$1 as i, errorFileNotFound as l, errorOutputFormatMutex as m, ERROR_CODE_DESTRUCTIVE_CHANGES as n, errorDatabaseConnectionRequired as o, errorMigrationPlanningFailed as p, errorConfigValidation$1 as r, errorDestructiveChanges as s, CliStructuredError$1 as t, errorHashMismatch as u, errorTargetMismatch as v, mapRefResolutionError as x, errorUnexpected$1 as y };
70
70
 
71
- //# sourceMappingURL=cli-errors-CF60g2cG.mjs.map
71
+ //# sourceMappingURL=cli-errors-Djtz98Vm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-errors-Djtz98Vm.mjs","names":[],"sources":["../src/utils/cli-errors.ts"],"sourcesContent":["/**\n * Re-export all domain error factories from @prisma-next/errors for convenience.\n * CLI-specific errors (e.g., Commander argument validation in the main CLI, or\n * clipanion parse errors in the migration-file CLI) can be added here if needed.\n */\nexport type { CliErrorConflict, CliErrorEnvelope } from '@prisma-next/errors/control';\n\nimport {\n CliStructuredError,\n errorConfigFileNotFound,\n errorConfigValidation,\n errorContractConfigMissing,\n errorContractMissingExtensionPacks,\n errorContractValidationFailed,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorFamilyReadMarkerSqlRequired,\n errorFileNotFound,\n errorInvalidOutputFormat,\n errorMigrationCliInvalidConfigArg,\n errorMigrationCliUnknownFlag,\n errorMigrationPlanningFailed,\n errorOutputFormatMutex,\n errorQueryRunnerFactoryRequired,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n} from '@prisma-next/errors/control';\nimport { errorRuntime } from '@prisma-next/errors/execution';\nimport type { MigrationToolsError } from '@prisma-next/migration-tools/errors';\nimport type { RefResolutionError } from '@prisma-next/migration-tools/ref-resolution';\n\nexport {\n ERROR_CODE_DESTRUCTIVE_CHANGES,\n errorDestructiveChanges,\n errorHashMismatch,\n errorMarkerMissing,\n errorMarkerRequired,\n errorRunnerFailed,\n errorRuntime,\n errorSchemaVerificationFailed,\n errorTargetMismatch,\n} from '@prisma-next/errors/execution';\nexport {\n errorMigrationFileMissing,\n errorMigrationInvalidDefaultExport,\n errorMigrationPlanNotArray,\n errorUnfilledPlaceholder,\n placeholder,\n} from '@prisma-next/errors/migration';\nexport {\n CliStructuredError,\n errorConfigFileNotFound,\n errorConfigValidation,\n errorContractConfigMissing,\n errorContractMissingExtensionPacks,\n errorContractValidationFailed,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorFamilyReadMarkerSqlRequired,\n errorFileNotFound,\n errorInvalidOutputFormat,\n errorMigrationCliInvalidConfigArg,\n errorMigrationCliUnknownFlag,\n errorMigrationPlanningFailed,\n errorOutputFormatMutex,\n errorQueryRunnerFactoryRequired,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n};\n\n/**\n * Maps a `MigrationToolsError` raised by the migration-tools loader/graph\n * surface (`readMigrationPackage`, `readMigrationsDir`, `readRefs`,\n * `resolveRef`, `reconstructGraph`, ...) into a CLI `errorRuntime` envelope.\n *\n * The full `error.details` payload is forwarded into `meta` so machine\n * consumers (`--json`) see structural fields like `dir`, `storedHash`,\n * `computedHash` (for `MIGRATION.HASH_MISMATCH`) alongside the stable\n * `code`. The user-visible `summary`/`why`/`fix` text is unchanged.\n *\n * Callers are expected to gate on `MigrationToolsError.is(error)` first\n * (mirroring the original inline pattern); non-`MigrationToolsError`\n * values are caller-classified (rethrow, wrap with command-specific\n * `errorUnexpected`, etc.).\n */\nexport function mapMigrationToolsError(error: MigrationToolsError): CliStructuredError {\n return errorRuntime(error.message, {\n why: error.why,\n fix: error.fix,\n meta: { code: error.code, ...(error.details ?? {}) },\n });\n}\n\n/**\n * Maps a `RefResolutionError` from the contract/migration reference\n * resolver into a CLI structured error envelope.\n */\nexport function mapRefResolutionError(error: RefResolutionError): CliStructuredError {\n switch (error.kind) {\n case 'not-found':\n return errorRuntime(`Not a known ${error.grammar} reference: \"${error.input}\"`, {\n why: `No ${error.grammar} matching \"${error.input}\" exists in the migration graph or refs index.`,\n fix:\n error.grammar === 'contract'\n ? 'Provide a valid contract hash, ref name, or migration directory name.'\n : 'Provide a valid migration directory name or migration hash.',\n meta: { input: error.input, grammar: error.grammar },\n });\n case 'ambiguous':\n return errorRuntime(`Ambiguous ${error.grammar} reference: \"${error.input}\"`, {\n why: `\"${error.input}\" matches multiple ${error.grammar}s: ${error.candidates.join(', ')}`,\n fix: 'Provide a longer prefix or use the full hash to disambiguate.',\n meta: { input: error.input, candidates: error.candidates, grammar: error.grammar },\n });\n case 'wrong-grammar':\n return errorRuntime(error.message, {\n why: error.message,\n fix: error.fix,\n meta: { input: error.input, expectedGrammar: error.expectedGrammar },\n });\n case 'invalid-format':\n return errorRuntime(`Invalid reference format: \"${error.input}\"`, {\n why: error.reason,\n fix: 'Provide a valid contract hash, ref name, or migration directory name.',\n meta: { input: error.input },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqFA,SAAgB,uBAAuB,OAAgD;CACrF,OAAO,aAAa,MAAM,SAAS;EACjC,KAAK,MAAM;EACX,KAAK,MAAM;EACX,MAAM;GAAE,MAAM,MAAM;GAAM,GAAI,MAAM,WAAW,EAAE;GAAG;EACrD,CAAC;;;;;;AAOJ,SAAgB,sBAAsB,OAA+C;CACnF,QAAQ,MAAM,MAAd;EACE,KAAK,aACH,OAAO,aAAa,eAAe,MAAM,QAAQ,eAAe,MAAM,MAAM,IAAI;GAC9E,KAAK,MAAM,MAAM,QAAQ,aAAa,MAAM,MAAM;GAClD,KACE,MAAM,YAAY,aACd,0EACA;GACN,MAAM;IAAE,OAAO,MAAM;IAAO,SAAS,MAAM;IAAS;GACrD,CAAC;EACJ,KAAK,aACH,OAAO,aAAa,aAAa,MAAM,QAAQ,eAAe,MAAM,MAAM,IAAI;GAC5E,KAAK,IAAI,MAAM,MAAM,qBAAqB,MAAM,QAAQ,KAAK,MAAM,WAAW,KAAK,KAAK;GACxF,KAAK;GACL,MAAM;IAAE,OAAO,MAAM;IAAO,YAAY,MAAM;IAAY,SAAS,MAAM;IAAS;GACnF,CAAC;EACJ,KAAK,iBACH,OAAO,aAAa,MAAM,SAAS;GACjC,KAAK,MAAM;GACX,KAAK,MAAM;GACX,MAAM;IAAE,OAAO,MAAM;IAAO,iBAAiB,MAAM;IAAiB;GACrE,CAAC;EACJ,KAAK,kBACH,OAAO,aAAa,8BAA8B,MAAM,MAAM,IAAI;GAChE,KAAK,MAAM;GACX,KAAK;GACL,MAAM,EAAE,OAAO,MAAM,OAAO;GAC7B,CAAC"}
package/dist/cli.mjs CHANGED
@@ -1,31 +1,30 @@
1
1
  #!/usr/bin/env node
2
- import { t as loadConfig } from "./config-loader-B6sJjXTv.mjs";
3
- import { t as isCI } from "./is-ci-YyvQBBke.mjs";
4
- import { _ as parseGlobalFlags, d as setCommandDescriptions, f as setCommandExamples, t as addGlobalOptions, v as formatCommandHelp, y as formatRootHelp } from "./command-helpers-Dvgul7UA.mjs";
5
- import { t as createContractEmitCommand } from "./contract-emit-BDBzHlaC.mjs";
6
- import { n as installShutdownHandlers } from "./terminal-ui-XtOQsqe9.mjs";
7
- import { t as createContractInferCommand } from "./contract-infer-Dm8pBZMR.mjs";
2
+ import { a as isCI, n as installShutdownHandlers } from "./terminal-ui-BiB_8KNo.mjs";
3
+ import { _ as parseGlobalFlags, b as formatCommandHelp, d as setCommandDescriptions, f as setCommandExamples, t as addGlobalOptions, v as parseGlobalFlagsOrExit, x as formatRootHelp } from "./command-helpers-BSb0tRC8.mjs";
4
+ import { t as createContractEmitCommand } from "./contract-emit-r4y8Zhf1.mjs";
5
+ import { t as createContractInferCommand } from "./contract-infer-BmySmqVT.mjs";
8
6
  import { createDbInitCommand } from "./commands/db-init.mjs";
9
7
  import { createDbSchemaCommand } from "./commands/db-schema.mjs";
10
8
  import { createDbSignCommand } from "./commands/db-sign.mjs";
11
9
  import { createDbUpdateCommand } from "./commands/db-update.mjs";
12
- import { t as createDbVerifyCommand } from "./db-verify-CW8DR5Ei.mjs";
10
+ import { t as createDbVerifyCommand } from "./db-verify-BClPs3ph.mjs";
13
11
  import { createMigrateCommand } from "./commands/migrate.mjs";
14
12
  import { createMigrationCheckCommand } from "./commands/migration-check.mjs";
15
13
  import { createMigrationGraphCommand } from "./commands/migration-graph.mjs";
16
14
  import { createMigrationListCommand } from "./commands/migration-list.mjs";
17
15
  import { createMigrationLogCommand } from "./commands/migration-log.mjs";
18
16
  import { createMigrationNewCommand } from "./commands/migration-new.mjs";
19
- import { t as createMigrationPlanCommand } from "./migration-plan-BSzcWsvm.mjs";
17
+ import { t as createMigrationPlanCommand } from "./migration-plan-CFwqw3Gk.mjs";
20
18
  import { createMigrationShowCommand } from "./commands/migration-show.mjs";
21
19
  import { createMigrationStatusCommand } from "./commands/migration-status.mjs";
22
20
  import { createRefCommand } from "./commands/ref.mjs";
23
21
  import { Command } from "commander";
22
+ import { ifDefined } from "@prisma-next/utils/defined";
24
23
  import { fileURLToPath } from "node:url";
25
24
  import { readUserConfig, resolveGating, runTelemetry } from "@prisma-next/cli-telemetry";
26
25
  import { distance } from "closest-match";
27
26
  //#region package.json
28
- var version = "0.10.0-dev.9";
27
+ var version = "0.11.0";
29
28
  //#endregion
30
29
  //#region src/utils/telemetry.ts
31
30
  /**
@@ -89,29 +88,6 @@ function resolveTelemetryGate() {
89
88
  };
90
89
  }
91
90
  /**
92
- * Best-effort extraction of `databaseTarget` and `extensions` from the
93
- * project config. Loads via the same `c12`-backed loader the action
94
- * handlers use so we honour the same lookup rules. Every failure mode
95
- * (no config file, malformed config, async load reject) collapses to
96
- * `(null, [])` because telemetry is non-blocking and may fire for
97
- * commands that legitimately don't have a config (e.g. `init`).
98
- */
99
- async function loadConfigForTelemetry() {
100
- try {
101
- const config = await loadConfig();
102
- const target = config.target;
103
- return {
104
- databaseTarget: target !== void 0 && typeof target.targetId === "string" ? target.targetId : null,
105
- extensions: (config.extensionPacks ?? []).map((pack) => pack.id).filter((id) => typeof id === "string")
106
- };
107
- } catch {
108
- return {
109
- databaseTarget: null,
110
- extensions: []
111
- };
112
- }
113
- }
114
- /**
115
91
  * Path to the compiled sender script inside `@prisma-next/cli-telemetry`'s
116
92
  * `dist/`. Resolved off this module's `import.meta.url` via the package
117
93
  * specifier `@prisma-next/cli-telemetry/sender`, so the consumer pays
@@ -120,30 +96,34 @@ async function loadConfigForTelemetry() {
120
96
  function senderPath() {
121
97
  return fileURLToPath(new URL(import.meta.resolve("@prisma-next/cli-telemetry/sender")));
122
98
  }
123
- function fireTelemetryWithFields(actionCommand, fields, userConfig) {
99
+ function fireTelemetry(actionCommand, userConfig, overrides = {}) {
124
100
  return runTelemetry({
125
101
  command: commanderSnapshotForTelemetry(actionCommand),
126
102
  version,
127
- databaseTarget: fields.databaseTarget,
128
- extensions: fields.extensions,
129
103
  projectRoot: process.cwd(),
130
104
  senderPath: senderPath(),
131
105
  isCI: isCI(),
132
106
  env: process.env,
133
- userConfig
107
+ userConfig,
108
+ ...ifDefined("databaseTarget", overrides.databaseTarget)
134
109
  });
135
110
  }
136
111
  /**
137
- * preAction-stage entry point: resolve env/CI/user-consent gates first,
138
- * then (only when enabled) load project config for database target and
139
- * extension metadata, then fork the detached sender. The early gate is
140
- * privacy- and UX-critical: config loading can execute user code and
141
- * must never happen before opt-out/default-off checks have resolved.
112
+ * preAction-stage entry point. Synchronous by construction: resolve
113
+ * env/CI/user-consent gates (cheap, all in-memory and a single tiny
114
+ * user-config read), then only when enabled `fork()` the detached
115
+ * sender script. The forked child loads `prisma-next.config.*` via
116
+ * c12 on its own (see `loadProjectConfig` in cli-telemetry); the
117
+ * parent does no project-config I/O on the command's hot path.
118
+ *
119
+ * Privacy invariant: gate resolution always happens before any project
120
+ * config touches disk. The child loading user TS code is acceptable
121
+ * only because it's gated behind the same resolved-enabled signal.
142
122
  */
143
- async function fireTelemetryFromPreAction(actionCommand) {
123
+ function fireTelemetryFromPreAction(actionCommand) {
144
124
  const gate = resolveTelemetryGate();
145
125
  if (!gate.enabled) return gate.outcome;
146
- return fireTelemetryWithFields(actionCommand, await loadConfigForTelemetry(), gate.userConfig);
126
+ return fireTelemetry(actionCommand, gate.userConfig);
147
127
  }
148
128
  /**
149
129
  * Manual one-shot telemetry path for the first `init` run where the user
@@ -152,13 +132,17 @@ async function fireTelemetryFromPreAction(actionCommand) {
152
132
  * default-off. After consent is persisted, `runInit` calls this helper
153
133
  * exactly for that first affirmative answer; subsequent init runs skip
154
134
  * it because the prompt is not shown again.
135
+ *
136
+ * The child's c12 load would return `databaseTarget: null` for this
137
+ * specific invocation because `prisma-next.config.*` is not yet on
138
+ * disk (init writes it later in the same run). To preserve the
139
+ * prompt-chosen target in the first-init telemetry event, this
140
+ * helper forwards the value as a parent-side IPC override on
141
+ * `ParentToSenderPayload.databaseTarget` — the child consults the
142
+ * override first and falls back to its c12 result when absent.
155
143
  */
156
144
  function fireTelemetryAfterInitConsent(actionCommand, inputs) {
157
- const userConfig = readUserConfig();
158
- return fireTelemetryWithFields(actionCommand, {
159
- databaseTarget: inputs.databaseTarget,
160
- extensions: []
161
- }, userConfig);
145
+ return fireTelemetry(actionCommand, readUserConfig(), { databaseTarget: inputs.databaseTarget });
162
146
  }
163
147
  //#endregion
164
148
  //#region src/commands/init/index.ts
@@ -181,8 +165,8 @@ Exit codes (see CLI Style Guide § Exit Codes):
181
165
  "prisma-next init --no-skill # skip the skills install (air-gapped / restricted env)"
182
166
  ]);
183
167
  return addGlobalOptions(command).option("--target <db>", "Database target: postgres or mongodb").option("--authoring <style>", "Schema authoring style: psl or typescript").option("--schema-path <path>", "Where to write the starter schema (default: prisma/contract.prisma)").option("--force", "Overwrite an existing scaffold without prompting").option("--write-env", "Write a .env file from .env.example (gitignored; default: only .env.example)").option("--probe-db", "Connect to DATABASE_URL once and check the server version against the target minimum (opt-in; off by default)").option("--strict-probe", "Treat a failed --probe-db as fatal (no-op without --probe-db; init is offline-by-default)").option("--no-install", "Skip dependency installation and contract emission").option("--no-skill", "Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)").action(async (options, actionCommand) => {
184
- const { runInit } = await import("./init-CxS9eqbQ.mjs");
185
- const flags = parseGlobalFlags(options);
168
+ const { runInit } = await import("./init-BCJZPWE1.mjs");
169
+ const flags = parseGlobalFlagsOrExit(options);
186
170
  const canPrompt = deriveCanPrompt({
187
171
  flagsInteractive: flags.interactive,
188
172
  optionInteractive: options.interactive,
@@ -279,7 +263,9 @@ function formatSuggestion(input, candidates) {
279
263
  const program = new Command();
280
264
  program.name("prisma-next").description("Prisma Next CLI").version(version);
281
265
  program.hook("preAction", (_thisCommand, actionCommand) => {
282
- fireTelemetryFromPreAction(actionCommand).catch(() => {});
266
+ try {
267
+ fireTelemetryFromPreAction(actionCommand);
268
+ } catch {}
283
269
  });
284
270
  const versionOption = program.options.find((opt) => opt.flags.includes("--version"));
285
271
  if (versionOption) versionOption.description = "Output the version number";
@@ -416,6 +402,15 @@ program.addCommand(contractCommand);
416
402
  program.addCommand(dbCommand);
417
403
  program.addCommand(migrationCommand);
418
404
  program.addCommand(refCommand);
405
+ const TELEMETRY_CRASH_TEST_SLEEP_MS = 200;
406
+ if (process.env["PRISMA_NEXT_ENABLE_TEST_COMMANDS"] === "1") {
407
+ const telemetryCrashTestCommand = new Command("__telemetry-crash-test").description("Internal: deliberately throw for the telemetry e2e suite.").action(async () => {
408
+ await new Promise((settle) => setTimeout(settle, TELEMETRY_CRASH_TEST_SLEEP_MS));
409
+ throw new Error("__telemetry-crash-test: intentional crash for e2e coverage");
410
+ });
411
+ telemetryCrashTestCommand.configureHelp({ visibleCommands: () => [] });
412
+ program.addCommand(telemetryCrashTestCommand, { hidden: true });
413
+ }
419
414
  const helpCommand = new Command("help").description("Show usage instructions").configureHelp({ formatHelp: (cmd) => {
420
415
  return formatCommandHelp({
421
416
  command: cmd,
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":["CLI_VERSION","packageJson.version"],"sources":["../package.json","../src/utils/telemetry.ts","../src/commands/init/index.ts","../src/utils/suggest-command.ts","../src/cli.ts"],"sourcesContent":["","import { fileURLToPath } from 'node:url';\nimport {\n type CommanderOptionShape,\n type CommanderResultShape,\n readUserConfig,\n resolveGating,\n runTelemetry,\n type TelemetryRunOutcome,\n type UserConfig,\n} from '@prisma-next/cli-telemetry';\nimport type { Command } from 'commander';\nimport { version as CLI_VERSION } from '../../package.json' with { type: 'json' };\nimport { loadConfig } from '../config-loader';\nimport { isCI } from './is-ci';\n\ninterface TelemetryFields {\n readonly databaseTarget: string | null;\n readonly extensions: readonly string[];\n}\n\ntype TelemetryGate =\n | { readonly enabled: true; readonly userConfig: UserConfig }\n | { readonly enabled: false; readonly outcome: TelemetryRunOutcome };\n\n/**\n * Resolve the commander command path from a leaf `Command`, walking up\n * the parent chain. Result is rooted at the program name and ends at\n * the leaf — `['prisma-next', 'migration', 'new']` for\n * `prisma-next migration new …`.\n */\nfunction commandPathFor(actionCommand: Command): string[] {\n const path: string[] = [];\n let cursor: Command | null = actionCommand;\n while (cursor !== null) {\n path.unshift(cursor.name());\n cursor = cursor.parent;\n }\n return path;\n}\n\nfunction commanderOptionSnapshots(actionCommand: Command): CommanderOptionShape[] {\n return actionCommand.options.map((option) => {\n const attributeName = option.attributeName();\n return {\n attributeName,\n longName: option.long ?? null,\n source: actionCommand.getOptionValueSource(attributeName) ?? null,\n };\n });\n}\n\n/**\n * Project commander's leaf `Command` into the wire-shape snapshot the\n * telemetry sanitiser consumes. Pure projection — no env, no I/O.\n */\nexport function commanderSnapshotForTelemetry(actionCommand: Command): CommanderResultShape {\n return {\n commandPath: commandPathFor(actionCommand),\n positionalArgs: actionCommand.args,\n options: commanderOptionSnapshots(actionCommand),\n };\n}\n\nfunction resolveTelemetryGate(): TelemetryGate {\n if (isCI()) {\n return { enabled: false, outcome: { spawned: false, reason: 'ci' } };\n }\n const userConfig = readUserConfig();\n const gating = resolveGating({ env: process.env, config: userConfig });\n if (!gating.enabled) {\n return { enabled: false, outcome: { spawned: false, reason: 'gated-off' } };\n }\n return { enabled: true, userConfig };\n}\n\n/**\n * Best-effort extraction of `databaseTarget` and `extensions` from the\n * project config. Loads via the same `c12`-backed loader the action\n * handlers use so we honour the same lookup rules. Every failure mode\n * (no config file, malformed config, async load reject) collapses to\n * `(null, [])` because telemetry is non-blocking and may fire for\n * commands that legitimately don't have a config (e.g. `init`).\n */\nasync function loadConfigForTelemetry(): Promise<TelemetryFields> {\n try {\n const config = await loadConfig();\n const target = config.target as { readonly targetId?: unknown } | undefined;\n const databaseTarget =\n target !== undefined && typeof target.targetId === 'string' ? target.targetId : null;\n const extensionPacks = (config.extensionPacks ?? []) as ReadonlyArray<{\n readonly id?: unknown;\n }>;\n const extensions = extensionPacks\n .map((pack) => pack.id)\n .filter((id): id is string => typeof id === 'string');\n return { databaseTarget, extensions };\n } catch {\n return { databaseTarget: null, extensions: [] };\n }\n}\n\n/**\n * Path to the compiled sender script inside `@prisma-next/cli-telemetry`'s\n * `dist/`. Resolved off this module's `import.meta.url` via the package\n * specifier `@prisma-next/cli-telemetry/sender`, so the consumer pays\n * no attention to internal package layout.\n */\nfunction senderPath(): string {\n return fileURLToPath(new URL(import.meta.resolve('@prisma-next/cli-telemetry/sender')));\n}\n\nfunction fireTelemetryWithFields(\n actionCommand: Command,\n fields: TelemetryFields,\n userConfig: UserConfig,\n): TelemetryRunOutcome {\n return runTelemetry({\n command: commanderSnapshotForTelemetry(actionCommand),\n version: CLI_VERSION,\n databaseTarget: fields.databaseTarget,\n extensions: fields.extensions,\n projectRoot: process.cwd(),\n senderPath: senderPath(),\n isCI: isCI(),\n env: process.env,\n userConfig,\n });\n}\n\n/**\n * preAction-stage entry point: resolve env/CI/user-consent gates first,\n * then (only when enabled) load project config for database target and\n * extension metadata, then fork the detached sender. The early gate is\n * privacy- and UX-critical: config loading can execute user code and\n * must never happen before opt-out/default-off checks have resolved.\n */\nexport async function fireTelemetryFromPreAction(\n actionCommand: Command,\n): Promise<TelemetryRunOutcome> {\n const gate = resolveTelemetryGate();\n if (!gate.enabled) {\n return gate.outcome;\n }\n const fields = await loadConfigForTelemetry();\n return fireTelemetryWithFields(actionCommand, fields, gate.userConfig);\n}\n\n/**\n * Manual one-shot telemetry path for the first `init` run where the user\n * explicitly answers Yes to the consent prompt. The preAction hook for\n * that same run has already resolved before consent existed, so it is\n * default-off. After consent is persisted, `runInit` calls this helper\n * exactly for that first affirmative answer; subsequent init runs skip\n * it because the prompt is not shown again.\n */\nexport function fireTelemetryAfterInitConsent(\n actionCommand: Command,\n inputs: { readonly databaseTarget: string },\n): TelemetryRunOutcome {\n const userConfig = readUserConfig();\n return fireTelemetryWithFields(\n actionCommand,\n { databaseTarget: inputs.databaseTarget, extensions: [] },\n userConfig,\n );\n}\n","import { Command } from 'commander';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../../utils/command-helpers';\nimport { type CommonCommandOptions, parseGlobalFlags } from '../../utils/global-flags';\nimport { fireTelemetryAfterInitConsent } from '../../utils/telemetry';\nimport {\n INIT_EXIT_EMIT_FAILED,\n INIT_EXIT_INSTALL_FAILED,\n INIT_EXIT_INTERNAL_ERROR,\n INIT_EXIT_OK,\n INIT_EXIT_PRECONDITION,\n INIT_EXIT_SKILL_INSTALL_FAILED,\n INIT_EXIT_USER_ABORTED,\n} from './exit-codes';\n\n/**\n * Commander.js parsed options for `init`. The init-specific options live\n * alongside the inherited `CommonCommandOptions` global flags.\n *\n * `target` and `authoring` are typed as plain `string` here because\n * Commander.js does not enforce enums at parse time — the validation /\n * normalisation happens in `inputs.ts::resolveInitInputs`, which can\n * raise a structured `errorInitInvalidFlagValue` with the full set of\n * allowed values.\n */\ninterface InitCommandOptions extends CommonCommandOptions {\n readonly target?: string;\n readonly authoring?: string;\n readonly schemaPath?: string;\n readonly force?: boolean;\n readonly writeEnv?: boolean;\n readonly probeDb?: boolean;\n readonly strictProbe?: boolean;\n readonly install?: boolean;\n readonly skill?: boolean;\n}\n\nexport function createInitCommand(): Command {\n const command = new Command('init');\n setCommandDescriptions(\n command,\n 'Initialize a new Prisma Next project',\n 'Scaffolds config, schema, and runtime files, installs dependencies,\\n' +\n 'and emits the contract. Gets you from zero to typed queries in one step.\\n' +\n '\\n' +\n 'Run interactively for a guided experience, or supply --target / --authoring\\n' +\n 'and --yes for a fully scriptable run (CI, AI coding agents, automation).\\n' +\n '\\n' +\n 'Exit codes (see CLI Style Guide § Exit Codes):\\n' +\n ` ${INIT_EXIT_OK} OK Init succeeded.\\n` +\n ` ${INIT_EXIT_INTERNAL_ERROR} INTERNAL_ERROR Unexpected bug in prisma-next (please report).\\n` +\n ` ${INIT_EXIT_PRECONDITION} PRECONDITION Bad flags / missing prerequisite (e.g. no package.json).\\n` +\n ` ${INIT_EXIT_USER_ABORTED} USER_ABORTED User cancelled an interactive prompt.\\n` +\n ` ${INIT_EXIT_INSTALL_FAILED} INSTALL_FAILED Dependency installation failed (init-specific).\\n` +\n ` ${INIT_EXIT_EMIT_FAILED} EMIT_FAILED \\`contract emit\\` failed after install (init-specific).\\n` +\n ` ${INIT_EXIT_SKILL_INSTALL_FAILED} SKILL_INSTALL_FAILED Agent-skill install failed (re-run with --no-skill to skip).`,\n );\n setCommandExamples(command, [\n 'prisma-next init',\n 'prisma-next init --yes --target postgres --authoring psl',\n 'prisma-next init --yes --target mongodb --authoring typescript --json',\n 'prisma-next init --yes --force --target postgres --authoring psl # overwrite an existing scaffold',\n 'prisma-next init --no-install # skip pnpm/npm install + emit',\n 'prisma-next init --no-skill # skip the skills install (air-gapped / restricted env)',\n ]);\n\n return addGlobalOptions(command)\n .option('--target <db>', 'Database target: postgres or mongodb')\n .option('--authoring <style>', 'Schema authoring style: psl or typescript')\n .option(\n '--schema-path <path>',\n 'Where to write the starter schema (default: prisma/contract.prisma)',\n )\n .option('--force', 'Overwrite an existing scaffold without prompting')\n .option(\n '--write-env',\n 'Write a .env file from .env.example (gitignored; default: only .env.example)',\n )\n .option(\n '--probe-db',\n 'Connect to DATABASE_URL once and check the server version against the target minimum (opt-in; off by default)',\n )\n .option(\n '--strict-probe',\n 'Treat a failed --probe-db as fatal (no-op without --probe-db; init is offline-by-default)',\n )\n .option('--no-install', 'Skip dependency installation and contract emission')\n .option(\n '--no-skill',\n 'Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)',\n )\n .action(async (options: InitCommandOptions, actionCommand: Command) => {\n const { runInit } = await import('./init');\n const flags = parseGlobalFlags(options);\n const canPrompt = deriveCanPrompt({\n flagsInteractive: flags.interactive,\n optionInteractive: options.interactive,\n stdinIsTTY: Boolean(process.stdin.isTTY),\n });\n const exitCode = await runInit(process.cwd(), {\n options,\n flags,\n canPrompt,\n afterFirstTelemetryConsent: (inputs) => {\n fireTelemetryAfterInitConsent(actionCommand, { databaseTarget: inputs.target });\n },\n });\n process.exit(exitCode);\n });\n}\n\n/**\n * Bridges the action handler's two TTY checks (stdout via `flags`, stdin\n * via `process.stdin.isTTY`) into the `canPrompt` boolean `runInit`\n * consumes.\n *\n * Per the [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity):\n *\n * - `flags.interactive` governs *decoration* (TerminalUI, intro/outro,\n * spinners) and is derived from stdout-TTY by `parseGlobalFlags`,\n * honouring `--interactive` / `--no-interactive`.\n * - Prompting additionally requires a stdin TTY — closing stdin is a\n * common signal in CI / agent environments even when stdout stays\n * attached.\n * - `--interactive` is the explicit override: when the user passes it,\n * we honour it (e.g. testing flows where stdin is stubbed).\n *\n * Exported so callers and tests can derive the same value without\n * touching `process` globals.\n */\nexport function deriveCanPrompt(opts: {\n readonly flagsInteractive: boolean | undefined;\n readonly optionInteractive: boolean | undefined;\n readonly stdinIsTTY: boolean;\n}): boolean {\n if (opts.optionInteractive === true) return true;\n if (opts.flagsInteractive === false) return false;\n return opts.stdinIsTTY;\n}\n","import { distance } from 'closest-match';\n\n/**\n * Suggests similar command names for a mistyped input.\n *\n * Uses Levenshtein distance to find close matches. Only suggests commands\n * within a reasonable distance threshold (40% of the input length, minimum 2).\n * Returns up to 3 suggestions in case of ties.\n *\n * @returns Array of suggested command names (empty if nothing is close enough).\n */\nexport function suggestCommands(input: string, candidates: readonly string[]): string[] {\n if (candidates.length === 0) return [];\n\n // Threshold: at most 40% of the input length (min 2) to avoid absurd suggestions\n const maxDistance = Math.max(2, Math.ceil(input.length * 0.4));\n\n const scored = candidates\n .map((name) => ({ name, dist: distance(input, name) }))\n .filter((entry) => entry.dist <= maxDistance)\n .sort((a, b) => a.dist - b.dist);\n\n if (scored.length === 0) return [];\n\n // Take the best distance, then include ties (up to 3)\n const bestDist = scored[0]!.dist;\n return scored\n .filter((entry) => entry.dist === bestDist)\n .slice(0, 3)\n .map((entry) => entry.name);\n}\n","import { Command } from 'commander';\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createContractEmitCommand } from './commands/contract-emit';\nimport { createContractInferCommand } from './commands/contract-infer';\nimport { createInitCommand } from './commands/init';\nimport { installShutdownHandlers } from './utils/shutdown';\n\n// Install SIGINT/SIGTERM handlers before anything else\ninstallShutdownHandlers();\n\nimport { createDbInitCommand } from './commands/db-init';\nimport { createDbSchemaCommand } from './commands/db-schema';\nimport { createDbSignCommand } from './commands/db-sign';\nimport { createDbUpdateCommand } from './commands/db-update';\nimport { createDbVerifyCommand } from './commands/db-verify';\nimport { createMigrateCommand } from './commands/migrate';\nimport { createMigrationCheckCommand } from './commands/migration-check';\nimport { createMigrationGraphCommand } from './commands/migration-graph';\nimport { createMigrationListCommand } from './commands/migration-list';\nimport { createMigrationLogCommand } from './commands/migration-log';\nimport { createMigrationNewCommand } from './commands/migration-new';\nimport { createMigrationPlanCommand } from './commands/migration-plan';\nimport { createMigrationShowCommand } from './commands/migration-show';\nimport { createMigrationStatusCommand } from './commands/migration-status';\nimport { createRefCommand } from './commands/ref';\nimport { setCommandDescriptions } from './utils/command-helpers';\nimport { formatCommandHelp, formatRootHelp } from './utils/formatters/help';\nimport { parseGlobalFlags } from './utils/global-flags';\nimport { suggestCommands } from './utils/suggest-command';\nimport { fireTelemetryFromPreAction } from './utils/telemetry';\n\n/**\n * Lookup table mapping removed subcommands to their replacement verbs.\n * Keyed by `<parent>:<subcommand>` (e.g. `migration:apply`).\n * The handler consults this before falling back to the fuzzy suggest engine.\n */\nconst removedVerbRedirects: Record<string, string> = {\n 'migration:apply': 'Use `prisma-next migrate --to <contract>` instead.',\n 'migration:ref': 'Use `prisma-next ref set|list|delete` instead.',\n};\n\n/**\n * Removed flags on specific subcommands. Keyed by `<parent>:<sub>:<flag>`.\n * Checked during the pre-parse argv scan before commander sees the flags.\n */\nconst removedFlagRedirects: Record<string, string> = {\n 'migration:status:graph': 'Use `prisma-next migration graph` to view the migration graph.',\n 'migration:status:all':\n 'Use `prisma-next migration log --db <url>` to view the full execution history.',\n 'migration:status:limit':\n 'Use `prisma-next migration log --db <url>` to view the full execution history.',\n 'migration:status:ref': 'Use `--to <contract>` instead of `--ref`.',\n};\n\n/**\n * Formats the \"Did you mean ...?\" hint for an unknown command.\n */\nfunction formatSuggestion(input: string, candidates: readonly string[]): string {\n const suggestions = suggestCommands(\n input,\n candidates.map((c) => c),\n );\n if (suggestions.length === 0) return '';\n if (suggestions.length === 1) return `\\nDid you mean ${suggestions[0]}?\\n`;\n return `\\nDid you mean one of these?\\n${suggestions.map((s) => ` ${s}`).join('\\n')}\\n`;\n}\n\nconst program = new Command();\n\nprogram.name('prisma-next').description('Prisma Next CLI').version(packageJson.version);\n\n// Telemetry hook — fires at command start, before the action body\n// runs. Every failure mode is swallowed inside `runTelemetry`; the\n// hook never throws and never blocks long enough to be perceptible.\n//\n// Fire-and-forget: `fireTelemetryFromPreAction` `await`s a c12 config\n// load before forking the sender, so awaiting it here would block the\n// command's action body behind telemetry. Use `void` to dispatch in\n// parallel; the existing `.catch(() => {})` keeps errors swallowed.\nprogram.hook('preAction', (_thisCommand, actionCommand) => {\n void fireTelemetryFromPreAction(actionCommand).catch(() => {\n // defence-in-depth — runTelemetry already swallows internally.\n });\n});\n\n// Override version option description to match capitalization style\nconst versionOption = program.options.find((opt) => opt.flags.includes('--version'));\nif (versionOption) {\n versionOption.description = 'Output the version number';\n}\n\nprogram.configureOutput({\n writeErr: () => {\n // Suppress all default error output - we handle errors in exitOverride\n },\n writeOut: (str) => {\n // Commander routes explicitly-requested `--help` (success-path help)\n // through writeOut; per the Style Guide § Output Conventions rule 8,\n // user-requested help is data and goes to stdout. Error-path help\n // (e.g. usage shown after an unknown command) goes through writeErr,\n // which stays suppressed because we render that ourselves with the\n // matching error envelope.\n //\n // Explicit `--version` is short-circuited before `program.parse()`\n // (see the argv pre-scan at the bottom of this file), so it does not\n // reach this writer.\n process.stdout.write(str);\n },\n});\n\n// Customize root help output to use our styled format\nconst rootHelpFormatter = (cmd: Command) => {\n const flags = parseGlobalFlags({});\n return formatRootHelp({ program: cmd, flags });\n};\n\nprogram.configureHelp({\n formatHelp: rootHelpFormatter,\n subcommandDescription: () => '',\n});\n\n// Override exit to handle unhandled errors (fail fast cases)\n// Commands handle structured errors themselves via process.exit()\nprogram.exitOverride((err) => {\n if (err) {\n const errorCode = (err as { code?: string }).code;\n const errorMessage = String(err.message ?? '');\n const errorName = err.name ?? '';\n\n // Unknown command/argument → exit 2 (CLI usage error)\n const isUnknownCommandError =\n errorCode === 'commander.unknownCommand' ||\n errorCode === 'commander.unknownArgument' ||\n (errorName === 'CommanderError' &&\n (errorMessage.includes('unknown command') || errorMessage.includes('unknown argument')));\n if (isUnknownCommandError) {\n const flags = parseGlobalFlags({});\n const match = errorMessage.match(/unknown command ['\"]([^'\"]+)['\"]/);\n const commandName = match ? match[1] : process.argv[3] || process.argv[2] || 'unknown';\n\n const firstArg = process.argv[2];\n const parentCommand = firstArg\n ? program.commands.find((cmd) => cmd.name() === firstArg)\n : undefined;\n\n if (parentCommand && commandName !== firstArg) {\n const subNames = parentCommand.commands.map((c) => c.name());\n process.stderr.write(\n `Unknown command: ${commandName}${formatSuggestion(commandName!, subNames)}\\n`,\n );\n const helpText = formatCommandHelp({ command: parentCommand, flags });\n process.stderr.write(`${helpText}\\n`);\n } else {\n const topNames = program.commands.map((c) => c.name());\n process.stderr.write(\n `Unknown command: ${commandName}${formatSuggestion(commandName!, topNames)}\\n`,\n );\n const helpText = formatRootHelp({ program, flags });\n process.stderr.write(`${helpText}\\n`);\n }\n process.exit(2);\n return;\n }\n\n // Help requests → exit 0\n const isHelpError =\n errorCode === 'commander.help' ||\n errorCode === 'commander.helpDisplayed' ||\n errorCode === 'outputHelp' ||\n errorMessage === '(outputHelp)' ||\n errorMessage.includes('outputHelp') ||\n (errorName === 'CommanderError' && errorMessage.includes('outputHelp'));\n if (isHelpError) {\n process.exit(0);\n return;\n }\n\n // Missing required arguments → exit 2 (CLI usage error)\n const isMissingArgumentError =\n errorCode === 'commander.missingArgument' ||\n errorCode === 'commander.missingMandatoryOptionValue' ||\n (errorName === 'CommanderError' &&\n (errorMessage.includes('missing') || errorMessage.includes('required')));\n if (isMissingArgumentError) {\n process.exit(2);\n return;\n }\n\n // Unhandled error → exit 1\n process.stderr.write(`Unhandled error: ${err.message}\\n`);\n if (err.stack) {\n process.stderr.write(`${err.stack}\\n`);\n }\n process.exit(1);\n }\n process.exit(0);\n});\n\n// Register contract subcommand\nconst contractCommand = new Command('contract');\nsetCommandDescriptions(\n contractCommand,\n 'Contract management commands',\n 'Define and emit your application data contract. The contract describes your schema as a\\n' +\n 'declarative data structure that can be signed and verified against your database.',\n);\ncontractCommand.configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n subcommandDescription: () => '',\n});\n\n// Add emit subcommand to contract\nconst contractEmitCommand = createContractEmitCommand();\ncontractCommand.addCommand(contractEmitCommand);\n\n// Add infer subcommand to contract\nconst contractInferCommand = createContractInferCommand();\ncontractCommand.addCommand(contractInferCommand);\n\n// Register db subcommand\nconst dbCommand = new Command('db');\nsetCommandDescriptions(\n dbCommand,\n 'Database management commands',\n 'Verify and sign your database with your contract. Ensure your database schema matches\\n' +\n 'your contract, and sign it to record the contract hash for future verification.',\n);\ndbCommand.configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n subcommandDescription: () => '',\n});\n\n// Add verify subcommand to db\nconst dbVerifyCommand = createDbVerifyCommand();\ndbCommand.addCommand(dbVerifyCommand);\n\n// Add init subcommand to db\nconst dbInitCommand = createDbInitCommand();\ndbCommand.addCommand(dbInitCommand);\n\n// Add update subcommand to db\nconst dbUpdateCommand = createDbUpdateCommand();\ndbCommand.addCommand(dbUpdateCommand);\n\n// Add schema subcommand to db\nconst dbSchemaCommand = createDbSchemaCommand();\ndbCommand.addCommand(dbSchemaCommand);\n\n// Add sign subcommand to db\nconst dbSignCommand = createDbSignCommand();\ndbCommand.addCommand(dbSignCommand);\n\n// Register migration subcommand\nconst migrationCommand = new Command('migration');\nsetCommandDescriptions(\n migrationCommand,\n 'On-disk migration management commands',\n 'Plan, apply, and scaffold on-disk migration packages. Migrations are\\n' +\n 'contract-to-contract edges stored as versioned directories under migrations/.',\n);\nmigrationCommand.configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n subcommandDescription: () => '',\n});\n\nconst migrationPlanCommand = createMigrationPlanCommand();\nmigrationCommand.addCommand(migrationPlanCommand);\n\nconst migrationNewCommand = createMigrationNewCommand();\nmigrationCommand.addCommand(migrationNewCommand);\n\nconst migrationShowCommand = createMigrationShowCommand();\nmigrationCommand.addCommand(migrationShowCommand);\n\nconst migrationStatusCommand = createMigrationStatusCommand();\nmigrationCommand.addCommand(migrationStatusCommand);\n\nconst migrationLogCommand = createMigrationLogCommand();\nmigrationCommand.addCommand(migrationLogCommand);\n\nconst migrationListCommand = createMigrationListCommand();\nmigrationCommand.addCommand(migrationListCommand);\n\nconst migrationGraphCommand = createMigrationGraphCommand();\nmigrationCommand.addCommand(migrationGraphCommand);\n\nconst migrationCheckCommand = createMigrationCheckCommand();\nmigrationCommand.addCommand(migrationCheckCommand);\n\n// Top-level migrate command\nconst migrateCommand = createMigrateCommand();\n\n// Top-level ref command (replaces `migration ref`)\nconst refCommand = createRefCommand();\n\n// Top-level init command\nconst initCommand = createInitCommand();\n\n// Register top-level commands in the order the spec's intended-surface\n// diagram lists them: verbs (init, migrate) first, then subject\n// namespaces (contract, db, migration, ref). The order shows up in\n// `prisma-next --help` and is the first thing a new user sees, so it\n// matches the order spec.md uses to introduce the surface.\nprogram.addCommand(initCommand);\nprogram.addCommand(migrateCommand);\nprogram.addCommand(contractCommand);\nprogram.addCommand(dbCommand);\nprogram.addCommand(migrationCommand);\nprogram.addCommand(refCommand);\n\n// Create help command\nconst helpCommand = new Command('help')\n .description('Show usage instructions')\n .configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n })\n .action(() => {\n const flags = parseGlobalFlags({});\n const helpText = formatRootHelp({ program, flags });\n // The `help` command was invoked explicitly: help is the data the\n // caller asked for. Per Style Guide § Output Conventions rule 8,\n // explicit help goes to stdout with exit code 0.\n process.stdout.write(`${helpText}\\n`);\n process.exit(0);\n });\n\nprogram.addCommand(helpCommand);\n\n// Set help as the default action when no command is provided. The user\n// did not invoke `--help`; we are voluntarily showing usage to help them\n// recover from an underspecified invocation, so the help text is\n// decoration around an implicit \"what did you want me to do?\" and goes\n// to stderr (Style Guide § Output Conventions rule 8).\n//\n// FOLLOW-UP: the exit code here is 0 today, but a no-arg invocation is\n// arguably a usage error (PRECONDITION → exit 2) for consistency with\n// the unknown-command path. Out of scope for the explicit-help routing\n// work; revisit when tightening exit-code semantics across the CLI.\nprogram.action(() => {\n const flags = parseGlobalFlags({});\n const helpText = formatRootHelp({ program, flags });\n process.stderr.write(`${helpText}\\n`);\n process.exit(0);\n});\n\n// Check if a command was invoked with no arguments (just the command name)\n// or if an unrecognized command was provided\nconst args = process.argv.slice(2);\nif (args.length > 0) {\n const commandName = args[0];\n // Handle version option explicitly since we suppress default output\n if (commandName === '--version' || commandName === '-V') {\n // Version is data → stdout\n process.stdout.write(`${program.version()}\\n`);\n process.exit(0);\n }\n // Skip command check for global options like --help, -h\n const isGlobalOption = commandName === '--help' || commandName === '-h';\n if (!isGlobalOption) {\n // Check if this is a recognized command\n const command = program.commands.find((cmd) => cmd.name() === commandName);\n\n if (!command) {\n // Unrecognized command → exit 2 (CLI usage error)\n const flags = parseGlobalFlags({});\n const topNames = program.commands.map((c) => c.name());\n process.stderr.write(\n `Unknown command: ${commandName}${formatSuggestion(commandName!, topNames)}\\n`,\n );\n const helpText = formatRootHelp({ program, flags });\n process.stderr.write(`${helpText}\\n`);\n process.exit(2);\n } else if (command.commands.length > 0 && args.length >= 2) {\n const subcommandName = args[1];\n const redirectKey = `${commandName}:${subcommandName}`;\n const redirect = removedVerbRedirects[redirectKey];\n if (redirect) {\n process.stderr.write(`Unknown command: ${subcommandName}\\n${redirect}\\n`);\n process.exit(2);\n }\n for (let i = 2; i < args.length; i++) {\n const arg = args[i]!;\n if (!arg.startsWith('--')) continue;\n const flagName = arg.slice(2);\n const flagKey = `${commandName}:${subcommandName}:${flagName}`;\n const flagRedirect = removedFlagRedirects[flagKey];\n if (flagRedirect) {\n process.stderr.write(`Unknown option: ${arg}\\n${flagRedirect}\\n`);\n process.exit(2);\n }\n }\n }\n\n if (command.commands.length > 0 && args.length === 1) {\n // Parent command called with no subcommand. Same shape as the\n // no-args case above: the user did not request help, we are\n // voluntarily rendering it as decoration around an underspecified\n // invocation, so it goes to stderr per Style Guide § Output\n // Conventions rule 8. Exit code 0 today; the FOLLOW-UP note on\n // `program.action` applies here too (arguably should be 2).\n const flags = parseGlobalFlags({});\n const helpText = formatCommandHelp({ command, flags });\n process.stderr.write(`${helpText}\\n`);\n process.exit(0);\n }\n }\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC8BA,SAAS,eAAe,eAAkC;CACxD,MAAM,OAAiB,EAAE;CACzB,IAAI,SAAyB;CAC7B,OAAO,WAAW,MAAM;EACtB,KAAK,QAAQ,OAAO,MAAM,CAAC;EAC3B,SAAS,OAAO;;CAElB,OAAO;;AAGT,SAAS,yBAAyB,eAAgD;CAChF,OAAO,cAAc,QAAQ,KAAK,WAAW;EAC3C,MAAM,gBAAgB,OAAO,eAAe;EAC5C,OAAO;GACL;GACA,UAAU,OAAO,QAAQ;GACzB,QAAQ,cAAc,qBAAqB,cAAc,IAAI;GAC9D;GACD;;;;;;AAOJ,SAAgB,8BAA8B,eAA8C;CAC1F,OAAO;EACL,aAAa,eAAe,cAAc;EAC1C,gBAAgB,cAAc;EAC9B,SAAS,yBAAyB,cAAc;EACjD;;AAGH,SAAS,uBAAsC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qBAAqB,GADvB,YAAY,GAAG,eAAe,GADhC,IAAI,MAAM,EACiC;IAE5D,IAAI,cAAc;KAChB,QAAQ,OAAO,MAAM,mBAAmB,IAAI,IAAI,aAAa,IAAI;KACjE,QAAQ,KAAK,EAAE;;;;EAKrB,IAAI,QAAQ,SAAS,SAAS,KAAK,KAAK,WAAW,GAAG;GAQpD,MAAM,WAAW,kBAAkB;IAAE;IAAS,OADhC,iBAAiB,EAAE,CACkB;IAAE,CAAC;GACtD,QAAQ,OAAO,MAAM,GAAG,SAAS,IAAI;GACrC,QAAQ,KAAK,EAAE;;;;AAKrB,QAAQ,OAAO"}
1
+ {"version":3,"file":"cli.mjs","names":["CLI_VERSION","packageJson.version"],"sources":["../package.json","../src/utils/telemetry.ts","../src/commands/init/index.ts","../src/utils/suggest-command.ts","../src/cli.ts"],"sourcesContent":["","import { fileURLToPath } from 'node:url';\nimport {\n type CommanderOptionShape,\n type CommanderResultShape,\n readUserConfig,\n resolveGating,\n runTelemetry,\n type TelemetryRunOutcome,\n type UserConfig,\n} from '@prisma-next/cli-telemetry';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Command } from 'commander';\nimport { version as CLI_VERSION } from '../../package.json' with { type: 'json' };\nimport { isCI } from './is-ci';\n\ntype TelemetryGate =\n | { readonly enabled: true; readonly userConfig: UserConfig }\n | { readonly enabled: false; readonly outcome: TelemetryRunOutcome };\n\n/**\n * Resolve the commander command path from a leaf `Command`, walking up\n * the parent chain. Result is rooted at the program name and ends at\n * the leaf — `['prisma-next', 'migration', 'new']` for\n * `prisma-next migration new …`.\n */\nfunction commandPathFor(actionCommand: Command): string[] {\n const path: string[] = [];\n let cursor: Command | null = actionCommand;\n while (cursor !== null) {\n path.unshift(cursor.name());\n cursor = cursor.parent;\n }\n return path;\n}\n\nfunction commanderOptionSnapshots(actionCommand: Command): CommanderOptionShape[] {\n return actionCommand.options.map((option) => {\n const attributeName = option.attributeName();\n return {\n attributeName,\n longName: option.long ?? null,\n source: actionCommand.getOptionValueSource(attributeName) ?? null,\n };\n });\n}\n\n/**\n * Project commander's leaf `Command` into the wire-shape snapshot the\n * telemetry sanitiser consumes. Pure projection — no env, no I/O.\n */\nexport function commanderSnapshotForTelemetry(actionCommand: Command): CommanderResultShape {\n return {\n commandPath: commandPathFor(actionCommand),\n positionalArgs: actionCommand.args,\n options: commanderOptionSnapshots(actionCommand),\n };\n}\n\nfunction resolveTelemetryGate(): TelemetryGate {\n if (isCI()) {\n return { enabled: false, outcome: { spawned: false, reason: 'ci' } };\n }\n const userConfig = readUserConfig();\n const gating = resolveGating({ env: process.env, config: userConfig });\n if (!gating.enabled) {\n return { enabled: false, outcome: { spawned: false, reason: 'gated-off' } };\n }\n return { enabled: true, userConfig };\n}\n\n/**\n * Path to the compiled sender script inside `@prisma-next/cli-telemetry`'s\n * `dist/`. Resolved off this module's `import.meta.url` via the package\n * specifier `@prisma-next/cli-telemetry/sender`, so the consumer pays\n * no attention to internal package layout.\n */\nfunction senderPath(): string {\n return fileURLToPath(new URL(import.meta.resolve('@prisma-next/cli-telemetry/sender')));\n}\n\nfunction fireTelemetry(\n actionCommand: Command,\n userConfig: UserConfig,\n overrides: { readonly databaseTarget?: string } = {},\n): TelemetryRunOutcome {\n return runTelemetry({\n command: commanderSnapshotForTelemetry(actionCommand),\n version: CLI_VERSION,\n projectRoot: process.cwd(),\n senderPath: senderPath(),\n isCI: isCI(),\n env: process.env,\n userConfig,\n ...ifDefined('databaseTarget', overrides.databaseTarget),\n });\n}\n\n/**\n * preAction-stage entry point. Synchronous by construction: resolve\n * env/CI/user-consent gates (cheap, all in-memory and a single tiny\n * user-config read), then — only when enabled — `fork()` the detached\n * sender script. The forked child loads `prisma-next.config.*` via\n * c12 on its own (see `loadProjectConfig` in cli-telemetry); the\n * parent does no project-config I/O on the command's hot path.\n *\n * Privacy invariant: gate resolution always happens before any project\n * config touches disk. The child loading user TS code is acceptable\n * only because it's gated behind the same resolved-enabled signal.\n */\nexport function fireTelemetryFromPreAction(actionCommand: Command): TelemetryRunOutcome {\n const gate = resolveTelemetryGate();\n if (!gate.enabled) {\n return gate.outcome;\n }\n return fireTelemetry(actionCommand, gate.userConfig);\n}\n\n/**\n * Manual one-shot telemetry path for the first `init` run where the user\n * explicitly answers Yes to the consent prompt. The preAction hook for\n * that same run has already resolved before consent existed, so it is\n * default-off. After consent is persisted, `runInit` calls this helper\n * exactly for that first affirmative answer; subsequent init runs skip\n * it because the prompt is not shown again.\n *\n * The child's c12 load would return `databaseTarget: null` for this\n * specific invocation because `prisma-next.config.*` is not yet on\n * disk (init writes it later in the same run). To preserve the\n * prompt-chosen target in the first-init telemetry event, this\n * helper forwards the value as a parent-side IPC override on\n * `ParentToSenderPayload.databaseTarget` — the child consults the\n * override first and falls back to its c12 result when absent.\n */\nexport function fireTelemetryAfterInitConsent(\n actionCommand: Command,\n inputs: { readonly databaseTarget: string },\n): TelemetryRunOutcome {\n return fireTelemetry(actionCommand, readUserConfig(), {\n databaseTarget: inputs.databaseTarget,\n });\n}\n","import { Command } from 'commander';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../../utils/command-helpers';\nimport { type CommonCommandOptions, parseGlobalFlagsOrExit } from '../../utils/global-flags';\nimport { fireTelemetryAfterInitConsent } from '../../utils/telemetry';\nimport {\n INIT_EXIT_EMIT_FAILED,\n INIT_EXIT_INSTALL_FAILED,\n INIT_EXIT_INTERNAL_ERROR,\n INIT_EXIT_OK,\n INIT_EXIT_PRECONDITION,\n INIT_EXIT_SKILL_INSTALL_FAILED,\n INIT_EXIT_USER_ABORTED,\n} from './exit-codes';\n\n/**\n * Commander.js parsed options for `init`. The init-specific options live\n * alongside the inherited `CommonCommandOptions` global flags.\n *\n * `target` and `authoring` are typed as plain `string` here because\n * Commander.js does not enforce enums at parse time — the validation /\n * normalisation happens in `inputs.ts::resolveInitInputs`, which can\n * raise a structured `errorInitInvalidFlagValue` with the full set of\n * allowed values.\n */\ninterface InitCommandOptions extends CommonCommandOptions {\n readonly target?: string;\n readonly authoring?: string;\n readonly schemaPath?: string;\n readonly force?: boolean;\n readonly writeEnv?: boolean;\n readonly probeDb?: boolean;\n readonly strictProbe?: boolean;\n readonly install?: boolean;\n readonly skill?: boolean;\n}\n\nexport function createInitCommand(): Command {\n const command = new Command('init');\n setCommandDescriptions(\n command,\n 'Initialize a new Prisma Next project',\n 'Scaffolds config, schema, and runtime files, installs dependencies,\\n' +\n 'and emits the contract. Gets you from zero to typed queries in one step.\\n' +\n '\\n' +\n 'Run interactively for a guided experience, or supply --target / --authoring\\n' +\n 'and --yes for a fully scriptable run (CI, AI coding agents, automation).\\n' +\n '\\n' +\n 'Exit codes (see CLI Style Guide § Exit Codes):\\n' +\n ` ${INIT_EXIT_OK} OK Init succeeded.\\n` +\n ` ${INIT_EXIT_INTERNAL_ERROR} INTERNAL_ERROR Unexpected bug in prisma-next (please report).\\n` +\n ` ${INIT_EXIT_PRECONDITION} PRECONDITION Bad flags / missing prerequisite (e.g. no package.json).\\n` +\n ` ${INIT_EXIT_USER_ABORTED} USER_ABORTED User cancelled an interactive prompt.\\n` +\n ` ${INIT_EXIT_INSTALL_FAILED} INSTALL_FAILED Dependency installation failed (init-specific).\\n` +\n ` ${INIT_EXIT_EMIT_FAILED} EMIT_FAILED \\`contract emit\\` failed after install (init-specific).\\n` +\n ` ${INIT_EXIT_SKILL_INSTALL_FAILED} SKILL_INSTALL_FAILED Agent-skill install failed (re-run with --no-skill to skip).`,\n );\n setCommandExamples(command, [\n 'prisma-next init',\n 'prisma-next init --yes --target postgres --authoring psl',\n 'prisma-next init --yes --target mongodb --authoring typescript --json',\n 'prisma-next init --yes --force --target postgres --authoring psl # overwrite an existing scaffold',\n 'prisma-next init --no-install # skip pnpm/npm install + emit',\n 'prisma-next init --no-skill # skip the skills install (air-gapped / restricted env)',\n ]);\n\n return addGlobalOptions(command)\n .option('--target <db>', 'Database target: postgres or mongodb')\n .option('--authoring <style>', 'Schema authoring style: psl or typescript')\n .option(\n '--schema-path <path>',\n 'Where to write the starter schema (default: prisma/contract.prisma)',\n )\n .option('--force', 'Overwrite an existing scaffold without prompting')\n .option(\n '--write-env',\n 'Write a .env file from .env.example (gitignored; default: only .env.example)',\n )\n .option(\n '--probe-db',\n 'Connect to DATABASE_URL once and check the server version against the target minimum (opt-in; off by default)',\n )\n .option(\n '--strict-probe',\n 'Treat a failed --probe-db as fatal (no-op without --probe-db; init is offline-by-default)',\n )\n .option('--no-install', 'Skip dependency installation and contract emission')\n .option(\n '--no-skill',\n 'Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)',\n )\n .action(async (options: InitCommandOptions, actionCommand: Command) => {\n const { runInit } = await import('./init');\n const flags = parseGlobalFlagsOrExit(options);\n const canPrompt = deriveCanPrompt({\n flagsInteractive: flags.interactive,\n optionInteractive: options.interactive,\n stdinIsTTY: Boolean(process.stdin.isTTY),\n });\n const exitCode = await runInit(process.cwd(), {\n options,\n flags,\n canPrompt,\n afterFirstTelemetryConsent: (inputs) => {\n fireTelemetryAfterInitConsent(actionCommand, { databaseTarget: inputs.target });\n },\n });\n process.exit(exitCode);\n });\n}\n\n/**\n * Bridges the action handler's two TTY checks (stdout via `flags`, stdin\n * via `process.stdin.isTTY`) into the `canPrompt` boolean `runInit`\n * consumes.\n *\n * Per the [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity):\n *\n * - `flags.interactive` governs *decoration* (TerminalUI, intro/outro,\n * spinners) and is derived from stdout-TTY by `parseGlobalFlags`,\n * honouring `--interactive` / `--no-interactive`.\n * - Prompting additionally requires a stdin TTY — closing stdin is a\n * common signal in CI / agent environments even when stdout stays\n * attached.\n * - `--interactive` is the explicit override: when the user passes it,\n * we honour it (e.g. testing flows where stdin is stubbed).\n *\n * Exported so callers and tests can derive the same value without\n * touching `process` globals.\n */\nexport function deriveCanPrompt(opts: {\n readonly flagsInteractive: boolean | undefined;\n readonly optionInteractive: boolean | undefined;\n readonly stdinIsTTY: boolean;\n}): boolean {\n if (opts.optionInteractive === true) return true;\n if (opts.flagsInteractive === false) return false;\n return opts.stdinIsTTY;\n}\n","import { distance } from 'closest-match';\n\n/**\n * Suggests similar command names for a mistyped input.\n *\n * Uses Levenshtein distance to find close matches. Only suggests commands\n * within a reasonable distance threshold (40% of the input length, minimum 2).\n * Returns up to 3 suggestions in case of ties.\n *\n * @returns Array of suggested command names (empty if nothing is close enough).\n */\nexport function suggestCommands(input: string, candidates: readonly string[]): string[] {\n if (candidates.length === 0) return [];\n\n // Threshold: at most 40% of the input length (min 2) to avoid absurd suggestions\n const maxDistance = Math.max(2, Math.ceil(input.length * 0.4));\n\n const scored = candidates\n .map((name) => ({ name, dist: distance(input, name) }))\n .filter((entry) => entry.dist <= maxDistance)\n .sort((a, b) => a.dist - b.dist);\n\n if (scored.length === 0) return [];\n\n // Take the best distance, then include ties (up to 3)\n const bestDist = scored[0]!.dist;\n return scored\n .filter((entry) => entry.dist === bestDist)\n .slice(0, 3)\n .map((entry) => entry.name);\n}\n","import { Command } from 'commander';\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createContractEmitCommand } from './commands/contract-emit';\nimport { createContractInferCommand } from './commands/contract-infer';\nimport { createInitCommand } from './commands/init';\nimport { installShutdownHandlers } from './utils/shutdown';\n\n// Install SIGINT/SIGTERM handlers before anything else\ninstallShutdownHandlers();\n\nimport { createDbInitCommand } from './commands/db-init';\nimport { createDbSchemaCommand } from './commands/db-schema';\nimport { createDbSignCommand } from './commands/db-sign';\nimport { createDbUpdateCommand } from './commands/db-update';\nimport { createDbVerifyCommand } from './commands/db-verify';\nimport { createMigrateCommand } from './commands/migrate';\nimport { createMigrationCheckCommand } from './commands/migration-check';\nimport { createMigrationGraphCommand } from './commands/migration-graph';\nimport { createMigrationListCommand } from './commands/migration-list';\nimport { createMigrationLogCommand } from './commands/migration-log';\nimport { createMigrationNewCommand } from './commands/migration-new';\nimport { createMigrationPlanCommand } from './commands/migration-plan';\nimport { createMigrationShowCommand } from './commands/migration-show';\nimport { createMigrationStatusCommand } from './commands/migration-status';\nimport { createRefCommand } from './commands/ref';\nimport { setCommandDescriptions } from './utils/command-helpers';\nimport { formatCommandHelp, formatRootHelp } from './utils/formatters/help';\nimport { parseGlobalFlags } from './utils/global-flags';\nimport { suggestCommands } from './utils/suggest-command';\nimport { fireTelemetryFromPreAction } from './utils/telemetry';\n\n/**\n * Lookup table mapping removed subcommands to their replacement verbs.\n * Keyed by `<parent>:<subcommand>` (e.g. `migration:apply`).\n * The handler consults this before falling back to the fuzzy suggest engine.\n */\nconst removedVerbRedirects: Record<string, string> = {\n 'migration:apply': 'Use `prisma-next migrate --to <contract>` instead.',\n 'migration:ref': 'Use `prisma-next ref set|list|delete` instead.',\n};\n\n/**\n * Removed flags on specific subcommands. Keyed by `<parent>:<sub>:<flag>`.\n * Checked during the pre-parse argv scan before commander sees the flags.\n */\nconst removedFlagRedirects: Record<string, string> = {\n 'migration:status:graph': 'Use `prisma-next migration graph` to view the migration graph.',\n 'migration:status:all':\n 'Use `prisma-next migration log --db <url>` to view the full execution history.',\n 'migration:status:limit':\n 'Use `prisma-next migration log --db <url>` to view the full execution history.',\n 'migration:status:ref': 'Use `--to <contract>` instead of `--ref`.',\n};\n\n/**\n * Formats the \"Did you mean ...?\" hint for an unknown command.\n */\nfunction formatSuggestion(input: string, candidates: readonly string[]): string {\n const suggestions = suggestCommands(\n input,\n candidates.map((c) => c),\n );\n if (suggestions.length === 0) return '';\n if (suggestions.length === 1) return `\\nDid you mean ${suggestions[0]}?\\n`;\n return `\\nDid you mean one of these?\\n${suggestions.map((s) => ` ${s}`).join('\\n')}\\n`;\n}\n\nconst program = new Command();\n\nprogram.name('prisma-next').description('Prisma Next CLI').version(packageJson.version);\n\n// Telemetry hook — fires at command start, before the action body\n// runs. Synchronous by construction: `fireTelemetryFromPreAction`\n// resolves gates (cheap), then `fork()`s the detached sender. The\n// fork is enqueued before the action body runs at all, so the child\n// survives even when the action throws synchronously. The try/catch\n// is defence-in-depth — `runTelemetry` already swallows every failure\n// mode internally and returns an outcome instead of throwing.\nprogram.hook('preAction', (_thisCommand, actionCommand) => {\n try {\n fireTelemetryFromPreAction(actionCommand);\n } catch {\n // defence-in-depth — runTelemetry already swallows internally.\n }\n});\n\n// Override version option description to match capitalization style\nconst versionOption = program.options.find((opt) => opt.flags.includes('--version'));\nif (versionOption) {\n versionOption.description = 'Output the version number';\n}\n\nprogram.configureOutput({\n writeErr: () => {\n // Suppress all default error output - we handle errors in exitOverride\n },\n writeOut: (str) => {\n // Commander routes explicitly-requested `--help` (success-path help)\n // through writeOut; per the Style Guide § Output Conventions rule 8,\n // user-requested help is data and goes to stdout. Error-path help\n // (e.g. usage shown after an unknown command) goes through writeErr,\n // which stays suppressed because we render that ourselves with the\n // matching error envelope.\n //\n // Explicit `--version` is short-circuited before `program.parse()`\n // (see the argv pre-scan at the bottom of this file), so it does not\n // reach this writer.\n process.stdout.write(str);\n },\n});\n\n// Customize root help output to use our styled format\nconst rootHelpFormatter = (cmd: Command) => {\n const flags = parseGlobalFlags({});\n return formatRootHelp({ program: cmd, flags });\n};\n\nprogram.configureHelp({\n formatHelp: rootHelpFormatter,\n subcommandDescription: () => '',\n});\n\n// Override exit to handle unhandled errors (fail fast cases)\n// Commands handle structured errors themselves via process.exit()\nprogram.exitOverride((err) => {\n if (err) {\n const errorCode = (err as { code?: string }).code;\n const errorMessage = String(err.message ?? '');\n const errorName = err.name ?? '';\n\n // Unknown command/argument → exit 2 (CLI usage error)\n const isUnknownCommandError =\n errorCode === 'commander.unknownCommand' ||\n errorCode === 'commander.unknownArgument' ||\n (errorName === 'CommanderError' &&\n (errorMessage.includes('unknown command') || errorMessage.includes('unknown argument')));\n if (isUnknownCommandError) {\n const flags = parseGlobalFlags({});\n const match = errorMessage.match(/unknown command ['\"]([^'\"]+)['\"]/);\n const commandName = match ? match[1] : process.argv[3] || process.argv[2] || 'unknown';\n\n const firstArg = process.argv[2];\n const parentCommand = firstArg\n ? program.commands.find((cmd) => cmd.name() === firstArg)\n : undefined;\n\n if (parentCommand && commandName !== firstArg) {\n const subNames = parentCommand.commands.map((c) => c.name());\n process.stderr.write(\n `Unknown command: ${commandName}${formatSuggestion(commandName!, subNames)}\\n`,\n );\n const helpText = formatCommandHelp({ command: parentCommand, flags });\n process.stderr.write(`${helpText}\\n`);\n } else {\n const topNames = program.commands.map((c) => c.name());\n process.stderr.write(\n `Unknown command: ${commandName}${formatSuggestion(commandName!, topNames)}\\n`,\n );\n const helpText = formatRootHelp({ program, flags });\n process.stderr.write(`${helpText}\\n`);\n }\n process.exit(2);\n return;\n }\n\n // Help requests → exit 0\n const isHelpError =\n errorCode === 'commander.help' ||\n errorCode === 'commander.helpDisplayed' ||\n errorCode === 'outputHelp' ||\n errorMessage === '(outputHelp)' ||\n errorMessage.includes('outputHelp') ||\n (errorName === 'CommanderError' && errorMessage.includes('outputHelp'));\n if (isHelpError) {\n process.exit(0);\n return;\n }\n\n // Missing required arguments → exit 2 (CLI usage error)\n const isMissingArgumentError =\n errorCode === 'commander.missingArgument' ||\n errorCode === 'commander.missingMandatoryOptionValue' ||\n (errorName === 'CommanderError' &&\n (errorMessage.includes('missing') || errorMessage.includes('required')));\n if (isMissingArgumentError) {\n process.exit(2);\n return;\n }\n\n // Unhandled error → exit 1\n process.stderr.write(`Unhandled error: ${err.message}\\n`);\n if (err.stack) {\n process.stderr.write(`${err.stack}\\n`);\n }\n process.exit(1);\n }\n process.exit(0);\n});\n\n// Register contract subcommand\nconst contractCommand = new Command('contract');\nsetCommandDescriptions(\n contractCommand,\n 'Contract management commands',\n 'Define and emit your application data contract. The contract describes your schema as a\\n' +\n 'declarative data structure that can be signed and verified against your database.',\n);\ncontractCommand.configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n subcommandDescription: () => '',\n});\n\n// Add emit subcommand to contract\nconst contractEmitCommand = createContractEmitCommand();\ncontractCommand.addCommand(contractEmitCommand);\n\n// Add infer subcommand to contract\nconst contractInferCommand = createContractInferCommand();\ncontractCommand.addCommand(contractInferCommand);\n\n// Register db subcommand\nconst dbCommand = new Command('db');\nsetCommandDescriptions(\n dbCommand,\n 'Database management commands',\n 'Verify and sign your database with your contract. Ensure your database schema matches\\n' +\n 'your contract, and sign it to record the contract hash for future verification.',\n);\ndbCommand.configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n subcommandDescription: () => '',\n});\n\n// Add verify subcommand to db\nconst dbVerifyCommand = createDbVerifyCommand();\ndbCommand.addCommand(dbVerifyCommand);\n\n// Add init subcommand to db\nconst dbInitCommand = createDbInitCommand();\ndbCommand.addCommand(dbInitCommand);\n\n// Add update subcommand to db\nconst dbUpdateCommand = createDbUpdateCommand();\ndbCommand.addCommand(dbUpdateCommand);\n\n// Add schema subcommand to db\nconst dbSchemaCommand = createDbSchemaCommand();\ndbCommand.addCommand(dbSchemaCommand);\n\n// Add sign subcommand to db\nconst dbSignCommand = createDbSignCommand();\ndbCommand.addCommand(dbSignCommand);\n\n// Register migration subcommand\nconst migrationCommand = new Command('migration');\nsetCommandDescriptions(\n migrationCommand,\n 'On-disk migration management commands',\n 'Plan, apply, and scaffold on-disk migration packages. Migrations are\\n' +\n 'contract-to-contract edges stored as versioned directories under migrations/.',\n);\nmigrationCommand.configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n subcommandDescription: () => '',\n});\n\nconst migrationPlanCommand = createMigrationPlanCommand();\nmigrationCommand.addCommand(migrationPlanCommand);\n\nconst migrationNewCommand = createMigrationNewCommand();\nmigrationCommand.addCommand(migrationNewCommand);\n\nconst migrationShowCommand = createMigrationShowCommand();\nmigrationCommand.addCommand(migrationShowCommand);\n\nconst migrationStatusCommand = createMigrationStatusCommand();\nmigrationCommand.addCommand(migrationStatusCommand);\n\nconst migrationLogCommand = createMigrationLogCommand();\nmigrationCommand.addCommand(migrationLogCommand);\n\nconst migrationListCommand = createMigrationListCommand();\nmigrationCommand.addCommand(migrationListCommand);\n\nconst migrationGraphCommand = createMigrationGraphCommand();\nmigrationCommand.addCommand(migrationGraphCommand);\n\nconst migrationCheckCommand = createMigrationCheckCommand();\nmigrationCommand.addCommand(migrationCheckCommand);\n\n// Top-level migrate command\nconst migrateCommand = createMigrateCommand();\n\n// Top-level ref command (replaces `migration ref`)\nconst refCommand = createRefCommand();\n\n// Top-level init command\nconst initCommand = createInitCommand();\n\n// Register top-level commands in the order the spec's intended-surface\n// diagram lists them: verbs (init, migrate) first, then subject\n// namespaces (contract, db, migration, ref). The order shows up in\n// `prisma-next --help` and is the first thing a new user sees, so it\n// matches the order spec.md uses to introduce the surface.\nprogram.addCommand(initCommand);\nprogram.addCommand(migrateCommand);\nprogram.addCommand(contractCommand);\nprogram.addCommand(dbCommand);\nprogram.addCommand(migrationCommand);\nprogram.addCommand(refCommand);\n\n// Test-only hidden command used by `cli-telemetry`'s `cli-e2e.test.ts`\n// to verify that telemetry still lands when a CLI command crashes\n// mid-execution. The preAction hook is synchronous and `fork()`s the\n// detached sender before this action body runs; the small sleep\n// gives the IPC `child.send()` a tick to flush before the throw\n// triggers commander's `exitOverride` and `process.exit(1)`. Hidden\n// from help; underscore prefix marks it as internal. Doesn't depend\n// on any project state, so it runs in any tempdir.\n//\n// Gated behind `PRISMA_NEXT_ENABLE_TEST_COMMANDS=1` so the command is\n// not even registered (and therefore not invocable) in shipped\n// binaries. `hidden: true` only filters the help output; without this\n// env gate the command would still be callable from production. The\n// e2e suite sets the env var when it spawns the CLI.\nconst TELEMETRY_CRASH_TEST_SLEEP_MS = 200;\nif (process.env['PRISMA_NEXT_ENABLE_TEST_COMMANDS'] === '1') {\n const telemetryCrashTestCommand = new Command('__telemetry-crash-test')\n .description('Internal: deliberately throw for the telemetry e2e suite.')\n .action(async () => {\n await new Promise((settle) => setTimeout(settle, TELEMETRY_CRASH_TEST_SLEEP_MS));\n throw new Error('__telemetry-crash-test: intentional crash for e2e coverage');\n });\n telemetryCrashTestCommand.configureHelp({ visibleCommands: () => [] });\n program.addCommand(telemetryCrashTestCommand, { hidden: true });\n}\n\n// Create help command\nconst helpCommand = new Command('help')\n .description('Show usage instructions')\n .configureHelp({\n formatHelp: (cmd) => {\n const flags = parseGlobalFlags({});\n return formatCommandHelp({ command: cmd, flags });\n },\n })\n .action(() => {\n const flags = parseGlobalFlags({});\n const helpText = formatRootHelp({ program, flags });\n // The `help` command was invoked explicitly: help is the data the\n // caller asked for. Per Style Guide § Output Conventions rule 8,\n // explicit help goes to stdout with exit code 0.\n process.stdout.write(`${helpText}\\n`);\n process.exit(0);\n });\n\nprogram.addCommand(helpCommand);\n\n// Set help as the default action when no command is provided. The user\n// did not invoke `--help`; we are voluntarily showing usage to help them\n// recover from an underspecified invocation, so the help text is\n// decoration around an implicit \"what did you want me to do?\" and goes\n// to stderr (Style Guide § Output Conventions rule 8).\n//\n// FOLLOW-UP: the exit code here is 0 today, but a no-arg invocation is\n// arguably a usage error (PRECONDITION → exit 2) for consistency with\n// the unknown-command path. Out of scope for the explicit-help routing\n// work; revisit when tightening exit-code semantics across the CLI.\nprogram.action(() => {\n const flags = parseGlobalFlags({});\n const helpText = formatRootHelp({ program, flags });\n process.stderr.write(`${helpText}\\n`);\n process.exit(0);\n});\n\n// Check if a command was invoked with no arguments (just the command name)\n// or if an unrecognized command was provided\nconst args = process.argv.slice(2);\nif (args.length > 0) {\n const commandName = args[0];\n // Handle version option explicitly since we suppress default output\n if (commandName === '--version' || commandName === '-V') {\n // Version is data → stdout\n process.stdout.write(`${program.version()}\\n`);\n process.exit(0);\n }\n // Skip command check for global options like --help, -h\n const isGlobalOption = commandName === '--help' || commandName === '-h';\n if (!isGlobalOption) {\n // Check if this is a recognized command\n const command = program.commands.find((cmd) => cmd.name() === commandName);\n\n if (!command) {\n // Unrecognized command → exit 2 (CLI usage error)\n const flags = parseGlobalFlags({});\n const topNames = program.commands.map((c) => c.name());\n process.stderr.write(\n `Unknown command: ${commandName}${formatSuggestion(commandName!, topNames)}\\n`,\n );\n const helpText = formatRootHelp({ program, flags });\n process.stderr.write(`${helpText}\\n`);\n process.exit(2);\n } else if (command.commands.length > 0 && args.length >= 2) {\n const subcommandName = args[1];\n const redirectKey = `${commandName}:${subcommandName}`;\n const redirect = removedVerbRedirects[redirectKey];\n if (redirect) {\n process.stderr.write(`Unknown command: ${subcommandName}\\n${redirect}\\n`);\n process.exit(2);\n }\n for (let i = 2; i < args.length; i++) {\n const arg = args[i]!;\n if (!arg.startsWith('--')) continue;\n const flagName = arg.slice(2);\n const flagKey = `${commandName}:${subcommandName}:${flagName}`;\n const flagRedirect = removedFlagRedirects[flagKey];\n if (flagRedirect) {\n process.stderr.write(`Unknown option: ${arg}\\n${flagRedirect}\\n`);\n process.exit(2);\n }\n }\n }\n\n if (command.commands.length > 0 && args.length === 1) {\n // Parent command called with no subcommand. Same shape as the\n // no-args case above: the user did not request help, we are\n // voluntarily rendering it as decoration around an underspecified\n // invocation, so it goes to stderr per Style Guide § Output\n // Conventions rule 8. Exit code 0 today; the FOLLOW-UP note on\n // `program.action` applies here too (arguably should be 2).\n const flags = parseGlobalFlags({});\n const helpText = formatCommandHelp({ command, flags });\n process.stderr.write(`${helpText}\\n`);\n process.exit(0);\n }\n }\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACyBA,SAAS,eAAe,eAAkC;CACxD,MAAM,OAAiB,EAAE;CACzB,IAAI,SAAyB;CAC7B,OAAO,WAAW,MAAM;EACtB,KAAK,QAAQ,OAAO,MAAM,CAAC;EAC3B,SAAS,OAAO;;CAElB,OAAO;;AAGT,SAAS,yBAAyB,eAAgD;CAChF,OAAO,cAAc,QAAQ,KAAK,WAAW;EAC3C,MAAM,gBAAgB,OAAO,eAAe;EAC5C,OAAO;GACL;GACA,UAAU,OAAO,QAAQ;GACzB,QAAQ,cAAc,qBAAqB,cAAc,IAAI;GAC9D;GAC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K,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;IACpC,MAAM,MAAM,KAAK;IACjB,IAAI,CAAC,IAAI,WAAW,KAAK,EAAE;IAG3B,MAAM,eAAe,qBAAqB,GADvB,YAAY,GAAG,eAAe,GADhC,IAAI,MAAM,EACiC;IAE5D,IAAI,cAAc;KAChB,QAAQ,OAAO,MAAM,mBAAmB,IAAI,IAAI,aAAa,IAAI;KACjE,QAAQ,KAAK,EAAE;;;;EAKrB,IAAI,QAAQ,SAAS,SAAS,KAAK,KAAK,WAAW,GAAG;GAQpD,MAAM,WAAW,kBAAkB;IAAE;IAAS,OADhC,iBAAiB,EAAE,CACkB;IAAE,CAAC;GACtD,QAAQ,OAAO,MAAM,GAAG,SAAS,IAAI;GACrC,QAAQ,KAAK,EAAE;;;;AAKrB,QAAQ,OAAO"}
@@ -1,7 +1,7 @@
1
- import { p as errorRunnerFailed, t as CliStructuredError } from "./cli-errors-CF60g2cG.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-xFLFpZUO.mjs";
1
+ import { h as errorRunnerFailed, t as CliStructuredError } from "./cli-errors-Djtz98Vm.mjs";
2
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-65gOHkHB.mjs";
3
3
  import { t as enrichContract } from "./contract-enrichment-Dani0mMW.mjs";
4
- import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-pAc8CDfY.mjs";
4
+ import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-BmNQwlws.mjs";
5
5
  import { emit } from "@prisma-next/emitter";
6
6
  import { ifDefined } from "@prisma-next/utils/defined";
7
7
  import { notOk, ok } from "@prisma-next/utils/result";
@@ -78,7 +78,8 @@ async function applyAggregate(inputs) {
78
78
  ...ifDefined("why", runnerResult.failure.why),
79
79
  meta: {
80
80
  ...runnerResult.failure.meta ?? {},
81
- failingSpace: runnerResult.failure.failingSpace
81
+ failingSpace: runnerResult.failure.failingSpace,
82
+ runnerErrorCode: runnerResult.failure.code
82
83
  }
83
84
  });
84
85
  }
@@ -1480,4 +1481,4 @@ var ControlClientImpl = class {
1480
1481
  //#endregion
1481
1482
  export { ContractValidationError as a, executeDbInit as i, executeDbVerify as n, executeDbUpdate as r, createControlClient as t };
1482
1483
 
1483
- //# sourceMappingURL=client-Brv4qlfB.mjs.map
1484
+ //# sourceMappingURL=client-oXO2WCPD.mjs.map