@intentius/chant 0.124.87 → 0.124.89
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/action-pins.d.ts +1 -0
- package/dist/action-pins.d.ts.map +1 -1
- package/dist/action-pins.js +2 -0
- package/dist/actor.d.ts +47 -0
- package/dist/actor.d.ts.map +1 -0
- package/dist/actor.js +56 -0
- package/dist/bundle-check.d.ts +20 -5
- package/dist/bundle-check.d.ts.map +1 -1
- package/dist/bundle-check.js +20 -5
- package/dist/chant-install.d.ts +98 -0
- package/dist/chant-install.d.ts.map +1 -1
- package/dist/chant-install.js +203 -2
- package/dist/ci-base.d.ts +30 -0
- package/dist/ci-base.d.ts.map +1 -0
- package/dist/ci-base.js +33 -0
- package/dist/ci-comment-commands.d.ts +177 -0
- package/dist/ci-comment-commands.d.ts.map +1 -0
- package/dist/ci-comment-commands.js +325 -0
- package/dist/ci-comment-replies.d.ts +40 -0
- package/dist/ci-comment-replies.d.ts.map +1 -0
- package/dist/ci-comment-replies.js +59 -0
- package/dist/ci-commit.d.ts +1 -1
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +1 -2
- package/dist/ci-control.d.ts +1 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +1 -1
- package/dist/ci-evidence-claims.d.ts +59 -0
- package/dist/ci-evidence-claims.d.ts.map +1 -0
- package/dist/ci-evidence-claims.js +87 -0
- package/dist/ci-evidence-from-job.d.ts +128 -0
- package/dist/ci-evidence-from-job.d.ts.map +1 -0
- package/dist/ci-evidence-from-job.js +203 -0
- package/dist/ci-evidence-jobs.d.ts +68 -4
- package/dist/ci-evidence-jobs.d.ts.map +1 -1
- package/dist/ci-evidence-jobs.js +82 -5
- package/dist/ci-handover.d.ts +12 -0
- package/dist/ci-handover.d.ts.map +1 -1
- package/dist/ci-handover.js +15 -3
- package/dist/ci-identity.d.ts +32 -6
- package/dist/ci-identity.d.ts.map +1 -1
- package/dist/ci-identity.js +40 -8
- package/dist/ci-image.d.ts +65 -10
- package/dist/ci-image.d.ts.map +1 -1
- package/dist/ci-image.js +101 -22
- package/dist/ci-jobs.d.ts +1 -1
- package/dist/ci-jobs.d.ts.map +1 -1
- package/dist/ci-jobs.js +7 -2
- package/dist/ci-login.d.ts +75 -13
- package/dist/ci-login.d.ts.map +1 -1
- package/dist/ci-login.js +89 -37
- package/dist/ci-note-commands.d.ts +63 -3
- package/dist/ci-note-commands.d.ts.map +1 -1
- package/dist/ci-note-commands.js +69 -35
- package/dist/ci-product-words.d.ts +62 -1
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +52 -1
- package/dist/ci-product.d.ts +52 -2
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +51 -2
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +29 -2
- package/dist/cli/handlers/approve-confirm.d.ts +14 -0
- package/dist/cli/handlers/approve-confirm.d.ts.map +1 -1
- package/dist/cli/handlers/approve-confirm.js +46 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +2 -1
- package/dist/cli/handlers/build.d.ts +1 -1
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -1
- package/dist/cli/handlers/ci-check.d.ts +1 -1
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +37 -7
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -1
- package/dist/cli/handlers/ci-evidence.js +255 -20
- package/dist/cli/handlers/ci-forge-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-forge-check.js +34 -17
- package/dist/cli/handlers/components.d.ts.map +1 -1
- package/dist/cli/handlers/components.js +3 -1
- package/dist/cli/handlers/generated-check.d.ts +11 -0
- package/dist/cli/handlers/generated-check.d.ts.map +1 -0
- package/dist/cli/handlers/generated-check.js +71 -0
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +3 -0
- package/dist/cli/handlers/local-chant.d.ts +13 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -1
- package/dist/cli/handlers/local-chant.js +42 -1
- package/dist/cli/handlers/lock.d.ts.map +1 -1
- package/dist/cli/handlers/lock.js +121 -4
- package/dist/cli/handlers/pr-comment.d.ts +21 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -0
- package/dist/cli/handlers/pr-comment.js +112 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -1
- package/dist/cli/handlers/pr-env.js +6 -3
- package/dist/cli/handlers/pr.d.ts +23 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +97 -14
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +2 -1
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +11 -2
- package/dist/cli/handlers/run-wave.d.ts.map +1 -1
- package/dist/cli/handlers/run-wave.js +36 -2
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +2 -1
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +60 -4
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +82 -0
- package/dist/cli/registry.d.ts +35 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/auto-release.d.ts.map +1 -1
- package/dist/components/auto-release.js +2 -1
- package/dist/components/check-hooks.d.ts +10 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +18 -0
- package/dist/components/pr-checks.d.ts +169 -0
- package/dist/components/pr-checks.d.ts.map +1 -0
- package/dist/components/pr-checks.js +180 -0
- package/dist/components/pr-pipeline.d.ts +38 -0
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +6 -1
- package/dist/components/product-pipeline.d.ts +58 -2
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +76 -9
- package/dist/components/product-plan.d.ts +445 -7
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +426 -15
- package/dist/config.d.ts +10 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +11 -6
- package/dist/control/consumers.d.ts +6 -0
- package/dist/control/consumers.d.ts.map +1 -1
- package/dist/control/consumers.js +6 -0
- package/dist/dead-guards.d.ts.map +1 -1
- package/dist/dead-guards.js +9 -6
- package/dist/discovery/files.d.ts +1 -1
- package/dist/discovery/files.js +1 -1
- package/dist/drift-issue.d.ts +20 -3
- package/dist/drift-issue.d.ts.map +1 -1
- package/dist/drift-issue.js +16 -0
- package/dist/drift-record.d.ts +52 -5
- package/dist/drift-record.d.ts.map +1 -1
- package/dist/drift-record.js +46 -6
- package/dist/floor-table.d.ts +6 -6
- package/dist/floor-table.d.ts.map +1 -1
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +81 -21
- package/dist/floor-table.js +10 -7
- package/dist/forge-check/contract.d.ts +19 -1
- package/dist/forge-check/contract.d.ts.map +1 -1
- package/dist/forge-check/contract.js +8 -2
- package/dist/forge-check/index.d.ts +4 -0
- package/dist/forge-check/index.d.ts.map +1 -1
- package/dist/forge-check/index.js +4 -0
- package/dist/forge-flags.d.ts +10 -0
- package/dist/forge-flags.d.ts.map +1 -1
- package/dist/forge-flags.js +31 -0
- package/dist/forge-remote.d.ts +47 -0
- package/dist/forge-remote.d.ts.map +1 -0
- package/dist/forge-remote.js +69 -0
- package/dist/gate-resume-run.d.ts +9 -1
- package/dist/gate-resume-run.d.ts.map +1 -1
- package/dist/gate-resume-run.js +26 -3
- package/dist/generated-check.d.ts +88 -0
- package/dist/generated-check.d.ts.map +1 -0
- package/dist/generated-check.js +248 -0
- package/dist/image-pins.d.ts +26 -0
- package/dist/image-pins.d.ts.map +1 -0
- package/dist/image-pins.js +19 -0
- package/dist/lexicon.d.ts +27 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +11 -0
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +30 -3
- package/dist/lifecycle/publish-npm.d.ts +26 -0
- package/dist/lifecycle/publish-npm.d.ts.map +1 -1
- package/dist/lifecycle/publish-npm.js +76 -4
- package/dist/lifecycle/reach-locks.d.ts +131 -0
- package/dist/lifecycle/reach-locks.d.ts.map +1 -0
- package/dist/lifecycle/reach-locks.js +118 -0
- package/dist/lifecycle/release-cut.d.ts +3 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +15 -0
- package/dist/lifecycle/release-images.d.ts +22 -1
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +26 -3
- package/dist/lifecycle/release-ledger.d.ts +4 -3
- package/dist/lifecycle/release-ledger.d.ts.map +1 -1
- package/dist/lifecycle/release-ledger.js +3 -2
- package/dist/local-chant.d.ts +57 -3
- package/dist/local-chant.d.ts.map +1 -1
- package/dist/local-chant.js +122 -13
- package/dist/notify-product.d.ts +12 -3
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +10 -6
- package/dist/op/activities/source-release.d.ts.map +1 -1
- package/dist/op/activities/source-release.js +2 -1
- package/dist/op/activities/source-rollback.d.ts.map +1 -1
- package/dist/op/activities/source-rollback.js +2 -1
- package/dist/op/index.d.ts +2 -0
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -0
- package/dist/op/op-waves-evidence-jobs.d.ts +97 -0
- package/dist/op/op-waves-evidence-jobs.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-jobs.js +118 -0
- package/dist/op/op-waves-evidence.d.ts +12 -1
- package/dist/op/op-waves-evidence.d.ts.map +1 -1
- package/dist/op/op-waves-evidence.js +23 -2
- package/dist/op/op-waves-render-spec.d.ts +100 -0
- package/dist/op/op-waves-render-spec.d.ts.map +1 -0
- package/dist/op/op-waves-render-spec.js +162 -0
- package/dist/op/op-waves-run.d.ts +14 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +56 -4
- package/dist/op/op-waves.d.ts +12 -0
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +14 -1
- package/dist/op/schedule-overdue.d.ts +39 -2
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +148 -10
- package/dist/op/wave-stop.d.ts +64 -0
- package/dist/op/wave-stop.d.ts.map +1 -0
- package/dist/op/wave-stop.js +127 -0
- package/dist/planned-files.d.ts +76 -0
- package/dist/planned-files.d.ts.map +1 -0
- package/dist/planned-files.js +108 -0
- package/dist/pr-forge-job.d.ts +22 -0
- package/dist/pr-forge-job.d.ts.map +1 -0
- package/dist/pr-forge-job.js +46 -0
- package/dist/pr-forge-reads.d.ts +21 -1
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +19 -1
- package/dist/pr-forge.d.ts +7 -1
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +7 -2
- package/dist/pr-loop.d.ts +3 -6
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +4 -81
- package/dist/pr-plan-note.d.ts +121 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +104 -1
- package/dist/pr-plan-record.d.ts +47 -0
- package/dist/pr-plan-record.d.ts.map +1 -0
- package/dist/pr-plan-record.js +89 -0
- package/dist/pr-post.d.ts +68 -3
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +218 -13
- package/dist/pr-requires.d.ts +8 -0
- package/dist/pr-requires.d.ts.map +1 -1
- package/dist/pr-requires.js +3 -1
- package/dist/pr-status.d.ts +16 -0
- package/dist/pr-status.d.ts.map +1 -0
- package/dist/pr-status.js +90 -0
- package/dist/ref-gate-init.d.ts +90 -0
- package/dist/ref-gate-init.d.ts.map +1 -0
- package/dist/ref-gate-init.js +155 -0
- package/dist/ref-gate-rules.d.ts +19 -0
- package/dist/ref-gate-rules.d.ts.map +1 -0
- package/dist/ref-gate-rules.js +17 -0
- package/dist/release-floors.d.ts +100 -16
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +101 -17
- package/dist/render-module.d.ts +15 -0
- package/dist/render-module.d.ts.map +1 -0
- package/dist/render-module.js +73 -0
- package/dist/state-migration.d.ts +24 -1
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +39 -4
- package/dist/state-unlock.d.ts +32 -1
- package/dist/state-unlock.d.ts.map +1 -1
- package/dist/state-unlock.js +31 -0
- package/dist/wave-runtime.mjs +307 -297
- package/dist/workspace/ci-green-cli.d.ts.map +1 -1
- package/dist/workspace/ci-green-cli.js +15 -8
- package/dist/workspace/drift-cli.d.ts +1 -1
- package/dist/workspace/drift-cli.d.ts.map +1 -1
- package/dist/workspace/drift-cli.js +5 -12
- package/dist/workspace/forge-work.d.ts +3 -2
- package/dist/workspace/forge-work.d.ts.map +1 -1
- package/dist/workspace/forge-work.js +7 -17
- package/dist/workspace/lexicon-outputs.js +2 -2
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +2 -1
- package/dist/workspace/release-workflow.d.ts +27 -3
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +52 -7
- package/dist/workspace/trust/check-evidence-report.d.ts +25 -2
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.js +28 -8
- package/dist/workspace/trust/check-evidence.d.ts +13 -1
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence.js +8 -3
- package/dist/workspace/trust/evidence.d.ts +5 -0
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- package/dist/workspace/trust/evidence.js +5 -0
- package/dist/workspace/trust/open-evidence.d.ts +67 -0
- package/dist/workspace/trust/open-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/open-evidence.js +92 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts +10 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate-cli.js +93 -11
- package/dist/workspace/trust/ref-gate.d.ts +61 -2
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -1
- package/dist/workspace/trust/ref-gate.js +72 -7
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -1
- package/package.json +1 -1
- package/src/action-pins.ts +2 -0
- package/src/actor.test.ts +78 -0
- package/src/actor.ts +79 -0
- package/src/bundle-check.test.ts +22 -0
- package/src/bundle-check.ts +33 -5
- package/src/chant-install.test.ts +108 -1
- package/src/chant-install.ts +242 -2
- package/src/ci-base.test.ts +41 -0
- package/src/ci-base.ts +43 -0
- package/src/ci-comment-commands.test.ts +376 -0
- package/src/ci-comment-commands.ts +389 -0
- package/src/ci-comment-replies.ts +78 -0
- package/src/ci-commit.test.ts +51 -6
- package/src/ci-commit.ts +1 -2
- package/src/ci-control.ts +1 -0
- package/src/ci-evidence-claims.ts +102 -0
- package/src/ci-evidence-from-job.test.ts +165 -0
- package/src/ci-evidence-from-job.ts +251 -0
- package/src/ci-evidence-jobs.ts +88 -6
- package/src/ci-handover.ts +16 -3
- package/src/ci-identity.test.ts +3 -3
- package/src/ci-identity.ts +51 -11
- package/src/ci-image.test.ts +187 -16
- package/src/ci-image.ts +157 -25
- package/src/ci-jobs.ts +7 -2
- package/src/ci-login.test.ts +131 -3
- package/src/ci-login.token-drop.test.ts +204 -0
- package/src/ci-login.ts +137 -39
- package/src/ci-note-commands.ts +104 -41
- package/src/ci-product-words.ts +89 -0
- package/src/ci-product.ts +62 -1
- package/src/cli/commands/__fixtures__/source-dir-root/migrations/0001-init/backfill.ts +3 -0
- package/src/cli/commands/build.test.ts +41 -0
- package/src/cli/commands/build.ts +27 -2
- package/src/cli/handlers/approve-confirm.test.ts +35 -0
- package/src/cli/handlers/approve-confirm.ts +44 -0
- package/src/cli/handlers/approve.ts +2 -1
- package/src/cli/handlers/build-source-dir.test.ts +4 -0
- package/src/cli/handlers/build.ts +20 -2
- package/src/cli/handlers/ci-check.ts +37 -7
- package/src/cli/handlers/ci-evidence-open.test.ts +164 -0
- package/src/cli/handlers/ci-evidence.ts +233 -18
- package/src/cli/handlers/ci-forge-check.ts +22 -9
- package/src/cli/handlers/components.ts +3 -1
- package/src/cli/handlers/generated-check.ts +69 -0
- package/src/cli/handlers/lifecycle.test.ts +20 -0
- package/src/cli/handlers/lifecycle.ts +4 -0
- package/src/cli/handlers/local-chant.ts +39 -1
- package/src/cli/handlers/lock-reach.test.ts +103 -0
- package/src/cli/handlers/lock.ts +100 -4
- package/src/cli/handlers/pr-comment.ts +104 -0
- package/src/cli/handlers/pr-env.ts +6 -3
- package/src/cli/handlers/pr-record.test.ts +1 -1
- package/src/cli/handlers/pr.ts +93 -15
- package/src/cli/handlers/promote.ts +2 -1
- package/src/cli/handlers/release.e2e.test.ts +35 -0
- package/src/cli/handlers/release.ts +14 -2
- package/src/cli/handlers/run-wave.ts +35 -2
- package/src/cli/handlers/run.ts +2 -1
- package/src/cli/main.ts +60 -4
- package/src/cli/parse-args.ts +58 -0
- package/src/cli/registry.ts +35 -0
- package/src/components/auto-release.ts +2 -1
- package/src/components/check-hooks.ts +22 -0
- package/src/components/check-report-summary.test.ts +78 -0
- package/src/components/pr-checks.ts +254 -0
- package/src/components/pr-pipeline.ts +43 -1
- package/src/components/product-pipeline.ts +113 -9
- package/src/components/product-plan.test.ts +140 -1
- package/src/components/product-plan.ts +707 -20
- package/src/config.ts +13 -8
- package/src/control/consumers.ts +7 -0
- package/src/dead-guards.test.ts +27 -5
- package/src/dead-guards.ts +9 -6
- package/src/discovery/files.ts +1 -1
- package/src/drift-issue.test.ts +29 -1
- package/src/drift-issue.ts +28 -3
- package/src/drift-record.test.ts +45 -0
- package/src/drift-record.ts +71 -6
- package/src/floor-table.data.ts +81 -21
- package/src/floor-table.ts +12 -9
- package/src/forge-check/contract.ts +23 -2
- package/src/forge-check/forge-check.test.ts +25 -0
- package/src/forge-check/index.ts +4 -0
- package/src/forge-flags.test.ts +25 -1
- package/src/forge-flags.ts +34 -0
- package/src/forge-remote.test.ts +37 -0
- package/src/forge-remote.ts +79 -0
- package/src/gate-resume-run.ts +27 -3
- package/src/generated-check.e2e.test.ts +118 -0
- package/src/generated-check.test.ts +170 -0
- package/src/generated-check.ts +310 -0
- package/src/image-pins.ts +31 -0
- package/src/lexicon.ts +28 -0
- package/src/lifecycle/git.test.ts +48 -0
- package/src/lifecycle/git.ts +27 -4
- package/src/lifecycle/publish-npm.ts +87 -4
- package/src/lifecycle/reach-locks.test.ts +87 -0
- package/src/lifecycle/reach-locks.ts +169 -0
- package/src/lifecycle/release-catalog.test.ts +2 -2
- package/src/lifecycle/release-cut.ts +17 -1
- package/src/lifecycle/release-images-dockerfile.test.ts +20 -0
- package/src/lifecycle/release-images.test.ts +100 -0
- package/src/lifecycle/release-images.ts +38 -3
- package/src/lifecycle/release-ledger.ts +4 -3
- package/src/local-chant.e2e.test.ts +81 -6
- package/src/local-chant.test.ts +22 -3
- package/src/local-chant.ts +130 -13
- package/src/notify-product.ts +19 -8
- package/src/op/activities/source-release.ts +2 -1
- package/src/op/activities/source-rollback.ts +2 -1
- package/src/op/gate-resume.test.ts +27 -0
- package/src/op/index.ts +10 -0
- package/src/op/op-waves-evidence-jobs.ts +140 -0
- package/src/op/op-waves-evidence.test.ts +36 -3
- package/src/op/op-waves-evidence.ts +23 -3
- package/src/op/op-waves-notify-words.test.ts +18 -0
- package/src/op/op-waves-render-spec.test.ts +160 -0
- package/src/op/op-waves-render-spec.ts +171 -0
- package/src/op/op-waves-run.ts +59 -3
- package/src/op/op-waves.ts +16 -2
- package/src/op/schedule-overdue.test.ts +126 -1
- package/src/op/schedule-overdue.ts +164 -12
- package/src/op/wave-stop.test.ts +72 -0
- package/src/op/wave-stop.ts +137 -0
- package/src/planned-files.test.ts +80 -0
- package/src/planned-files.ts +134 -0
- package/src/pr-forge-job.test.ts +53 -0
- package/src/pr-forge-job.ts +46 -0
- package/src/pr-forge-reads-compare.test.ts +2 -1
- package/src/pr-forge-reads.ts +37 -1
- package/src/pr-forge.ts +14 -3
- package/src/pr-loop-narrowed.test.ts +2 -1
- package/src/pr-loop-words.test.ts +2 -1
- package/src/pr-loop.test.ts +1 -2
- package/src/pr-loop.ts +4 -80
- package/src/pr-plan-note.ts +184 -3
- package/src/pr-plan-record.test.ts +75 -0
- package/src/pr-plan-record.ts +101 -0
- package/src/pr-post-plan-note.test.ts +60 -0
- package/src/pr-post-replan.test.ts +144 -0
- package/src/pr-post-subject.test.ts +230 -0
- package/src/pr-post.test.ts +32 -1
- package/src/pr-post.ts +254 -15
- package/src/pr-requires.test.ts +20 -0
- package/src/pr-requires.ts +10 -1
- package/src/pr-status.ts +91 -0
- package/src/ref-gate-init.ts +208 -0
- package/src/ref-gate-rules.ts +26 -0
- package/src/release-floors.ts +139 -17
- package/src/render-module.ts +73 -0
- package/src/state-migration-record.test.ts +89 -0
- package/src/state-migration.test.ts +1 -1
- package/src/state-migration.ts +52 -4
- package/src/state-unlock.test.ts +33 -1
- package/src/state-unlock.ts +49 -1
- package/src/workspace/ci-green-cli.ts +14 -7
- package/src/workspace/ci-green-workflow.test.ts +32 -1
- package/src/workspace/drift-cli.ts +6 -18
- package/src/workspace/forge-work.ts +7 -14
- package/src/workspace/lexicon-outputs.ts +2 -2
- package/src/workspace/release-train.ts +2 -1
- package/src/workspace/release-workflow.test.ts +104 -3
- package/src/workspace/release-workflow.ts +60 -9
- package/src/workspace/trust/check-evidence-report.ts +39 -8
- package/src/workspace/trust/check-evidence.test.ts +5 -0
- package/src/workspace/trust/check-evidence.ts +17 -5
- package/src/workspace/trust/evidence.ts +5 -0
- package/src/workspace/trust/open-evidence.ts +129 -0
- package/src/workspace/trust/ref-gate-cli.ts +88 -10
- package/src/workspace/trust/ref-gate-pieces.test.ts +220 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +17 -0
- package/src/workspace/trust/ref-gate.test.ts +10 -0
- package/src/workspace/trust/ref-gate.ts +87 -6
- package/src/workspace/workspace-run.ts +2 -1
package/src/chant-install.ts
CHANGED
|
@@ -18,12 +18,24 @@
|
|
|
18
18
|
* {@link chantArgv} runs the package's `bin/chant` with the node running
|
|
19
19
|
* now: the bin picks the compiled CLI in an installed package and the source
|
|
20
20
|
* in a checkout (#3878), so a product never chooses between them.
|
|
21
|
+
*
|
|
22
|
+
* #4889: {@link runChant} spawns that chant and returns its output and its
|
|
23
|
+
* last `--json` document ({@link lastJsonLine}), and
|
|
24
|
+
* {@link installResolveFallback} and {@link fallbackImportArgs} resolve any
|
|
25
|
+
* bare specifier a file with no `node_modules` above it imports, in the
|
|
26
|
+
* product's process and in chant's children, from the product's install
|
|
27
|
+
* (SQL Yodeler's `resolve-fallback.ts` and `process.ts`, terragucci's
|
|
28
|
+
* `runChant` in `resume.ts`).
|
|
21
29
|
*/
|
|
22
30
|
|
|
31
|
+
import { spawn } from "node:child_process";
|
|
23
32
|
import { existsSync, readFileSync } from "node:fs";
|
|
24
33
|
import * as nodeModule from "node:module";
|
|
25
|
-
import { delimiter, dirname, join, resolve } from "node:path";
|
|
26
|
-
import { fileURLToPath } from "node:url";
|
|
34
|
+
import { delimiter, dirname, join, resolve, sep } from "node:path";
|
|
35
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
36
|
+
|
|
37
|
+
/** The first chant with `runChant`, `lastJsonLine`, `installResolveFallback` and `fallbackImportArgs` in `@intentius/chant/chant-install` (#4889): a product runs chant and reads its `--json` document, and a file with no `node_modules` above it imports the product's packages, with no code of the product's own. */
|
|
38
|
+
export const CHANT_RUN_FLOOR = "0.124.88";
|
|
27
39
|
|
|
28
40
|
/** Where a chant package is installed. */
|
|
29
41
|
export interface ChantInstall {
|
|
@@ -177,3 +189,231 @@ export function installChantResolveFallback(from: string = import.meta.url): boo
|
|
|
177
189
|
flags[FALLBACK] = true;
|
|
178
190
|
return true;
|
|
179
191
|
}
|
|
192
|
+
|
|
193
|
+
// ── #4889: any bare specifier, for a file with no node_modules above it ────
|
|
194
|
+
|
|
195
|
+
/** A bare specifier: a package name, not a relative or absolute path, a URL, a `node:` builtin or a `#` import. */
|
|
196
|
+
export function isBareSpecifier(specifier: string): boolean {
|
|
197
|
+
return !/^(\.{0,2}\/|[a-zA-Z][a-zA-Z0-9+.-]*:)/.test(specifier) && !specifier.startsWith("#");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Whether the file at `url` has a `node_modules` directory in its own directory or any above it. A URL that is not a file's counts as having one. */
|
|
201
|
+
export function hasNodeModulesAbove(url: unknown): boolean {
|
|
202
|
+
if (typeof url !== "string" || !url.startsWith("file:")) return true;
|
|
203
|
+
for (let dir = dirname(fileURLToPath(url)); ; ) {
|
|
204
|
+
if (existsSync(join(dir, "node_modules"))) return true;
|
|
205
|
+
const up = dirname(dir);
|
|
206
|
+
if (up === dir) return false;
|
|
207
|
+
dir = up;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The file URL a bare specifier is retried from: a file beside the
|
|
213
|
+
* `node_modules` directory that holds `from` (by default this module, in
|
|
214
|
+
* the chant the product depends on), so the retry finds the product's own
|
|
215
|
+
* packages first; `from` itself when it is in no `node_modules`, as in a
|
|
216
|
+
* chant checkout. SQL Yodeler's `ownModules`.
|
|
217
|
+
*/
|
|
218
|
+
export function fallbackParent(from: string = import.meta.url): string {
|
|
219
|
+
const path = from.startsWith("file:") ? fileURLToPath(from) : from;
|
|
220
|
+
const marker = `${sep}node_modules${sep}`;
|
|
221
|
+
const at = path.lastIndexOf(marker);
|
|
222
|
+
if (at < 0) return from.startsWith("file:") ? from : pathToFileURL(from).href;
|
|
223
|
+
return pathToFileURL(join(path.slice(0, at), "chant-resolve-fallback.js")).href;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* A resolve hook (SQL Yodeler's `resolve-fallback.ts`): a bare specifier
|
|
228
|
+
* Node could not find, imported by a file with no `node_modules` in its
|
|
229
|
+
* directory or any above it, resolves from `parent`. chant's commit job
|
|
230
|
+
* runs a product's command in a git worktree outside the checkout the job
|
|
231
|
+
* installed, so a `chant.config.ts` or an Op there imports chant, its
|
|
232
|
+
* lexicons and the product by name and finds none of them. A file that has
|
|
233
|
+
* an install of its own, and any other failure, is left as Node reports it.
|
|
234
|
+
*/
|
|
235
|
+
export function bareResolveFallback(parent: string) {
|
|
236
|
+
return (specifier: string, context: Record<string, unknown>, next: NextResolve): ResolveResult => {
|
|
237
|
+
try {
|
|
238
|
+
return next(specifier, context);
|
|
239
|
+
} catch (err) {
|
|
240
|
+
const code = (err as { code?: unknown }).code;
|
|
241
|
+
if (code !== "ERR_MODULE_NOT_FOUND" && code !== "MODULE_NOT_FOUND") throw err;
|
|
242
|
+
if (!isBareSpecifier(specifier) || context.parentURL === parent || hasNodeModulesAbove(context.parentURL)) throw err;
|
|
243
|
+
return next(specifier, { ...context, parentURL: parent });
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* {@link bareResolveFallback} as module source for a child's `--import`,
|
|
250
|
+
* with `PARENT` bound: the same checks, written for Node's synchronous
|
|
251
|
+
* `registerHooks` and, on a Node without it, the asynchronous `register`,
|
|
252
|
+
* whose `next` returns a promise.
|
|
253
|
+
*/
|
|
254
|
+
function hooksSource(parent: string): string {
|
|
255
|
+
return [
|
|
256
|
+
'import { existsSync } from "node:fs";',
|
|
257
|
+
'import { dirname, join } from "node:path";',
|
|
258
|
+
'import { fileURLToPath } from "node:url";',
|
|
259
|
+
`const PARENT = ${JSON.stringify(parent)};`,
|
|
260
|
+
'const bare = (s) => !/^(\\.{0,2}\\/|[a-zA-Z][a-zA-Z0-9+.-]*:)/.test(s) && !s.startsWith("#");',
|
|
261
|
+
"function installed(url) {",
|
|
262
|
+
' if (typeof url !== "string" || !url.startsWith("file:")) return true;',
|
|
263
|
+
" for (let d = dirname(fileURLToPath(url)); ; ) {",
|
|
264
|
+
' if (existsSync(join(d, "node_modules"))) return true;',
|
|
265
|
+
" const up = dirname(d);",
|
|
266
|
+
" if (up === d) return false;",
|
|
267
|
+
" d = up;",
|
|
268
|
+
" }",
|
|
269
|
+
"}",
|
|
270
|
+
"function retry(specifier, context, next, e) {",
|
|
271
|
+
' if (!e || (e.code !== "ERR_MODULE_NOT_FOUND" && e.code !== "MODULE_NOT_FOUND") || !bare(specifier) || context.parentURL === PARENT || installed(context.parentURL)) throw e;',
|
|
272
|
+
" return next(specifier, { ...context, parentURL: PARENT });",
|
|
273
|
+
"}",
|
|
274
|
+
"export function resolve(specifier, context, next) {",
|
|
275
|
+
" let r;",
|
|
276
|
+
" try { r = next(specifier, context); } catch (e) { return retry(specifier, context, next, e); }",
|
|
277
|
+
' return r && typeof r.then === "function" ? r.catch((e) => retry(specifier, context, next, e)) : r;',
|
|
278
|
+
"}",
|
|
279
|
+
].join("\n");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const dataUrl = (source: string): string => `data:text/javascript,${encodeURIComponent(source)}`;
|
|
283
|
+
|
|
284
|
+
const BARE_FALLBACK = Symbol.for("chant.bareResolveFallback");
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Install {@link bareResolveFallback} once in this process, retrying from
|
|
288
|
+
* `parent` (default {@link fallbackParent}). A product's bin calls it before
|
|
289
|
+
* it loads a repository's `chant.config.ts` or Ops. Uses Node's
|
|
290
|
+
* `module.registerHooks` where it has one, else `module.register`. Returns
|
|
291
|
+
* whether it is installed: false on a Node with neither.
|
|
292
|
+
*/
|
|
293
|
+
export function installResolveFallback(parent: string = fallbackParent()): boolean {
|
|
294
|
+
const flags = globalThis as { [BARE_FALLBACK]?: boolean };
|
|
295
|
+
if (flags[BARE_FALLBACK]) return true;
|
|
296
|
+
const m = nodeModule as unknown as { registerHooks?: RegisterHooks; register?: (url: string) => unknown };
|
|
297
|
+
if (typeof m.registerHooks === "function") m.registerHooks({ resolve: bareResolveFallback(parent) });
|
|
298
|
+
else if (typeof m.register === "function") m.register(dataUrl(hooksSource(parent)));
|
|
299
|
+
else return false;
|
|
300
|
+
flags[BARE_FALLBACK] = true;
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The node arguments that install {@link bareResolveFallback} in a chant
|
|
306
|
+
* child (`chant build`, `chant run`), before its own imports of the
|
|
307
|
+
* repository's files: one `--import` of a `data:` module, so it loads the
|
|
308
|
+
* same from a product's `src/` under tsx and from its bundle. Pass them as
|
|
309
|
+
* {@link chantArgv}'s `nodeArgs`, or {@link runChant}'s `resolveFallback`.
|
|
310
|
+
*/
|
|
311
|
+
export function fallbackImportArgs(parent: string = fallbackParent()): string[] {
|
|
312
|
+
const hooks = dataUrl(hooksSource(parent));
|
|
313
|
+
const registrar = [
|
|
314
|
+
'import * as m from "node:module";',
|
|
315
|
+
`import { resolve } from ${JSON.stringify(hooks)};`,
|
|
316
|
+
`if (typeof m.registerHooks === "function") m.registerHooks({ resolve }); else m.register(${JSON.stringify(hooks)});`,
|
|
317
|
+
].join("\n");
|
|
318
|
+
return ["--import", dataUrl(registrar)];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// ── #4889: running chant and reading its --json document ──────────────────
|
|
322
|
+
|
|
323
|
+
/** What {@link runChant} returns once the child exits. */
|
|
324
|
+
export interface ChantRun {
|
|
325
|
+
/** The exit code; 128 when a signal ended it. */
|
|
326
|
+
code: number;
|
|
327
|
+
stdout: string;
|
|
328
|
+
stderr: string;
|
|
329
|
+
/** {@link lastJsonLine} of `stdout`: the `--json` document, when the command printed one. */
|
|
330
|
+
json?: unknown;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export interface RunChantOptions {
|
|
334
|
+
/** The directory chant runs in. Default the current one. */
|
|
335
|
+
cwd?: string;
|
|
336
|
+
/** The environment the child starts from, before {@link chantEnv}. Default `process.env`. */
|
|
337
|
+
env?: NodeJS.ProcessEnv;
|
|
338
|
+
/**
|
|
339
|
+
* A chant executable to run as it is (a product's `--chant` flag): no
|
|
340
|
+
* node in front of it, so `nodeArgs` and `resolveFallback` do not apply.
|
|
341
|
+
*/
|
|
342
|
+
chant?: string;
|
|
343
|
+
/** The install to run. Default {@link bundledChant}, else the first of `from` that {@link installedChant} finds, else `chant` on PATH. */
|
|
344
|
+
install?: ChantInstall;
|
|
345
|
+
/** Directories to look for an install from when this module is in none (terragucci looks from the repository). */
|
|
346
|
+
from?: readonly string[];
|
|
347
|
+
/** Node arguments before the bin, such as a product's own `--import`. */
|
|
348
|
+
nodeArgs?: readonly string[];
|
|
349
|
+
/** Install {@link bareResolveFallback} in the child (`true` from {@link fallbackParent}, or a parent URL). */
|
|
350
|
+
resolveFallback?: boolean | string;
|
|
351
|
+
/** `FORCE_COLOR=0` and `NO_COLOR=1`, for output a product reads. */
|
|
352
|
+
noColor?: boolean;
|
|
353
|
+
/** `inherit` writes the child's output to this process's and captures none. Default `pipe`. */
|
|
354
|
+
stdio?: "pipe" | "inherit";
|
|
355
|
+
/** Each chunk as it arrives, for output a person watches. */
|
|
356
|
+
onStdout?: (text: string) => void;
|
|
357
|
+
onStderr?: (text: string) => void;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Run `chant <args>` and resolve with its exit code, its output and its
|
|
362
|
+
* `--json` document (#4889; SQL Yodeler's `runChant`, terragucci's in
|
|
363
|
+
* `resume.ts`). The chant is the product's own ({@link chantArgv}) with its
|
|
364
|
+
* bin first on PATH ({@link chantEnv}). Never rejects on a non-zero exit;
|
|
365
|
+
* rejects when the child cannot start.
|
|
366
|
+
*/
|
|
367
|
+
export function runChant(args: readonly string[], options: RunChantOptions = {}): Promise<ChantRun> {
|
|
368
|
+
const install = options.chant === undefined ? (options.install ?? bundledChant() ?? installedChant(options.from ?? [])) : undefined;
|
|
369
|
+
const fallback = options.resolveFallback === true ? fallbackImportArgs() : typeof options.resolveFallback === "string" ? fallbackImportArgs(options.resolveFallback) : [];
|
|
370
|
+
const [command, ...argv] = install ? chantArgv(args, { install, nodeArgs: [...fallback, ...(options.nodeArgs ?? [])] }) : [options.chant ?? "chant", ...args];
|
|
371
|
+
const env = { ...chantEnv(options.env ?? process.env, install), ...(options.noColor ? { FORCE_COLOR: "0", NO_COLOR: "1" } : {}) };
|
|
372
|
+
const piped = options.stdio !== "inherit";
|
|
373
|
+
return new Promise((done, reject) => {
|
|
374
|
+
const child = spawn(command!, argv, { cwd: options.cwd ?? process.cwd(), env, stdio: ["ignore", piped ? "pipe" : "inherit", piped ? "pipe" : "inherit"] });
|
|
375
|
+
let stdout = "";
|
|
376
|
+
let stderr = "";
|
|
377
|
+
child.stdout?.setEncoding("utf8");
|
|
378
|
+
child.stderr?.setEncoding("utf8");
|
|
379
|
+
child.stdout?.on("data", (chunk: string) => {
|
|
380
|
+
stdout += chunk;
|
|
381
|
+
options.onStdout?.(chunk);
|
|
382
|
+
});
|
|
383
|
+
child.stderr?.on("data", (chunk: string) => {
|
|
384
|
+
stderr += chunk;
|
|
385
|
+
options.onStderr?.(chunk);
|
|
386
|
+
});
|
|
387
|
+
child.on("error", reject);
|
|
388
|
+
child.on("close", (code, signal) => {
|
|
389
|
+
const json = lastJsonLine(stdout);
|
|
390
|
+
done({ code: code ?? (signal ? 128 : 1), stdout, stderr, ...(json !== undefined ? { json } : {}) });
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* The last line of `stdout` that parses as a JSON object: chant prints its
|
|
397
|
+
* `--json` document as one line, after any log lines. A pretty-printed
|
|
398
|
+
* document is read from the first `{` to the end. Undefined when there is
|
|
399
|
+
* none.
|
|
400
|
+
*/
|
|
401
|
+
export function lastJsonLine(stdout: string): unknown {
|
|
402
|
+
const lines = stdout.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("{"));
|
|
403
|
+
for (const line of lines.reverse()) {
|
|
404
|
+
try {
|
|
405
|
+
return JSON.parse(line) as unknown;
|
|
406
|
+
} catch {
|
|
407
|
+
// A log line that starts with "{"; keep looking.
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const at = stdout.indexOf("{");
|
|
411
|
+
if (at >= 0) {
|
|
412
|
+
try {
|
|
413
|
+
return JSON.parse(stdout.slice(at)) as unknown;
|
|
414
|
+
} catch {
|
|
415
|
+
// Not JSON.
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** #4966: the base a CI job measures a change from, and `chant ci check`'s default `--base`. */
|
|
2
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
3
|
+
import { ciBaseRef } from "./ci-base";
|
|
4
|
+
import type { CommandContext } from "./cli/registry";
|
|
5
|
+
import { runCiCheck } from "./cli/handlers/ci-check";
|
|
6
|
+
|
|
7
|
+
describe("ciBaseRef", () => {
|
|
8
|
+
test("a pull request's target branch, on GitHub and Forgejo, and on GitLab", () => {
|
|
9
|
+
expect(ciBaseRef({ GITHUB_BASE_REF: "main", GITHUB_REF_NAME: "12/merge" })).toBe("origin/main");
|
|
10
|
+
expect(ciBaseRef({ CI_MERGE_REQUEST_TARGET_BRANCH_NAME: "release", CI_COMMIT_BRANCH: "feature" })).toBe("origin/release");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test("a push to another branch than the default is measured from the default branch", () => {
|
|
14
|
+
expect(ciBaseRef({ GITHUB_REF_NAME: "feature" }, { defaultBranch: "main" })).toBe("origin/main");
|
|
15
|
+
expect(ciBaseRef({ CI_COMMIT_BRANCH: "feature", CI_DEFAULT_BRANCH: "trunk" })).toBe("origin/trunk");
|
|
16
|
+
expect(ciBaseRef({ CI_COMMIT_BRANCH: "feature", CI_DEFAULT_BRANCH: "trunk" }, { remote: "upstream" })).toBe("upstream/trunk");
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("a push to the default branch, or a job that names no default branch, has no base", () => {
|
|
20
|
+
expect(ciBaseRef({ GITHUB_REF_NAME: "main" }, { defaultBranch: "main" })).toBeUndefined();
|
|
21
|
+
expect(ciBaseRef({ GITHUB_REF_NAME: "feature" })).toBeUndefined();
|
|
22
|
+
expect(ciBaseRef({})).toBeUndefined();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("a base the caller has wins, and blanks count as unset", () => {
|
|
26
|
+
expect(ciBaseRef({ GITHUB_BASE_REF: "main" }, { base: "HEAD^" })).toBe("HEAD^");
|
|
27
|
+
expect(ciBaseRef({ GITHUB_BASE_REF: " ", CI_MERGE_REQUEST_TARGET_BRANCH_NAME: "main" }, { base: " " })).toBe("origin/main");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("chant ci check with no --base", () => {
|
|
32
|
+
afterEach(() => vi.restoreAllMocks());
|
|
33
|
+
|
|
34
|
+
test("refuses when the job names no base either", async () => {
|
|
35
|
+
const errors: string[] = [];
|
|
36
|
+
vi.spyOn(console, "error").mockImplementation((m: unknown) => void errors.push(String(m)));
|
|
37
|
+
const ctx = { args: { positionals: ["ci", "check"] }, plugins: [], serializers: [] } as unknown as CommandContext;
|
|
38
|
+
expect(await runCiCheck(ctx, { GITHUB_REF_NAME: "main" })).toBe(1);
|
|
39
|
+
expect(errors.join("\n")).toContain("the job names no pull request target or default branch to take it from");
|
|
40
|
+
});
|
|
41
|
+
});
|
package/src/ci-base.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@intentius/chant/ci-base` (#4966): the base a CI job measures a change
|
|
3
|
+
* from, read off the job's own variables, so a product's check and policy
|
|
4
|
+
* steps need no rule of their own for it (terragucci's `policyBase`).
|
|
5
|
+
*
|
|
6
|
+
* - A pull request's job: its target branch, `origin/<target>`
|
|
7
|
+
* (`GITHUB_BASE_REF` on GitHub and Forgejo, GitLab's
|
|
8
|
+
* `CI_MERGE_REQUEST_TARGET_BRANCH_NAME`).
|
|
9
|
+
* - A push to a branch other than the default branch: `origin/<default>`,
|
|
10
|
+
* so a change that edits a check or a policy on a side branch is still
|
|
11
|
+
* judged by the default branch's.
|
|
12
|
+
* - A push to the default branch, or a job with no branch: no base, and
|
|
13
|
+
* the checkout's own files are the trusted ones.
|
|
14
|
+
*
|
|
15
|
+
* `chant ci check` takes it as its `--base` when none is given.
|
|
16
|
+
*
|
|
17
|
+
* This module imports nothing.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export interface CiBaseOptions {
|
|
21
|
+
/** A base the caller already has (a flag, a product's own variable); it wins over everything. */
|
|
22
|
+
base?: string;
|
|
23
|
+
/** The default branch. Default GitLab's `CI_DEFAULT_BRANCH`; GitHub and Forgejo jobs carry none, so a product passes its own. */
|
|
24
|
+
defaultBranch?: string;
|
|
25
|
+
/** The remote the branches are fetched from. Default `origin`. */
|
|
26
|
+
remote?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const set = (v: string | undefined): string | undefined => (v && v.trim() ? v.trim() : undefined);
|
|
30
|
+
|
|
31
|
+
/** The base ref for the job `env` describes, as the module comment says; undefined when there is none. */
|
|
32
|
+
export function ciBaseRef(env: Record<string, string | undefined> = process.env, options: CiBaseOptions = {}): string | undefined {
|
|
33
|
+
const given = set(options.base);
|
|
34
|
+
if (given) return given;
|
|
35
|
+
const remote = options.remote ?? "origin";
|
|
36
|
+
const target = set(env.GITHUB_BASE_REF) ?? set(env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME);
|
|
37
|
+
if (target) return `${remote}/${target}`;
|
|
38
|
+
const branch = set(env.GITHUB_REF_NAME) ?? set(env.CI_COMMIT_BRANCH);
|
|
39
|
+
const main = set(options.defaultBranch) ?? set(env.CI_DEFAULT_BRANCH);
|
|
40
|
+
return branch && main && branch !== main ? `${remote}/${main}` : undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { CI_BASE_REF_FLOOR } from "./release-floors";
|