@intentius/chant 0.124.84 → 0.124.86
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/bundle-check.d.ts +102 -0
- package/dist/bundle-check.d.ts.map +1 -0
- package/dist/bundle-check.js +310 -0
- package/dist/chant-install.d.ts +100 -0
- package/dist/chant-install.d.ts.map +1 -0
- package/dist/chant-install.js +158 -0
- package/dist/ci-commit.d.ts +19 -6
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +23 -4
- package/dist/ci-evidence-jobs.d.ts +54 -0
- package/dist/ci-evidence-jobs.d.ts.map +1 -0
- package/dist/ci-evidence-jobs.js +55 -0
- package/dist/ci-image.d.ts +274 -0
- package/dist/ci-image.d.ts.map +1 -0
- package/dist/ci-image.js +635 -0
- package/dist/ci-login.d.ts +150 -0
- package/dist/ci-login.d.ts.map +1 -0
- package/dist/ci-login.js +240 -0
- package/dist/ci-product.d.ts +16 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +17 -0
- package/dist/cli/commands/import-index.js +2 -2
- package/dist/cli/handlers/build.d.ts +8 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -4
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +57 -2
- package/dist/cli/handlers/ci-evidence.d.ts +3 -0
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
- package/dist/cli/handlers/ci-evidence.js +171 -0
- package/dist/cli/handlers/components.js +3 -3
- package/dist/cli/handlers/dead-guards.d.ts +3 -0
- package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
- package/dist/cli/handlers/dead-guards.js +35 -0
- package/dist/cli/handlers/graph.js +4 -4
- package/dist/cli/handlers/lifecycle.d.ts +2 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +5 -4
- package/dist/cli/handlers/local-chant.d.ts +16 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -0
- package/dist/cli/handlers/local-chant.js +109 -0
- package/dist/cli/handlers/operator.js +2 -2
- package/dist/cli/handlers/search.js +5 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +49 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +64 -4
- package/dist/components/check-steps.d.ts +17 -0
- package/dist/components/check-steps.d.ts.map +1 -1
- package/dist/components/check-steps.js +37 -5
- package/dist/components/product-pipeline.d.ts +23 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +6 -2
- package/dist/components/product-plan.d.ts +137 -0
- package/dist/components/product-plan.d.ts.map +1 -0
- package/dist/components/product-plan.js +143 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +2 -2
- package/dist/config.d.ts +39 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -3
- package/dist/dead-guards.d.ts +82 -0
- package/dist/dead-guards.d.ts.map +1 -0
- package/dist/dead-guards.js +436 -0
- package/dist/discovery/files.d.ts +3 -1
- package/dist/discovery/files.d.ts.map +1 -1
- package/dist/discovery/files.js +5 -3
- package/dist/drift-issue.d.ts +152 -0
- package/dist/drift-issue.d.ts.map +1 -0
- package/dist/drift-issue.js +167 -0
- package/dist/floor-table.d.ts +30 -0
- package/dist/floor-table.d.ts.map +1 -0
- package/dist/floor-table.data.d.ts +3 -0
- package/dist/floor-table.data.d.ts.map +1 -0
- package/dist/floor-table.data.js +178 -0
- package/dist/floor-table.js +56 -0
- package/dist/forge-flags.d.ts +90 -0
- package/dist/forge-flags.d.ts.map +1 -0
- package/dist/forge-flags.js +184 -0
- package/dist/lexicon.d.ts +69 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.d.ts +7 -1
- package/dist/lifecycle/gated-op.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.js +7 -4
- package/dist/local-chant.d.ts +98 -0
- package/dist/local-chant.d.ts.map +1 -0
- package/dist/local-chant.js +307 -0
- package/dist/op/activities/predict-behaviour.js +2 -2
- package/dist/op/op-waves-evidence-spec.d.ts +13 -0
- package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-spec.js +21 -0
- package/dist/op/op-waves-evidence.d.ts +38 -0
- package/dist/op/op-waves-evidence.d.ts.map +1 -0
- package/dist/op/op-waves-evidence.js +57 -0
- package/dist/op/op-waves-run.d.ts +4 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +24 -1
- package/dist/op/op-waves.d.ts +17 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -0
- package/dist/op/schedule-overdue.d.ts +41 -9
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +154 -25
- package/dist/plan-summary.d.ts +25 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +31 -0
- package/dist/pr-plan-note.d.ts +35 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +10 -0
- package/dist/pr-post.d.ts +23 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +125 -3
- package/dist/release-floors.d.ts +31 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +31 -1
- package/dist/state-migration.d.ts +24 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +100 -5
- package/dist/wave-runtime.mjs +305 -298
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +21 -7
- package/dist/workspace/reason-codes.d.ts +3 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +4 -0
- package/dist/workspace/ref-gate.schema.json +85 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence-report.js +102 -0
- package/dist/workspace/trust/check-evidence.d.ts +126 -0
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence.js +237 -0
- package/dist/workspace/trust/local-evidence.d.ts +120 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/local-evidence.js +259 -0
- package/dist/workspace/trust/policy.d.ts +84 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +94 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-cli.js +234 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-fixture.js +97 -0
- package/dist/workspace/trust/ref-gate.d.ts +187 -0
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate.js +430 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +18 -1
- package/package.json +1 -1
- package/src/bundle-check.test.ts +140 -0
- package/src/bundle-check.ts +352 -0
- package/src/chant-install.test.ts +112 -0
- package/src/chant-install.ts +179 -0
- package/src/ci-commit.test.ts +45 -0
- package/src/ci-commit.ts +38 -4
- package/src/ci-evidence-jobs.ts +67 -0
- package/src/ci-image.test.ts +506 -0
- package/src/ci-image.ts +822 -0
- package/src/ci-login.test.ts +235 -0
- package/src/ci-login.ts +307 -0
- package/src/ci-product.ts +18 -0
- package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/import-index.ts +2 -2
- package/src/cli/handlers/build-source-dir.test.ts +64 -0
- package/src/cli/handlers/build.ts +21 -4
- package/src/cli/handlers/ci-check.ts +56 -3
- package/src/cli/handlers/ci-evidence.ts +162 -0
- package/src/cli/handlers/components.ts +3 -3
- package/src/cli/handlers/dead-guards.ts +37 -0
- package/src/cli/handlers/graph.ts +4 -4
- package/src/cli/handlers/lifecycle.ts +5 -4
- package/src/cli/handlers/local-chant.ts +106 -0
- package/src/cli/handlers/operator.ts +2 -2
- package/src/cli/handlers/search.ts +5 -5
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +38 -0
- package/src/cli/parse-args.ts +21 -0
- package/src/cli/registry.ts +16 -0
- package/src/components/check-evidence-stage.test.ts +80 -0
- package/src/components/check-hooks.ts +84 -4
- package/src/components/check-local-evidence-stage.test.ts +141 -0
- package/src/components/check-steps.ts +56 -6
- package/src/components/product-pipeline.ts +28 -3
- package/src/components/product-plan.test.ts +87 -0
- package/src/components/product-plan.ts +226 -0
- package/src/components/release-compile.ts +2 -2
- package/src/config.ts +44 -3
- package/src/dead-guards.test.ts +206 -0
- package/src/dead-guards.ts +446 -0
- package/src/discovery/files.ts +5 -3
- package/src/drift-issue-bundle.test.ts +31 -0
- package/src/drift-issue.test.ts +206 -0
- package/src/drift-issue.ts +274 -0
- package/src/fit-note.test.ts +44 -0
- package/src/floor-table.data.ts +180 -0
- package/src/floor-table.ts +77 -0
- package/src/forge-flags.test.ts +110 -0
- package/src/forge-flags.ts +208 -0
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/lexicon.ts +68 -0
- package/src/lifecycle/gated-op.ts +10 -5
- package/src/local-chant.e2e.test.ts +94 -0
- package/src/local-chant.test.ts +162 -0
- package/src/local-chant.ts +341 -0
- package/src/op/activities/predict-behaviour.ts +2 -2
- package/src/op/op-waves-evidence-spec.ts +24 -0
- package/src/op/op-waves-evidence.test.ts +130 -0
- package/src/op/op-waves-evidence.ts +57 -0
- package/src/op/op-waves-run.ts +25 -1
- package/src/op/op-waves.ts +31 -1
- package/src/op/schedule-overdue.test.ts +85 -0
- package/src/op/schedule-overdue.ts +162 -26
- package/src/plan-summary.ts +40 -0
- package/src/pr-plan-note.ts +34 -0
- package/src/pr-post-plan-note.test.ts +146 -0
- package/src/pr-post.ts +127 -3
- package/src/release-floors.ts +44 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/state-migration.test.ts +52 -1
- package/src/state-migration.ts +107 -5
- package/src/workspace/lexicon-outputs.ts +23 -6
- package/src/workspace/reason-codes.test.ts +3 -0
- package/src/workspace/reason-codes.ts +4 -0
- package/src/workspace/ref-gate.schema.json +85 -0
- package/src/workspace/trust/check-evidence-report.ts +106 -0
- package/src/workspace/trust/check-evidence.test.ts +133 -0
- package/src/workspace/trust/check-evidence.ts +257 -0
- package/src/workspace/trust/local-evidence.test.ts +127 -0
- package/src/workspace/trust/local-evidence.ts +266 -0
- package/src/workspace/trust/policy.ts +134 -1
- package/src/workspace/trust/ref-gate-cli.ts +244 -0
- package/src/workspace/trust/ref-gate-fixture.ts +125 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
- package/src/workspace/trust/ref-gate.test.ts +247 -0
- package/src/workspace/trust/ref-gate.ts +538 -0
- package/src/workspace/trust/trust-files.test.ts +16 -0
- package/src/workspace/trust/trust-files.ts +41 -1
|
@@ -9,6 +9,16 @@
|
|
|
9
9
|
* when every hook and step passed or there were none, 1 (`failed`) when one
|
|
10
10
|
* failed. See `../../components/check-hooks.ts` and
|
|
11
11
|
* `../../components/check-steps.ts`.
|
|
12
|
+
*
|
|
13
|
+
* With a runner key in `CHANT_RUNNER_KEY` (#4870), each hook that passed is
|
|
14
|
+
* signed as a named check over `HEAD` and attached under `refs/notes/chant/evidence`, which
|
|
15
|
+
* is pushed unless `--no-push`; the key never reaches a hook.
|
|
16
|
+
*
|
|
17
|
+
* #4868: with a local key in `CHANT_LOCAL_EVIDENCE_KEY` (a developer's or an
|
|
18
|
+
* agent session's, listed under `local.keys` at base) each hook that passed
|
|
19
|
+
* is signed as local evidence instead, under `refs/notes/chant/local-evidence`.
|
|
20
|
+
* Without one, a hook whose check `local.checks` at base names is skipped
|
|
21
|
+
* when current local evidence for the tree stands in for it; the rest run.
|
|
12
22
|
*/
|
|
13
23
|
import { resolve } from "node:path";
|
|
14
24
|
import { CHANT_EXIT } from "../../exit-codes.js";
|
|
@@ -31,7 +41,44 @@ async function lexiconCheckSteps(ctx, cwd) {
|
|
|
31
41
|
}
|
|
32
42
|
return plugins.map((p) => p.checkSteps?.()).filter((a) => a !== undefined);
|
|
33
43
|
}
|
|
34
|
-
const USAGE = "chant ci check --base <rev> [<target>...] [--output <dir>] [--json]";
|
|
44
|
+
const USAGE = "chant ci check --base <rev> [<target>...] [--output <dir>] [--no-push] [--json]";
|
|
45
|
+
/**
|
|
46
|
+
* The check stage's signer (#4870), when the job holds a runner key in
|
|
47
|
+
* `CHANT_RUNNER_KEY`: the runner `.chant/trust.json` at `base` lists for it.
|
|
48
|
+
* Throws when the key is there and the policy at base does not list it, so
|
|
49
|
+
* a job asked to sign never passes while signing nothing.
|
|
50
|
+
*/
|
|
51
|
+
async function checkEvidenceSigner(base, noPush) {
|
|
52
|
+
const { CHECK_EVIDENCE_KEY_ENV, LOCAL_EVIDENCE_KEY_ENV } = await import("../../workspace/trust/check-evidence-report.js");
|
|
53
|
+
const pem = process.env[CHECK_EVIDENCE_KEY_ENV];
|
|
54
|
+
const localPem = process.env[LOCAL_EVIDENCE_KEY_ENV];
|
|
55
|
+
if (!pem && !localPem)
|
|
56
|
+
return undefined;
|
|
57
|
+
if (pem && localPem)
|
|
58
|
+
throw new Error(`${CHECK_EVIDENCE_KEY_ENV} and ${LOCAL_EVIDENCE_KEY_ENV} are both set; a job signs as a runner or as a person or agent, never both`);
|
|
59
|
+
const { top, commit } = await baseCommit(base);
|
|
60
|
+
if (localPem) {
|
|
61
|
+
const { localKeyEvidenceSigner } = await import("../../workspace/trust/local-evidence.js");
|
|
62
|
+
return { signer: localKeyEvidenceSigner(top, commit, localPem), ...(noPush ? { push: false } : {}) };
|
|
63
|
+
}
|
|
64
|
+
const { runnerKeyEvidenceSigner } = await import("../../workspace/trust/check-evidence.js");
|
|
65
|
+
return { signer: runnerKeyEvidenceSigner(top, commit, pem), ...(noPush ? { push: false } : {}) };
|
|
66
|
+
}
|
|
67
|
+
async function baseCommit(base) {
|
|
68
|
+
const { execFileSync } = await import("node:child_process");
|
|
69
|
+
const top = execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
70
|
+
const commit = execFileSync("git", ["rev-parse", "--verify", `${base}^{commit}`], { cwd: top, encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
71
|
+
return { top, commit };
|
|
72
|
+
}
|
|
73
|
+
/** Skipping on local evidence (#4868), judged by the policy at `base`; undefined outside a git repository. */
|
|
74
|
+
async function localEvidenceAt(base) {
|
|
75
|
+
try {
|
|
76
|
+
return { base: (await baseCommit(base)).commit };
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
35
82
|
export async function runCiCheck(ctx) {
|
|
36
83
|
const { args } = ctx;
|
|
37
84
|
if (!args.base) {
|
|
@@ -43,7 +90,10 @@ export async function runCiCheck(ctx) {
|
|
|
43
90
|
let report;
|
|
44
91
|
try {
|
|
45
92
|
const adapters = await lexiconCheckSteps(ctx, process.cwd());
|
|
46
|
-
|
|
93
|
+
const evidence = await checkEvidenceSigner(args.base, args.noPush === true);
|
|
94
|
+
// #4868: a job that signs local evidence runs every hook; any other may skip one on local evidence.
|
|
95
|
+
const local = evidence && "class" in evidence.signer ? undefined : await localEvidenceAt(args.base);
|
|
96
|
+
report = await runCheckStage({ base: args.base, targets, adapters, ...(args.output ? { dir: args.output } : {}), ...(evidence ? { evidence } : {}), ...(local ? { localEvidence: local } : {}) });
|
|
47
97
|
}
|
|
48
98
|
catch (err) {
|
|
49
99
|
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
@@ -58,6 +108,11 @@ export async function runCiCheck(ctx) {
|
|
|
58
108
|
console.error(`ci check: ${all.filter((h) => h.outcome === "passed").length} passed, ${all.filter((h) => h.outcome === "failed").length} failed, ${all.filter((h) => h.outcome === "skipped").length} skipped`);
|
|
59
109
|
if (report.failed)
|
|
60
110
|
console.error(`ci check: ${report.failed}`);
|
|
111
|
+
if (report.evidence)
|
|
112
|
+
console.error(`ci check: signed ${report.evidence.signed.join(", ")} as ${report.evidence.runner}`);
|
|
113
|
+
const onLocal = report.hooks.filter((h) => h.localEvidence);
|
|
114
|
+
if (onLocal.length > 0)
|
|
115
|
+
console.error(`ci check: skipped on local evidence: ${onLocal.map((h) => `${h.name} (${h.localEvidence.class} ${h.localEvidence.signer})`).join(", ")}`);
|
|
61
116
|
}
|
|
62
117
|
return report.status === "failed" ? CHANT_EXIT.failed : CHANT_EXIT.done;
|
|
63
118
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci-evidence.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/ci-evidence.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA2BlD,wBAAsB,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAWxE"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant ci evidence sign|verify` (#4870): evidence for the named checks a
|
|
3
|
+
* generated pipeline runs, attached to the commit under
|
|
4
|
+
* `refs/notes/chant/evidence`, where #4867's ref gate reads them
|
|
5
|
+
* (../../workspace/trust/check-evidence.ts).
|
|
6
|
+
*
|
|
7
|
+
* - `sign --check-id <id>[,<id>...]` signs that each check passed at `--at`
|
|
8
|
+
* (default `HEAD`), with the runner key in `--key <file>` or
|
|
9
|
+
* `CHANT_RUNNER_KEY`, and pushes the notes unless `--no-push`.
|
|
10
|
+
* - `sign --from-report <dir> --result <result>` is the plan note job's
|
|
11
|
+
* form: it signs `plan` when the plan job succeeded and left a report in
|
|
12
|
+
* `<dir>`, and `policy` when the policy evaluated inside that plan did not
|
|
13
|
+
* deny it (a `pr-plan.json`'s `policy`, a plan note hand-off's overrides).
|
|
14
|
+
* It writes `evidence.json` in `<dir>`, which `pr-post` reads to say in the
|
|
15
|
+
* note which checks were signed.
|
|
16
|
+
* - `verify --check-id <id>[,<id>...]` reads the evidence for `--at`'s tree
|
|
17
|
+
* and verifies it against the runner keys at `--base`; exits 1 when one
|
|
18
|
+
* is not current.
|
|
19
|
+
*
|
|
20
|
+
* Without a runner key, `sign` signs nothing and says so: a project that
|
|
21
|
+
* declares no runner identity gets the same job it had.
|
|
22
|
+
*
|
|
23
|
+
* `--local` (#4868) is the developer's or agent session's form: `sign
|
|
24
|
+
* --local` signs with the key in `--key` or `CHANT_LOCAL_EVIDENCE_KEY`, which
|
|
25
|
+
* `local.keys` at base lists, and pushes `refs/notes/chant/local-evidence`;
|
|
26
|
+
* `verify --local` says whether CI would skip each check on that evidence.
|
|
27
|
+
*/
|
|
28
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
29
|
+
import { join } from "node:path";
|
|
30
|
+
import { CHANT_EXIT } from "../../exit-codes.js";
|
|
31
|
+
import { formatError } from "../format.js";
|
|
32
|
+
import { gitRoot } from "../../workspace/record-source.js";
|
|
33
|
+
import { resolveBase } from "../../workspace/trust/provenance.js";
|
|
34
|
+
import { CHECK_EVIDENCE_KEY_ENV, readCheckEvidence, recordChecks, runnerKeyEvidenceSigner, signChecks, } from "../../workspace/trust/check-evidence.js";
|
|
35
|
+
import { CHECK_EVIDENCE_FILE, LOCAL_EVIDENCE_KEY_ENV, planReportChecks } from "../../workspace/trust/check-evidence-report.js";
|
|
36
|
+
const USAGE = "chant ci evidence sign (--check-id <id>[,<id>...] | --from-report <dir> --result <result>) [--at <rev>] [--base <rev>] [--key <file>] [--claim <file>] [--no-push] [--json]\n" +
|
|
37
|
+
" chant ci evidence sign --local --check-id <id>[,<id>...] [--at <rev>] [--base <rev>] [--key <file>] [--claim <file>] [--no-push] [--json]\n" +
|
|
38
|
+
" chant ci evidence verify [--local] --check-id <id>[,<id>...] [--at <rev>] [--base <rev>] [--json]";
|
|
39
|
+
function usage(message) {
|
|
40
|
+
console.error(formatError({ message, hint: USAGE }));
|
|
41
|
+
return CHANT_EXIT.failed;
|
|
42
|
+
}
|
|
43
|
+
function idsOf(value) {
|
|
44
|
+
return (value ?? "").split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
45
|
+
}
|
|
46
|
+
export async function runCiEvidence(ctx) {
|
|
47
|
+
const { args } = ctx;
|
|
48
|
+
const sub = args.extraPositional;
|
|
49
|
+
if (sub !== "sign" && sub !== "verify")
|
|
50
|
+
return usage(sub ? `Unknown evidence subcommand: ${sub}` : "chant ci evidence needs sign or verify");
|
|
51
|
+
const repo = gitRoot(process.cwd());
|
|
52
|
+
if (!repo)
|
|
53
|
+
return usage("check evidence is bound to git commits, and this directory is not in a git repository");
|
|
54
|
+
const base = resolveBase(repo, args.base);
|
|
55
|
+
if (!base.commit)
|
|
56
|
+
return usage(base.problem ?? "no base: pass --base <rev>, the commit whose .chant/trust.json lists the runner keys");
|
|
57
|
+
const at = args.at ?? "HEAD";
|
|
58
|
+
if (args.local)
|
|
59
|
+
return sub === "sign" ? signLocal(ctx, repo, base.commit, at) : verifyLocal(ctx, repo, base.commit, at);
|
|
60
|
+
return sub === "sign" ? sign(ctx, repo, base.commit, at) : verify(ctx, repo, base.commit, at);
|
|
61
|
+
}
|
|
62
|
+
/** `sign --local` (#4868): local evidence for each named check, signed by a person's or an agent's key. */
|
|
63
|
+
async function signLocal(ctx, repo, base, at) {
|
|
64
|
+
const { args } = ctx;
|
|
65
|
+
const checks = idsOf(args.checkId);
|
|
66
|
+
if (checks.length === 0)
|
|
67
|
+
return usage("sign --local needs --check-id <id>");
|
|
68
|
+
if (args.fromReport)
|
|
69
|
+
return usage("--from-report is the plan note job's; plan and policy never take local evidence");
|
|
70
|
+
const pem = args.key ? readFileSync(args.key, "utf-8") : process.env[LOCAL_EVIDENCE_KEY_ENV];
|
|
71
|
+
if (!pem)
|
|
72
|
+
return usage(`sign --local needs a local evidence key: --key <file> or ${LOCAL_EVIDENCE_KEY_ENV}`);
|
|
73
|
+
const { localKeyEvidenceSigner, recordLocalChecks, signLocalChecks } = await import("../../workspace/trust/local-evidence.js");
|
|
74
|
+
let signer;
|
|
75
|
+
try {
|
|
76
|
+
signer = localKeyEvidenceSigner(repo, base, pem);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
80
|
+
return CHANT_EXIT.failed;
|
|
81
|
+
}
|
|
82
|
+
const claim = args.claim ? readFileSync(args.claim) : undefined;
|
|
83
|
+
const signed = signLocalChecks(repo, at, checks.map((check) => ({ check, ...(claim ? { claim } : {}) })), signer);
|
|
84
|
+
const pushed = await recordLocalChecks(repo, signed, { push: !args.noPush });
|
|
85
|
+
for (const s of signed)
|
|
86
|
+
console.error(`ci evidence: signed local evidence for ${s.check} at ${s.commit.slice(0, 12)} as ${signer.class} ${s.runner}`);
|
|
87
|
+
if (!args.noPush && !pushed.pushed && pushed.pushWarning)
|
|
88
|
+
console.error(`ci evidence: the evidence is attached here, and the push did not land: ${pushed.pushWarning}`);
|
|
89
|
+
if (args.json)
|
|
90
|
+
console.log(JSON.stringify({ signed: signed.map((s) => ({ check: s.check, signer: s.runner, class: signer.class, commit: s.commit, tree: s.tree })) }, null, 2));
|
|
91
|
+
return CHANT_EXIT.done;
|
|
92
|
+
}
|
|
93
|
+
/** `verify --local` (#4868): whether CI would skip each check on local evidence; exits 1 when one would run. */
|
|
94
|
+
async function verifyLocal(ctx, repo, base, at) {
|
|
95
|
+
const { args } = ctx;
|
|
96
|
+
const checks = idsOf(args.checkId);
|
|
97
|
+
if (checks.length === 0)
|
|
98
|
+
return usage("verify --local needs --check-id <id>");
|
|
99
|
+
const { acceptedLocalEvidence } = await import("../../workspace/trust/local-evidence.js");
|
|
100
|
+
const verdicts = acceptedLocalEvidence(repo, at, base, checks);
|
|
101
|
+
if (args.json)
|
|
102
|
+
console.log(JSON.stringify({ at, base, local: true, checks: verdicts }, null, 2));
|
|
103
|
+
else
|
|
104
|
+
for (const v of verdicts)
|
|
105
|
+
console.error(v.status === "accepted" ? ` accepted ${v.check} (${v.class} ${v.signer} at ${v.commit.slice(0, 12)})` : ` ${v.status.padEnd(12)} ${v.check}: ${v.reason}`);
|
|
106
|
+
return verdicts.every((v) => v.status === "accepted") ? CHANT_EXIT.done : CHANT_EXIT.failed;
|
|
107
|
+
}
|
|
108
|
+
async function sign(ctx, repo, base, at) {
|
|
109
|
+
const { args } = ctx;
|
|
110
|
+
const fromReport = args.fromReport;
|
|
111
|
+
if (!fromReport && idsOf(args.checkId).length === 0)
|
|
112
|
+
return usage("sign needs --check-id <id>, or --from-report <dir> in a plan note job");
|
|
113
|
+
const pem = args.key ? readFileSync(args.key, "utf-8") : process.env[CHECK_EVIDENCE_KEY_ENV];
|
|
114
|
+
const note = { signed: [], skipped: [] };
|
|
115
|
+
let wanted;
|
|
116
|
+
if (fromReport) {
|
|
117
|
+
const decided = planReportChecks(fromReport, args.planResult);
|
|
118
|
+
wanted = decided.sign;
|
|
119
|
+
note.skipped.push(...decided.skipped);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const claim = args.claim ? readFileSync(args.claim) : undefined;
|
|
123
|
+
wanted = idsOf(args.checkId).map((check) => ({ check, ...(claim ? { claim } : {}) }));
|
|
124
|
+
}
|
|
125
|
+
const finish = (code) => {
|
|
126
|
+
if (fromReport)
|
|
127
|
+
writeFileSync(join(fromReport, CHECK_EVIDENCE_FILE), JSON.stringify(note, null, 2) + "\n");
|
|
128
|
+
if (args.json)
|
|
129
|
+
console.log(JSON.stringify(note, null, 2));
|
|
130
|
+
return code;
|
|
131
|
+
};
|
|
132
|
+
if (!pem) {
|
|
133
|
+
note.skipped.push(...wanted.map((w) => ({ check: w.check, reason: `no runner key: ${CHECK_EVIDENCE_KEY_ENV} is not set` })));
|
|
134
|
+
console.error(`ci evidence: no runner key in ${CHECK_EVIDENCE_KEY_ENV}, so no check was signed`);
|
|
135
|
+
return finish(CHANT_EXIT.done);
|
|
136
|
+
}
|
|
137
|
+
let signer;
|
|
138
|
+
try {
|
|
139
|
+
signer = runnerKeyEvidenceSigner(repo, base, pem);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err), hint: USAGE }));
|
|
143
|
+
return finish(CHANT_EXIT.failed);
|
|
144
|
+
}
|
|
145
|
+
for (const s of note.skipped)
|
|
146
|
+
console.error(`ci evidence: ${s.check} not signed: ${s.reason}`);
|
|
147
|
+
if (wanted.length === 0)
|
|
148
|
+
return finish(CHANT_EXIT.done);
|
|
149
|
+
const signed = signChecks(repo, at, wanted, signer);
|
|
150
|
+
const pushed = await recordChecks(repo, signed, { push: !args.noPush });
|
|
151
|
+
for (const s of signed) {
|
|
152
|
+
note.signed.push({ check: s.check, runner: s.runner, commit: s.commit, tree: s.tree });
|
|
153
|
+
console.error(`ci evidence: signed ${s.check} at ${s.commit.slice(0, 12)} as ${s.runner}`);
|
|
154
|
+
}
|
|
155
|
+
if (!args.noPush && !pushed.pushed && pushed.pushWarning)
|
|
156
|
+
console.error(`ci evidence: the evidence is attached here, and the push did not land: ${pushed.pushWarning}`);
|
|
157
|
+
return finish(CHANT_EXIT.done);
|
|
158
|
+
}
|
|
159
|
+
async function verify(ctx, repo, base, at) {
|
|
160
|
+
const { args } = ctx;
|
|
161
|
+
const checks = idsOf(args.checkId);
|
|
162
|
+
if (checks.length === 0)
|
|
163
|
+
return usage("verify needs --check-id <id>");
|
|
164
|
+
const verdicts = await readCheckEvidence(repo, at, base, checks);
|
|
165
|
+
if (args.json)
|
|
166
|
+
console.log(JSON.stringify({ at, base, checks: verdicts }, null, 2));
|
|
167
|
+
else
|
|
168
|
+
for (const v of verdicts)
|
|
169
|
+
console.error(v.status === "current" ? ` current ${v.check} (signed by ${v.runner} at ${v.commit.slice(0, 12)})` : ` ${v.status.padEnd(7)} ${v.check}: ${v.reason}`);
|
|
170
|
+
return verdicts.every((v) => v.status === "current") ? CHANT_EXIT.done : CHANT_EXIT.failed;
|
|
171
|
+
}
|
|
@@ -37,7 +37,7 @@ import { commandBuildParams } from "../build-params-cli.js";
|
|
|
37
37
|
import { buildChangeSet } from "../../lifecycle/change-set.js";
|
|
38
38
|
import { buildLedgerEntries, componentBomSummary } from "../../lifecycle/build-ledger.js";
|
|
39
39
|
import { findBuildManifestByArtifactDigest, readBuildManifest } from "../../lifecycle/build-ledger-store.js";
|
|
40
|
-
import { loadChantConfig } from "../../config.js";
|
|
40
|
+
import { loadChantConfig, resolveSourceDir } from "../../config.js";
|
|
41
41
|
import { applyLiveEndpoint } from "../../live-endpoint.js";
|
|
42
42
|
import { isObservableDeclarable } from "../../declarable.js";
|
|
43
43
|
import { build } from "../../build.js";
|
|
@@ -467,7 +467,7 @@ export async function runComponentsStatus(ctx) {
|
|
|
467
467
|
// Discover components (best-effort) so a live/owned-but-never-recorded
|
|
468
468
|
// component still gets a row, not just those that appear in the ledger.
|
|
469
469
|
const { config } = await loadChantConfig(resolve("."));
|
|
470
|
-
const discovery = await discoverComponents(resolve(
|
|
470
|
+
const discovery = await discoverComponents(resolveSourceDir(resolve("."), config, args.src), {
|
|
471
471
|
sandbox: args.sandbox,
|
|
472
472
|
});
|
|
473
473
|
const allComponents = [...discovery.components.keys()];
|
|
@@ -506,7 +506,7 @@ export async function runComponentsStatus(ctx) {
|
|
|
506
506
|
const statusParams = await commandBuildParams(config.buildParams, args);
|
|
507
507
|
if (!statusParams)
|
|
508
508
|
return 1;
|
|
509
|
-
const buildResult = await build(resolve(
|
|
509
|
+
const buildResult = await build(resolveSourceDir(resolve("."), config, args.src), targetSerializers, undefined, {
|
|
510
510
|
buildParams: statusParams,
|
|
511
511
|
config: config,
|
|
512
512
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dead-guards.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/dead-guards.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB3E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant dev dead-guards [<product-dir>]` (#4792): each feature-detect in a
|
|
3
|
+
* product whose chant floor the product's pin already meets, so the product
|
|
4
|
+
* deletes it. Exit 1 when there is one, 2 for a usage error.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, statSync } from "node:fs";
|
|
7
|
+
import { resolve } from "node:path";
|
|
8
|
+
import { deadGuardLine, findDeadGuards } from "../../dead-guards.js";
|
|
9
|
+
import { formatError } from "../format.js";
|
|
10
|
+
const USAGE = "chant dev dead-guards [<product-dir>] [--chant-version <version>] [--json]";
|
|
11
|
+
export async function runDevDeadGuards(ctx) {
|
|
12
|
+
const dir = resolve(ctx.args.extraPositional ?? process.cwd());
|
|
13
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) {
|
|
14
|
+
console.error(formatError({ message: `${dir} is not a directory`, hint: USAGE }));
|
|
15
|
+
return 2;
|
|
16
|
+
}
|
|
17
|
+
const r = findDeadGuards({ productDir: dir, ...(ctx.args.chantVersion ? { chant: ctx.args.chantVersion } : {}) });
|
|
18
|
+
if (!ctx.args.chantVersion && r.pins.length === 0) {
|
|
19
|
+
console.error(formatError({ message: `no package.json under ${dir} pins @intentius/chant at a version`, hint: USAGE }));
|
|
20
|
+
return 2;
|
|
21
|
+
}
|
|
22
|
+
if (ctx.args.json) {
|
|
23
|
+
console.log(JSON.stringify(r, null, 2));
|
|
24
|
+
return r.ok ? 0 : 1;
|
|
25
|
+
}
|
|
26
|
+
const against = ctx.args.chantVersion ? `chant ${ctx.args.chantVersion}` : r.pins.map((p) => `${p.file} ${p.pin}`).join(", ");
|
|
27
|
+
if (r.ok) {
|
|
28
|
+
console.error(`dead-guards: ${r.files} files, no feature-detect the pin meets (${r.live.length} still needed; against ${against})`);
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
console.error(`dead-guards: ${r.dead.length} feature-detect(s) the pin already meets; delete each check and its fallback (against ${against})`);
|
|
32
|
+
for (const g of r.dead)
|
|
33
|
+
console.error(` ${deadGuardLine(g)}`);
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
@@ -11,7 +11,7 @@ import { reconstructEdges, mergeCatalogs, containmentGroups } from "../../graph-
|
|
|
11
11
|
import { carryAnnotations, observeResources } from "../../lifecycle/observe.js";
|
|
12
12
|
import { withLiveReadSession } from "../../live-read-session.js";
|
|
13
13
|
import { replaySnapshots, hasSnapshot } from "../../lifecycle/replay.js";
|
|
14
|
-
import { loadChantConfig, environmentNames, matchesDeclaredEnvironment, loadChantConfigUpward } from "../../config.js";
|
|
14
|
+
import { loadChantConfig, environmentNames, matchesDeclaredEnvironment, loadChantConfigUpward, resolveSourceDir } from "../../config.js";
|
|
15
15
|
import { applyLiveEndpoint } from "../../live-endpoint.js";
|
|
16
16
|
import { applyDetail, detailInertNotice } from "../../graph-detail.js";
|
|
17
17
|
import { applyLens, parseLens } from "../../graph-lens.js";
|
|
@@ -213,7 +213,7 @@ async function runGraphLive(ctx, format) {
|
|
|
213
213
|
// declared entity. Without this the built estate carried them but the graph
|
|
214
214
|
// build here didn't, and the overlay called every one of them foreign.
|
|
215
215
|
const buildRoots = collectBuildRootContributors(plugins, config, projectPath);
|
|
216
|
-
const buildResult = await build(resolve(
|
|
216
|
+
const buildResult = await build(resolveSourceDir(resolve("."), config, args.src), plugins.map((p) => p.serializer), undefined,
|
|
217
217
|
// #4252: the serializers read lexicon settings from config (gcp.project
|
|
218
218
|
// becomes each resource's project annotation, which the live read takes).
|
|
219
219
|
{ buildParams: liveBuildParams, buildRoots, config: config });
|
|
@@ -237,7 +237,7 @@ async function runGraphLive(ctx, format) {
|
|
|
237
237
|
// no components (or whose discovery errors) yields no stacks, so
|
|
238
238
|
// `observeResources` falls back to its original single-stack call —
|
|
239
239
|
// unchanged.
|
|
240
|
-
const componentsDiscovery = await discoverComponents(resolve(
|
|
240
|
+
const componentsDiscovery = await discoverComponents(resolveSourceDir(resolve("."), config, args.src), {
|
|
241
241
|
sandbox: args.sandbox,
|
|
242
242
|
});
|
|
243
243
|
const stacks = [];
|
|
@@ -402,7 +402,7 @@ async function runGraphLive(ctx, format) {
|
|
|
402
402
|
}
|
|
403
403
|
else {
|
|
404
404
|
const declaredParams = await graphBuildParams(ctx, projectPath);
|
|
405
|
-
const declared = await discover(resolve(
|
|
405
|
+
const declared = await discover(resolveSourceDir(resolve("."), config, args.src), {
|
|
406
406
|
...(declaredParams ? { buildParams: declaredParams } : {}),
|
|
407
407
|
});
|
|
408
408
|
// #1626 — the declared canvas must include what the build declares, and
|
|
@@ -7,7 +7,8 @@ import type { ChantConfig } from "../../config.js";
|
|
|
7
7
|
* subdirectory so a mixed-layout project — chant `src/` next to app code with
|
|
8
8
|
* import side effects — only synthesizes its infra. Precedence: `--src` flag,
|
|
9
9
|
* then `config.sourceDir`, then "." (the root). Snapshot/diff/plan all use this
|
|
10
|
-
* so their build digests stay consistent.
|
|
10
|
+
* so their build digests stay consistent. The rule is `resolveSourceDir`'s,
|
|
11
|
+
* which every command that picks a source directory shares (#4794).
|
|
11
12
|
*/
|
|
12
13
|
export declare function resolveBuildRoot(args: ParsedArgs, config: ChantConfig): string;
|
|
13
14
|
/** One stack a lifecycle command operates on: its build root and, for a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/lifecycle.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/lifecycle.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKhD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAE9E;AAED;;cAEc;AACd,UAAU,WAAW;IACnB;iDAC6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;0CACsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb;;;6DAGyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,EAAE,CAMxF;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8H/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA6C3E;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8B/E;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8Q3E;AA8xBD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA2R3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA2L/E;AAsBD;;GAEG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB1E;AAgBD;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAmE7E;AAiCD;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAM9E;AAkBD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA0E/E"}
|
|
@@ -26,7 +26,7 @@ import { changedFilesBetween, lexiconChangedUnits } from "../../components/chang
|
|
|
26
26
|
import { cfnDeployStacks } from "./components.js";
|
|
27
27
|
import { affectedStacks } from "../../lifecycle/affected.js";
|
|
28
28
|
import { rollbackToRevision } from "../../lifecycle/rollback.js";
|
|
29
|
-
import { loadChantConfig, environmentNames, matchesDeclaredEnvironment, resolveOwnershipStack } from "../../config.js";
|
|
29
|
+
import { loadChantConfig, environmentNames, matchesDeclaredEnvironment, resolveOwnershipStack, resolveSourceDir, configuredSourceDir } from "../../config.js";
|
|
30
30
|
import { unknownEnvError, isProdLikeEnvironment } from "../../env.js";
|
|
31
31
|
import { planTeardown, executeTeardown } from "../../lifecycle/teardown.js";
|
|
32
32
|
import { collectBuildRootContributors } from "../plugins.js";
|
|
@@ -40,10 +40,11 @@ import { formatError, formatWarning, formatSuccess, formatBold } from "../format
|
|
|
40
40
|
* subdirectory so a mixed-layout project — chant `src/` next to app code with
|
|
41
41
|
* import side effects — only synthesizes its infra. Precedence: `--src` flag,
|
|
42
42
|
* then `config.sourceDir`, then "." (the root). Snapshot/diff/plan all use this
|
|
43
|
-
* so their build digests stay consistent.
|
|
43
|
+
* so their build digests stay consistent. The rule is `resolveSourceDir`'s,
|
|
44
|
+
* which every command that picks a source directory shares (#4794).
|
|
44
45
|
*/
|
|
45
46
|
export function resolveBuildRoot(args, config) {
|
|
46
|
-
return resolve(
|
|
47
|
+
return resolveSourceDir(resolve("."), config, args.src);
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* The stacks a lifecycle command (`snapshot`/`diff`) iterates. A multi-stack
|
|
@@ -243,7 +244,7 @@ export async function runLifecycleRollback(ctx) {
|
|
|
243
244
|
return 1;
|
|
244
245
|
}
|
|
245
246
|
const { config } = await loadChantConfig(resolve("."));
|
|
246
|
-
const sourceDir = config
|
|
247
|
+
const sourceDir = configuredSourceDir(config);
|
|
247
248
|
try {
|
|
248
249
|
const result = await rollbackToRevision({ ref, env: environment, sourceDir, cwd: resolve("."), dryRun: args.dryRun });
|
|
249
250
|
if (result.noop) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CommandContext } from "../registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* `chant dev local <chant-dir>`: pack the checkout and install it into the
|
|
4
|
+
* product in the current directory (`installLocalChant`), run `--build`, then
|
|
5
|
+
* the bundle check of every package that declares `chantBundleCheck`.
|
|
6
|
+
* `--reset` goes back to the lock's pins the same way. Exit 1 when a step
|
|
7
|
+
* fails, 2 for a usage error.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runDevLocal(ctx: CommandContext): Promise<number>;
|
|
10
|
+
/**
|
|
11
|
+
* `chant dev bundle-check [<package-dir>]`: check one package's bundle against
|
|
12
|
+
* its `chantBundleCheck`, or, with no directory, every package of the product
|
|
13
|
+
* in the current directory that declares one.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runDevBundleCheck(ctx: CommandContext): Promise<number>;
|
|
16
|
+
//# sourceMappingURL=local-chant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-chant.d.ts","sourceRoot":"","sources":["../../../src/cli/handlers/local-chant.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA+BlD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BtE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB5E"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant dev local` and `chant dev bundle-check` (#4787): build a product
|
|
3
|
+
* against a chant checkout, and check the product's bundle. Both modules are
|
|
4
|
+
* imported here, before the install, so the command keeps running the chant
|
|
5
|
+
* it started with while npm replaces the installed one.
|
|
6
|
+
*/
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
import { checkBundle, readBundleCheckConfig } from "../../bundle-check.js";
|
|
10
|
+
import { installLocalChant, LocalChantError, productManifests, resetLocalChant } from "../../local-chant.js";
|
|
11
|
+
import { formatError } from "../format.js";
|
|
12
|
+
const LOCAL_USAGE = "chant dev local <chant-dir> [--with <package>]... [--build '<command>'] [--json] | chant dev local --reset [--build '<command>']";
|
|
13
|
+
const CHECK_USAGE = "chant dev bundle-check [<package-dir>] [--json]";
|
|
14
|
+
/** The product packages that declare `chantBundleCheck`, as directories. */
|
|
15
|
+
function checkedPackages(productDir) {
|
|
16
|
+
return productManifests(productDir)
|
|
17
|
+
.map((f) => join(productDir, f.replace(/\/?package\.json$/, "")))
|
|
18
|
+
.filter((d) => readBundleCheckConfig(d) !== undefined);
|
|
19
|
+
}
|
|
20
|
+
/** Run each package's bundle check and print the result; true when every one passes. */
|
|
21
|
+
function runChecks(dirs, json) {
|
|
22
|
+
const results = dirs.map((dir) => ({ dir, ...checkBundle(dir, readBundleCheckConfig(dir)) }));
|
|
23
|
+
if (!json) {
|
|
24
|
+
for (const r of results) {
|
|
25
|
+
if (r.ok)
|
|
26
|
+
console.error(` bundle-check: ${r.summary}`);
|
|
27
|
+
else
|
|
28
|
+
console.error(`bundle-check: ${r.dir}\n ${r.problems.join("\n ")}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { ok: results.every((r) => r.ok), results };
|
|
32
|
+
}
|
|
33
|
+
/** The product's build, as one shell command in its root. */
|
|
34
|
+
function runBuild(command, cwd) {
|
|
35
|
+
console.error(`chant dev local: ${command}`);
|
|
36
|
+
const r = spawnSync("sh", ["-c", command], { cwd, stdio: "inherit" });
|
|
37
|
+
return r.status === 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* `chant dev local <chant-dir>`: pack the checkout and install it into the
|
|
41
|
+
* product in the current directory (`installLocalChant`), run `--build`, then
|
|
42
|
+
* the bundle check of every package that declares `chantBundleCheck`.
|
|
43
|
+
* `--reset` goes back to the lock's pins the same way. Exit 1 when a step
|
|
44
|
+
* fails, 2 for a usage error.
|
|
45
|
+
*/
|
|
46
|
+
export async function runDevLocal(ctx) {
|
|
47
|
+
const productDir = process.cwd();
|
|
48
|
+
const reset = ctx.args.reset === true;
|
|
49
|
+
const chantDir = ctx.args.extraPositional;
|
|
50
|
+
if (reset === (chantDir !== undefined)) {
|
|
51
|
+
console.error(formatError({ message: reset ? "--reset takes no chant directory" : "chant dev local needs a chant checkout", hint: LOCAL_USAGE }));
|
|
52
|
+
return 2;
|
|
53
|
+
}
|
|
54
|
+
let installed;
|
|
55
|
+
try {
|
|
56
|
+
if (reset)
|
|
57
|
+
resetLocalChant({ productDir });
|
|
58
|
+
else
|
|
59
|
+
installed = installLocalChant({ productDir, chantDir: resolve(chantDir), with: ctx.args.withPackages });
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
if (!(err instanceof LocalChantError))
|
|
63
|
+
throw err;
|
|
64
|
+
console.error(formatError({ message: err.message }));
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
if (ctx.args.buildCommand && !runBuild(ctx.args.buildCommand, productDir)) {
|
|
68
|
+
console.error(formatError({ message: `the build failed: ${ctx.args.buildCommand}` }));
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
const dirs = checkedPackages(productDir);
|
|
72
|
+
if (!dirs.length)
|
|
73
|
+
console.error("chant dev local: no package declares chantBundleCheck, so no bundle was checked");
|
|
74
|
+
const { ok, results } = runChecks(dirs, ctx.args.json === true);
|
|
75
|
+
if (ctx.args.json) {
|
|
76
|
+
console.log(JSON.stringify({ reset, local: installed ? { commit: installed.mark.commit, dir: installed.mark.dir, packed: installed.packed.map((p) => ({ name: p.name, version: p.version })), marked: installed.marked } : undefined, checks: results }, null, 2));
|
|
77
|
+
}
|
|
78
|
+
else if (installed) {
|
|
79
|
+
console.log(`chant commit: ${installed.mark.commit}`);
|
|
80
|
+
}
|
|
81
|
+
return ok ? 0 : 1;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* `chant dev bundle-check [<package-dir>]`: check one package's bundle against
|
|
85
|
+
* its `chantBundleCheck`, or, with no directory, every package of the product
|
|
86
|
+
* in the current directory that declares one.
|
|
87
|
+
*/
|
|
88
|
+
export async function runDevBundleCheck(ctx) {
|
|
89
|
+
const dir = ctx.args.extraPositional;
|
|
90
|
+
let dirs;
|
|
91
|
+
if (dir !== undefined) {
|
|
92
|
+
if (readBundleCheckConfig(resolve(dir)) === undefined) {
|
|
93
|
+
console.error(formatError({ message: `${join(dir, "package.json")} has no chantBundleCheck`, hint: CHECK_USAGE }));
|
|
94
|
+
return 2;
|
|
95
|
+
}
|
|
96
|
+
dirs = [resolve(dir)];
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
dirs = checkedPackages(process.cwd());
|
|
100
|
+
if (!dirs.length) {
|
|
101
|
+
console.error(formatError({ message: "no package here declares chantBundleCheck", hint: CHECK_USAGE }));
|
|
102
|
+
return 2;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const { ok, results } = runChecks(dirs, ctx.args.json === true);
|
|
106
|
+
if (ctx.args.json)
|
|
107
|
+
console.log(JSON.stringify(results, null, 2));
|
|
108
|
+
return ok ? 0 : 1;
|
|
109
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `loadProfiles` from the project's configured lexicons).
|
|
8
8
|
*/
|
|
9
9
|
import { lexiconNames } from "../../lexicon-module.js";
|
|
10
|
-
import { loadChantConfig } from "../../config.js";
|
|
10
|
+
import { loadChantConfig, resolveSourceDir } from "../../config.js";
|
|
11
11
|
import { build } from "../../build.js";
|
|
12
12
|
import { isObservableDeclarable } from "../../declarable.js";
|
|
13
13
|
import { collectBuildRootContributors, collectChangeSubscribers } from "../plugins.js";
|
|
@@ -63,7 +63,7 @@ async function collectOperatorSubscribers(ctx, env) {
|
|
|
63
63
|
try {
|
|
64
64
|
const { config } = await loadChantConfig(cwd);
|
|
65
65
|
const buildRoots = collectBuildRootContributors(ctx.plugins, config, cwd);
|
|
66
|
-
const buildResult = await build(config
|
|
66
|
+
const buildResult = await build(resolveSourceDir(cwd, config), ctx.serializers, undefined, { buildRoots });
|
|
67
67
|
if (buildResult.errors.length > 0) {
|
|
68
68
|
console.error(formatWarning({
|
|
69
69
|
message: "build failed while scoping the change signal, so this runs on the timer alone",
|
|
@@ -12,7 +12,7 @@ import { replaySnapshots, hasSnapshot } from "../../lifecycle/replay.js";
|
|
|
12
12
|
import { diffLive } from "../../lifecycle/live-diff.js";
|
|
13
13
|
import { formatUnobserved } from "../../observation.js";
|
|
14
14
|
import { readChantPackageVersion } from "../../package-version.js";
|
|
15
|
-
import { loadChantConfig, matchesDeclaredEnvironment } from "../../config.js";
|
|
15
|
+
import { loadChantConfig, matchesDeclaredEnvironment, resolveSourceDir } from "../../config.js";
|
|
16
16
|
import { collectBuildRootContributors, loadPlugins, resolveProjectLexicons } from "../plugins.js";
|
|
17
17
|
import { declaredBuildRootContributors, mergeDeclaredBuildRoots, withLexiconEdges } from "./declared-graph.js";
|
|
18
18
|
import { parseCountBy, countGroups, countsJson, formatCounts, groupMembers, hasManyTerraformRoots } from "./search-count.js";
|
|
@@ -120,7 +120,7 @@ export async function runSearch(ctx) {
|
|
|
120
120
|
// Why --check-snapshot had nothing to check against, for --json (#4367).
|
|
121
121
|
let driftUnavailable;
|
|
122
122
|
if (args.index !== undefined) {
|
|
123
|
-
const answered = await indexAnswer(ctx, String(args.index), projectPath, resolve(
|
|
123
|
+
const answered = await indexAnswer(ctx, String(args.index), projectPath, resolveSourceDir(resolve("."), config, args.src), config);
|
|
124
124
|
if ("error" in answered)
|
|
125
125
|
return refuse(answered.error);
|
|
126
126
|
ir = answered.ir;
|
|
@@ -142,7 +142,7 @@ export async function runSearch(ctx) {
|
|
|
142
142
|
// root's blocks are entities only once its root is rendered, and an
|
|
143
143
|
// entity the build never produced is never observed.
|
|
144
144
|
const buildRoots = collectBuildRootContributors(plugins, config, projectPath);
|
|
145
|
-
const buildResult = await build(resolve(
|
|
145
|
+
const buildResult = await build(resolveSourceDir(resolve("."), config, args.src), plugins.map((p) => p.serializer), undefined, {
|
|
146
146
|
buildRoots,
|
|
147
147
|
config: config,
|
|
148
148
|
});
|
|
@@ -293,7 +293,7 @@ export async function runSearch(ctx) {
|
|
|
293
293
|
// root overlays onto a canvas that has the root's resources on it.
|
|
294
294
|
const declared = stacks.length > 0
|
|
295
295
|
? await buildDeclaredPerStack(stacks, projectPath, (g, entities) => withLexiconEdges(g, plugins, entities))
|
|
296
|
-
: await declaredGraph(ctx, projectPath, resolve(
|
|
296
|
+
: await declaredGraph(ctx, projectPath, resolveSourceDir(resolve("."), config, args.src), plugins);
|
|
297
297
|
if (!declared)
|
|
298
298
|
return refuse(BUILD_ROOT_FAILED);
|
|
299
299
|
declaredForDrift = declared;
|
|
@@ -339,7 +339,7 @@ export async function runSearch(ctx) {
|
|
|
339
339
|
ir = { ...ir, nodes: carryAnnotations(ir.nodes, annotations) };
|
|
340
340
|
}
|
|
341
341
|
else {
|
|
342
|
-
const declared = await declaredGraph(ctx, projectPath, resolve(
|
|
342
|
+
const declared = await declaredGraph(ctx, projectPath, resolveSourceDir(resolve("."), config, args.src));
|
|
343
343
|
if (!declared)
|
|
344
344
|
return refuse(BUILD_ROOT_FAILED);
|
|
345
345
|
ir = declared;
|
package/dist/cli/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoB,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAItG,OAAO,EAAkB,KAAK,UAAU,EAAmB,MAAM,YAAY,CAAC;AAa9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoB,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAItG,OAAO,EAAkB,KAAK,UAAU,EAAmB,MAAM,YAAY,CAAC;AAa9E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAgB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG3D,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;AA6vDzC;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,mBAAmB,GAAG,cAAc,CAAC;IAAC,GAAG,CAAC,EAAE,OAAO,qBAAqB,EAAE,cAAc,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,2BAA2B,EAAE,eAAe,CAAA;CAAO,GAC7K,OAAO,CAAC,MAAM,CAAC,CAuCjB;AAID;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,EAoRvC,CAAC"}
|