@prisma/orm-toolchain 8.0.0-rc.1-dev.5 → 8.0.0-rc.1-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{aggregate-B4mhR4Sk.mjs → aggregate-D53gnb7v.mjs} +8 -8
- package/dist/{aggregate-B4mhR4Sk.mjs.map → aggregate-D53gnb7v.mjs.map} +1 -1
- package/dist/bin__prisma-next.mjs +22 -22
- package/dist/bin__prisma-next.mjs.map +1 -1
- package/dist/caught-errors-D7Qznyrm-BzYooF6H.mjs +14 -0
- package/dist/caught-errors-D7Qznyrm-BzYooF6H.mjs.map +1 -0
- package/dist/{types-DZWEs4si-D8UlyJI0.d.mts → cli-errors-CDr3WcJP-NFry5GHb.d.mts} +8 -2
- package/dist/cli-errors-CDr3WcJP-NFry5GHb.d.mts.map +1 -0
- package/dist/cli.mjs +2 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__commands__contract-emit.mjs +1 -1
- package/dist/cli__commands__contract-infer.mjs +1 -1
- package/dist/cli__commands__db-init.mjs +1 -1
- package/dist/cli__commands__db-schema.mjs +1 -1
- package/dist/cli__commands__db-sign.mjs +1 -1
- package/dist/cli__commands__db-update.mjs +1 -1
- package/dist/cli__commands__db-verify.mjs +1 -1
- package/dist/cli__commands__migrate.d.mts +3 -12
- package/dist/cli__commands__migrate.d.mts.map +1 -1
- package/dist/cli__commands__migrate.mjs +1 -1
- package/dist/cli__commands__migration-check.d.mts +1 -57
- package/dist/cli__commands__migration-check.d.mts.map +1 -1
- package/dist/cli__commands__migration-check.mjs +2 -2
- package/dist/cli__commands__migration-graph.d.mts +1 -1
- package/dist/cli__commands__migration-graph.mjs +1 -1
- package/dist/cli__commands__migration-list.d.mts +4 -44
- package/dist/cli__commands__migration-list.d.mts.map +1 -1
- package/dist/cli__commands__migration-list.mjs +2 -2
- package/dist/cli__commands__migration-log.d.mts +1 -1
- package/dist/cli__commands__migration-log.mjs +1 -1
- package/dist/cli__commands__migration-new.mjs +1 -1
- package/dist/cli__commands__migration-plan.d.mts +2 -47
- package/dist/cli__commands__migration-plan.d.mts.map +1 -1
- package/dist/cli__commands__migration-plan.mjs +1 -1
- package/dist/cli__commands__migration-show.mjs +1 -1
- package/dist/cli__commands__migration-status.d.mts +1 -1
- package/dist/cli__commands__migration-status.mjs +1 -1
- package/dist/cli__commands__ref.d.mts +1 -28
- package/dist/cli__commands__ref.d.mts.map +1 -1
- package/dist/cli__commands__ref.mjs +2 -2
- package/dist/cli__commands__telemetry.mjs +1 -1
- package/dist/cli__control-api.d.mts +502 -2
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +18 -3
- package/dist/cli__migration-cli.mjs +3 -6
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/{client-75qrAPqf-7l0C0H_b.mjs → client-Y6qbDk7X-BzKLmBZo.mjs} +16 -12
- package/dist/client-Y6qbDk7X-BzKLmBZo.mjs.map +1 -0
- package/dist/{command-helpers-CAoXqAY9-DWUBcTXM.mjs → command-helpers-C4WpR-QE-DE494TSG.mjs} +30 -74
- package/dist/command-helpers-C4WpR-QE-DE494TSG.mjs.map +1 -0
- package/dist/config-loader.d.mts +2 -18
- package/dist/contract-at-errors-Dv1mxKYO-C29YB4RC.mjs +44 -0
- package/dist/contract-at-errors-Dv1mxKYO-C29YB4RC.mjs.map +1 -0
- package/dist/{contract-emit-B6odMoem-C87PBvmo.mjs → contract-emit-CTm2zfuG-7PV9SBY6.mjs} +12 -11
- package/dist/contract-emit-CTm2zfuG-7PV9SBY6.mjs.map +1 -0
- package/dist/{contract-emit-0hSjbuxp-BJLC-VgC.mjs → contract-emit-D8IXP9Qp-Df6NwXn8.mjs} +4 -4
- package/dist/{contract-emit-0hSjbuxp-BJLC-VgC.mjs.map → contract-emit-D8IXP9Qp-Df6NwXn8.mjs.map} +1 -1
- package/dist/{contract-infer-BnkqpftN-DwBzasOu.mjs → contract-infer-BwT7ngoo-Dx6aAwIN.mjs} +5 -5
- package/dist/contract-infer-BwT7ngoo-Dx6aAwIN.mjs.map +1 -0
- package/dist/contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs +82 -0
- package/dist/contract-snapshot-resolution-SATuw0JW-CsYq7g_n.mjs.map +1 -0
- package/dist/{contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs → contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs} +3 -3
- package/dist/{contract-snapshot-store-sf5nP4mb-MLpG-ihh.mjs.map → contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs → contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs} +7 -7
- package/dist/contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs.map +1 -0
- package/dist/{db-init-bd0_x2Q8.mjs → db-init-CBj_EWg3.mjs} +18 -32
- package/dist/db-init-CBj_EWg3.mjs.map +1 -0
- package/dist/{db-schema-CwgAWTqG.mjs → db-schema-BWpeh0Q_.mjs} +4 -4
- package/dist/{db-schema-CwgAWTqG.mjs.map → db-schema-BWpeh0Q_.mjs.map} +1 -1
- package/dist/{db-sign-vqiYfpjI.mjs → db-sign-DCb_DKtv.mjs} +13 -29
- package/dist/db-sign-DCb_DKtv.mjs.map +1 -0
- package/dist/{db-update-Br0diOCo.mjs → db-update-WX0KitcX.mjs} +29 -52
- package/dist/db-update-WX0KitcX.mjs.map +1 -0
- package/dist/{db-verify-CKPsRFrj-T7nSt7yT.mjs → db-verify-B8ax2Y_x-Bp4s5Ra6.mjs} +9 -6
- package/dist/db-verify-B8ax2Y_x-Bp4s5Ra6.mjs.map +1 -0
- package/dist/{errors-IpZm1Skp-BH495dRd.mjs → errors-Co-8oaiB-CB-6Uqki.mjs} +45 -53
- package/dist/errors-Co-8oaiB-CB-6Uqki.mjs.map +1 -0
- package/dist/{errors--qsXZUtL.d.mts → errors-NRmFpwR1.d.mts} +13 -9
- package/dist/errors-NRmFpwR1.d.mts.map +1 -0
- package/dist/{format-ByDm2goZ-BIRlFoo6.mjs → format-Bw3LVJ1v-BJ6lVFMA.mjs} +12 -9
- package/dist/format-Bw3LVJ1v-BJ6lVFMA.mjs.map +1 -0
- package/dist/{framework-components-CjshQKHA-Dlp6Leo5.mjs → framework-components-3DdB31mk-BHyX-OlJ.mjs} +3 -3
- package/dist/{framework-components-CjshQKHA-Dlp6Leo5.mjs.map → framework-components-3DdB31mk-BHyX-OlJ.mjs.map} +1 -1
- package/dist/{graph-membership-DW6nnbyQ-Bp2KcVwR.mjs → graph-membership-BEmNEMtP-rz61CLM5.mjs} +3 -3
- package/dist/{graph-membership-DW6nnbyQ-Bp2KcVwR.mjs.map → graph-membership-BEmNEMtP-rz61CLM5.mjs.map} +1 -1
- package/dist/index-Df9igRvP.d.mts +18 -0
- package/dist/index-Df9igRvP.d.mts.map +1 -0
- package/dist/{init-BGm77aWc-jHVUn63W.mjs → init-CPB89WK2-DPZRZ9Ee.mjs} +4 -4
- package/dist/{init-BGm77aWc-jHVUn63W.mjs.map → init-CPB89WK2-DPZRZ9Ee.mjs.map} +1 -1
- package/dist/{inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs → inspect-live-schema-Da76TWOs-CAFqkhGb.mjs} +4 -4
- package/dist/{inspect-live-schema-CnwYTRZ0-P-6asJFl.mjs.map → inspect-live-schema-Da76TWOs-CAFqkhGb.mjs.map} +1 -1
- package/dist/invariants-BzYfO9IL-BXTvx0z9.mjs +52 -0
- package/dist/invariants-BzYfO9IL-BXTvx0z9.mjs.map +1 -0
- package/dist/{invariants-lXzy6txi-DAoP4nTE.mjs → invariants-C1WVUAH7-DlOBTTkM.mjs} +3 -3
- package/dist/{invariants-lXzy6txi-DAoP4nTE.mjs.map → invariants-C1WVUAH7-DlOBTTkM.mjs.map} +1 -1
- package/dist/{io-C8TdyBKt-DloEBi70.mjs → io-CHUUeHh0-CoCBe9eN.mjs} +8 -8
- package/dist/{io-C8TdyBKt-DloEBi70.mjs.map → io-CHUUeHh0-CoCBe9eN.mjs.map} +1 -1
- package/dist/legend-5iwwlLU2-CB8bdQKJ.mjs +22 -0
- package/dist/legend-5iwwlLU2-CB8bdQKJ.mjs.map +1 -0
- package/dist/{migrate-BdVFDKF2.mjs → migrate-B-NAuO90.mjs} +90 -227
- package/dist/migrate-B-NAuO90.mjs.map +1 -0
- package/dist/migrate-show-60NNqVia-oGqMaVA9.d.mts +56 -0
- package/dist/migrate-show-60NNqVia-oGqMaVA9.d.mts.map +1 -0
- package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs +202 -0
- package/dist/migrate-show-B2LkXkoB-D1ZNl84C.mjs.map +1 -0
- package/dist/{migration-BuUmO7It.mjs → migration-DAJY-NmR.mjs} +3 -3
- package/dist/{migration-BuUmO7It.mjs.map → migration-DAJY-NmR.mjs.map} +1 -1
- package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs +254 -0
- package/dist/migration-check-BDjtAn7x-B0nEBR0k.mjs.map +1 -0
- package/dist/{migration-check-DcwUnadt-jamDqOmM.mjs → migration-check-DONPyXff-CGTUpLv-.mjs} +12 -254
- package/dist/migration-check-DONPyXff-CGTUpLv-.mjs.map +1 -0
- package/dist/{migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs → migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs} +4 -4
- package/dist/{migration-command-scaffold-BCuoeAki-DMy_5ztW.mjs.map → migration-command-scaffold-BPqXPCFV-Bls2Wwg7.mjs.map} +1 -1
- package/dist/{migration-graph-CBf9ORe7-B4xAF8GN.mjs → migration-graph-DDaOHo10-yJFAbKCu.mjs} +3 -3
- package/dist/{migration-graph-CBf9ORe7-B4xAF8GN.mjs.map → migration-graph-DDaOHo10-yJFAbKCu.mjs.map} +1 -1
- package/dist/{migration-graph-vmgkL3k4.mjs → migration-graph-Dn469b0l.mjs} +10 -19
- package/dist/migration-graph-Dn469b0l.mjs.map +1 -0
- package/dist/migration-graph-HKch1Xk4-DyWhXtjZ.mjs +35 -0
- package/dist/migration-graph-HKch1Xk4-DyWhXtjZ.mjs.map +1 -0
- package/dist/migration-list-C9OPCMt--C28yBgVr.mjs +102 -0
- package/dist/migration-list-C9OPCMt--C28yBgVr.mjs.map +1 -0
- package/dist/migration-list-jk4iCtmO.mjs +120 -0
- package/dist/migration-list-jk4iCtmO.mjs.map +1 -0
- package/dist/{migration-log-CS5IWcNq-DI7FTHCA.mjs → migration-log-DQzUBrm8-D3m9wcuf.mjs} +7 -7
- package/dist/migration-log-DQzUBrm8-D3m9wcuf.mjs.map +1 -0
- package/dist/migration-new-BkSY6m0t.mjs +50 -0
- package/dist/migration-new-BkSY6m0t.mjs.map +1 -0
- package/dist/{migration-new-GmW2anVb.mjs → migration-new-g98oB3nC-BcrkxAAt.mjs} +19 -58
- package/dist/migration-new-g98oB3nC-BcrkxAAt.mjs.map +1 -0
- package/dist/{migration-path-target-D3Sj55PI-BICblCuk.mjs → migration-path-target-BPYp3LNc-DsDdLU0J.mjs} +4 -4
- package/dist/migration-path-target-BPYp3LNc-DsDdLU0J.mjs.map +1 -0
- package/dist/migration-plan-BsOYRogP-CC1UFAbu.d.mts +159 -0
- package/dist/migration-plan-BsOYRogP-CC1UFAbu.d.mts.map +1 -0
- package/dist/migration-plan-CjIYMJZy.mjs +172 -0
- package/dist/migration-plan-CjIYMJZy.mjs.map +1 -0
- package/dist/{migration-plan-q_L84PN1-ClkGgtVz.mjs → migration-plan-CwuZLXVE-DAJ-JUQT.mjs} +46 -185
- package/dist/migration-plan-CwuZLXVE-DAJ-JUQT.mjs.map +1 -0
- package/dist/{migration-show--pW4XhKs.mjs → migration-show-CW6EKtfw.mjs} +16 -12
- package/dist/migration-show-CW6EKtfw.mjs.map +1 -0
- package/dist/{migration-status-CE7cQLDq-P1x1-BsZ.mjs → migration-status-DSQcBhiN.mjs} +37 -68
- package/dist/migration-status-DSQcBhiN.mjs.map +1 -0
- package/dist/migration-tools.d.mts +5 -5
- package/dist/migration-tools.mjs +13 -13
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.d.mts +2 -2
- package/dist/migration-tools__errors.mjs +2 -2
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.d.mts +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{project-import-root-CpwLCDLY-DkVwAnWj.mjs → project-import-root-C_bd0ooL-WkbJLnAA.mjs} +10 -8
- package/dist/project-import-root-C_bd0ooL-WkbJLnAA.mjs.map +1 -0
- package/dist/ref-DSAZime8.mjs +72 -0
- package/dist/ref-DSAZime8.mjs.map +1 -0
- package/dist/ref-advancement-DaZBzm7m-BZQtedYC.mjs +96 -0
- package/dist/ref-advancement-DaZBzm7m-BZQtedYC.mjs.map +1 -0
- package/dist/ref-eJjxzYTh-CNiyDL4p.mjs +109 -0
- package/dist/ref-eJjxzYTh-CNiyDL4p.mjs.map +1 -0
- package/dist/{ref-resolution-BjJBWPjX.mjs → ref-resolution-Ct2GMcNB.mjs} +2 -2
- package/dist/{ref-resolution-BjJBWPjX.mjs.map → ref-resolution-Ct2GMcNB.mjs.map} +1 -1
- package/dist/ref-resolution-_S4xTT2L-BE5zgO2W.mjs +16 -0
- package/dist/ref-resolution-_S4xTT2L-BE5zgO2W.mjs.map +1 -0
- package/dist/{refs-BDbB9BRB-D6Za3Q49.mjs → refs-B2BL8z3i-DGGFB7Mj.mjs} +6 -6
- package/dist/refs-B2BL8z3i-DGGFB7Mj.mjs.map +1 -0
- package/dist/refs-fQLFcMoq-UTlvnijY.mjs +47 -0
- package/dist/refs-fQLFcMoq-UTlvnijY.mjs.map +1 -0
- package/dist/{spaces-DxFj5y8l.d.mts → spaces-D5qtTlhj.d.mts} +2 -2
- package/dist/{spaces-DxFj5y8l.d.mts.map → spaces-D5qtTlhj.d.mts.map} +1 -1
- package/dist/{spaces-C27bA-xc.mjs → spaces-DxuvClN9.mjs} +7 -7
- package/dist/spaces-DxuvClN9.mjs.map +1 -0
- package/dist/{telemetry-CmbCa3Ld-CmE5zcIG.mjs → telemetry-DVBHDQd6-Ckn5oClN.mjs} +3 -3
- package/dist/{telemetry-CmbCa3Ld-CmE5zcIG.mjs.map → telemetry-DVBHDQd6-Ckn5oClN.mjs.map} +1 -1
- package/dist/{verify-DnVNjc5C-BGdsblBK.mjs → verify-C6L_hiJU-B4V3bqvG.mjs} +3 -3
- package/dist/{verify-DnVNjc5C-BGdsblBK.mjs.map → verify-C6L_hiJU-B4V3bqvG.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs → verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs} +4 -4
- package/dist/{verify-contract-spaces-BZDcJsuA-De8v4Z4T.mjs.map → verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/client-75qrAPqf-7l0C0H_b.mjs.map +0 -1
- package/dist/command-helpers-CAoXqAY9-DWUBcTXM.mjs.map +0 -1
- package/dist/config-loader.d.mts.map +0 -1
- package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs +0 -36
- package/dist/contract-at-errors-BX7w-p19-SxA8eaV2.mjs.map +0 -1
- package/dist/contract-emit-B6odMoem-C87PBvmo.mjs.map +0 -1
- package/dist/contract-infer-BnkqpftN-DwBzasOu.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-CFH-336b-BhAyRQEL.mjs.map +0 -1
- package/dist/db-init-bd0_x2Q8.mjs.map +0 -1
- package/dist/db-sign-vqiYfpjI.mjs.map +0 -1
- package/dist/db-update-Br0diOCo.mjs.map +0 -1
- package/dist/db-verify-CKPsRFrj-T7nSt7yT.mjs.map +0 -1
- package/dist/errors--qsXZUtL.d.mts.map +0 -1
- package/dist/errors-IpZm1Skp-BH495dRd.mjs.map +0 -1
- package/dist/format-ByDm2goZ-BIRlFoo6.mjs.map +0 -1
- package/dist/migrate-BdVFDKF2.mjs.map +0 -1
- package/dist/migration-check-DcwUnadt-jamDqOmM.mjs.map +0 -1
- package/dist/migration-graph-vmgkL3k4.mjs.map +0 -1
- package/dist/migration-list-BFBeo1_X-ckYMhETH.mjs +0 -228
- package/dist/migration-list-BFBeo1_X-ckYMhETH.mjs.map +0 -1
- package/dist/migration-log-CS5IWcNq-DI7FTHCA.mjs.map +0 -1
- package/dist/migration-new-GmW2anVb.mjs.map +0 -1
- package/dist/migration-path-target-D3Sj55PI-BICblCuk.mjs.map +0 -1
- package/dist/migration-plan-q_L84PN1-ClkGgtVz.mjs.map +0 -1
- package/dist/migration-show--pW4XhKs.mjs.map +0 -1
- package/dist/migration-status-CE7cQLDq-P1x1-BsZ.mjs.map +0 -1
- package/dist/project-import-root-CpwLCDLY-DkVwAnWj.mjs.map +0 -1
- package/dist/ref-advancement-CSPMoQs3-fEipZrdu.mjs +0 -57
- package/dist/ref-advancement-CSPMoQs3-fEipZrdu.mjs.map +0 -1
- package/dist/ref-sHE8zOcm.mjs +0 -171
- package/dist/ref-sHE8zOcm.mjs.map +0 -1
- package/dist/refs-BDbB9BRB-D6Za3Q49.mjs.map +0 -1
- package/dist/spaces-C27bA-xc.mjs.map +0 -1
- package/dist/types-DZWEs4si-D8UlyJI0.d.mts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-graph-Dn469b0l.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-graph.mjs"],"sourcesContent":["import { A as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { r as buildReadAggregate } from \"../contract-space-aggregate-loader-C5r12INu.mjs\";\nimport { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList, t as listRefsByContractHash } from \"../migration-list-C9OPCMt-.mjs\";\nimport { a as renderMigrationGraphLegend, f as indentMigrationGraphTreeBlock, l as computeGlobalMaxDirNameWidth, p as renderMigrationGraphSpaceTree, u as computeGlobalMaxEdgeTreePrefixWidth } from \"../migration-graph-command-render-BKrg6BPv.mjs\";\nimport { t as buildMigrationSpaceGraphEntries } from \"../migration-graph-HKch1Xk4.mjs\";\nimport { n as validateLegendOptions, t as shouldShowLegend } from \"../legend-5iwwlLU2.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { ok } from \"@internal/utils/result\";\n//#region src/commands/migration-graph.ts\nfunction computeGraphSummary(spaces) {\n\tconst contractCount = spaces.reduce((count, space) => count + space.contracts.length, 0);\n\tconst migrationCount = spaces.reduce((count, space) => count + space.migrations.length, 0);\n\treturn `${spaces.length} space(s), ${contractCount} contract(s), ${migrationCount} migration(s)`;\n}\nfunction formatMigrationGraphHumanOutput(result) {\n\tconst sections = [];\n\tfor (const section of result.treeSections) {\n\t\tif (section.showHeading) sections.push(`${section.space}:`);\n\t\tif (section.tree.length > 0) sections.push(section.tree);\n\t\telse sections.push(\"(no migrations)\");\n\t\tsections.push(\"\");\n\t}\n\tsections.push(result.summary);\n\treturn sections.join(\"\\n\").trimEnd();\n}\nasync function executeMigrationGraphCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsRelative, migrationsDir } = resolveMigrationPaths(options.config, config);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration graph\",\n\t\t\tdescription: \"Show the migration graph topology\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: migrationsRelative\n\t\t\t\t},\n\t\t\t\t...options.space !== void 0 ? [{\n\t\t\t\t\tlabel: \"space\",\n\t\t\t\t\tvalue: options.space\n\t\t\t\t}] : []\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return loaded;\n\tconst { aggregate, contractHash: liveContractHash } = loaded.value;\n\tconst appGraph = aggregate.app.graph();\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\tconst scopedSpaces = listResult.value.spaces;\n\tconst showSpaceHeadings = scopedSpaces.length > 1;\n\tconst glyphMode = ui.resolveGlyphMode(options.ascii === true);\n\tconst colorize = flags.color !== false;\n\tconst globalLayoutInputs = showSpaceHeadings ? scopedSpaces.filter((spaceEntry) => spaceEntry.migrations.length > 0).map((spaceEntry) => ({\n\t\tgraph: aggregate.space(spaceEntry.space).graph(),\n\t\tliveContractHash\n\t})) : [];\n\tconst globalMaxEdgeTreePrefixWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxEdgeTreePrefixWidth(globalLayoutInputs) : void 0;\n\tconst globalMaxDirNameWidth = globalLayoutInputs.length > 0 ? computeGlobalMaxDirNameWidth(globalLayoutInputs) : void 0;\n\tconst treeSections = [];\n\tfor (const spaceEntry of scopedSpaces) {\n\t\tconst space = aggregate.space(spaceEntry.space);\n\t\tif (space === void 0) continue;\n\t\tconst graph = space.graph();\n\t\tconst isAppSpace = spaceEntry.space === aggregate.app.spaceId;\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tconst tree = spaceEntry.migrations.length === 0 ? \"\" : renderMigrationGraphSpaceTree({\n\t\t\tgraph,\n\t\t\tmigrations: spaceEntry.migrations,\n\t\t\tliveContractHash,\n\t\t\tglyphMode,\n\t\t\tcolorize,\n\t\t\tisAppSpace,\n\t\t\trefsByHash,\n\t\t\t...globalMaxEdgeTreePrefixWidth !== void 0 ? { globalMaxEdgeTreePrefixWidth } : {},\n\t\t\t...globalMaxDirNameWidth !== void 0 ? { globalMaxDirNameWidth } : {}\n\t\t});\n\t\tconst displayTree = showSpaceHeadings && tree.length > 0 ? indentMigrationGraphTreeBlock(tree, \" \") : tree;\n\t\ttreeSections.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\ttree: displayTree,\n\t\t\tshowHeading: showSpaceHeadings\n\t\t});\n\t}\n\tconst spaces = [...buildMigrationSpaceGraphEntries({\n\t\taggregate,\n\t\tscopedSpaces\n\t})];\n\treturn ok({\n\t\tok: true,\n\t\tgraph: appGraph,\n\t\tspaces,\n\t\ttreeSections,\n\t\tsummary: computeGraphSummary(spaces)\n\t});\n}\nfunction createMigrationGraphCommand() {\n\tconst command = new Command(\"graph\");\n\tsetCommandDescriptions(command, \"Show the migration graph topology\", \"Renders the migration graph topology.\\nOffline — does not consult the database.\\n--ascii swaps box-drawing for pipe-friendly ASCII glyphs.\\nUse --json for machine-readable output, or --dot for Graphviz DOT\\nformat.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration graph\",\n\t\t\"prisma-next migration graph --json\",\n\t\t\"prisma-next migration graph --dot\",\n\t\t\"prisma-next migration graph --ascii\",\n\t\t\"prisma-next migration graph --legend\",\n\t\t\"prisma-next migration graph --space app\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--dot\", \"Output in Graphviz DOT format\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationGraphCommand(options, flags, ui), flags, ui, (graphResult) => {\n\t\t\tif (options.dot) {\n\t\t\t\tconst lines = [\"digraph migrations {\"];\n\t\t\t\tfor (const edge of graphResult.graph.migrationByHash.values()) {\n\t\t\t\t\tconst from = edge.from.slice(0, 12);\n\t\t\t\t\tconst to = edge.to.slice(0, 12);\n\t\t\t\t\tlines.push(` \"${from}\" -> \"${to}\" [label=\"${edge.dirName}\"];`);\n\t\t\t\t}\n\t\t\t\tlines.push(\"}\");\n\t\t\t\tui.output(lines.join(\"\\n\"));\n\t\t\t} else if (flags.json) {\n\t\t\t\tconst jsonResult = {\n\t\t\t\t\tok: true,\n\t\t\t\t\tspaces: [...graphResult.spaces],\n\t\t\t\t\tsummary: graphResult.summary\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(jsonResult, null, 2));\n\t\t\t} else if (!flags.quiet) ui.output(formatMigrationGraphHumanOutput(graphResult));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationGraphCommand, executeMigrationGraphCommand, formatMigrationGraphHumanOutput };\n\n//# sourceMappingURL=migration-graph.mjs.map"],"mappings":";;;;;;;;;;;AAWA,SAAS,oBAAoB,QAAQ;CACpC,MAAM,gBAAgB,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,UAAU,QAAQ,CAAC;CACvF,MAAM,iBAAiB,OAAO,QAAQ,OAAO,UAAU,QAAQ,MAAM,WAAW,QAAQ,CAAC;CACzF,OAAO,GAAG,OAAO,OAAO,aAAa,cAAc,gBAAgB,eAAe;AACnF;AACA,SAAS,gCAAgC,QAAQ;CAChD,MAAM,WAAW,CAAC;CAClB,KAAK,MAAM,WAAW,OAAO,cAAc;EAC1C,IAAI,QAAQ,aAAa,SAAS,KAAK,GAAG,QAAQ,MAAM,EAAE;EAC1D,IAAI,QAAQ,KAAK,SAAS,GAAG,SAAS,KAAK,QAAQ,IAAI;OAClD,SAAS,KAAK,iBAAiB;EACpC,SAAS,KAAK,EAAE;CACjB;CACA,SAAS,KAAK,OAAO,OAAO;CAC5B,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,QAAQ;AACpC;AACA,eAAe,6BAA6B,SAAS,OAAO,IAAI;CAC/D,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,EAAE,YAAY,oBAAoB,kBAAkB,sBAAsB,QAAQ,QAAQ,MAAM;CACtG,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,SAAS,mBAAmB;GACjC,SAAS;GACT,aAAa;GACb,SAAS;IACR;KACC,OAAO;KACP,OAAO;IACR;IACA;KACC,OAAO;KACP,OAAO;IACR;IACA,GAAG,QAAQ,UAAU,KAAK,IAAI,CAAC;KAC9B,OAAO;KACP,OAAO,QAAQ;IAChB,CAAC,IAAI,CAAC;GACP;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;EAChB,IAAI,iBAAiB,SAAS,KAAK,GAAG;GACrC,GAAG,OAAO,2B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,EAAE,GAAG,OAAO,KAAK,gBAAgB;GACjH,IAAI,QAAQ,KAAK;IAChB,MAAM,QAAQ,CAAC,sBAAsB;IACrC,KAAK,MAAM,QAAQ,YAAY,MAAM,gBAAgB,OAAO,GAAG;KAC9D,MAAM,OAAO,KAAK,KAAK,MAAM,GAAG,EAAE;KAClC,MAAM,KAAK,KAAK,GAAG,MAAM,GAAG,EAAE;KAC9B,MAAM,KAAK,MAAM,KAAK,QAAQ,GAAG,YAAY,KAAK,QAAQ,IAAI;IAC/D;IACA,MAAM,KAAK,GAAG;IACd,GAAG,OAAO,MAAM,KAAK,IAAI,CAAC;GAC3B,OAAO,IAAI,MAAM,MAAM;IACtB,MAAM,aAAa;KAClB,IAAI;KACJ,QAAQ,CAAC,GAAG,YAAY,MAAM;KAC9B,SAAS,YAAY;IACtB;IACA,GAAG,OAAO,KAAK,UAAU,YAAY,MAAM,CAAC,CAAC;GAC9C,OAAO,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,gCAAgC,WAAW,CAAC;EAChF,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
2
|
+
import { t as listRefsByContractHash } from "./migration-list-C9OPCMt--C28yBgVr.mjs";
|
|
3
|
+
//#region ../../../1-framework/3-tooling/cli/dist/migration-graph-HKch1Xk4.mjs
|
|
4
|
+
/**
|
|
5
|
+
* Project scoped list entries into the per-space contracts+migrations rows the migration
|
|
6
|
+
* graph --json output serializes (EMPTY_CONTRACT_HASH from-hash → null). Skips space ids
|
|
7
|
+
* the aggregate no longer resolves, mirroring the command loop.
|
|
8
|
+
*/
|
|
9
|
+
function buildMigrationSpaceGraphEntries(args) {
|
|
10
|
+
const spaces = [];
|
|
11
|
+
for (const spaceEntry of args.scopedSpaces) {
|
|
12
|
+
const space = args.aggregate.space(spaceEntry.space);
|
|
13
|
+
if (space === void 0) continue;
|
|
14
|
+
const graph = space.graph();
|
|
15
|
+
const refsByHash = listRefsByContractHash(space);
|
|
16
|
+
spaces.push({
|
|
17
|
+
space: spaceEntry.space,
|
|
18
|
+
contracts: [...graph.nodes].map((hash) => ({
|
|
19
|
+
hash,
|
|
20
|
+
refs: [...refsByHash.get(hash) ?? []]
|
|
21
|
+
})),
|
|
22
|
+
migrations: [...graph.migrationByHash.values()].map((edge) => ({
|
|
23
|
+
name: edge.dirName,
|
|
24
|
+
hash: edge.migrationHash,
|
|
25
|
+
fromContract: edge.from === "empty" ? null : edge.from,
|
|
26
|
+
toContract: edge.to
|
|
27
|
+
}))
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return spaces;
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { buildMigrationSpaceGraphEntries as t };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=migration-graph-HKch1Xk4-DyWhXtjZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-graph-HKch1Xk4-DyWhXtjZ.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-graph-HKch1Xk4.mjs"],"sourcesContent":["import { t as listRefsByContractHash } from \"./migration-list-C9OPCMt-.mjs\";\nimport { EMPTY_CONTRACT_HASH } from \"@internal/migration-tools/constants\";\n//#region src/control-api/operations/migration-graph.ts\n/**\n* Project scoped list entries into the per-space contracts+migrations rows the migration\n* graph --json output serializes (EMPTY_CONTRACT_HASH from-hash → null). Skips space ids\n* the aggregate no longer resolves, mirroring the command loop.\n*/\nfunction buildMigrationSpaceGraphEntries(args) {\n\tconst spaces = [];\n\tfor (const spaceEntry of args.scopedSpaces) {\n\t\tconst space = args.aggregate.space(spaceEntry.space);\n\t\tif (space === void 0) continue;\n\t\tconst graph = space.graph();\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tspaces.push({\n\t\t\tspace: spaceEntry.space,\n\t\t\tcontracts: [...graph.nodes].map((hash) => ({\n\t\t\t\thash,\n\t\t\t\trefs: [...refsByHash.get(hash) ?? []]\n\t\t\t})),\n\t\t\tmigrations: [...graph.migrationByHash.values()].map((edge) => ({\n\t\t\t\tname: edge.dirName,\n\t\t\t\thash: edge.migrationHash,\n\t\t\t\tfromContract: edge.from === EMPTY_CONTRACT_HASH ? null : edge.from,\n\t\t\t\ttoContract: edge.to\n\t\t\t}))\n\t\t});\n\t}\n\treturn spaces;\n}\n//#endregion\nexport { buildMigrationSpaceGraphEntries as t };\n\n//# sourceMappingURL=migration-graph-HKch1Xk4.mjs.map"],"mappings":";;;;;;;;AAQA,SAAS,gCAAgC,MAAM;CAC9C,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,cAAc,KAAK,cAAc;EAC3C,MAAM,QAAQ,KAAK,UAAU,MAAM,WAAW,KAAK;EACnD,IAAI,UAAU,KAAK,GAAG;EACtB,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,aAAa,uBAAuB,KAAK;EAC/C,OAAO,KAAK;GACX,OAAO,WAAW;GAClB,WAAW,CAAC,GAAG,MAAM,KAAK,CAAC,CAAC,KAAK,UAAU;IAC1C;IACA,MAAM,CAAC,GAAG,WAAW,IAAI,IAAI,KAAK,CAAC,CAAC;GACrC,EAAE;GACF,YAAY,CAAC,GAAG,MAAM,gBAAgB,OAAO,CAAC,CAAC,CAAC,KAAK,UAAU;IAC9D,MAAM,KAAK;IACX,MAAM,KAAK;IACX,cAAc,KAAK,SAAA,UAA+B,OAAO,KAAK;IAC9D,YAAY,KAAK;GAClB,EAAE;EACH,CAAC;CACF;CACA,OAAO;AACR"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { a as isValidSpaceId, o as listContractSpaceDirectories, t as APP_SPACE_ID } from "./verify-contract-spaces-WvjSiWcB-zGhaCnfs.mjs";
|
|
2
|
+
import { A as errorSpaceNotFound, _ as errorInvalidSpaceId } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
|
|
3
|
+
import { o as refsByContractHash, t as HEAD_REF_NAME } from "./refs-B2BL8z3i-DGGFB7Mj.mjs";
|
|
4
|
+
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
5
|
+
//#region ../../../1-framework/3-tooling/cli/dist/migration-list-C9OPCMt-.mjs
|
|
6
|
+
function compareSpaceIds(a, b) {
|
|
7
|
+
if (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;
|
|
8
|
+
if (b === APP_SPACE_ID) return 1;
|
|
9
|
+
if (a < b) return -1;
|
|
10
|
+
if (a > b) return 1;
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
function compareDirNamesDescending(a, b) {
|
|
14
|
+
if (a.name < b.name) return 1;
|
|
15
|
+
if (a.name > b.name) return -1;
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Ref names decorating a space's destination contract hashes. The
|
|
20
|
+
* tolerant `space.refs` deliberately omits the structural `head.json`;
|
|
21
|
+
* for extension spaces the old enumerator surfaced it as a `head`
|
|
22
|
+
* decoration on the tip migration, so fold `space.headRef` back in to
|
|
23
|
+
* keep that output. The app space synthesises its head, so it carries
|
|
24
|
+
* no on-disk `head` ref to restore.
|
|
25
|
+
*/
|
|
26
|
+
function listRefsByContractHash(space) {
|
|
27
|
+
const byHash = new Map(refsByContractHash(space.refs));
|
|
28
|
+
if (space.spaceId !== APP_SPACE_ID && space.headRef !== null) {
|
|
29
|
+
const hash = space.headRef.hash;
|
|
30
|
+
const bucket = byHash.get(hash) ?? [];
|
|
31
|
+
if (!bucket.includes("head")) byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());
|
|
32
|
+
}
|
|
33
|
+
return byHash;
|
|
34
|
+
}
|
|
35
|
+
async function orderedOnDiskSpaceIds(projectMigrationsDir) {
|
|
36
|
+
return (await listContractSpaceDirectories(projectMigrationsDir)).filter(isValidSpaceId).sort(compareSpaceIds);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Project the loaded {@link ContractSpaceAggregate} into the render-ready
|
|
40
|
+
* {@link MigrationSpaceListEntry} rows `migration list` displays.
|
|
41
|
+
*
|
|
42
|
+
* Space membership matches the on-disk contract-space directories (not the
|
|
43
|
+
* aggregate's always-present synthesized app space when `migrations/app/`
|
|
44
|
+
* is absent); package and ref data come from `aggregate.space(id)`.
|
|
45
|
+
*/
|
|
46
|
+
async function migrationSpaceListEntriesFromAggregate(aggregate, projectMigrationsDir) {
|
|
47
|
+
const spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);
|
|
48
|
+
const spaces = [];
|
|
49
|
+
for (const spaceId of spaceIds) {
|
|
50
|
+
const space = aggregate.space(spaceId);
|
|
51
|
+
if (space === void 0) continue;
|
|
52
|
+
const refsByHash = listRefsByContractHash(space);
|
|
53
|
+
const migrations = space.packages.map((pkg) => ({
|
|
54
|
+
name: pkg.dirName,
|
|
55
|
+
hash: pkg.metadata.migrationHash,
|
|
56
|
+
fromContract: pkg.metadata.from,
|
|
57
|
+
toContract: pkg.metadata.to,
|
|
58
|
+
operationCount: pkg.ops.length,
|
|
59
|
+
createdAt: pkg.metadata.createdAt,
|
|
60
|
+
refs: [...refsByHash.get(pkg.metadata.to) ?? []],
|
|
61
|
+
providedInvariants: [...pkg.metadata.providedInvariants]
|
|
62
|
+
})).sort(compareDirNamesDescending);
|
|
63
|
+
spaces.push({
|
|
64
|
+
space: spaceId,
|
|
65
|
+
migrations
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return spaces;
|
|
69
|
+
}
|
|
70
|
+
function computeSummary(spaces) {
|
|
71
|
+
const totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);
|
|
72
|
+
if (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;
|
|
73
|
+
return `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Policy core of `migration list`: validates `--space`, narrows the
|
|
77
|
+
* pre-enumerated spaces, and assembles a {@link MigrationListResult}.
|
|
78
|
+
*
|
|
79
|
+
* - `migrations/` missing or contains no valid space directories →
|
|
80
|
+
* caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.
|
|
81
|
+
* - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.
|
|
82
|
+
* - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.
|
|
83
|
+
*/
|
|
84
|
+
function runMigrationList(inputs) {
|
|
85
|
+
const { spaces, spaceFilter } = inputs;
|
|
86
|
+
if (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return notOk(errorInvalidSpaceId(spaceFilter));
|
|
87
|
+
if (spaceFilter !== void 0 && !spaces.some((s) => s.space === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.space).sort()));
|
|
88
|
+
const scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.space === spaceFilter) : spaces;
|
|
89
|
+
const resultSpaces = scopedSpaces.length === 0 ? [{
|
|
90
|
+
space: APP_SPACE_ID,
|
|
91
|
+
migrations: []
|
|
92
|
+
}] : scopedSpaces;
|
|
93
|
+
return ok({
|
|
94
|
+
ok: true,
|
|
95
|
+
spaces: [...resultSpaces],
|
|
96
|
+
summary: computeSummary(resultSpaces)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { migrationSpaceListEntriesFromAggregate as n, runMigrationList as r, listRefsByContractHash as t };
|
|
101
|
+
|
|
102
|
+
//# sourceMappingURL=migration-list-C9OPCMt--C28yBgVr.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-list-C9OPCMt--C28yBgVr.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-list-C9OPCMt-.mjs"],"sourcesContent":["import { K as errorInvalidSpaceId, at as errorSpaceNotFound } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { APP_SPACE_ID, isValidSpaceId, listContractSpaceDirectories } from \"@internal/migration-tools/spaces\";\nimport { HEAD_REF_NAME, refsByContractHash } from \"@internal/migration-tools/refs\";\n//#region src/control-api/operations/migration-list.ts\nfunction compareSpaceIds(a, b) {\n\tif (a === APP_SPACE_ID) return b === APP_SPACE_ID ? 0 : -1;\n\tif (b === APP_SPACE_ID) return 1;\n\tif (a < b) return -1;\n\tif (a > b) return 1;\n\treturn 0;\n}\nfunction compareDirNamesDescending(a, b) {\n\tif (a.name < b.name) return 1;\n\tif (a.name > b.name) return -1;\n\treturn 0;\n}\n/**\n* Ref names decorating a space's destination contract hashes. The\n* tolerant `space.refs` deliberately omits the structural `head.json`;\n* for extension spaces the old enumerator surfaced it as a `head`\n* decoration on the tip migration, so fold `space.headRef` back in to\n* keep that output. The app space synthesises its head, so it carries\n* no on-disk `head` ref to restore.\n*/\nfunction listRefsByContractHash(space) {\n\tconst byHash = new Map(refsByContractHash(space.refs));\n\tif (space.spaceId !== APP_SPACE_ID && space.headRef !== null) {\n\t\tconst hash = space.headRef.hash;\n\t\tconst bucket = byHash.get(hash) ?? [];\n\t\tif (!bucket.includes(HEAD_REF_NAME)) byHash.set(hash, [...bucket, HEAD_REF_NAME].sort());\n\t}\n\treturn byHash;\n}\nasync function orderedOnDiskSpaceIds(projectMigrationsDir) {\n\treturn (await listContractSpaceDirectories(projectMigrationsDir)).filter(isValidSpaceId).sort(compareSpaceIds);\n}\n/**\n* Project the loaded {@link ContractSpaceAggregate} into the render-ready\n* {@link MigrationSpaceListEntry} rows `migration list` displays.\n*\n* Space membership matches the on-disk contract-space directories (not the\n* aggregate's always-present synthesized app space when `migrations/app/`\n* is absent); package and ref data come from `aggregate.space(id)`.\n*/\nasync function migrationSpaceListEntriesFromAggregate(aggregate, projectMigrationsDir) {\n\tconst spaceIds = await orderedOnDiskSpaceIds(projectMigrationsDir);\n\tconst spaces = [];\n\tfor (const spaceId of spaceIds) {\n\t\tconst space = aggregate.space(spaceId);\n\t\tif (space === void 0) continue;\n\t\tconst refsByHash = listRefsByContractHash(space);\n\t\tconst migrations = space.packages.map((pkg) => ({\n\t\t\tname: pkg.dirName,\n\t\t\thash: pkg.metadata.migrationHash,\n\t\t\tfromContract: pkg.metadata.from,\n\t\t\ttoContract: pkg.metadata.to,\n\t\t\toperationCount: pkg.ops.length,\n\t\t\tcreatedAt: pkg.metadata.createdAt,\n\t\t\trefs: [...refsByHash.get(pkg.metadata.to) ?? []],\n\t\t\tprovidedInvariants: [...pkg.metadata.providedInvariants]\n\t\t})).sort(compareDirNamesDescending);\n\t\tspaces.push({\n\t\t\tspace: spaceId,\n\t\t\tmigrations\n\t\t});\n\t}\n\treturn spaces;\n}\nfunction computeSummary(spaces) {\n\tconst totalMigrations = spaces.reduce((count, space) => count + space.migrations.length, 0);\n\tif (spaces.length <= 1) return `${totalMigrations} migration(s) on disk`;\n\treturn `${totalMigrations} migration(s) across ${spaces.length} contract space(s)`;\n}\n/**\n* Policy core of `migration list`: validates `--space`, narrows the\n* pre-enumerated spaces, and assembles a {@link MigrationListResult}.\n*\n* - `migrations/` missing or contains no valid space directories →\n* caller passes `spaces: []`; this synthesizes `[{ spaceId: APP_SPACE_ID, migrations: [] }]`.\n* - `--space <id>` on an existing-but-empty space → `{ spaceId, migrations: [] }` in the input.\n* - `--space <id>` on a non-existent (or reserved) space → `SPACE_NOT_FOUND`.\n*/\nfunction runMigrationList(inputs) {\n\tconst { spaces, spaceFilter } = inputs;\n\tif (spaceFilter !== void 0 && !isValidSpaceId(spaceFilter)) return notOk(errorInvalidSpaceId(spaceFilter));\n\tif (spaceFilter !== void 0 && !spaces.some((s) => s.space === spaceFilter)) return notOk(errorSpaceNotFound(spaceFilter, spaces.map((s) => s.space).sort()));\n\tconst scopedSpaces = spaceFilter !== void 0 ? spaces.filter((s) => s.space === spaceFilter) : spaces;\n\tconst resultSpaces = scopedSpaces.length === 0 ? [{\n\t\tspace: APP_SPACE_ID,\n\t\tmigrations: []\n\t}] : scopedSpaces;\n\treturn ok({\n\t\tok: true,\n\t\tspaces: [...resultSpaces],\n\t\tsummary: computeSummary(resultSpaces)\n\t});\n}\n//#endregion\nexport { migrationSpaceListEntriesFromAggregate as n, runMigrationList as r, listRefsByContractHash as t };\n\n//# sourceMappingURL=migration-list-C9OPCMt-.mjs.map"],"mappings":";;;;;AAKA,SAAS,gBAAgB,GAAG,GAAG;CAC9B,IAAI,MAAM,cAAc,OAAO,MAAM,eAAe,IAAI;CACxD,IAAI,MAAM,cAAc,OAAO;CAC/B,IAAI,IAAI,GAAG,OAAO;CAClB,IAAI,IAAI,GAAG,OAAO;CAClB,OAAO;AACR;AACA,SAAS,0BAA0B,GAAG,GAAG;CACxC,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO;CAC5B,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO;CAC5B,OAAO;AACR;;;;;;;;;AASA,SAAS,uBAAuB,OAAO;CACtC,MAAM,SAAS,IAAI,IAAI,mBAAmB,MAAM,IAAI,CAAC;CACrD,IAAI,MAAM,YAAY,gBAAgB,MAAM,YAAY,MAAM;EAC7D,MAAM,OAAO,MAAM,QAAQ;EAC3B,MAAM,SAAS,OAAO,IAAI,IAAI,KAAK,CAAC;EACpC,IAAI,CAAC,OAAO,SAAA,MAAsB,GAAG,OAAO,IAAI,MAAM,CAAC,GAAG,QAAQ,aAAa,CAAC,CAAC,KAAK,CAAC;CACxF;CACA,OAAO;AACR;AACA,eAAe,sBAAsB,sBAAsB;CAC1D,QAAQ,MAAM,6BAA6B,oBAAoB,EAAA,CAAG,OAAO,cAAc,CAAC,CAAC,KAAK,eAAe;AAC9G;;;;;;;;;AASA,eAAe,uCAAuC,WAAW,sBAAsB;CACtF,MAAM,WAAW,MAAM,sBAAsB,oBAAoB;CACjE,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,QAAQ,UAAU,MAAM,OAAO;EACrC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Y;EACxB,SAAS,eAAe,YAAY;CACrC,CAAC;AACF"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { W as formatStyledHeader, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
|
|
2
|
+
import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
|
|
3
|
+
import { r as buildReadAggregate } from "./contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs";
|
|
4
|
+
import { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList } from "./migration-list-C9OPCMt--C28yBgVr.mjs";
|
|
5
|
+
import { g as renderMigrationGraphLegend, l as createAnsiMigrationListStyler, v as renderMigrationListWithStyle } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
|
|
6
|
+
import { n as validateLegendOptions, t as shouldShowLegend } from "./legend-5iwwlLU2-CB8bdQKJ.mjs";
|
|
7
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
8
|
+
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
9
|
+
import { Command } from "commander";
|
|
10
|
+
//#region ../../../1-framework/3-tooling/cli/dist/commands/migration-list.mjs
|
|
11
|
+
function renderMigrationListHumanOutput(result, options) {
|
|
12
|
+
return renderMigrationListWithStyle(result, createAnsiMigrationListStyler({ useColor: options.useColor }), options.glyphMode, {
|
|
13
|
+
colorize: options.useColor,
|
|
14
|
+
liveContractHash: options.liveContractHash,
|
|
15
|
+
graphForSpace: options.graphForSpace,
|
|
16
|
+
...options.appSpaceId !== void 0 ? { appSpaceId: options.appSpaceId } : {}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* CLI shell: loads config, resolves paths, prints the styled header on
|
|
21
|
+
* stderr (interactive mode only), and delegates to {@link runMigrationList}.
|
|
22
|
+
* Kept intentionally thin so the unit-testable surface lives in the core.
|
|
23
|
+
*/
|
|
24
|
+
async function executeMigrationListCommand(options, flags, ui) {
|
|
25
|
+
const config = await loadConfig(options.config);
|
|
26
|
+
const { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);
|
|
27
|
+
if (!flags.json && !flags.quiet) {
|
|
28
|
+
const header = formatStyledHeader({
|
|
29
|
+
command: "migration list",
|
|
30
|
+
description: "List on-disk migrations per contract space",
|
|
31
|
+
details: [
|
|
32
|
+
{
|
|
33
|
+
label: "config",
|
|
34
|
+
value: configPath
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "migrations",
|
|
38
|
+
value: migrationsRelative
|
|
39
|
+
},
|
|
40
|
+
...options.space !== void 0 ? [{
|
|
41
|
+
label: "space",
|
|
42
|
+
value: options.space
|
|
43
|
+
}] : []
|
|
44
|
+
],
|
|
45
|
+
flags
|
|
46
|
+
});
|
|
47
|
+
ui.stderr(header);
|
|
48
|
+
if (shouldShowLegend(options, flags)) {
|
|
49
|
+
ui.stderr(renderMigrationGraphLegend({
|
|
50
|
+
colorize: flags.color !== false,
|
|
51
|
+
glyphMode: ui.resolveGlyphMode(options.ascii === true)
|
|
52
|
+
}));
|
|
53
|
+
ui.stderr("");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const loaded = await buildReadAggregate(config, { migrationsDir });
|
|
57
|
+
if (!loaded.ok) return notOk(loaded.failure);
|
|
58
|
+
const { aggregate, contractHash: liveContractHash } = loaded.value;
|
|
59
|
+
const listResult = runMigrationList({
|
|
60
|
+
spaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),
|
|
61
|
+
...ifDefined("spaceFilter", options.space)
|
|
62
|
+
});
|
|
63
|
+
if (!listResult.ok) return listResult;
|
|
64
|
+
return ok({
|
|
65
|
+
list: listResult.value,
|
|
66
|
+
liveContractHash,
|
|
67
|
+
aggregate
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function createMigrationListCommand() {
|
|
71
|
+
const command = new Command("list");
|
|
72
|
+
setCommandDescriptions(command, "List on-disk migrations per contract space", "Enumerates every on-disk migration under migrations/<space>/ for every\ncontract space found on disk. Offline — does not consult the database.\nHuman output draws the shared migration graph tree with operation counts,\ninvariants on each migration row, and refs on destination contract nodes.\nPass --space <id> to narrow to one contract space. --ascii forces ASCII\ntree glyphs (orthogonal to --no-color).");
|
|
73
|
+
setCommandExamples(command, [
|
|
74
|
+
"prisma-next migration list",
|
|
75
|
+
"prisma-next migration list --space app",
|
|
76
|
+
"prisma-next migration list --ascii",
|
|
77
|
+
"prisma-next migration list --legend",
|
|
78
|
+
"prisma-next migration list --json"
|
|
79
|
+
]);
|
|
80
|
+
setCommandSeeAlso(command, [
|
|
81
|
+
{
|
|
82
|
+
verb: "migration status",
|
|
83
|
+
oneLiner: "Show migration path and pending status"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
verb: "migration log",
|
|
87
|
+
oneLiner: "Show executed migration history"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
verb: "migration graph",
|
|
91
|
+
oneLiner: "Show the migration graph topology"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
verb: "migration show",
|
|
95
|
+
oneLiner: "Display migration package contents"
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
addGlobalOptions(command).option("--config <path>", "Path to prisma-next.config.ts").option("--space <id>", "Narrow output to a single contract space").option("--ascii", "Use ASCII kind glyphs (pipe-friendly)").option("--legend", "Print a key for the tree glyphs and lane colors").action(async (options) => {
|
|
99
|
+
const flags = parseGlobalFlagsOrExit(options);
|
|
100
|
+
const ui = createTerminalUI(flags);
|
|
101
|
+
const legendValidation = validateLegendOptions(options, flags);
|
|
102
|
+
if (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));
|
|
103
|
+
const exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, ({ list, liveContractHash, aggregate }) => {
|
|
104
|
+
if (flags.json) ui.output(JSON.stringify(list, null, 2));
|
|
105
|
+
else if (!flags.quiet) ui.output(renderMigrationListHumanOutput(list, {
|
|
106
|
+
glyphMode: ui.resolveGlyphMode(options.ascii === true),
|
|
107
|
+
useColor: ui.useColor,
|
|
108
|
+
liveContractHash,
|
|
109
|
+
graphForSpace: (spaceId) => aggregate.space(spaceId)?.graph(),
|
|
110
|
+
appSpaceId: aggregate.app.spaceId
|
|
111
|
+
}));
|
|
112
|
+
});
|
|
113
|
+
process.exit(exitCode);
|
|
114
|
+
});
|
|
115
|
+
return command;
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
export { executeMigrationListCommand as n, renderMigrationListHumanOutput as r, createMigrationListCommand as t };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=migration-list-jk4iCtmO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-list-jk4iCtmO.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-list.mjs"],"sourcesContent":["import { A as formatStyledHeader, _ as createTerminalUI, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { r as buildReadAggregate } from \"../contract-space-aggregate-loader-C5r12INu.mjs\";\nimport { n as migrationSpaceListEntriesFromAggregate, r as runMigrationList } from \"../migration-list-C9OPCMt-.mjs\";\nimport { a as renderMigrationGraphLegend, c as renderMigrationListWithStyle, o as createAnsiMigrationListStyler } from \"../migration-graph-command-render-BKrg6BPv.mjs\";\nimport { n as validateLegendOptions, t as shouldShowLegend } from \"../legend-5iwwlLU2.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\n//#region src/commands/migration-list.ts\nfunction renderMigrationListHumanOutput(result, options) {\n\treturn renderMigrationListWithStyle(result, createAnsiMigrationListStyler({ useColor: options.useColor }), options.glyphMode, {\n\t\tcolorize: options.useColor,\n\t\tliveContractHash: options.liveContractHash,\n\t\tgraphForSpace: options.graphForSpace,\n\t\t...options.appSpaceId !== void 0 ? { appSpaceId: options.appSpaceId } : {}\n\t});\n}\n/**\n* CLI shell: loads config, resolves paths, prints the styled header on\n* stderr (interactive mode only), and delegates to {@link runMigrationList}.\n* Kept intentionally thin so the unit-testable surface lives in the core.\n*/\nasync function executeMigrationListCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath, migrationsDir, migrationsRelative } = resolveMigrationPaths(options.config, config);\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration list\",\n\t\t\tdescription: \"List on-disk migrations per contract space\",\n\t\t\tdetails: [\n\t\t\t\t{\n\t\t\t\t\tlabel: \"config\",\n\t\t\t\t\tvalue: configPath\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tlabel: \"migrations\",\n\t\t\t\t\tvalue: migrationsRelative\n\t\t\t\t},\n\t\t\t\t...options.space !== void 0 ? [{\n\t\t\t\t\tlabel: \"space\",\n\t\t\t\t\tvalue: options.space\n\t\t\t\t}] : []\n\t\t\t],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t\tif (shouldShowLegend(options, flags)) {\n\t\t\tui.stderr(renderMigrationGraphLegend({\n\t\t\t\tcolorize: flags.color !== false,\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t}));\n\t\t\tui.stderr(\"\");\n\t\t}\n\t}\n\tconst loaded = await buildReadAggregate(config, { migrationsDir });\n\tif (!loaded.ok) return notOk(loaded.failure);\n\tconst { aggregate, contractHash: liveContractHash } = loaded.value;\n\tconst listResult = runMigrationList({\n\t\tspaces: await migrationSpaceListEntriesFromAggregate(aggregate, migrationsDir),\n\t\t...ifDefined(\"spaceFilter\", options.space)\n\t});\n\tif (!listResult.ok) return listResult;\n\treturn ok({\n\t\tlist: listResult.value,\n\t\tliveContractHash,\n\t\taggregate\n\t});\n}\nfunction createMigrationListCommand() {\n\tconst command = new Command(\"list\");\n\tsetCommandDescriptions(command, \"List on-disk migrations per contract space\", \"Enumerates every on-disk migration under migrations/<space>/ for every\\ncontract space found on disk. Offline — does not consult the database.\\nHuman output draws the shared migration graph tree with operation counts,\\ninvariants on each migration row, and refs on destination contract nodes.\\nPass --space <id> to narrow to one contract space. --ascii forces ASCII\\ntree glyphs (orthogonal to --no-color).\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration list\",\n\t\t\"prisma-next migration list --space app\",\n\t\t\"prisma-next migration list --ascii\",\n\t\t\"prisma-next migration list --legend\",\n\t\t\"prisma-next migration list --json\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration log\",\n\t\t\toneLiner: \"Show executed migration history\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--space <id>\", \"Narrow output to a single contract space\").option(\"--ascii\", \"Use ASCII kind glyphs (pipe-friendly)\").option(\"--legend\", \"Print a key for the tree glyphs and lane colors\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst legendValidation = validateLegendOptions(options, flags);\n\t\tif (!legendValidation.ok) process.exit(handleResult(legendValidation, flags, ui));\n\t\tconst exitCode = handleResult(await executeMigrationListCommand(options, flags, ui), flags, ui, ({ list, liveContractHash, aggregate }) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(list, null, 2));\n\t\t\telse if (!flags.quiet) ui.output(renderMigrationListHumanOutput(list, {\n\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true),\n\t\t\t\tuseColor: ui.useColor,\n\t\t\t\tliveContractHash,\n\t\t\t\tgraphForSpace: (spaceId) => aggregate.space(spaceId)?.graph(),\n\t\t\t\tappSpaceId: aggregate.app.spaceId\n\t\t\t}));\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationListCommand, executeMigrationListCommand, renderMigrationListHumanOutput };\n\n//# sourceMappingURL=migration-list.mjs.map"],"mappings":";;;;;;;;;;AAUA,SAAS,+BAA+B,QAAQ,SAAS;CACxD,OAAO,6BAA6B,QAAQ,8BAA8B,EAAE,UAAU,QAAQ,SAAS,CAAC,GAAG,QAAQ,WAAW;EAC7H,UAAU,QAAQ;EAClB,kBAAkB,QAAQ;EAC1B,eAAe,QAAQ;EACvB,GAAG,QAAQ,eAAe,KAAK,IAAI,EAAE,YAAY,QAAQ,WAAW,IAAI,CAAC;CAC1E,CAAC;AACF;;;;;;AAMA,eAAe,4BAA4B,SAAS,OAAO,IAAI;CAC9D,MAAM,SAAS,MAAM,WAAW,QAAQ,MAAM;CAC9C,MAAM,EAAE,YAAY,eAAe,uBAAuB,sBAAsB,QAAQ,QAAQ,MAAM;CACtG,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;EAChC,MAAM,SAAS,mBAAmB;GACjC,SAAS;GACT,aAAa;GACb,SAAS;IACR;KACC,OAAO;KACP,OAAO;IACR;IACA;KACC,OAAO;KACP,OAAO;IACR;IACA,GAAG,QAAQ,UAAU,KAAK,IAAI,CAAC;KAC9B,OAAO;KACP,OAAO,QAAQ;IAChB,CAAC,IAAI,CAAC;GACP;GACA;EACD,CAAC;EACD,GAAG,OAAO,MAAM;EAChB,IAAI,iBAAiB,SAAS,KAAK,GAAG;GACrC,GAAG,OAAO,2BAA2B;IACpC,UAAU,MAAM,U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AAE,MAAM,kBAAkB,gBAAgB;GAC1I,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,OAAO,GAAG,OAAO,+BAA+B,MAAM;IACrE,WAAW,GAAG,iBAAiB,QAAQ,UAAU,IAAI;IACrD,UAAU,GAAG;IACb;IACA,gBAAgB,YAAY,UAAU,MAAM,OAAO,CAAC,EAAE,MAAM;IAC5D,YAAY,UAAU,IAAI;GAC3B,CAAC,CAAC;EACH,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { $ as maskConnectionUrl, N as errorUnexpected, W as formatStyledHeader, Z as mapMigrationToolsError, at as resolveMigrationPaths, ct as setCommandExamples, lt as setCommandSeeAlso, o as createTerminalUI, q as handleResult, r as addGlobalOptions, rt as requireLiveDatabase, st as setCommandDescriptions, t as CliStructuredError$1, tt as parseGlobalFlagsOrExit, ut as targetSupportsMigrations } from "./command-helpers-CAoXqAY9-DWUBcTXM.mjs";
|
|
1
|
+
import { N as errorUnexpected, Q as maskConnectionUrl, W as formatStyledHeader, ct as setCommandSeeAlso, et as parseGlobalFlagsOrExit, it as resolveMigrationPaths, lt as targetSupportsMigrations, nt as requireLiveDatabase, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
|
|
3
2
|
import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
|
|
4
|
-
import { t as createControlClient } from "./client-
|
|
3
|
+
import { t as createControlClient } from "./client-Y6qbDk7X-BzKLmBZo.mjs";
|
|
5
4
|
import { l as createAnsiMigrationListStyler, m as migrationListForwardArrow, n as abbreviateContractHash, p as migrationListEmptySource, t as IDENTITY_MIGRATION_LIST_STYLER } from "./migration-graph-command-render-BKrg6BPv-BP8Pfj4J.mjs";
|
|
5
|
+
import { t as mapCaughtMigrationError } from "./caught-errors-D7Qznyrm-BzYooF6H.mjs";
|
|
6
6
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
7
7
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
8
8
|
import stringWidth from "string-width";
|
|
9
9
|
import { Command } from "commander";
|
|
10
|
-
//#region ../../../1-framework/3-tooling/cli/dist/migration-log-
|
|
10
|
+
//#region ../../../1-framework/3-tooling/cli/dist/migration-log-DQzUBrm8.mjs
|
|
11
11
|
const HEADING_APPLIED_AT = "Applied at";
|
|
12
12
|
const HEADING_SPACE = "Space";
|
|
13
13
|
const HEADING_MIGRATION = "Migration";
|
|
@@ -155,8 +155,8 @@ async function executeMigrationLogCommand(options, flags, ui) {
|
|
|
155
155
|
await client.connect(dbConnection);
|
|
156
156
|
return ok(await client.readLedger());
|
|
157
157
|
} catch (error) {
|
|
158
|
-
|
|
159
|
-
if (
|
|
158
|
+
const mapped = mapCaughtMigrationError(error);
|
|
159
|
+
if (mapped) return notOk(mapped);
|
|
160
160
|
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migration log: ${error instanceof Error ? error.message : String(error)}` }));
|
|
161
161
|
} finally {
|
|
162
162
|
await client.close();
|
|
@@ -217,4 +217,4 @@ function createMigrationLogCommand() {
|
|
|
217
217
|
//#endregion
|
|
218
218
|
export { executeMigrationLogCommand as n, createMigrationLogCommand as t };
|
|
219
219
|
|
|
220
|
-
//# sourceMappingURL=migration-log-
|
|
220
|
+
//# sourceMappingURL=migration-log-DQzUBrm8-D3m9wcuf.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-log-DQzUBrm8-D3m9wcuf.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-log-DQzUBrm8.mjs"],"sourcesContent":["import { A as formatStyledHeader, _ as createTerminalUI, ct as errorUnexpected, d as setCommandSeeAlso, f as targetSupportsMigrations, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, s as resolveMigrationPaths, t as addGlobalOptions, u as setCommandExamples, ut as requireLiveDatabase, y as handleResult } from \"./command-helpers-C4WpR-QE.mjs\";\nimport { t as createControlClient } from \"./client-Y6qbDk7X.mjs\";\nimport { t as mapCaughtMigrationError } from \"./caught-errors-D7Qznyrm.mjs\";\nimport { _ as migrationListEmptySource, g as abbreviateContractHash, o as createAnsiMigrationListStyler, s as IDENTITY_MIGRATION_LIST_STYLER, v as migrationListForwardArrow } from \"./migration-graph-command-render-BKrg6BPv.mjs\";\nimport { Command } from \"commander\";\nimport { loadConfig } from \"@internal/config-loader\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport stringWidth from \"string-width\";\n//#region src/utils/formatters/migration-log-table.ts\nconst HEADING_APPLIED_AT = \"Applied at\";\nconst HEADING_SPACE = \"Space\";\nconst HEADING_MIGRATION = \"Migration\";\nconst HEADING_CHANGE = \"Change\";\nconst HEADING_OPS = \"Ops\";\nconst COLUMN_SEPARATOR = \" \";\nconst DIVIDER_CHAR = \"─\";\nconst ASCII_DIVIDER_CHAR = \"-\";\nfunction sortLedgerEntries(entries) {\n\treturn [...entries].sort((left, right) => {\n\t\tconst timeDiff = left.appliedAt.getTime() - right.appliedAt.getTime();\n\t\tif (timeDiff !== 0) return timeDiff;\n\t\tconst spaceDiff = left.space.localeCompare(right.space);\n\t\tif (spaceDiff !== 0) return spaceDiff;\n\t\treturn left.migrationName.localeCompare(right.migrationName);\n\t});\n}\nfunction pad2(value) {\n\treturn String(value).padStart(2, \"0\");\n}\nfunction formatLedgerAppliedAt(date, mode) {\n\tif (mode === \"iso\") return date.toISOString();\n\tif (mode === \"utc\") return `${date.getUTCFullYear()}-${pad2(date.getUTCMonth() + 1)}-${pad2(date.getUTCDate())} ${pad2(date.getUTCHours())}:${pad2(date.getUTCMinutes())}:${pad2(date.getUTCSeconds())}Z`;\n\tconst offsetMinutes = -date.getTimezoneOffset();\n\tconst sign = offsetMinutes >= 0 ? \"+\" : \"-\";\n\tconst absoluteOffset = Math.abs(offsetMinutes);\n\tconst offsetHours = pad2(Math.floor(absoluteOffset / 60));\n\tconst offsetMins = pad2(absoluteOffset % 60);\n\treturn `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}:${pad2(date.getSeconds())} ${sign}${offsetHours}:${offsetMins}`;\n}\nfunction formatHashEndpoint(hash, glyphMode = \"unicode\") {\n\tif (hash === null) return migrationListEmptySource(glyphMode);\n\treturn abbreviateContractHash(hash);\n}\nfunction formatHashTransition(from, to, glyphMode = \"unicode\") {\n\treturn `${formatHashEndpoint(from, glyphMode)} ${migrationListForwardArrow(glyphMode)} ${abbreviateContractHash(to)}`;\n}\nfunction styleHashTransition(from, to, styler, glyphMode = \"unicode\") {\n\treturn `${from === null ? styler.glyph(migrationListEmptySource(glyphMode)) : styler.sourceHash(abbreviateContractHash(from))} ${styler.glyph(migrationListForwardArrow(glyphMode))} ${styler.destHash(abbreviateContractHash(to))}`;\n}\nfunction padVisible(text, targetWidth) {\n\tconst padding = Math.max(0, targetWidth - stringWidth(text));\n\treturn text + \" \".repeat(padding);\n}\nfunction columnWidth(values) {\n\treturn values.reduce((max, value) => Math.max(max, stringWidth(value)), 0);\n}\nfunction padDividerCell(valueWidth, dividerChar) {\n\treturn dividerChar.repeat(valueWidth + 2);\n}\nfunction padTextCell(value, valueWidth) {\n\treturn ` ${padVisible(value, valueWidth)} `;\n}\nfunction padOpsCell(value, valueWidth) {\n\tconst padding = Math.max(0, valueWidth - stringWidth(value));\n\treturn ` ${\" \".repeat(padding)}${value} `;\n}\nfunction renderMigrationLogTable(entries, options = {}) {\n\tconst sorted = sortLedgerEntries(entries);\n\tif (sorted.length === 0) return \"\";\n\tconst styler = options.styler ?? IDENTITY_MIGRATION_LIST_STYLER;\n\tconst glyphMode = options.glyphMode ?? \"unicode\";\n\tconst dividerChar = glyphMode === \"ascii\" ? ASCII_DIVIDER_CHAR : DIVIDER_CHAR;\n\tconst showSpace = new Set(sorted.map((entry) => entry.space)).size > 1;\n\tconst timestampMode = options.utc ? \"utc\" : \"local\";\n\tconst rows = sorted.map((entry) => ({\n\t\tappliedAt: formatLedgerAppliedAt(entry.appliedAt, timestampMode),\n\t\tspace: entry.space,\n\t\tmigrationName: entry.migrationName,\n\t\ttransition: formatHashTransition(entry.from, entry.to, glyphMode),\n\t\tops: `${entry.operationCount} ops`,\n\t\tfrom: entry.from,\n\t\tto: entry.to\n\t}));\n\tconst appliedAtWidth = columnWidth([HEADING_APPLIED_AT, ...rows.map((row) => row.appliedAt)]);\n\tconst spaceWidth = showSpace ? columnWidth([HEADING_SPACE, ...rows.map((row) => row.space)]) : 0;\n\tconst nameWidth = columnWidth([HEADING_MIGRATION, ...rows.map((row) => row.migrationName)]);\n\tconst transitionWidth = columnWidth([HEADING_CHANGE, ...rows.map((row) => row.transition)]);\n\tconst opsWidth = columnWidth([HEADING_OPS, ...rows.map((row) => row.ops)]);\n\tconst headingParts = [padTextCell(HEADING_APPLIED_AT, appliedAtWidth)];\n\tif (showSpace) headingParts.push(padTextCell(HEADING_SPACE, spaceWidth));\n\theadingParts.push(padTextCell(HEADING_MIGRATION, nameWidth), padTextCell(HEADING_CHANGE, transitionWidth), padOpsCell(HEADING_OPS, opsWidth));\n\tconst heading = headingParts.join(COLUMN_SEPARATOR);\n\tconst dividerParts = [padDividerCell(appliedAtWidth, dividerChar)];\n\tif (showSpace) dividerParts.push(padDividerCell(spaceWidth, dividerChar));\n\tdividerParts.push(padDividerCell(nameWidth, dividerChar), padDividerCell(transitionWidth, dividerChar), padDividerCell(opsWidth, dividerChar));\n\treturn [\n\t\theading,\n\t\tdividerParts.map((cell) => styler.summary(cell)).join(COLUMN_SEPARATOR),\n\t\t...rows.map((row) => {\n\t\t\tconst parts = [padTextCell(row.appliedAt, appliedAtWidth)];\n\t\t\tif (showSpace) parts.push(padTextCell(row.space, spaceWidth));\n\t\t\tparts.push(padTextCell(styler.dirName(row.migrationName), nameWidth), padTextCell(styleHashTransition(row.from, row.to, styler, glyphMode), transitionWidth), padOpsCell(row.ops, opsWidth));\n\t\t\treturn parts.join(COLUMN_SEPARATOR);\n\t\t})\n\t].join(\"\\n\");\n}\nfunction serializeLedgerEntriesForJson(entries) {\n\treturn sortLedgerEntries(entries).map((entry) => ({\n\t\tspace: entry.space,\n\t\tname: entry.migrationName,\n\t\thash: entry.migrationHash,\n\t\tfromContract: entry.from,\n\t\ttoContract: entry.to,\n\t\tappliedAt: formatLedgerAppliedAt(entry.appliedAt, \"iso\"),\n\t\toperationCount: entry.operationCount\n\t}));\n}\nconst MIGRATION_LOG_EMPTY_MESSAGE = \"No migrations have been applied to this database.\";\n//#endregion\n//#region src/commands/migration-log.ts\nasync function executeMigrationLogCommand(options, flags, ui) {\n\tconst config = await loadConfig(options.config);\n\tconst { configPath } = resolveMigrationPaths(options.config, config);\n\tconst dbConnection = options.db ?? config.db?.connection;\n\tconst missingDb = requireLiveDatabase({\n\t\tdbConnection,\n\t\thasDriver: !!config.driver,\n\t\twhy: `migration log needs a database connection and driver to read the ledger (set db.connection in ${configPath}, or pass --db <url>)`,\n\t\tcommandName: \"migration log\"\n\t});\n\tif (missingDb) return notOk(missingDb);\n\tif (!targetSupportsMigrations(config.target)) return notOk(errorUnexpected(\"Target does not support migrations\"));\n\tif (!flags.json && !flags.quiet) {\n\t\tconst header = formatStyledHeader({\n\t\t\tcommand: \"migration log\",\n\t\t\tdescription: \"Show executed migration history from the database ledger\",\n\t\t\tdetails: [{\n\t\t\t\tlabel: \"config\",\n\t\t\t\tvalue: configPath\n\t\t\t}, ...typeof dbConnection === \"string\" ? [{\n\t\t\t\tlabel: \"database\",\n\t\t\t\tvalue: maskConnectionUrl(dbConnection)\n\t\t\t}] : []],\n\t\t\tflags\n\t\t});\n\t\tui.stderr(header);\n\t}\n\tconst client = createControlClient({\n\t\tfamily: config.family,\n\t\ttarget: config.target,\n\t\tadapter: config.adapter,\n\t\t...ifDefined(\"driver\", config.driver),\n\t\textensions: config.extensions ?? []\n\t});\n\ttry {\n\t\tawait client.connect(dbConnection);\n\t\treturn ok(await client.readLedger());\n\t} catch (error) {\n\t\tconst mapped = mapCaughtMigrationError(error);\n\t\tif (mapped) return notOk(mapped);\n\t\treturn notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migration log: ${error instanceof Error ? error.message : String(error)}` }));\n\t} finally {\n\t\tawait client.close();\n\t}\n}\nfunction createMigrationLogCommand() {\n\tconst command = new Command(\"log\");\n\tsetCommandDescriptions(command, \"Show executed migration history\", \"Reads the database ledger and displays every applied migration edge\\nin chronological order, including rollbacks and re-applies, merged\\nacross all contract spaces. Requires a database connection.\");\n\tsetCommandExamples(command, [\n\t\t\"prisma-next migration log --db $DATABASE_URL\",\n\t\t\"prisma-next migration log --utc --db $DATABASE_URL\",\n\t\t\"prisma-next migration log --json --db $DATABASE_URL\"\n\t]);\n\tsetCommandSeeAlso(command, [\n\t\t{\n\t\t\tverb: \"migration status\",\n\t\t\toneLiner: \"Show migration path and pending status\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration list\",\n\t\t\toneLiner: \"List on-disk migrations\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration graph\",\n\t\t\toneLiner: \"Show the migration graph topology\"\n\t\t},\n\t\t{\n\t\t\tverb: \"migration show\",\n\t\t\toneLiner: \"Display migration package contents\"\n\t\t}\n\t]);\n\taddGlobalOptions(command).option(\"--db <url>\", \"Database connection string\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").option(\"--utc\", \"Render human timestamps in UTC instead of local time\").option(\"--ascii\", \"Use ASCII glyphs (pipe-friendly)\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tconst exitCode = handleResult(await executeMigrationLogCommand(options, flags, ui), flags, ui, (entries) => {\n\t\t\tif (flags.json) {\n\t\t\t\tconst records = serializeLedgerEntriesForJson(entries);\n\t\t\t\tconst result = {\n\t\t\t\t\tok: true,\n\t\t\t\t\trecords,\n\t\t\t\t\tsummary: `${records.length} migration(s) applied`\n\t\t\t\t};\n\t\t\t\tui.output(JSON.stringify(result, null, 2));\n\t\t\t} else if (!flags.quiet) if (entries.length === 0) ui.output(MIGRATION_LOG_EMPTY_MESSAGE);\n\t\t\telse {\n\t\t\t\tconst styler = createAnsiMigrationListStyler({ useColor: ui.useColor });\n\t\t\t\tui.output(renderMigrationLogTable(entries, {\n\t\t\t\t\tutc: options.utc === true,\n\t\t\t\t\tstyler,\n\t\t\t\t\tglyphMode: ui.resolveGlyphMode(options.ascii === true)\n\t\t\t\t}));\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { executeMigrationLogCommand as n, createMigrationLogCommand as t };\n\n//# sourceMappingURL=migration-log-DQzUBrm8.mjs.map"],"mappings":";;;;;;;;;;AAUA,MAAM,qBAAqB;AAC3B,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,qBAAqB;AAC3B,SAAS,kBAAkB,SAAS;CACnC,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,MAAM,UAAU;EACzC,MAAM,WAAW,KAAK,UAAU,QAAQ,IAAI,MAAM,UAAU,QAAQ;EACpE,IAAI,aAAa,GAAG,OAAO;EAC3B,MAAM,YAAY,KAAK,MAAM,cAAc,MAAM,KAAK;EACtD,IAAI,cAAc,GAAG,OAAO;EAC5B,OAAO,KAAK,cAAc,cAAc,MAAM,aAAa;CAC5D,CAAC;AACF;AACA,SAAS,KAAK,OAAO;CACpB,OAAO,OAAO,KAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACrC;AACA,SAAS,sBAAsB,MAAM,MAAM;CAC1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AM,SAAS,8BAA8B,EAAE,UAAU,GAAG,SAAS,CAAC;IACtE,GAAG,OAAO,wBAAwB,SAAS;KAC1C,KAAK,QAAQ,QAAQ;KACrB;KACA,WAAW,GAAG,iBAAiB,QAAQ,UAAU,IAAI;IACtD,CAAC,CAAC;GACH;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { W as formatStyledHeader, et as parseGlobalFlagsOrExit, o as createTerminalUI, ot as setCommandDescriptions, q as handleResult, r as addGlobalOptions, st as setCommandExamples } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
|
|
2
|
+
import { t as executeMigrationNewCommand } from "./migration-new-g98oB3nC-BcrkxAAt.mjs";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
//#region ../../../1-framework/3-tooling/cli/dist/commands/migration-new.mjs
|
|
5
|
+
/**
|
|
6
|
+
* `migration new` — scaffolds a migration package with a `migration.ts` file
|
|
7
|
+
* for manual authoring.
|
|
8
|
+
*
|
|
9
|
+
* The planner's `emptyMigration(context)` returns a
|
|
10
|
+
* `MigrationPlanWithAuthoringSurface`, whose `renderTypeScript(resolver)`
|
|
11
|
+
* produces the target-appropriate empty stub. The CLI writes the returned
|
|
12
|
+
* source verbatim.
|
|
13
|
+
*
|
|
14
|
+
* The resolver is the one this project's own manifest implies, so the
|
|
15
|
+
* scaffold names packages the project can resolve — the same resolver
|
|
16
|
+
* `contract emit` hands to the emitter (ADR 242).
|
|
17
|
+
*/
|
|
18
|
+
function createMigrationNewCommand() {
|
|
19
|
+
const command = new Command("new");
|
|
20
|
+
setCommandDescriptions(command, "Scaffold a new migration for manual authoring", "Creates a migration package with a migration.ts file for manual authoring.\nWrite the migration body in migration.ts, then run the file with Node\n(`node migration.ts`) to self-emit ops.json and attest the package.");
|
|
21
|
+
setCommandExamples(command, ["prisma-next migration new --name split-name", "prisma-next migration new --name custom-fk --from abc123..."]);
|
|
22
|
+
addGlobalOptions(command).option("--name <slug>", "Migration name (used in directory name)").option("--from <hash>", "Starting contract hash (default: latest migration target)").option("--config <path>", "Path to prisma-next.config.ts").action(async (options) => {
|
|
23
|
+
const flags = parseGlobalFlagsOrExit(options);
|
|
24
|
+
const ui = createTerminalUI(flags);
|
|
25
|
+
if (!flags.json && !flags.quiet) {
|
|
26
|
+
const header = formatStyledHeader({
|
|
27
|
+
command: "migration new",
|
|
28
|
+
description: "Scaffold a new migration",
|
|
29
|
+
details: [],
|
|
30
|
+
flags
|
|
31
|
+
});
|
|
32
|
+
ui.stderr(header);
|
|
33
|
+
}
|
|
34
|
+
const exitCode = handleResult(await executeMigrationNewCommand(options), flags, ui, (value) => {
|
|
35
|
+
if (flags.json) ui.output(JSON.stringify(value, null, 2));
|
|
36
|
+
else if (!flags.quiet) {
|
|
37
|
+
ui.output(`\nScaffolded migration at ${value.dir}`);
|
|
38
|
+
ui.output(` from: ${value.from}`);
|
|
39
|
+
ui.output(` to: ${value.to}`);
|
|
40
|
+
ui.output(`\nEdit migration.ts, then run it directly (\`node "${value.dir}/migration.ts"\`) to self-emit and attest.`);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
process.exit(exitCode);
|
|
44
|
+
});
|
|
45
|
+
return command;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { createMigrationNewCommand as t };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=migration-new-BkSY6m0t.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration-new-BkSY6m0t.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/commands/migration-new.mjs"],"sourcesContent":["import { A as formatStyledHeader, _ as createTerminalUI, g as parseGlobalFlagsOrExit, l as setCommandDescriptions, t as addGlobalOptions, u as setCommandExamples, y as handleResult } from \"../command-helpers-C4WpR-QE.mjs\";\nimport { t as executeMigrationNewCommand } from \"../migration-new-g98oB3nC.mjs\";\nimport { Command } from \"commander\";\n//#region src/commands/migration-new.ts\n/**\n* `migration new` — scaffolds a migration package with a `migration.ts` file\n* for manual authoring.\n*\n* The planner's `emptyMigration(context)` returns a\n* `MigrationPlanWithAuthoringSurface`, whose `renderTypeScript(resolver)`\n* produces the target-appropriate empty stub. The CLI writes the returned\n* source verbatim.\n*\n* The resolver is the one this project's own manifest implies, so the\n* scaffold names packages the project can resolve — the same resolver\n* `contract emit` hands to the emitter (ADR 242).\n*/\nfunction createMigrationNewCommand() {\n\tconst command = new Command(\"new\");\n\tsetCommandDescriptions(command, \"Scaffold a new migration for manual authoring\", \"Creates a migration package with a migration.ts file for manual authoring.\\nWrite the migration body in migration.ts, then run the file with Node\\n(`node migration.ts`) to self-emit ops.json and attest the package.\");\n\tsetCommandExamples(command, [\"prisma-next migration new --name split-name\", \"prisma-next migration new --name custom-fk --from abc123...\"]);\n\taddGlobalOptions(command).option(\"--name <slug>\", \"Migration name (used in directory name)\").option(\"--from <hash>\", \"Starting contract hash (default: latest migration target)\").option(\"--config <path>\", \"Path to prisma-next.config.ts\").action(async (options) => {\n\t\tconst flags = parseGlobalFlagsOrExit(options);\n\t\tconst ui = createTerminalUI(flags);\n\t\tif (!flags.json && !flags.quiet) {\n\t\t\tconst header = formatStyledHeader({\n\t\t\t\tcommand: \"migration new\",\n\t\t\t\tdescription: \"Scaffold a new migration\",\n\t\t\t\tdetails: [],\n\t\t\t\tflags\n\t\t\t});\n\t\t\tui.stderr(header);\n\t\t}\n\t\tconst exitCode = handleResult(await executeMigrationNewCommand(options), flags, ui, (value) => {\n\t\t\tif (flags.json) ui.output(JSON.stringify(value, null, 2));\n\t\t\telse if (!flags.quiet) {\n\t\t\t\tui.output(`\\nScaffolded migration at ${value.dir}`);\n\t\t\t\tui.output(` from: ${value.from}`);\n\t\t\t\tui.output(` to: ${value.to}`);\n\t\t\t\tui.output(`\\nEdit migration.ts, then run it directly (\\`node \"${value.dir}/migration.ts\"\\`) to self-emit and attest.`);\n\t\t\t}\n\t\t});\n\t\tprocess.exit(exitCode);\n\t});\n\treturn command;\n}\n//#endregion\nexport { createMigrationNewCommand };\n\n//# sourceMappingURL=migration-new.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,4BAA4B;CACpC,MAAM,UAAU,IAAI,QAAQ,KAAK;CACjC,uBAAuB,SAAS,iDAAiD,wNAAwN;CACzS,mBAAmB,SAAS,CAAC,+CAA+C,6DAA6D,CAAC;CAC1I,iBAAiB,OAAO,CAAC,CAAC,OAAO,iBAAiB,yCAAyC,CAAC,CAAC,OAAO,iBAAiB,2DAA2D,CAAC,CAAC,OAAO,mBAAmB,+BAA+B,CAAC,CAAC,OAAO,OAAO,YAAY;EACtQ,MAAM,QAAQ,uBAAuB,OAAO;EAC5C,MAAM,KAAK,iBAAiB,KAAK;EACjC,IAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,OAAO;GAChC,MAAM,SAAS,mBAAmB;IACjC,SAAS;IACT,aAAa;IACb,SAAS,CAAC;IACV;GACD,CAAC;GACD,GAAG,OAAO,MAAM;EACjB;EACA,MAAM,WAAW,aAAa,MAAM,2BAA2B,OAAO,GAAG,OAAO,KAAK,UAAU;GAC9F,IAAI,MAAM,MAAM,GAAG,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,OAAO;IACtB,GAAG,OAAO,6BAA6B,MAAM,KAAK;IAClD,GAAG,OAAO,WAAW,MAAM,MAAM;IACjC,GAAG,OAAO,WAAW,MAAM,IAAI;IAC/B,GAAG,OAAO,sDAAsD,MAAM,IAAI,2CAA2C;GACtH;EACD,CAAC;EACD,QAAQ,KAAK,QAAQ;CACtB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
import { a as snapshotsImportPathFrom, o as writeContractSnapshot, t as contractSnapshotDir } from "./contract-snapshot-store-
|
|
1
|
+
import { a as snapshotsImportPathFrom, o as writeContractSnapshot, t as contractSnapshotDir } from "./contract-snapshot-store-C9-J6OBn-ByElY0EC.mjs";
|
|
2
2
|
import { t as computeMigrationHash } from "./hash-DH8hl5Rq-BpM2t3Nu.mjs";
|
|
3
|
-
import { r as formatMigrationDirName, u as writeMigrationPackage } from "./io-
|
|
4
|
-
import { r as findLatestMigration } from "./migration-graph-
|
|
5
|
-
import { K as getTargetMigrations, N as errorUnexpected, O as errorRuntime$1,
|
|
6
|
-
import { t as assertFrameworkComponentsCompatible } from "./framework-components-
|
|
7
|
-
import { t as createProjectSpecifierResolver } from "./project-import-root-
|
|
3
|
+
import { r as formatMigrationDirName, u as writeMigrationPackage } from "./io-CHUUeHh0-CoCBe9eN.mjs";
|
|
4
|
+
import { r as findLatestMigration } from "./migration-graph-DDaOHo10-yJFAbKCu.mjs";
|
|
5
|
+
import { K as getTargetMigrations, N as errorUnexpected, O as errorRuntime$1, it as resolveMigrationPaths, j as errorTargetMigrationNotSupported, rt as resolveContractPath, t as CliStructuredError$1 } from "./command-helpers-C4WpR-QE-DE494TSG.mjs";
|
|
6
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-3DdB31mk-BHyX-OlJ.mjs";
|
|
7
|
+
import { t as createProjectSpecifierResolver } from "./project-import-root-C_bd0ooL-WkbJLnAA.mjs";
|
|
8
8
|
import { r as getEmittedArtifactPaths } from "./exports-BCLg4CiV-okAfZydo.mjs";
|
|
9
9
|
import { r as loadConfig } from "./exports-CDX9kZuw.mjs";
|
|
10
|
-
import { s as loadContractSpaceAggregate } from "./aggregate-
|
|
11
|
-
import {
|
|
10
|
+
import { s as loadContractSpaceAggregate } from "./aggregate-D53gnb7v.mjs";
|
|
11
|
+
import { l as refusePackageCorruptionOnAggregate } from "./contract-space-aggregate-loader-C5r12INu-Db_pa3rX.mjs";
|
|
12
12
|
import { i as writeMigrationTs } from "./migration-ts-FyF55c4M.mjs";
|
|
13
13
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
14
14
|
import { join, relative } from "pathe";
|
|
15
15
|
import { readFile } from "node:fs/promises";
|
|
16
16
|
import { APP_SPACE_ID, createControlStack } from "@prisma/orm-framework/components/control";
|
|
17
|
-
|
|
18
|
-
//#region ../../../1-framework/3-tooling/cli/dist/commands/migration-new.mjs
|
|
17
|
+
//#region ../../../1-framework/3-tooling/cli/dist/migration-new-g98oB3nC.mjs
|
|
19
18
|
/**
|
|
20
|
-
* `migration new
|
|
21
|
-
* for manual authoring.
|
|
22
|
-
*
|
|
23
|
-
* The planner's `emptyMigration(context)` returns a
|
|
24
|
-
* `MigrationPlanWithAuthoringSurface`, whose `renderTypeScript(resolver)`
|
|
25
|
-
* produces the target-appropriate empty stub. The CLI writes the returned
|
|
26
|
-
* source verbatim.
|
|
27
|
-
*
|
|
28
|
-
* The resolver is the one this project's own manifest implies, so the
|
|
29
|
-
* scaffold names packages the project can resolve — the same resolver
|
|
30
|
-
* `contract emit` hands to the emitter (ADR 242).
|
|
19
|
+
* Policy core of `migration new`: scaffolds a migration package with a `migration.ts` stub for manual authoring.
|
|
31
20
|
*/
|
|
32
21
|
async function executeMigrationNewCommand(options) {
|
|
33
22
|
const config = await loadConfig(options.config);
|
|
@@ -40,7 +29,7 @@ async function executeMigrationNewCommand(options) {
|
|
|
40
29
|
try {
|
|
41
30
|
contractJsonContent = await readFile(contractPathAbsolute, "utf-8");
|
|
42
31
|
} catch (error) {
|
|
43
|
-
if (error instanceof Error && error.code === "ENOENT") return notOk(errorRuntime$1(`Contract file not found at ${contractPathAbsolute}`, {
|
|
32
|
+
if (error instanceof Error && error.code === "ENOENT") return notOk(errorRuntime$1("CLI.FILE_NOT_FOUND", `Contract file not found at ${contractPathAbsolute}`, {
|
|
44
33
|
why: `Contract file not found at ${contractPathAbsolute}`,
|
|
45
34
|
fix: "Run `prisma-next contract emit` first to generate the contract"
|
|
46
35
|
}));
|
|
@@ -51,13 +40,14 @@ async function executeMigrationNewCommand(options) {
|
|
|
51
40
|
const parsedContract = JSON.parse(contractJsonContent);
|
|
52
41
|
toContract = familyInstance.deserializeContract(parsedContract);
|
|
53
42
|
} catch (error) {
|
|
54
|
-
return notOk(errorRuntime$1("Contract JSON is invalid", {
|
|
43
|
+
return notOk(errorRuntime$1("MIGRATION.CONTRACT_DESERIALIZATION_FAILED", "Contract JSON is invalid", {
|
|
55
44
|
why: `Failed to deserialize ${contractPathAbsolute}: ${error instanceof Error ? error.message : String(error)}`,
|
|
56
|
-
fix: "Run `prisma-next contract emit` to regenerate the contract"
|
|
45
|
+
fix: "Run `prisma-next contract emit` to regenerate the contract",
|
|
46
|
+
cause: error
|
|
57
47
|
}));
|
|
58
48
|
}
|
|
59
49
|
const toStorageHash = toContract.storage?.storageHash;
|
|
60
|
-
if (typeof toStorageHash !== "string") return notOk(errorRuntime$1("Contract is missing storageHash", {
|
|
50
|
+
if (typeof toStorageHash !== "string") return notOk(errorRuntime$1("CONTRACT.VALIDATION_FAILED", "Contract is missing storageHash", {
|
|
61
51
|
why: `Contract at ${contractPathAbsolute} has no storageHash`,
|
|
62
52
|
fix: "Run `prisma-next contract emit` to regenerate the contract"
|
|
63
53
|
}));
|
|
@@ -73,7 +63,7 @@ async function executeMigrationNewCommand(options) {
|
|
|
73
63
|
let fromHash = null;
|
|
74
64
|
if (packages.length > 0) if (options.from) {
|
|
75
65
|
const match = packages.find((p) => p.metadata.to.startsWith(options.from));
|
|
76
|
-
if (!match) return notOk(errorRuntime$1("Starting contract not found", {
|
|
66
|
+
if (!match) return notOk(errorRuntime$1("MIGRATION.HASH_NOT_IN_GRAPH", "Starting contract not found", {
|
|
77
67
|
why: `No migration with to hash matching "${options.from}" exists in ${appMigrationsRelative}`,
|
|
78
68
|
fix: "Check that the --from hash matches a known migration target hash."
|
|
79
69
|
}));
|
|
@@ -82,7 +72,7 @@ async function executeMigrationNewCommand(options) {
|
|
|
82
72
|
const latestMigration = findLatestMigration(graph);
|
|
83
73
|
if (latestMigration) fromHash = latestMigration.to;
|
|
84
74
|
}
|
|
85
|
-
if (fromHash === toStorageHash && !options.from) return notOk(errorRuntime$1("No changes detected", {
|
|
75
|
+
if (fromHash === toStorageHash && !options.from) return notOk(errorRuntime$1("MIGRATION.NO_CHANGES", "No changes detected", {
|
|
86
76
|
why: "The from and to contract hashes are identical — there is nothing to migrate.",
|
|
87
77
|
fix: "Change the contract and run `prisma-next contract emit` before creating a new migration. To author a data-only migration on the current contract hash, pass `--from <hash>` explicitly."
|
|
88
78
|
}));
|
|
@@ -133,36 +123,7 @@ async function executeMigrationNewCommand(options) {
|
|
|
133
123
|
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to scaffold migration: ${error instanceof Error ? error.message : String(error)}` }));
|
|
134
124
|
}
|
|
135
125
|
}
|
|
136
|
-
function createMigrationNewCommand() {
|
|
137
|
-
const command = new Command("new");
|
|
138
|
-
setCommandDescriptions(command, "Scaffold a new migration for manual authoring", "Creates a migration package with a migration.ts file for manual authoring.\nWrite the migration body in migration.ts, then run the file with Node\n(`node migration.ts`) to self-emit ops.json and attest the package.");
|
|
139
|
-
setCommandExamples(command, ["prisma-next migration new --name split-name", "prisma-next migration new --name custom-fk --from abc123..."]);
|
|
140
|
-
addGlobalOptions(command).option("--name <slug>", "Migration name (used in directory name)").option("--from <hash>", "Starting contract hash (default: latest migration target)").option("--config <path>", "Path to prisma-next.config.ts").action(async (options) => {
|
|
141
|
-
const flags = parseGlobalFlagsOrExit(options);
|
|
142
|
-
const ui = createTerminalUI(flags);
|
|
143
|
-
if (!flags.json && !flags.quiet) {
|
|
144
|
-
const header = formatStyledHeader({
|
|
145
|
-
command: "migration new",
|
|
146
|
-
description: "Scaffold a new migration",
|
|
147
|
-
details: [],
|
|
148
|
-
flags
|
|
149
|
-
});
|
|
150
|
-
ui.stderr(header);
|
|
151
|
-
}
|
|
152
|
-
const exitCode = handleResult(await executeMigrationNewCommand(options), flags, ui, (value) => {
|
|
153
|
-
if (flags.json) ui.output(JSON.stringify(value, null, 2));
|
|
154
|
-
else if (!flags.quiet) {
|
|
155
|
-
ui.output(`\nScaffolded migration at ${value.dir}`);
|
|
156
|
-
ui.output(` from: ${value.from}`);
|
|
157
|
-
ui.output(` to: ${value.to}`);
|
|
158
|
-
ui.output(`\nEdit migration.ts, then run it directly (\`node "${value.dir}/migration.ts"\`) to self-emit and attest.`);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
process.exit(exitCode);
|
|
162
|
-
});
|
|
163
|
-
return command;
|
|
164
|
-
}
|
|
165
126
|
//#endregion
|
|
166
|
-
export {
|
|
127
|
+
export { executeMigrationNewCommand as t };
|
|
167
128
|
|
|
168
|
-
//# sourceMappingURL=migration-new-
|
|
129
|
+
//# sourceMappingURL=migration-new-g98oB3nC-BcrkxAAt.mjs.map
|