@intentius/chant 0.124.46 → 0.124.49
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/__golden__/wave-loop/op-by-apply-after-fails.json +10 -0
- package/dist/__golden__/wave-loop/op-by-apply-hold.json +10 -0
- package/dist/__golden__/wave-loop/op-by-apply-ignored.json +10 -0
- package/dist/__golden__/wave-loop/op-by-apply-pass.json +10 -0
- package/dist/__golden__/wave-loop/op-by-apply-skip.json +10 -0
- package/dist/__golden__/wave-loop/op-cost-member-clash.json +6 -0
- package/dist/__golden__/wave-loop/op-cost-member.json +13 -0
- package/dist/__golden__/wave-loop/op-denied-source.json +16 -0
- package/dist/__golden__/wave-loop/op-denied.json +16 -0
- package/dist/__golden__/wave-loop/op-discover-rest-short.json +6 -0
- package/dist/__golden__/wave-loop/op-discover-rest-stops.json +13 -0
- package/dist/__golden__/wave-loop/op-discover-rest.json +26 -0
- package/dist/__golden__/wave-loop/op-discover-wide.json +26 -0
- package/dist/__golden__/wave-loop/op-held-on-again.json +16 -0
- package/dist/__golden__/wave-loop/op-held-on-before-apply.json +16 -0
- package/dist/__golden__/wave-loop/op-held-on.json +16 -0
- package/dist/__golden__/wave-loop/op-hooks-apply-fails.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-fail-after-apply.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-fail-before-apply.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-fail-before-plan.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-held.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-hold-before-apply.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-pass.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-refused-at-base.json +13 -0
- package/dist/__golden__/wave-loop/op-hooks-share.json +33 -0
- package/dist/__golden__/wave-loop/op-outcome-held.json +10 -0
- package/dist/__golden__/wave-loop/op-outcome-replan-approved.json +10 -0
- package/dist/__golden__/wave-loop/op-outcome-replan-forever.json +10 -0
- package/dist/__golden__/wave-loop/op-outcome-replan.json +10 -0
- package/dist/__golden__/wave-loop/op-outcome-stood-down.json +10 -0
- package/dist/__golden__/wave-loop/op-outcome-unreadable.json +10 -0
- package/dist/__golden__/wave-loop/op-overridden.json +16 -0
- package/dist/__golden__/wave-loop/op-per-run.json +20 -0
- package/dist/__golden__/wave-loop/op-point.json +13 -0
- package/dist/__golden__/wave-loop/op-pr-review.json +10 -0
- package/dist/__golden__/wave-loop/op-sealed.json +10 -0
- package/dist/__golden__/wave-loop/op-spend-change-only.json +10 -0
- package/dist/__golden__/wave-loop/op-spend.json +10 -0
- package/dist/__golden__/wave-loop/op-wave-commands.json +55 -0
- package/dist/__golden__/wave-loop/op-wide-refused.json +26 -0
- package/dist/__golden__/wave-loop/op-wide-waiting.json +29 -0
- package/dist/__golden__/wave-loop/op-wide.json +39 -0
- package/dist/action-pins.d.ts +61 -0
- package/dist/action-pins.d.ts.map +1 -0
- package/dist/action-pins.js +77 -0
- package/dist/cli/commands/carve.d.ts +3 -0
- package/dist/cli/commands/carve.d.ts.map +1 -1
- package/dist/cli/commands/carve.js +36 -7
- package/dist/cli/commands/import-report.d.ts +26 -0
- package/dist/cli/commands/import-report.d.ts.map +1 -0
- package/dist/cli/commands/import-report.js +65 -0
- package/dist/cli/commands/import.d.ts +11 -1
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +22 -3
- package/dist/cli/commands/migrate.d.ts +13 -1
- package/dist/cli/commands/migrate.d.ts.map +1 -1
- package/dist/cli/commands/migrate.js +134 -10
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +41 -14
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +6 -1
- package/dist/cli/handlers/graph-reader.d.ts +26 -0
- package/dist/cli/handlers/graph-reader.d.ts.map +1 -0
- package/dist/cli/handlers/graph-reader.js +41 -0
- package/dist/cli/handlers/graph.d.ts.map +1 -1
- package/dist/cli/handlers/graph.js +14 -0
- package/dist/cli/handlers/ledger.d.ts +3 -0
- package/dist/cli/handlers/ledger.d.ts.map +1 -0
- package/dist/cli/handlers/ledger.js +55 -0
- package/dist/cli/handlers/migrate.d.ts.map +1 -1
- package/dist/cli/handlers/migrate.js +18 -11
- package/dist/cli/handlers/misc.d.ts.map +1 -1
- package/dist/cli/handlers/misc.js +12 -1
- package/dist/cli/handlers/pr-env.js +2 -2
- package/dist/cli/handlers/pr.d.ts +15 -1
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +183 -40
- package/dist/cli/handlers/query.d.ts +7 -2
- package/dist/cli/handlers/query.d.ts.map +1 -1
- package/dist/cli/handlers/query.js +16 -4
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +6 -3
- package/dist/cli/handlers/search.d.ts +2 -4
- package/dist/cli/handlers/search.d.ts.map +1 -1
- package/dist/cli/handlers/search.js +13 -39
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +87 -14
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +47 -2
- package/dist/cli/registry.d.ts +22 -4
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/builders.d.ts +5 -1
- package/dist/components/builders.d.ts.map +1 -1
- package/dist/components/builders.js +5 -0
- package/dist/components/capability-plugin-loader.d.ts.map +1 -1
- package/dist/components/capability-plugin-loader.js +16 -1
- package/dist/components/capability-plugin.d.ts +14 -0
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/pr-hooks.d.ts +21 -1
- package/dist/components/pr-hooks.d.ts.map +1 -1
- package/dist/components/pr-hooks.js +72 -4
- package/dist/components/pr-pipeline.d.ts +45 -10
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +47 -14
- package/dist/components/pr-policy.d.ts +36 -0
- package/dist/components/pr-policy.d.ts.map +1 -1
- package/dist/components/pr-policy.js +36 -0
- package/dist/components/pr-run.d.ts +3 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +1 -0
- package/dist/components/starter-plugin.d.ts +1 -0
- package/dist/components/starter-plugin.d.ts.map +1 -1
- package/dist/components/starter-plugin.js +5 -1
- package/dist/components/verbs/index.d.ts +2 -0
- package/dist/components/verbs/index.d.ts.map +1 -1
- package/dist/components/verbs/index.js +2 -0
- package/dist/components/verbs/publish-artifact.d.ts +65 -0
- package/dist/components/verbs/publish-artifact.d.ts.map +1 -0
- package/dist/components/verbs/publish-artifact.js +74 -0
- package/dist/components/verbs/publish-image.d.ts +129 -0
- package/dist/components/verbs/publish-image.d.ts.map +1 -0
- package/dist/components/verbs/publish-image.js +145 -0
- package/dist/config-environments.d.ts +20 -0
- package/dist/config-environments.d.ts.map +1 -1
- package/dist/config-environments.js +12 -0
- package/dist/config.d.ts +25 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -2
- package/dist/gate-decision.d.ts +20 -2
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +30 -3
- package/dist/graph-ir.d.ts +25 -0
- package/dist/graph-ir.d.ts.map +1 -1
- package/dist/graph-walk.d.ts +66 -0
- package/dist/graph-walk.d.ts.map +1 -0
- package/dist/graph-walk.js +70 -0
- package/dist/import/parser.d.ts +19 -0
- package/dist/import/parser.d.ts.map +1 -1
- package/dist/lexicon.d.ts +94 -6
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.d.ts +11 -0
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/git.d.ts +2 -5
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/ledger-read.d.ts +65 -0
- package/dist/lifecycle/ledger-read.d.ts.map +1 -0
- package/dist/lifecycle/ledger-read.js +160 -0
- package/dist/lifecycle/release-workstation.d.ts +7 -0
- package/dist/lifecycle/release-workstation.d.ts.map +1 -1
- package/dist/lifecycle/release-workstation.js +25 -0
- package/dist/lifecycle/run-ledger.d.ts +4 -3
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +1 -0
- package/dist/lint/discover.js +3 -1
- package/dist/lint/post-synth.d.ts +127 -1
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/lint/post-synth.js +84 -2
- package/dist/lint/rules/op/index.d.ts +1 -0
- package/dist/lint/rules/op/index.d.ts.map +1 -1
- package/dist/lint/rules/op/index.js +2 -0
- package/dist/lint/rules/op/ops019-workspace-op-target.d.ts +32 -0
- package/dist/lint/rules/op/ops019-workspace-op-target.d.ts.map +1 -0
- package/dist/lint/rules/op/ops019-workspace-op-target.js +63 -0
- package/dist/op/activities/activity-contracts.d.ts +9 -6
- package/dist/op/activities/activity-contracts.d.ts.map +1 -1
- package/dist/op/activities/activity-contracts.js +5 -2
- package/dist/op/activities/index.d.ts +2 -2
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +1 -1
- package/dist/op/activities/review-agent.d.ts +90 -4
- package/dist/op/activities/review-agent.d.ts.map +1 -1
- package/dist/op/activities/review-agent.js +217 -19
- package/dist/op/activities/work-evidence.d.ts +8 -1
- package/dist/op/activities/work-evidence.d.ts.map +1 -1
- package/dist/op/activities/work-evidence.js +1 -0
- package/dist/op/builders.d.ts +9 -5
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/builders.js +9 -5
- package/dist/op/composites/apply-op.d.ts +29 -2
- package/dist/op/composites/apply-op.d.ts.map +1 -1
- package/dist/op/composites/apply-op.js +20 -1
- package/dist/op/gate-approval-base.d.ts +25 -0
- package/dist/op/gate-approval-base.d.ts.map +1 -0
- package/dist/op/gate-approval-base.js +71 -0
- package/dist/op/gate-approval.d.ts +18 -9
- package/dist/op/gate-approval.d.ts.map +1 -1
- package/dist/op/gate-approval.js +13 -31
- package/dist/op/gate-name.d.ts +13 -0
- package/dist/op/gate-name.d.ts.map +1 -1
- package/dist/op/gate-name.js +14 -1
- package/dist/op/gate-quorum.d.ts +100 -3
- package/dist/op/gate-quorum.d.ts.map +1 -1
- package/dist/op/gate-quorum.js +108 -6
- package/dist/op/gate-review.d.ts +9 -0
- package/dist/op/gate-review.d.ts.map +1 -1
- package/dist/op/gate-review.js +13 -0
- package/dist/op/gate.d.ts +47 -5
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +25 -4
- package/dist/op/index.d.ts +3 -3
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -1
- package/dist/op/local-executor.d.ts +45 -3
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +68 -7
- package/dist/op/op-waves-run.d.ts +26 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +259 -13
- package/dist/op/op-waves.d.ts +72 -5
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +110 -15
- package/dist/op/runtime.d.ts +11 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/op/schedule-overdue.d.ts +16 -0
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +36 -0
- package/dist/op/stage-hooks.d.ts +9 -2
- package/dist/op/stage-hooks.d.ts.map +1 -1
- package/dist/op/stage-hooks.js +7 -5
- package/dist/op/workspace-run-env.d.ts +22 -0
- package/dist/op/workspace-run-env.d.ts.map +1 -0
- package/dist/op/workspace-run-env.js +21 -0
- package/dist/pr-forge.d.ts +24 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +47 -0
- package/dist/pr-loop.d.ts +10 -0
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +4 -0
- package/dist/pr-migrations.d.ts +62 -0
- package/dist/pr-migrations.d.ts.map +1 -0
- package/dist/pr-migrations.js +50 -0
- package/dist/pr-post.d.ts +42 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +68 -2
- package/dist/read-filter.d.ts +65 -0
- package/dist/read-filter.d.ts.map +1 -0
- package/dist/read-filter.js +179 -0
- package/dist/run-event.d.ts +1 -1
- package/dist/run-event.d.ts.map +1 -1
- package/dist/terraform/carve.d.ts +24 -3
- package/dist/terraform/carve.d.ts.map +1 -1
- package/dist/terraform/carve.js +32 -14
- package/dist/terraform/cuts.d.ts +97 -0
- package/dist/terraform/cuts.d.ts.map +1 -0
- package/dist/terraform/cuts.js +138 -0
- package/dist/terraform/folds.d.ts +26 -0
- package/dist/terraform/folds.d.ts.map +1 -0
- package/dist/terraform/folds.js +38 -0
- package/dist/terraform/graph.d.ts.map +1 -1
- package/dist/terraform/graph.js +10 -0
- package/dist/terraform/reach.d.ts +140 -0
- package/dist/terraform/reach.d.ts.map +1 -0
- package/dist/terraform/reach.js +170 -0
- package/dist/terraform/score.d.ts +14 -0
- package/dist/terraform/score.d.ts.map +1 -1
- package/dist/terraform/score.js +14 -31
- package/dist/terraform/state.d.ts.map +1 -1
- package/dist/terraform/state.js +4 -2
- package/dist/terraform/types.d.ts +8 -0
- package/dist/terraform/types.d.ts.map +1 -1
- package/dist/wave-blocked.d.ts +10 -1
- package/dist/wave-blocked.d.ts.map +1 -1
- package/dist/wave-blocked.js +31 -3
- package/dist/wave-runtime.mjs +264 -254
- package/dist/workspace/check.schema.json +13 -2
- package/dist/workspace/checks/ci-branch.d.ts +44 -0
- package/dist/workspace/checks/ci-branch.d.ts.map +1 -0
- package/dist/workspace/checks/ci-branch.js +133 -0
- package/dist/workspace/checks/gate-approval.d.ts +58 -0
- package/dist/workspace/checks/gate-approval.d.ts.map +1 -0
- package/dist/workspace/checks/gate-approval.js +103 -0
- package/dist/workspace/checks/links.d.ts +3 -0
- package/dist/workspace/checks/links.d.ts.map +1 -1
- package/dist/workspace/checks/links.js +12 -1
- package/dist/workspace/checks/org.d.ts +48 -0
- package/dist/workspace/checks/org.d.ts.map +1 -0
- package/dist/workspace/checks/org.js +156 -0
- package/dist/workspace/checks.d.ts +12 -1
- package/dist/workspace/checks.d.ts.map +1 -1
- package/dist/workspace/checks.js +63 -7
- package/dist/workspace/ci-branches.d.ts +16 -0
- package/dist/workspace/ci-branches.d.ts.map +1 -1
- package/dist/workspace/ci-branches.js +27 -0
- package/dist/workspace/ci-green-cli.js +7 -7
- package/dist/workspace/ci-green-workflow.d.ts +1 -1
- package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
- package/dist/workspace/ci-green-workflow.js +13 -8
- package/dist/workspace/ci-green.d.ts +14 -0
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +44 -11
- package/dist/workspace/ci-run.d.ts +9 -1
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +67 -6
- package/dist/workspace/ci-serve.d.ts +9 -0
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +114 -76
- package/dist/workspace/compose-graph.d.ts +14 -0
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/composites.d.ts +4 -1
- package/dist/workspace/composites.d.ts.map +1 -1
- package/dist/workspace/composites.js +5 -2
- package/dist/workspace/composites.schema.json +22 -0
- package/dist/workspace/conformance/__writer_fixture__/work/work.schema.json +105 -1
- package/dist/workspace/cross-root-lint.d.ts +56 -0
- package/dist/workspace/cross-root-lint.d.ts.map +1 -0
- package/dist/workspace/cross-root-lint.js +111 -0
- package/dist/workspace/dbt-models-reader.d.ts +44 -0
- package/dist/workspace/dbt-models-reader.d.ts.map +1 -0
- package/dist/workspace/dbt-models-reader.js +356 -0
- package/dist/workspace/dbt-project-common.d.ts +40 -0
- package/dist/workspace/dbt-project-common.d.ts.map +1 -0
- package/dist/workspace/dbt-project-common.js +106 -0
- package/dist/workspace/dbt-project-reader.d.ts +4 -3
- package/dist/workspace/dbt-project-reader.d.ts.map +1 -1
- package/dist/workspace/dbt-project-reader.js +14 -108
- package/dist/workspace/decision-rank.d.ts +26 -0
- package/dist/workspace/decision-rank.d.ts.map +1 -0
- package/dist/workspace/decision-rank.js +16 -0
- package/dist/workspace/declaration.d.ts +50 -2
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +57 -11
- package/dist/workspace/declaration.schema.json +166 -24
- package/dist/workspace/environments.d.ts +26 -2
- package/dist/workspace/environments.d.ts.map +1 -1
- package/dist/workspace/environments.js +26 -2
- package/dist/workspace/exit-cli.d.ts +44 -0
- package/dist/workspace/exit-cli.d.ts.map +1 -0
- package/dist/workspace/exit-cli.js +198 -0
- package/dist/workspace/exit.d.ts +159 -0
- package/dist/workspace/exit.d.ts.map +1 -0
- package/dist/workspace/exit.js +480 -0
- package/dist/workspace/exit.schema.json +257 -0
- package/dist/workspace/flyway-dir.d.ts +39 -0
- package/dist/workspace/flyway-dir.d.ts.map +1 -0
- package/dist/workspace/flyway-dir.js +104 -0
- package/dist/workspace/flyway-layout.d.ts +96 -0
- package/dist/workspace/flyway-layout.d.ts.map +1 -0
- package/dist/workspace/flyway-layout.js +308 -0
- package/dist/workspace/graph-cache.d.ts +3 -1
- package/dist/workspace/graph-cache.d.ts.map +1 -1
- package/dist/workspace/graph-cache.js +12 -1
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +26 -8
- package/dist/workspace/graph.schema.json +34 -0
- package/dist/workspace/import-fetch.d.ts +38 -0
- package/dist/workspace/import-fetch.d.ts.map +1 -0
- package/dist/workspace/import-fetch.js +99 -0
- package/dist/workspace/import-init.d.ts +26 -0
- package/dist/workspace/import-init.d.ts.map +1 -0
- package/dist/workspace/import-init.js +130 -0
- package/dist/workspace/import-source.d.ts +147 -0
- package/dist/workspace/import-source.d.ts.map +1 -0
- package/dist/workspace/import-source.js +370 -0
- package/dist/workspace/init.d.ts +4 -0
- package/dist/workspace/init.d.ts.map +1 -1
- package/dist/workspace/init.js +70 -3
- package/dist/workspace/intent.d.ts +2 -3
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +5 -9
- package/dist/workspace/kind-link-readers.d.ts +59 -2
- package/dist/workspace/kind-link-readers.d.ts.map +1 -1
- package/dist/workspace/kind-link-readers.js +17 -1
- package/dist/workspace/kind-readers.d.ts +6 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +18 -0
- package/dist/workspace/kinds.d.ts +90 -3
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +161 -7
- package/dist/workspace/ledger.schema.json +158 -0
- package/dist/workspace/lexicon-outputs.d.ts +20 -1
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +102 -10
- package/dist/workspace/lineage-check.d.ts +3 -0
- package/dist/workspace/lineage-check.d.ts.map +1 -1
- package/dist/workspace/lineage-check.js +23 -4
- package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.js +13 -4
- package/dist/workspace/links.d.ts +8 -1
- package/dist/workspace/links.d.ts.map +1 -1
- package/dist/workspace/links.js +25 -1
- package/dist/workspace/ls.d.ts +8 -0
- package/dist/workspace/ls.d.ts.map +1 -1
- package/dist/workspace/ls.js +7 -1
- package/dist/workspace/ls.schema.json +7 -0
- package/dist/workspace/member-commands.d.ts.map +1 -1
- package/dist/workspace/member-commands.js +54 -5
- package/dist/workspace/migrate-links.d.ts +45 -0
- package/dist/workspace/migrate-links.d.ts.map +1 -0
- package/dist/workspace/migrate-links.js +100 -0
- package/dist/workspace/migration-dirs.d.ts +74 -0
- package/dist/workspace/migration-dirs.d.ts.map +1 -0
- package/dist/workspace/migration-dirs.js +254 -0
- package/dist/workspace/new-migrations.d.ts +47 -0
- package/dist/workspace/new-migrations.d.ts.map +1 -0
- package/dist/workspace/new-migrations.js +91 -0
- package/dist/workspace/pr-report.schema.json +46 -0
- package/dist/workspace/promote.d.ts +96 -0
- package/dist/workspace/promote.d.ts.map +1 -0
- package/dist/workspace/promote.js +263 -0
- package/dist/workspace/reason-codes.d.ts +21 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +25 -0
- package/dist/workspace/records-cli.d.ts +11 -0
- package/dist/workspace/records-cli.d.ts.map +1 -1
- package/dist/workspace/records-cli.js +57 -5
- package/dist/workspace/records.schema.json +5 -0
- package/dist/workspace/release-candidates.d.ts +2 -0
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +5 -2
- package/dist/workspace/release-train.d.ts +53 -0
- package/dist/workspace/release-train.d.ts.map +1 -0
- package/dist/workspace/release-train.js +134 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +4 -3
- package/dist/workspace/repo-ref.d.ts +45 -0
- package/dist/workspace/repo-ref.d.ts.map +1 -0
- package/dist/workspace/repo-ref.js +114 -0
- package/dist/workspace/run-event.schema.json +2 -2
- package/dist/workspace/runs-cli.d.ts +9 -0
- package/dist/workspace/runs-cli.d.ts.map +1 -1
- package/dist/workspace/runs-cli.js +48 -3
- package/dist/workspace/runs.schema.json +7 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/status-decisions.d.ts +37 -0
- package/dist/workspace/status-decisions.d.ts.map +1 -0
- package/dist/workspace/status-decisions.js +147 -0
- package/dist/workspace/status-gates.d.ts +9 -0
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status.d.ts +4 -0
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/status.js +14 -2
- package/dist/workspace/status.schema.json +6 -0
- package/dist/workspace/work-cli.d.ts.map +1 -1
- package/dist/workspace/work-cli.js +5 -3
- package/dist/workspace/work-evidence-ops.d.ts +83 -0
- package/dist/workspace/work-evidence-ops.d.ts.map +1 -0
- package/dist/workspace/work-evidence-ops.js +169 -0
- package/dist/workspace/work-evidence.d.ts +12 -2
- package/dist/workspace/work-evidence.d.ts.map +1 -1
- package/dist/workspace/work-evidence.js +21 -3
- package/dist/workspace/work-evidence.schema.json +49 -2
- package/dist/workspace/workspace-gates.d.ts +110 -0
- package/dist/workspace/workspace-gates.d.ts.map +1 -0
- package/dist/workspace/workspace-gates.js +140 -0
- package/dist/workspace/workspace-kinds.schema.json +108 -10
- package/dist/workspace/workspace-ledger.d.ts +76 -0
- package/dist/workspace/workspace-ledger.d.ts.map +1 -0
- package/dist/workspace/workspace-ledger.js +91 -0
- package/dist/workspace/workspace-run.d.ts +112 -0
- package/dist/workspace/workspace-run.d.ts.map +1 -0
- package/dist/workspace/workspace-run.js +432 -0
- package/package.json +1 -1
- package/src/__golden__/wave-loop/op-by-apply-after-fails.json +10 -0
- package/src/__golden__/wave-loop/op-by-apply-hold.json +10 -0
- package/src/__golden__/wave-loop/op-by-apply-ignored.json +10 -0
- package/src/__golden__/wave-loop/op-by-apply-pass.json +10 -0
- package/src/__golden__/wave-loop/op-by-apply-skip.json +10 -0
- package/src/__golden__/wave-loop/op-cost-member-clash.json +6 -0
- package/src/__golden__/wave-loop/op-cost-member.json +13 -0
- package/src/__golden__/wave-loop/op-denied-source.json +16 -0
- package/src/__golden__/wave-loop/op-denied.json +16 -0
- package/src/__golden__/wave-loop/op-discover-rest-short.json +6 -0
- package/src/__golden__/wave-loop/op-discover-rest-stops.json +13 -0
- package/src/__golden__/wave-loop/op-discover-rest.json +26 -0
- package/src/__golden__/wave-loop/op-discover-wide.json +26 -0
- package/src/__golden__/wave-loop/op-held-on-again.json +16 -0
- package/src/__golden__/wave-loop/op-held-on-before-apply.json +16 -0
- package/src/__golden__/wave-loop/op-held-on.json +16 -0
- package/src/__golden__/wave-loop/op-hooks-apply-fails.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-fail-after-apply.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-fail-before-apply.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-fail-before-plan.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-held.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-hold-before-apply.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-pass.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-refused-at-base.json +13 -0
- package/src/__golden__/wave-loop/op-hooks-share.json +33 -0
- package/src/__golden__/wave-loop/op-outcome-held.json +10 -0
- package/src/__golden__/wave-loop/op-outcome-replan-approved.json +10 -0
- package/src/__golden__/wave-loop/op-outcome-replan-forever.json +10 -0
- package/src/__golden__/wave-loop/op-outcome-replan.json +10 -0
- package/src/__golden__/wave-loop/op-outcome-stood-down.json +10 -0
- package/src/__golden__/wave-loop/op-outcome-unreadable.json +10 -0
- package/src/__golden__/wave-loop/op-overridden.json +16 -0
- package/src/__golden__/wave-loop/op-per-run.json +20 -0
- package/src/__golden__/wave-loop/op-point.json +13 -0
- package/src/__golden__/wave-loop/op-pr-review.json +10 -0
- package/src/__golden__/wave-loop/op-sealed.json +10 -0
- package/src/__golden__/wave-loop/op-spend-change-only.json +10 -0
- package/src/__golden__/wave-loop/op-spend.json +10 -0
- package/src/__golden__/wave-loop/op-wave-commands.json +55 -0
- package/src/__golden__/wave-loop/op-wide-refused.json +26 -0
- package/src/__golden__/wave-loop/op-wide-waiting.json +29 -0
- package/src/__golden__/wave-loop/op-wide.json +39 -0
- package/src/action-pins.test.ts +78 -0
- package/src/action-pins.ts +92 -0
- package/src/cli/commands/carve-score-once.test.ts +99 -0
- package/src/cli/commands/carve.ts +37 -6
- package/src/cli/commands/check-lexicon.test.ts +2 -2
- package/src/cli/commands/import-report.ts +71 -0
- package/src/cli/commands/import.ts +33 -3
- package/src/cli/commands/migrate-dialect.test.ts +145 -0
- package/src/cli/commands/migrate.ts +132 -11
- package/src/cli/handlers/__snapshots__/build-member.test.ts.snap +4 -4
- package/src/cli/handlers/approve.ts +33 -4
- package/src/cli/handlers/build.ts +7 -1
- package/src/cli/handlers/graph-reader.test.ts +31 -0
- package/src/cli/handlers/graph-reader.ts +51 -0
- package/src/cli/handlers/graph.ts +14 -0
- package/src/cli/handlers/ledger.ts +54 -0
- package/src/cli/handlers/migrate.ts +21 -12
- package/src/cli/handlers/misc.ts +10 -1
- package/src/cli/handlers/pr-env.ts +2 -2
- package/src/cli/handlers/pr.ts +176 -37
- package/src/cli/handlers/query.ts +16 -4
- package/src/cli/handlers/release.ts +6 -3
- package/src/cli/handlers/search.ts +13 -34
- package/src/cli/main.test.ts +17 -0
- package/src/cli/main.ts +87 -14
- package/src/cli/parse-args.ts +35 -2
- package/src/cli/registry.ts +22 -4
- package/src/components/builders.ts +8 -0
- package/src/components/capability-plugin-loader.ts +13 -1
- package/src/components/capability-plugin.ts +16 -0
- package/src/components/pr-env-run-bundle.test.ts +1 -0
- package/src/components/pr-hooks.test.ts +73 -5
- package/src/components/pr-hooks.ts +95 -5
- package/src/components/pr-pipeline.ts +64 -16
- package/src/components/pr-policy.test.ts +64 -1
- package/src/components/pr-policy.ts +53 -0
- package/src/components/pr-run.ts +4 -0
- package/src/components/registry.test.ts +1 -1
- package/src/components/starter-plugin.ts +6 -0
- package/src/components/verbs/index.ts +2 -0
- package/src/components/verbs/publish-artifact.test.ts +60 -0
- package/src/components/verbs/publish-artifact.ts +122 -0
- package/src/components/verbs/publish-image.test.ts +101 -0
- package/src/components/verbs/publish-image.ts +265 -0
- package/src/config-environments.ts +28 -1
- package/src/config.ts +24 -1
- package/src/gate-decision-bundle.test.ts +5 -2
- package/src/gate-decision-identity.test.ts +20 -0
- package/src/gate-decision.ts +46 -3
- package/src/graph-ir.ts +27 -0
- package/src/graph-walk.test.ts +44 -0
- package/src/graph-walk.ts +102 -0
- package/src/import/parser.ts +20 -0
- package/src/lexicon.ts +98 -6
- package/src/lifecycle/gate-ledger.ts +8 -0
- package/src/lifecycle/git.ts +2 -2
- package/src/lifecycle/ledger-read.test.ts +107 -0
- package/src/lifecycle/ledger-read.ts +195 -0
- package/src/lifecycle/release-workstation.ts +24 -0
- package/src/lifecycle/run-ledger.ts +5 -2
- package/src/lint/cross-root.test.ts +122 -0
- package/src/lint/discover.ts +3 -1
- package/src/lint/post-synth.ts +212 -2
- package/src/lint/rules/op/index.ts +2 -0
- package/src/lint/rules/op/ops019-workspace-op-target.ts +89 -0
- package/src/op/activities/activity-contracts.ts +5 -2
- package/src/op/activities/index.ts +2 -2
- package/src/op/activities/review-agent.test.ts +221 -4
- package/src/op/activities/review-agent.ts +265 -22
- package/src/op/activities/work-evidence.ts +9 -1
- package/src/op/builders.ts +9 -5
- package/src/op/composites/apply-op.test.ts +108 -0
- package/src/op/composites/apply-op.ts +37 -2
- package/src/op/gate-approval-at-base.test.ts +97 -0
- package/src/op/gate-approval-base.ts +72 -0
- package/src/op/gate-approval.test.ts +6 -1
- package/src/op/gate-approval.ts +22 -27
- package/src/op/gate-name.ts +16 -1
- package/src/op/gate-quorum-at-base.test.ts +211 -0
- package/src/op/gate-quorum.ts +156 -8
- package/src/op/gate-review.ts +14 -0
- package/src/op/gate.ts +69 -9
- package/src/op/index.ts +3 -2
- package/src/op/local-executor.ts +91 -11
- package/src/op/op-waves-depends-on.test.ts +81 -0
- package/src/op/op-waves-hook-targets.test.ts +4 -2
- package/src/op/op-waves-quorum-product.test.ts +158 -0
- package/src/op/op-waves-run.ts +288 -14
- package/src/op/op-waves.ts +143 -14
- package/src/op/runtime.ts +8 -0
- package/src/op/schedule-overdue.ts +33 -0
- package/src/op/stage-hooks.ts +13 -5
- package/src/op/workspace-run-env.ts +29 -0
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +47 -0
- package/src/pr-forge.ts +68 -0
- package/src/pr-loop-bundle.test.ts +3 -2
- package/src/pr-loop.test.ts +52 -0
- package/src/pr-loop.ts +12 -0
- package/src/pr-migrations.ts +97 -0
- package/src/pr-post-open.e2e.test.ts +36 -0
- package/src/pr-post.test.ts +102 -3
- package/src/pr-post.ts +90 -2
- package/src/read-filter.test.ts +54 -0
- package/src/read-filter.ts +193 -0
- package/src/run-event.ts +1 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/terraform/carve.ts +52 -15
- package/src/terraform/cuts.test.ts +173 -0
- package/src/terraform/cuts.ts +188 -0
- package/src/terraform/folds.ts +44 -0
- package/src/terraform/graph.ts +9 -0
- package/src/terraform/radius.test.ts +90 -0
- package/src/terraform/reach.test.ts +146 -0
- package/src/terraform/reach.ts +247 -0
- package/src/terraform/score.ts +27 -29
- package/src/terraform/state.ts +3 -1
- package/src/terraform/types.ts +8 -0
- package/src/wave-blocked.ts +28 -3
- package/src/wave-loop-golden.test.ts +4 -3
- package/src/workspace/__fixtures__/import/spacelift.json +9 -0
- package/src/workspace/__fixtures__/import/tfc.json +13 -0
- package/src/workspace/behold-kinds.test.ts +2 -1
- package/src/workspace/check-contract.test.ts +8 -6
- package/src/workspace/check.schema.json +13 -2
- package/src/workspace/checks/ci-branch.test.ts +128 -0
- package/src/workspace/checks/ci-branch.ts +141 -0
- package/src/workspace/checks/gate-approval.test.ts +77 -0
- package/src/workspace/checks/gate-approval.ts +121 -0
- package/src/workspace/checks/links.ts +12 -1
- package/src/workspace/checks/org.ts +169 -0
- package/src/workspace/checks.ts +68 -7
- package/src/workspace/ci-branches.ts +31 -0
- package/src/workspace/ci-green-branches.test.ts +153 -0
- package/src/workspace/ci-green-cli.ts +7 -7
- package/src/workspace/ci-green-workflow.test.ts +4 -3
- package/src/workspace/ci-green-workflow.ts +13 -9
- package/src/workspace/ci-green.ts +49 -12
- package/src/workspace/ci-run.test.ts +72 -1
- package/src/workspace/ci-run.ts +68 -8
- package/src/workspace/ci-serve.test.ts +95 -0
- package/src/workspace/ci-serve.ts +106 -65
- package/src/workspace/component-environments.test.ts +25 -2
- package/src/workspace/compose-graph.ts +9 -2
- package/src/workspace/composites.schema.json +22 -0
- package/src/workspace/composites.test.ts +39 -8
- package/src/workspace/composites.ts +6 -2
- package/src/workspace/conformance/__writer_fixture__/work/work.schema.json +105 -1
- package/src/workspace/cross-root-lint.test.ts +90 -0
- package/src/workspace/cross-root-lint.ts +126 -0
- package/src/workspace/dbt-kind.test.ts +3 -2
- package/src/workspace/dbt-models-reader.ts +362 -0
- package/src/workspace/dbt-models.test.ts +248 -0
- package/src/workspace/dbt-project-common.ts +113 -0
- package/src/workspace/dbt-project-reader.ts +29 -112
- package/src/workspace/decision-rank.ts +40 -0
- package/src/workspace/declaration.schema.json +166 -24
- package/src/workspace/declaration.ts +101 -15
- package/src/workspace/environments.ts +40 -4
- package/src/workspace/exit-cli.ts +219 -0
- package/src/workspace/exit.schema.json +257 -0
- package/src/workspace/exit.test.ts +185 -0
- package/src/workspace/exit.ts +560 -0
- package/src/workspace/flyway-dir.ts +113 -0
- package/src/workspace/flyway-layout.ts +337 -0
- package/src/workspace/graph-cache.ts +12 -2
- package/src/workspace/graph-cli.ts +25 -10
- package/src/workspace/graph-contract.test.ts +4 -2
- package/src/workspace/graph.schema.json +34 -0
- package/src/workspace/identity.test.ts +29 -2
- package/src/workspace/import-fetch.ts +151 -0
- package/src/workspace/import-init.ts +147 -0
- package/src/workspace/import-source.test.ts +183 -0
- package/src/workspace/import-source.ts +462 -0
- package/src/workspace/init.test.ts +55 -1
- package/src/workspace/init.ts +66 -4
- package/src/workspace/intent.ts +6 -14
- package/src/workspace/kind-link-readers.ts +68 -3
- package/src/workspace/kind-readers.test.ts +36 -0
- package/src/workspace/kind-readers.ts +18 -1
- package/src/workspace/kinds.test.ts +35 -7
- package/src/workspace/kinds.ts +212 -11
- package/src/workspace/ledger.schema.json +158 -0
- package/src/workspace/lexicon-outputs.ts +132 -13
- package/src/workspace/lineage-check.ts +30 -7
- package/src/workspace/lineage-upgrade.test.ts +20 -0
- package/src/workspace/lineage-upgrade.ts +16 -7
- package/src/workspace/links.ts +24 -1
- package/src/workspace/ls-contract.test.ts +1 -1
- package/src/workspace/ls.schema.json +7 -0
- package/src/workspace/ls.ts +10 -1
- package/src/workspace/member-commands.ts +60 -2
- package/src/workspace/member-file-schema.test.ts +124 -0
- package/src/workspace/migrate-links.test.ts +99 -0
- package/src/workspace/migrate-links.ts +108 -0
- package/src/workspace/migration-dirs.test.ts +272 -0
- package/src/workspace/migration-dirs.ts +267 -0
- package/src/workspace/new-migrations.test.ts +98 -0
- package/src/workspace/new-migrations.ts +109 -0
- package/src/workspace/org-scope.test.ts +238 -0
- package/src/workspace/pr-report.schema.json +46 -0
- package/src/workspace/promote.test.ts +114 -0
- package/src/workspace/promote.ts +302 -0
- package/src/workspace/reason-codes.test.ts +10 -1
- package/src/workspace/reason-codes.ts +25 -0
- package/src/workspace/records-cli.ts +58 -5
- package/src/workspace/records.schema.json +5 -0
- package/src/workspace/release-candidates.ts +7 -2
- package/src/workspace/release-train.ts +157 -0
- package/src/workspace/release-workflow.ts +4 -3
- package/src/workspace/repo-ref.ts +113 -0
- package/src/workspace/run-event.schema.json +2 -2
- package/src/workspace/runs-cli.ts +48 -4
- package/src/workspace/runs.schema.json +7 -0
- package/src/workspace/status-contract.test.ts +46 -1
- package/src/workspace/status-decisions.test.ts +100 -0
- package/src/workspace/status-decisions.ts +151 -0
- package/src/workspace/status-gates.ts +9 -0
- package/src/workspace/status.schema.json +6 -0
- package/src/workspace/status.ts +17 -3
- package/src/workspace/where-filters.test.ts +39 -0
- package/src/workspace/work-cli.ts +5 -3
- package/src/workspace/work-evidence-ops.test.ts +176 -0
- package/src/workspace/work-evidence-ops.ts +189 -0
- package/src/workspace/work-evidence.schema.json +49 -2
- package/src/workspace/work-evidence.ts +22 -3
- package/src/workspace/workspace-gates.ts +200 -0
- package/src/workspace/workspace-kinds.schema.json +108 -10
- package/src/workspace/workspace-ledger.ts +130 -0
- package/src/workspace/workspace-run.test.ts +322 -0
- package/src/workspace/workspace-run.ts +461 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Flyway project's layout, read from a workspace tree (#4400): its
|
|
3
|
+
* `flyway.toml` or `flyway.conf`, the locations it names, read recursively,
|
|
4
|
+
* and the placeholders it substitutes.
|
|
5
|
+
*
|
|
6
|
+
* This is the layout reading of sql-yodeler's `src/check/flyway.ts` (#250),
|
|
7
|
+
* moved here so the workspace kind and `yodel check` share one reader. It
|
|
8
|
+
* works on a {@link WorkspaceTree} and tree-relative paths instead of the
|
|
9
|
+
* file system, and it never runs Flyway or connects to a database.
|
|
10
|
+
*
|
|
11
|
+
* The configuration is the first `flyway.toml`, else `flyway.conf`, found in
|
|
12
|
+
* the directory checked or a directory above it, up to the tree's root. Its
|
|
13
|
+
* locations are read relative to the file's own directory:
|
|
14
|
+
*
|
|
15
|
+
* filesystem:<path> that directory
|
|
16
|
+
* classpath:<path> src/main/resources/<path> (and, for code
|
|
17
|
+
* <path> migrations, src/main/java/<path> and src/main/kotlin/<path>)
|
|
18
|
+
*
|
|
19
|
+
* With no configuration, or one that names no location, the directory
|
|
20
|
+
* checked is the one location. A location outside the tree is reported by
|
|
21
|
+
* {@link FlywayConfig.outside}, not read. A Java or Kotlin migration in a
|
|
22
|
+
* location is not SQL and is reported by {@link codeMigrations}.
|
|
23
|
+
*
|
|
24
|
+
* Placeholders are `${name}` (the prefix and suffix are configurable), from
|
|
25
|
+
* `flyway.placeholders.<name>` (conf) or `[flyway.placeholders]` (toml), plus
|
|
26
|
+
* Flyway's own: `flyway:defaultSchema`, `flyway:user`, `flyway:database`,
|
|
27
|
+
* `flyway:timestamp`, `flyway:filename`, `flyway:workingDirectory`,
|
|
28
|
+
* `flyway:table` and `flyway:environment`. {@link substitute} replaces them
|
|
29
|
+
* for a replay; the reader that lists migrations leaves the text as it is.
|
|
30
|
+
*/
|
|
31
|
+
import { posix } from "node:path";
|
|
32
|
+
import { joinPath } from "./tree.js";
|
|
33
|
+
/** The first `flyway.toml`, else `flyway.conf`, in `dir` or a directory above it, up to the tree's root. */
|
|
34
|
+
export function findFlywayConfig(tree, dir) {
|
|
35
|
+
let at = dir;
|
|
36
|
+
for (;;) {
|
|
37
|
+
for (const name of ["flyway.toml", "flyway.conf"]) {
|
|
38
|
+
const f = joinPath(at, name);
|
|
39
|
+
if (tree.stat(f) === "file")
|
|
40
|
+
return f;
|
|
41
|
+
}
|
|
42
|
+
if (at === "" || at === ".")
|
|
43
|
+
return undefined;
|
|
44
|
+
at = posix.dirname(at) === "." ? "" : posix.dirname(at);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Java-properties `flyway.*` keys, without the `flyway.` prefix. */
|
|
48
|
+
export function parseFlywayConf(text) {
|
|
49
|
+
const out = {};
|
|
50
|
+
const lines = text.split(/\r?\n/);
|
|
51
|
+
for (let i = 0; i < lines.length; i++) {
|
|
52
|
+
let line = lines[i] ?? "";
|
|
53
|
+
while (/\\$/.test(line) && i + 1 < lines.length)
|
|
54
|
+
line = line.slice(0, -1) + (lines[++i] ?? "").trimStart();
|
|
55
|
+
const t = line.trim();
|
|
56
|
+
if (t === "" || t.startsWith("#") || t.startsWith("!"))
|
|
57
|
+
continue;
|
|
58
|
+
const m = /^([^=:\s]+)\s*[=:]\s*(.*)$/.exec(t);
|
|
59
|
+
if (!m)
|
|
60
|
+
continue;
|
|
61
|
+
const key = m[1] ?? "";
|
|
62
|
+
if (!key.startsWith("flyway."))
|
|
63
|
+
continue;
|
|
64
|
+
out[key.slice("flyway.".length)] = (m[2] ?? "").trim();
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** A TOML document, as far as Flyway's configuration uses it: tables, strings, arrays of strings, booleans and numbers. */
|
|
69
|
+
export function parseToml(text) {
|
|
70
|
+
const tables = { "": {} };
|
|
71
|
+
let current = "";
|
|
72
|
+
const lines = text.split(/\r?\n/);
|
|
73
|
+
for (let i = 0; i < lines.length; i++) {
|
|
74
|
+
const t = stripComment(lines[i] ?? "").trim();
|
|
75
|
+
if (t === "")
|
|
76
|
+
continue;
|
|
77
|
+
const table = /^\[\s*([^\]]+?)\s*\]$/.exec(t);
|
|
78
|
+
if (table) {
|
|
79
|
+
current = (table[1] ?? "").split(".").map((k) => unquote(k.trim())).join(".");
|
|
80
|
+
tables[current] ?? (tables[current] = {});
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const kv = /^("[^"]*"|'[^']*'|[A-Za-z0-9_.:-]+)\s*=\s*(.*)$/.exec(t);
|
|
84
|
+
if (!kv)
|
|
85
|
+
continue;
|
|
86
|
+
let raw = kv[2] ?? "";
|
|
87
|
+
// A multi-line array runs to its closing bracket.
|
|
88
|
+
while (raw.trimStart().startsWith("[") && !balanced(raw) && i + 1 < lines.length)
|
|
89
|
+
raw += ` ${stripComment(lines[++i] ?? "").trim()}`;
|
|
90
|
+
const path = unquote(kv[1] ?? "").split(".");
|
|
91
|
+
const key = path.pop() ?? "";
|
|
92
|
+
const where = [current, ...path].filter(Boolean).join(".");
|
|
93
|
+
tables[where] ?? (tables[where] = {});
|
|
94
|
+
tables[where][key] = tomlValue(raw.trim());
|
|
95
|
+
}
|
|
96
|
+
return tables;
|
|
97
|
+
}
|
|
98
|
+
function stripComment(line) {
|
|
99
|
+
let quote;
|
|
100
|
+
for (let i = 0; i < line.length; i++) {
|
|
101
|
+
const c = line[i];
|
|
102
|
+
if (quote) {
|
|
103
|
+
if (c === "\\" && quote === '"')
|
|
104
|
+
i++;
|
|
105
|
+
else if (c === quote)
|
|
106
|
+
quote = undefined;
|
|
107
|
+
}
|
|
108
|
+
else if (c === '"' || c === "'")
|
|
109
|
+
quote = c;
|
|
110
|
+
else if (c === "#")
|
|
111
|
+
return line.slice(0, i);
|
|
112
|
+
}
|
|
113
|
+
return line;
|
|
114
|
+
}
|
|
115
|
+
const balanced = (s) => (s.match(/\[/g) ?? []).length <= (s.match(/\]/g) ?? []).length;
|
|
116
|
+
function unquote(s) {
|
|
117
|
+
if ((s.startsWith('"') && s.endsWith('"')) || (s.startsWith("'") && s.endsWith("'")))
|
|
118
|
+
return s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
119
|
+
return s;
|
|
120
|
+
}
|
|
121
|
+
function tomlValue(raw) {
|
|
122
|
+
if (raw === "true" || raw === "false")
|
|
123
|
+
return raw === "true";
|
|
124
|
+
if (raw.startsWith("[")) {
|
|
125
|
+
const inner = raw.replace(/^\[/, "").replace(/\]\s*$/, "");
|
|
126
|
+
return (inner.match(/"(?:[^"\\]|\\.)*"|'[^']*'|[^,\s]+/g) ?? []).map((v) => unquote(v.trim())).filter((v) => v !== "");
|
|
127
|
+
}
|
|
128
|
+
return unquote(raw);
|
|
129
|
+
}
|
|
130
|
+
const list = (v) => v === undefined || typeof v === "boolean" ? undefined : Array.isArray(v) ? v : v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
131
|
+
const str = (v) => (typeof v === "string" ? v : Array.isArray(v) ? v.join(",") : undefined);
|
|
132
|
+
/** The database name a JDBC URL names: the path after the host. */
|
|
133
|
+
function databaseOf(url) {
|
|
134
|
+
const m = url === undefined ? null : /^jdbc:[a-z0-9]+:\/\/[^/]+\/([^?;]+)/i.exec(url);
|
|
135
|
+
return m?.[1] ?? undefined;
|
|
136
|
+
}
|
|
137
|
+
/** The dialect a JDBC URL names. */
|
|
138
|
+
function dialectOf(url) {
|
|
139
|
+
const m = url === undefined ? null : /^jdbc:([a-z0-9]+):/i.exec(url);
|
|
140
|
+
const driver = m?.[1]?.toLowerCase();
|
|
141
|
+
return driver === "postgresql" ? "postgres" : driver === "clickhouse" ? "clickhouse" : undefined;
|
|
142
|
+
}
|
|
143
|
+
/** The configuration `file` holds, or the defaults with `dir` as the one location when there is none. */
|
|
144
|
+
export function readFlywayConfig(tree, file, dir) {
|
|
145
|
+
let values = {};
|
|
146
|
+
let placeholders = {};
|
|
147
|
+
if (file !== undefined) {
|
|
148
|
+
const text = tree.read(file);
|
|
149
|
+
if (file.endsWith(".toml")) {
|
|
150
|
+
const t = parseToml(text);
|
|
151
|
+
const flyway = t.flyway ?? {};
|
|
152
|
+
const name = str(flyway.environment) ?? "default";
|
|
153
|
+
const env = t[`environments.${name}`] ?? {};
|
|
154
|
+
values = { ...flyway, ...(t[`environments.${name}.flyway`] ?? {}), ...(env.url !== undefined ? { url: env.url } : {}), ...(env.user !== undefined ? { user: env.user } : {}), ...(env.schemas !== undefined ? { schemas: env.schemas } : {}) };
|
|
155
|
+
if (str(flyway.environment) !== undefined)
|
|
156
|
+
values.environment = name;
|
|
157
|
+
placeholders = Object.fromEntries(Object.entries({ ...(t["flyway.placeholders"] ?? {}), ...(t[`environments.${name}.flyway.placeholders`] ?? {}) }).map(([k, v]) => [k, str(v) ?? String(v)]));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
values = parseFlywayConf(text);
|
|
161
|
+
placeholders = Object.fromEntries(Object.entries(values).flatMap(([k, v]) => (k.startsWith("placeholders.") ? [[k.slice("placeholders.".length), str(v) ?? ""]] : [])));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const root = file === undefined ? dir : posix.dirname(file) === "." ? "" : posix.dirname(file);
|
|
165
|
+
const named = list(values.locations) ?? [];
|
|
166
|
+
const locations = [];
|
|
167
|
+
const codeLocations = [];
|
|
168
|
+
const outside = [];
|
|
169
|
+
const inside = (...parts) => {
|
|
170
|
+
const p = posix.normalize(joinPath(...parts)) || ".";
|
|
171
|
+
if (p === ".." || p.startsWith("../") || posix.isAbsolute(p))
|
|
172
|
+
return undefined;
|
|
173
|
+
return p === "." ? "" : p;
|
|
174
|
+
};
|
|
175
|
+
for (const l of named) {
|
|
176
|
+
const m = /^(filesystem|classpath):(.*)$/.exec(l);
|
|
177
|
+
const kind = m?.[1] ?? "classpath";
|
|
178
|
+
const raw = m?.[2] ?? l;
|
|
179
|
+
if (kind === "filesystem") {
|
|
180
|
+
const at = posix.isAbsolute(raw) ? undefined : inside(root, raw);
|
|
181
|
+
if (at === undefined)
|
|
182
|
+
outside.push(l);
|
|
183
|
+
else
|
|
184
|
+
locations.push(at);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
const path = raw.replace(/^\/+/, "");
|
|
188
|
+
const res = inside(root, "src/main/resources", path);
|
|
189
|
+
if (res === undefined)
|
|
190
|
+
outside.push(l);
|
|
191
|
+
else {
|
|
192
|
+
locations.push(res);
|
|
193
|
+
for (const lang of ["java", "kotlin"]) {
|
|
194
|
+
const c = inside(root, "src/main", lang, path);
|
|
195
|
+
if (c !== undefined)
|
|
196
|
+
codeLocations.push(c);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (named.length === 0)
|
|
202
|
+
locations.push(dir);
|
|
203
|
+
const schemas = list(values.schemas);
|
|
204
|
+
const replacement = values.placeholderReplacement;
|
|
205
|
+
const defaultSchema = str(values.defaultSchema) ?? schemas?.[0];
|
|
206
|
+
const user = str(values.user);
|
|
207
|
+
const url = str(values.url);
|
|
208
|
+
const database = databaseOf(url);
|
|
209
|
+
const dialect = dialectOf(url);
|
|
210
|
+
const environment = str(values.environment);
|
|
211
|
+
return {
|
|
212
|
+
...(file !== undefined ? { file } : {}),
|
|
213
|
+
root,
|
|
214
|
+
locations,
|
|
215
|
+
codeLocations,
|
|
216
|
+
outside,
|
|
217
|
+
placeholders,
|
|
218
|
+
placeholderPrefix: str(values.placeholderPrefix) ?? "${",
|
|
219
|
+
placeholderSuffix: str(values.placeholderSuffix) ?? "}",
|
|
220
|
+
placeholderReplacement: !(replacement === false || replacement === "false"),
|
|
221
|
+
sqlMigrationPrefix: str(values.sqlMigrationPrefix) ?? "V",
|
|
222
|
+
repeatableSqlMigrationPrefix: str(values.repeatableSqlMigrationPrefix) ?? "R",
|
|
223
|
+
baselineMigrationPrefix: str(values.baselineMigrationPrefix) ?? "B",
|
|
224
|
+
undoSqlMigrationPrefix: str(values.undoSqlMigrationPrefix) ?? "U",
|
|
225
|
+
sqlMigrationSeparator: str(values.sqlMigrationSeparator) ?? "__",
|
|
226
|
+
sqlMigrationSuffixes: list(values.sqlMigrationSuffixes) ?? [".sql"],
|
|
227
|
+
...(defaultSchema !== undefined ? { defaultSchema } : {}),
|
|
228
|
+
...(user !== undefined ? { user } : {}),
|
|
229
|
+
...(database !== undefined ? { database } : {}),
|
|
230
|
+
...(url !== undefined ? { url } : {}),
|
|
231
|
+
...(dialect !== undefined ? { dialect } : {}),
|
|
232
|
+
table: str(values.table) ?? "flyway_schema_history",
|
|
233
|
+
...(environment !== undefined ? { environment } : {}),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/** Every file under `dir`, recursively, tree-relative, sorted; none when it does not exist. */
|
|
237
|
+
export function walk(tree, dir) {
|
|
238
|
+
const entries = tree.list(dir);
|
|
239
|
+
if (!entries)
|
|
240
|
+
return [];
|
|
241
|
+
const out = [];
|
|
242
|
+
for (const e of [...entries].sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))) {
|
|
243
|
+
const p = joinPath(dir, e.name);
|
|
244
|
+
if (e.type === "dir")
|
|
245
|
+
out.push(...walk(tree, p));
|
|
246
|
+
else
|
|
247
|
+
out.push(p);
|
|
248
|
+
}
|
|
249
|
+
return out;
|
|
250
|
+
}
|
|
251
|
+
const base = (f) => posix.basename(f);
|
|
252
|
+
/** A Flyway SQL callback (`beforeMigrate.sql`, `afterEachMigrate__notify.sql`, ...): run around a migrate, not a migration. */
|
|
253
|
+
export const isCallback = (file) => /^(before|after)[A-Z][A-Za-z]*(__.*)?\.[A-Za-z]+$/.test(base(file));
|
|
254
|
+
/** The code migrations (Java, Kotlin) in `config`'s locations, relative to the tree. */
|
|
255
|
+
export function codeMigrations(tree, config) {
|
|
256
|
+
const code = /\.(java|kt|class)$/;
|
|
257
|
+
const prefixes = [config.sqlMigrationPrefix, config.repeatableSqlMigrationPrefix, config.baselineMigrationPrefix].filter(Boolean);
|
|
258
|
+
const migration = (f) => code.test(f) && prefixes.some((p) => base(f).startsWith(p)) && base(f).includes(config.sqlMigrationSeparator);
|
|
259
|
+
return [...new Set([...config.locations, ...config.codeLocations])].flatMap((d) => walk(tree, d)).filter(migration);
|
|
260
|
+
}
|
|
261
|
+
/** The values Flyway gives its own placeholders, for `file`. */
|
|
262
|
+
function builtins(config, file, fallback) {
|
|
263
|
+
return {
|
|
264
|
+
"flyway:defaultSchema": config.defaultSchema ?? fallback.defaultSchema,
|
|
265
|
+
"flyway:user": config.user,
|
|
266
|
+
"flyway:database": config.database,
|
|
267
|
+
"flyway:timestamp": new Date().toISOString().replace("T", " ").replace(/\..*$/, ""),
|
|
268
|
+
"flyway:filename": base(file),
|
|
269
|
+
"flyway:workingDirectory": process.cwd(),
|
|
270
|
+
"flyway:table": config.table,
|
|
271
|
+
"flyway:environment": config.environment,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
275
|
+
/** A placeholder with no value; `file` is as the caller passed it, `line` is from 1. */
|
|
276
|
+
export class FlywayPlaceholderError extends Error {
|
|
277
|
+
constructor(file, line, placeholder, name, where) {
|
|
278
|
+
super(`${file}:${String(line)}: no value for the placeholder ${placeholder}; set it in ${where} (flyway.placeholders.${name} in flyway.conf, [flyway.placeholders] in flyway.toml)`);
|
|
279
|
+
this.file = file;
|
|
280
|
+
this.line = line;
|
|
281
|
+
this.placeholder = placeholder;
|
|
282
|
+
this.name = name;
|
|
283
|
+
this.where = where;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* `text` with its placeholders replaced, line by line so line numbers hold.
|
|
288
|
+
* A placeholder with no value throws a {@link FlywayPlaceholderError} naming
|
|
289
|
+
* `file` and the line, as Flyway's own run would fail.
|
|
290
|
+
*/
|
|
291
|
+
export function substitute(text, file, config, fallback = {}) {
|
|
292
|
+
if (!config.placeholderReplacement)
|
|
293
|
+
return text;
|
|
294
|
+
const values = { ...builtins(config, file, fallback), ...config.placeholders };
|
|
295
|
+
const lower = new Map(Object.entries(values).map(([k, v]) => [k.toLowerCase(), v]));
|
|
296
|
+
const pattern = new RegExp(`${escape(config.placeholderPrefix)}([A-Za-z0-9_.:-]+)${escape(config.placeholderSuffix)}`, "g");
|
|
297
|
+
return text
|
|
298
|
+
.split("\n")
|
|
299
|
+
.map((line, i) => line.replace(pattern, (whole, name) => {
|
|
300
|
+
const v = values[name] ?? lower.get(name.toLowerCase());
|
|
301
|
+
if (v === undefined) {
|
|
302
|
+
const where = config.file === undefined ? "a flyway.toml or flyway.conf beside the migrations" : config.file;
|
|
303
|
+
throw new FlywayPlaceholderError(file, i + 1, whole, name, where);
|
|
304
|
+
}
|
|
305
|
+
return v;
|
|
306
|
+
}))
|
|
307
|
+
.join("\n");
|
|
308
|
+
}
|
|
@@ -85,7 +85,9 @@ export declare function memberStamp(abs: string, exclude?: readonly string[], at
|
|
|
85
85
|
export declare function toolchainStamp(toolchain: Toolchain): string;
|
|
86
86
|
/** What a kind's reader adds to the key: its graph block, and the installed version of the package supplying it. */
|
|
87
87
|
export declare function readerStamp(reader: {
|
|
88
|
-
lexicon
|
|
88
|
+
lexicon?: string;
|
|
89
|
+
reader?: string;
|
|
90
|
+
readerFile?: string;
|
|
89
91
|
config: unknown;
|
|
90
92
|
packageDir: string;
|
|
91
93
|
}): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-cache.d.ts","sourceRoot":"","sources":["../../src/workspace/graph-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAc,KAAK,UAAU,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/G,gFAAgF;AAChF,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B,mHAAmH;AACnH,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C,eAAO,MAAM,WAAW,MAAM,CAAC;AAC/B,eAAO,MAAM,SAAS,QAAoB,CAAC;AAE3C,gFAAgF;AAChF,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,qFAA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;IACzB,4EAA4E;IAC5E,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,mEAAmE;IACnE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,oHAAoH;IACpH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,GAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,EAAwC,GAAG,UAAU,CA4B5L;AASD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUnF;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,UAAU,CAInF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CASrG"}
|
|
@@ -197,7 +197,18 @@ export function readerStamp(reader) {
|
|
|
197
197
|
catch {
|
|
198
198
|
// An unreadable manifest keys on the directory alone.
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
// A reader module is code: its size and mtime key too, so an edit under the same version is a new read (#4413).
|
|
201
|
+
let module = "";
|
|
202
|
+
if (reader.readerFile) {
|
|
203
|
+
try {
|
|
204
|
+
const st = statSync(reader.readerFile);
|
|
205
|
+
module = `${reader.reader}:${st.size}:${st.mtimeMs}`;
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
module = `${reader.reader}:unreadable`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return JSON.stringify([reader.lexicon, reader.config, reader.packageDir, version, ...(module ? [module] : [])]);
|
|
201
212
|
}
|
|
202
213
|
/** The ambient environment, less {@link VOLATILE_ENV}, as one digest. */
|
|
203
214
|
export function environmentStamp(env = process.env) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/graph-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAA2F,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI/I,OAAO,EAA6E,KAAK,WAAW,EAAE,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"graph-cli.d.ts","sourceRoot":"","sources":["../../src/workspace/graph-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAA0B,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAA2F,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAI/I,OAAO,EAA6E,KAAK,WAAW,EAAE,KAAK,aAAa,EAAgB,MAAM,eAAe,CAAC;AAC9J,OAAO,EAAgF,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpL,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAOzE,OAAO,EAAoC,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAExF,6DAA6D;AAC7D,eAA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,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,CAuCrG;AAiBD,qGAAqG;AACrG,wBAAsB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CA2C5E;AA2DD,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAsE5E"}
|
|
@@ -35,7 +35,8 @@ import { refusedCapabilityView } from "./nested-graph.js";
|
|
|
35
35
|
import { openGraphCache, planStamps, splitCached, storeReads, withoutUnits } from "./graph-cache.js";
|
|
36
36
|
import { readDeclaration, readerVersion, WORKSPACE_ERROR_CODES, WorkspaceReadError } from "./declaration.js";
|
|
37
37
|
import { describePlan, emitDocument, executePlan, memberStatus, planJson, planMembers } from "./member-commands.js";
|
|
38
|
-
import { loadKindRegistry } from "./kinds.js";
|
|
38
|
+
import { loadKindRegistry, REPO_KIND } from "./kinds.js";
|
|
39
|
+
import { repoIdentity } from "./repo-ref.js";
|
|
39
40
|
import { readKindLinks } from "./kind-link-readers.js";
|
|
40
41
|
import { prepareKindReaders } from "./kind-readers.js";
|
|
41
42
|
import { recordLinkRows } from "./record-assets.js";
|
|
@@ -247,11 +248,12 @@ export async function workspaceGraph(query) {
|
|
|
247
248
|
}
|
|
248
249
|
// Links (#2539) resolve against the declaration that was read, the revision's for --at, and the kinds installed now.
|
|
249
250
|
// A kind's link reader (#3932) reads the member's files in the tree read, as check does.
|
|
250
|
-
const graph = composeWorkspaceGraph({ name: declaration.name, root: located.root }, inputs, { declaration, kinds, read: readKindLinks(declaration, located.tree, kinds) });
|
|
251
|
+
const graph = composeWorkspaceGraph({ name: declaration.name, root: located.root, repo: repoIdentity(located.rootOnDisk) }, inputs, { declaration, kinds, read: readKindLinks(declaration, located.tree, kinds) });
|
|
251
252
|
// The box's factory and listing (#3146), from the declaration read, so --at gives them at that revision.
|
|
252
253
|
for (const member of graph.members)
|
|
253
254
|
member.box = graphBox(declaration.members.find((m) => m.name === member.name)?.box ?? null, located.tree, declaration.members);
|
|
254
255
|
// Nested workspaces (#2551, ws-071): read-only, through their own chant workspace graph.
|
|
256
|
+
// Repo members (#3168): another repository's workspace at its pinned revision, read the same way.
|
|
255
257
|
const nestedFailed = await expandNested(graph, declaration.members, query, located.rootOnDisk, located.at);
|
|
256
258
|
let recordsFailed = false;
|
|
257
259
|
if (query.kind !== undefined) {
|
|
@@ -281,28 +283,44 @@ export async function workspaceGraph(query) {
|
|
|
281
283
|
}
|
|
282
284
|
/**
|
|
283
285
|
* Expand every member of kind `workspace` the query covers, read-only (#2551,
|
|
284
|
-
* ws-071)
|
|
286
|
+
* ws-071), and every member of kind `repo` the same way, at its pinned
|
|
287
|
+
* revision, fetched into the user's cache (#3168). Returns whether one could
|
|
288
|
+
* not be read.
|
|
285
289
|
*/
|
|
286
290
|
async function expandNested(graph, members, query, rootOnDisk, at) {
|
|
287
|
-
const
|
|
291
|
+
const covered = (m) => !query.members?.length || query.members.includes(m.name);
|
|
292
|
+
const nested = members.filter((m) => (m.kind === "workspace" || (m.kind === REPO_KIND && m.repo !== null)) && covered(m));
|
|
288
293
|
if (nested.length === 0)
|
|
289
294
|
return false;
|
|
290
295
|
const { foldNested, readNested } = await import("./nested-graph.js");
|
|
296
|
+
const { fetchRepoAt } = await import("./repo-ref.js");
|
|
291
297
|
const reads = await Promise.all(nested.map(async (m) => {
|
|
298
|
+
if (m.repo) {
|
|
299
|
+
// The other repository at its pinned revision, whatever revision the outer read is at.
|
|
300
|
+
const fetched = fetchRepoAt(m.repo, rootOnDisk);
|
|
301
|
+
if (!fetched.ok)
|
|
302
|
+
return { m, read: null, missing: fetched.message };
|
|
303
|
+
if (!existsSync(fetched.dir))
|
|
304
|
+
return { m, read: null, missing: `${m.repo.url} at ${m.repo.rev} has no directory ${m.repo.workspace}` };
|
|
305
|
+
return { m, read: await readNested(fetched.dir, query.args ?? {}, m.repo.rev, GRAPH_OUTPUT_SCHEMA_ID, GRAPH_CONTRACT_VERSION, query.reader), missing: null };
|
|
306
|
+
}
|
|
292
307
|
const abs = join(rootOnDisk, ...m.dir.split("/"));
|
|
293
308
|
if (!existsSync(abs))
|
|
294
|
-
return { m, read: null };
|
|
295
|
-
return { m, read: await readNested(abs, query.args ?? {}, at, GRAPH_OUTPUT_SCHEMA_ID, GRAPH_CONTRACT_VERSION, query.reader) };
|
|
309
|
+
return { m, read: null, missing: null };
|
|
310
|
+
return { m, read: await readNested(abs, query.args ?? {}, at, GRAPH_OUTPUT_SCHEMA_ID, GRAPH_CONTRACT_VERSION, query.reader), missing: null };
|
|
296
311
|
}));
|
|
297
312
|
let failed = false;
|
|
298
|
-
for (const { m, read } of reads) {
|
|
313
|
+
for (const { m, read, missing } of reads) {
|
|
299
314
|
const member = graph.members.find((x) => x.name === m.name);
|
|
300
315
|
if (!member)
|
|
301
316
|
continue;
|
|
317
|
+
if (m.repo)
|
|
318
|
+
member.repo = { ...m.repo, read: read?.ok ? (read.doc.workspace.repo ?? null) : null };
|
|
302
319
|
if (!read) {
|
|
303
320
|
failed = true;
|
|
304
321
|
member.status = "failed";
|
|
305
|
-
|
|
322
|
+
// A repo that can't be fetched is a read that failed; the contract's codes stay as they are.
|
|
323
|
+
member.reason = missing !== null ? { code: "command-failed", message: missing } : { code: "dir-missing", message: `the nested workspace's directory ${m.dir} does not exist` };
|
|
306
324
|
continue;
|
|
307
325
|
}
|
|
308
326
|
if (read.stderr.trim() && query.onStderr)
|
|
@@ -67,6 +67,13 @@
|
|
|
67
67
|
"type": "string",
|
|
68
68
|
"description": "The declared name. With `at`, it identifies the workspace."
|
|
69
69
|
},
|
|
70
|
+
"repo": {
|
|
71
|
+
"type": [
|
|
72
|
+
"string",
|
|
73
|
+
"null"
|
|
74
|
+
],
|
|
75
|
+
"description": "Added in contract 1 by #3168. The repository the document came from: the URL of the remote origin of the git repository that holds the workspace, with any user name or password removed, or null when there is no origin or the workspace is outside git. With name, root and the revision, it says which repository's workspace a document describes, so a reader that gathers several repositories' documents, such as an org workspace's repo members, tells them apart."
|
|
76
|
+
},
|
|
70
77
|
"root": {
|
|
71
78
|
"type": "string",
|
|
72
79
|
"description": "The workspace root relative to the git root, with / separators, \".\" for the git root itself. An absolute path outside a git repository."
|
|
@@ -287,6 +294,33 @@
|
|
|
287
294
|
"type": "string",
|
|
288
295
|
"description": "Relative to the workspace root, with / separators; \".\" is the root member."
|
|
289
296
|
},
|
|
297
|
+
"repo": {
|
|
298
|
+
"type": "object",
|
|
299
|
+
"description": "Added in contract 1 by #3168. For a member of kind repo, the other repository's workspace it names: url, the pinned rev and the workspace root inside that repository. Absent for every other kind. A repo member's dir is @repo/<name>, a marker that names no directory of this repository.",
|
|
300
|
+
"required": [
|
|
301
|
+
"url",
|
|
302
|
+
"rev",
|
|
303
|
+
"workspace"
|
|
304
|
+
],
|
|
305
|
+
"properties": {
|
|
306
|
+
"url": {
|
|
307
|
+
"type": "string"
|
|
308
|
+
},
|
|
309
|
+
"rev": {
|
|
310
|
+
"type": "string"
|
|
311
|
+
},
|
|
312
|
+
"workspace": {
|
|
313
|
+
"type": "string"
|
|
314
|
+
},
|
|
315
|
+
"read": {
|
|
316
|
+
"type": [
|
|
317
|
+
"string",
|
|
318
|
+
"null"
|
|
319
|
+
],
|
|
320
|
+
"description": "The repo identity the other repository's own graph document gave (its workspace.repo), or null when it gave none or the read failed."
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
},
|
|
290
324
|
"kind": {
|
|
291
325
|
"type": "string"
|
|
292
326
|
},
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The network half of `chant workspace init --from tfc|spacelift` (#3178).
|
|
3
|
+
*
|
|
4
|
+
* Reads the Terraform Cloud API or the Spacelift GraphQL API into the input
|
|
5
|
+
* documents `import-source.ts` maps. The transport is a parameter, so a test
|
|
6
|
+
* feeds fixture responses and nothing here is reached without a token. A
|
|
7
|
+
* token is read from `--token`, else `TFE_TOKEN` / `TF_TOKEN_app_terraform_io`
|
|
8
|
+
* for Terraform Cloud and `SPACELIFT_API_TOKEN` for Spacelift. Only reads:
|
|
9
|
+
* every request is a GET, or a GraphQL query with no mutation.
|
|
10
|
+
*/
|
|
11
|
+
import type { SpaceliftInput, TfcInput } from "./import-source.js";
|
|
12
|
+
export type Fetcher = (url: string, init?: {
|
|
13
|
+
method?: string;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
body?: string;
|
|
16
|
+
}) => Promise<{
|
|
17
|
+
ok: boolean;
|
|
18
|
+
status: number;
|
|
19
|
+
json(): Promise<unknown>;
|
|
20
|
+
}>;
|
|
21
|
+
export declare class ImportFetchError extends Error {
|
|
22
|
+
}
|
|
23
|
+
export interface TfcFetchOptions {
|
|
24
|
+
organization: string;
|
|
25
|
+
token: string;
|
|
26
|
+
/** Default `https://app.terraform.io`; a Terraform Enterprise host works too. */
|
|
27
|
+
host?: string;
|
|
28
|
+
fetcher?: Fetcher;
|
|
29
|
+
}
|
|
30
|
+
export declare function fetchTfc(options: TfcFetchOptions): Promise<TfcInput>;
|
|
31
|
+
export interface SpaceliftFetchOptions {
|
|
32
|
+
/** The account's endpoint, e.g. `https://acme.app.spacelift.io/graphql`. */
|
|
33
|
+
endpoint: string;
|
|
34
|
+
token: string;
|
|
35
|
+
fetcher?: Fetcher;
|
|
36
|
+
}
|
|
37
|
+
export declare function fetchSpacelift(options: SpaceliftFetchOptions): Promise<SpaceliftInput>;
|
|
38
|
+
//# sourceMappingURL=import-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-fetch.d.ts","sourceRoot":"","sources":["../../src/workspace/import-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC,CAAC;AAEvL,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAa9C,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqD1E;AAID,MAAM,WAAW,qBAAqB;IACpC,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AASD,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CA2C5F"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The network half of `chant workspace init --from tfc|spacelift` (#3178).
|
|
3
|
+
*
|
|
4
|
+
* Reads the Terraform Cloud API or the Spacelift GraphQL API into the input
|
|
5
|
+
* documents `import-source.ts` maps. The transport is a parameter, so a test
|
|
6
|
+
* feeds fixture responses and nothing here is reached without a token. A
|
|
7
|
+
* token is read from `--token`, else `TFE_TOKEN` / `TF_TOKEN_app_terraform_io`
|
|
8
|
+
* for Terraform Cloud and `SPACELIFT_API_TOKEN` for Spacelift. Only reads:
|
|
9
|
+
* every request is a GET, or a GraphQL query with no mutation.
|
|
10
|
+
*/
|
|
11
|
+
export class ImportFetchError extends Error {
|
|
12
|
+
}
|
|
13
|
+
const defaultFetch = (url, init) => fetch(url, init);
|
|
14
|
+
export async function fetchTfc(options) {
|
|
15
|
+
const fetcher = options.fetcher ?? defaultFetch;
|
|
16
|
+
const base = (options.host ?? "https://app.terraform.io").replace(/\/$/, "");
|
|
17
|
+
const headers = { Authorization: `Bearer ${options.token}`, "Content-Type": "application/vnd.api+json" };
|
|
18
|
+
const list = async (path) => {
|
|
19
|
+
const out = [];
|
|
20
|
+
let url = `${base}/api/v2${path}${path.includes("?") ? "&" : "?"}page%5Bsize%5D=100`;
|
|
21
|
+
while (url) {
|
|
22
|
+
const res = await fetcher(url, { method: "GET", headers });
|
|
23
|
+
if (!res.ok)
|
|
24
|
+
throw new ImportFetchError(`Terraform Cloud answered ${res.status} for ${url.replace(base, "")}`);
|
|
25
|
+
const body = (await res.json());
|
|
26
|
+
out.push(...(body.data ?? []));
|
|
27
|
+
url = body.links?.next ?? undefined;
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
};
|
|
31
|
+
const org = encodeURIComponent(options.organization);
|
|
32
|
+
const [projects, workspaces, policySets] = await Promise.all([list(`/organizations/${org}/projects`), list(`/organizations/${org}/workspaces`), list(`/organizations/${org}/policy-sets`)]);
|
|
33
|
+
const full = [];
|
|
34
|
+
for (const w of workspaces) {
|
|
35
|
+
const a = w.attributes ?? {};
|
|
36
|
+
const [vars, triggers] = await Promise.all([list(`/workspaces/${w.id}/vars`), list(`/workspaces/${w.id}/run-triggers?filter%5Brun-trigger%5D%5Btype%5D=inbound`)]);
|
|
37
|
+
const project = w.relationships?.project?.data;
|
|
38
|
+
full.push({
|
|
39
|
+
id: w.id,
|
|
40
|
+
name: String(a.name ?? w.id),
|
|
41
|
+
...(project && !Array.isArray(project) ? { project: project.id } : {}),
|
|
42
|
+
...(a["working-directory"] ? { workingDirectory: String(a["working-directory"]) } : {}),
|
|
43
|
+
...(a["terraform-version"] ? { terraformVersion: String(a["terraform-version"]) } : {}),
|
|
44
|
+
...(a["vcs-repo"]?.identifier ? { vcsRepo: a["vcs-repo"].identifier } : {}),
|
|
45
|
+
tags: Array.isArray(a["tag-names"]) ? a["tag-names"] : [],
|
|
46
|
+
variables: vars.map((v) => ({ key: String(v.attributes?.key ?? ""), category: String(v.attributes?.category ?? ""), sensitive: v.attributes?.sensitive === true })),
|
|
47
|
+
runTriggers: triggers
|
|
48
|
+
.map((t) => t.relationships?.sourceable?.data?.id)
|
|
49
|
+
.filter((id) => typeof id === "string"),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
organization: options.organization,
|
|
54
|
+
projects: projects.map((p) => ({ id: p.id, name: String(p.attributes?.name ?? p.id) })),
|
|
55
|
+
workspaces: full,
|
|
56
|
+
policySets: policySets.map((p) => ({
|
|
57
|
+
id: p.id,
|
|
58
|
+
name: String(p.attributes?.name ?? p.id),
|
|
59
|
+
kind: String(p.attributes?.kind ?? "sentinel"),
|
|
60
|
+
global: p.attributes?.global === true,
|
|
61
|
+
workspaces: (p.relationships?.workspaces?.data ?? []).map((x) => x.id),
|
|
62
|
+
})),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const SPACELIFT_QUERY = `query ChantImport {
|
|
66
|
+
stacks { id name space repository branch projectRoot vendor { __typename } labels
|
|
67
|
+
attachedPolicies: attachedPolicies { id }
|
|
68
|
+
dependsOn: dependencies { stackId references { outputName inputName } } }
|
|
69
|
+
policies { id name type }
|
|
70
|
+
}`;
|
|
71
|
+
export async function fetchSpacelift(options) {
|
|
72
|
+
const fetcher = options.fetcher ?? defaultFetch;
|
|
73
|
+
const res = await fetcher(options.endpoint, {
|
|
74
|
+
method: "POST",
|
|
75
|
+
headers: { Authorization: `Bearer ${options.token}`, "Content-Type": "application/json" },
|
|
76
|
+
body: JSON.stringify({ query: SPACELIFT_QUERY }),
|
|
77
|
+
});
|
|
78
|
+
if (!res.ok)
|
|
79
|
+
throw new ImportFetchError(`Spacelift answered ${res.status} for ${options.endpoint}`);
|
|
80
|
+
const body = (await res.json());
|
|
81
|
+
if (body.errors?.length)
|
|
82
|
+
throw new ImportFetchError(`Spacelift: ${body.errors.map((e) => e.message).join("; ")}`);
|
|
83
|
+
return {
|
|
84
|
+
account: new URL(options.endpoint).hostname.split(".")[0],
|
|
85
|
+
stacks: (body.data?.stacks ?? []).map((s) => ({
|
|
86
|
+
id: s.id,
|
|
87
|
+
name: s.name,
|
|
88
|
+
...(s.space ? { space: s.space } : {}),
|
|
89
|
+
...(s.repository ? { repository: s.repository } : {}),
|
|
90
|
+
...(s.branch ? { branch: s.branch } : {}),
|
|
91
|
+
...(s.projectRoot ? { projectRoot: s.projectRoot } : {}),
|
|
92
|
+
vendor: (s.vendor?.__typename ?? "TerraformStackVendor").replace(/StackVendor$|Vendor$/, "").toLowerCase() || "terraform",
|
|
93
|
+
labels: s.labels ?? [],
|
|
94
|
+
policies: (s.attachedPolicies ?? []).map((p) => p.id),
|
|
95
|
+
dependsOn: (s.dependsOn ?? []).map((d) => ({ stack: d.stackId, references: d.references ?? [] })),
|
|
96
|
+
})),
|
|
97
|
+
policies: body.data?.policies ?? [],
|
|
98
|
+
};
|
|
99
|
+
}
|