@intentius/chant 0.124.15 → 0.124.16
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/cli/flush.d.ts +16 -0
- package/dist/cli/flush.d.ts.map +1 -0
- package/dist/cli/flush.js +42 -0
- package/dist/cli/handlers/approve.d.ts +98 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -0
- package/dist/cli/handlers/approve.js +495 -0
- package/dist/cli/handlers/operator.d.ts +1 -95
- package/dist/cli/handlers/operator.d.ts.map +1 -1
- package/dist/cli/handlers/operator.js +4 -488
- package/dist/cli/handlers/override-approve.js +1 -1
- package/dist/cli/main.d.ts +4 -15
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +4 -1062
- package/dist/cli/parse-args.d.ts +6 -0
- package/dist/cli/parse-args.d.ts.map +1 -0
- package/dist/cli/parse-args.js +1028 -0
- package/dist/components/fan-out-record.d.ts +1 -1
- package/dist/components/fan-out-record.d.ts.map +1 -1
- package/dist/components/fan-out-record.js +3 -7
- package/dist/components/fan-out-run.d.ts +5 -3
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +7 -5
- package/dist/gated-waves.d.ts +25 -6
- package/dist/gated-waves.d.ts.map +1 -1
- package/dist/gated-waves.js +21 -6
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/op/op-waves-run.d.ts +1 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +5 -6
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +4 -8
- package/dist/package-version.d.ts +2 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +10 -0
- package/dist/wave-engine.d.ts +62 -0
- package/dist/wave-engine.d.ts.map +1 -0
- package/dist/wave-engine.js +59 -0
- package/dist/wave-layout.d.ts +29 -0
- package/dist/wave-layout.d.ts.map +1 -0
- package/dist/wave-layout.js +41 -0
- package/dist/wave-runtime.d.ts +29 -0
- package/dist/wave-runtime.d.ts.map +1 -0
- package/dist/wave-runtime.js +103 -0
- package/dist/wave-runtime.mjs +331 -0
- package/dist/workspace/ajv2020.d.ts +5 -0
- package/dist/workspace/ajv2020.d.ts.map +1 -0
- package/dist/workspace/ajv2020.js +14 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +4 -8
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +2 -5
- package/dist/workspace/points.d.ts.map +1 -1
- package/dist/workspace/points.js +2 -5
- package/dist/workspace/principal-classes.d.ts.map +1 -1
- package/dist/workspace/principal-classes.js +2 -5
- package/package.json +5 -3
- package/src/cli/flush.ts +44 -0
- package/src/cli/handlers/approve.ts +618 -0
- package/src/cli/handlers/operator.ts +10 -608
- package/src/cli/handlers/override-approve.test.ts +1 -1
- package/src/cli/handlers/override-approve.ts +1 -1
- package/src/cli/main.ts +5 -816
- package/src/cli/parse-args.ts +781 -0
- package/src/components/fan-out-record.ts +3 -7
- package/src/components/fan-out-run.ts +7 -5
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/gated-waves.ts +28 -6
- package/src/op/op-waves-run.ts +5 -6
- package/src/op/op-waves.ts +4 -8
- package/src/package-version.ts +11 -0
- package/src/wave-engine.test.ts +107 -0
- package/src/wave-engine.ts +98 -0
- package/src/wave-layout.ts +44 -0
- package/src/wave-runtime-bundle.test.ts +70 -0
- package/src/wave-runtime.e2e.test.ts +177 -0
- package/src/wave-runtime.ts +104 -0
- package/src/workspace/ajv2020.ts +17 -0
- package/src/workspace/declaration.ts +4 -10
- package/src/workspace/kinds.ts +2 -5
- package/src/workspace/points.ts +2 -5
- package/src/workspace/principal-classes.ts +2 -5
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave gate names and the share split of a wide wave (#3766), the parts of
|
|
3
|
+
* the wave engine (`./wave-engine.ts`) that the Op waves spec module
|
|
4
|
+
* (`./op/op-waves.ts`) needs. That module is in the gate-decision bundle
|
|
5
|
+
* (`./gate-decision.ts` re-exports a constant from it), so this imports
|
|
6
|
+
* nothing and keeps the change-set digest code out of that bundle.
|
|
7
|
+
*/
|
|
8
|
+
/** The default wave gate name pattern: `{gate}` is the base gate name, `{k}` the wave's number. */
|
|
9
|
+
export const WAVE_GATE_NAME_PATTERN = "{gate}-wave-{k}";
|
|
10
|
+
/**
|
|
11
|
+
* The gate wave `k` waits on under a name pattern (#3821). With the default
|
|
12
|
+
* pattern this is `waveGateName(gate, k)` from `./gated-waves.ts`; an Op
|
|
13
|
+
* waves spec's `gateName` names another (such as `"wave-{k}"`) so approvals
|
|
14
|
+
* already on the ledger under a product's old names keep matching.
|
|
15
|
+
*
|
|
16
|
+
* `{gate}` is filled in before `{k}`, as `opWaveGateName` always did, so a
|
|
17
|
+
* base gate name holding the text `{k}` is filled in too. That is the one
|
|
18
|
+
* input on which this and `waveGateName` differ, and each entry point keeps
|
|
19
|
+
* the one it shipped with.
|
|
20
|
+
*/
|
|
21
|
+
export function waveGateNameFrom(pattern, gate, k) {
|
|
22
|
+
return (pattern ?? WAVE_GATE_NAME_PATTERN).replaceAll("{gate}", gate).replaceAll("{k}", String(k));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Share `share` (1-based) of `shares` of a wide wave (#3679): the items
|
|
26
|
+
* sorted by `keyOf`, cut into contiguous slices whose sizes differ by at most
|
|
27
|
+
* one. The deciding job and every share job cut the same way, so each item
|
|
28
|
+
* is applied by exactly one share.
|
|
29
|
+
*/
|
|
30
|
+
export function waveShare(items, share, shares, keyOf) {
|
|
31
|
+
const sorted = [...items].sort((a, b) => {
|
|
32
|
+
const x = keyOf(a);
|
|
33
|
+
const y = keyOf(b);
|
|
34
|
+
return x < y ? -1 : x > y ? 1 : 0;
|
|
35
|
+
});
|
|
36
|
+
const base = Math.floor(sorted.length / shares);
|
|
37
|
+
const extra = sorted.length % shares;
|
|
38
|
+
const start = (share - 1) * base + Math.min(share - 1, extra);
|
|
39
|
+
const size = base + (share <= extra ? 1 : 0);
|
|
40
|
+
return sorted.slice(start, start + size);
|
|
41
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slim wave-job runtime (#3896): the four commands a generated Op waves
|
|
3
|
+
* pipeline runs, and nothing else.
|
|
4
|
+
*
|
|
5
|
+
* chant run wave --spec <file> --wave <k> [--decide | --share <i> | --record-plans]
|
|
6
|
+
* chant run resume [--gate <op>/<gate>] [--dry-run]
|
|
7
|
+
* chant approve <op> <gate> [...]
|
|
8
|
+
* chant workspace points ask|answer|list|... [...]
|
|
9
|
+
*
|
|
10
|
+
* `scripts/build-runtime.mjs` bundles this file with esbuild into
|
|
11
|
+
* `dist/wave-runtime.mjs`: one self-contained ES module whose only imports are
|
|
12
|
+
* `node:` builtins, with no TypeScript compiler, esbuild, tsx or zod in it. A
|
|
13
|
+
* product copies that one file into its CI image and runs it with plain node,
|
|
14
|
+
* or runs it from an installed `@intentius/chant`
|
|
15
|
+
* (`node node_modules/@intentius/chant/dist/wave-runtime.mjs run wave ...`).
|
|
16
|
+
*
|
|
17
|
+
* The handlers are the full CLI's own (`./cli/main.ts` dispatches to the same
|
|
18
|
+
* functions), parsed by the same `parseArgs`, so flags, output, exit codes and
|
|
19
|
+
* the ledgers each command writes are the same. What the runtime does not do:
|
|
20
|
+
* evaluate `chant.config.ts` (which needs a TypeScript loader). None of the
|
|
21
|
+
* four commands reads the config; the full CLI loads it only to check `--env`
|
|
22
|
+
* against the declared `environments`, a check the runtime skips.
|
|
23
|
+
*/
|
|
24
|
+
import { type CommandDef } from "./cli/registry.js";
|
|
25
|
+
/** The commands the runtime carries, under the names the full CLI registers them by. */
|
|
26
|
+
export declare const RUNTIME_COMMANDS: CommandDef[];
|
|
27
|
+
/** Parse, dispatch and return the exit code. Exported for tests. */
|
|
28
|
+
export declare function runRuntime(argv: string[]): Promise<number>;
|
|
29
|
+
//# sourceMappingURL=wave-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wave-runtime.d.ts","sourceRoot":"","sources":["../src/wave-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAkB,KAAK,UAAU,EAAmB,MAAM,gBAAgB,CAAC;AAYlF,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,EAAE,UAAU,EAKxC,CAAC;AAsBF,oEAAoE;AACpE,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BhE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The slim wave-job runtime (#3896): the four commands a generated Op waves
|
|
3
|
+
* pipeline runs, and nothing else.
|
|
4
|
+
*
|
|
5
|
+
* chant run wave --spec <file> --wave <k> [--decide | --share <i> | --record-plans]
|
|
6
|
+
* chant run resume [--gate <op>/<gate>] [--dry-run]
|
|
7
|
+
* chant approve <op> <gate> [...]
|
|
8
|
+
* chant workspace points ask|answer|list|... [...]
|
|
9
|
+
*
|
|
10
|
+
* `scripts/build-runtime.mjs` bundles this file with esbuild into
|
|
11
|
+
* `dist/wave-runtime.mjs`: one self-contained ES module whose only imports are
|
|
12
|
+
* `node:` builtins, with no TypeScript compiler, esbuild, tsx or zod in it. A
|
|
13
|
+
* product copies that one file into its CI image and runs it with plain node,
|
|
14
|
+
* or runs it from an installed `@intentius/chant`
|
|
15
|
+
* (`node node_modules/@intentius/chant/dist/wave-runtime.mjs run wave ...`).
|
|
16
|
+
*
|
|
17
|
+
* The handlers are the full CLI's own (`./cli/main.ts` dispatches to the same
|
|
18
|
+
* functions), parsed by the same `parseArgs`, so flags, output, exit codes and
|
|
19
|
+
* the ledgers each command writes are the same. What the runtime does not do:
|
|
20
|
+
* evaluate `chant.config.ts` (which needs a TypeScript loader). None of the
|
|
21
|
+
* four commands reads the config; the full CLI loads it only to check `--env`
|
|
22
|
+
* against the declared `environments`, a check the runtime skips.
|
|
23
|
+
*/
|
|
24
|
+
import { parseArgs } from "./cli/parse-args.js";
|
|
25
|
+
import { resolveCommand } from "./cli/registry.js";
|
|
26
|
+
import { formatError } from "./cli/format.js";
|
|
27
|
+
import { flushAndExit } from "./cli/flush.js";
|
|
28
|
+
import { CHANT_VERSION } from "./cli/version.js";
|
|
29
|
+
import { isEntryPoint } from "./cli/is-entry-point.js";
|
|
30
|
+
import { ENV_VAR } from "./env.js";
|
|
31
|
+
import { initRuntime } from "./runtime-adapter.js";
|
|
32
|
+
import { runOpWaveCommand } from "./cli/handlers/run-wave.js";
|
|
33
|
+
import { runResumeCommand } from "./cli/handlers/gate-resume.js";
|
|
34
|
+
import { runApprove } from "./cli/handlers/approve.js";
|
|
35
|
+
import { runWorkspacePoints } from "./workspace/points-cli.js";
|
|
36
|
+
/** The commands the runtime carries, under the names the full CLI registers them by. */
|
|
37
|
+
export const RUNTIME_COMMANDS = [
|
|
38
|
+
{ name: "run wave", handler: runOpWaveCommand },
|
|
39
|
+
{ name: "run resume", handler: runResumeCommand },
|
|
40
|
+
{ name: "approve", handler: runApprove },
|
|
41
|
+
{ name: "workspace points", handler: runWorkspacePoints },
|
|
42
|
+
];
|
|
43
|
+
const HELP = `
|
|
44
|
+
chant runtime ${CHANT_VERSION} - the wave-job commands of chant, in one file
|
|
45
|
+
|
|
46
|
+
Usage: node wave-runtime.mjs <command> [options]
|
|
47
|
+
|
|
48
|
+
Commands:
|
|
49
|
+
run wave --spec <file> --wave <k> Plan, gate and apply wave k of an Op waves spec
|
|
50
|
+
(--decide, --share <i>, --record-plans, --base <ref>, --json)
|
|
51
|
+
run resume Start the CI jobs that wait at gates whose approval arrived
|
|
52
|
+
(--gate <op>/<gate>, --dry-run, --json)
|
|
53
|
+
approve <op> <gate> Record a gate's resolution on the lifecycle ledger
|
|
54
|
+
(--actor, --plan, --note, --url, --sign, --expire, --resume, ...)
|
|
55
|
+
workspace points <verb> Ask, answer and list decision points
|
|
56
|
+
|
|
57
|
+
Flags, output, exit codes and ledger formats are the full chant CLI's;
|
|
58
|
+
see "chant --help" in @intentius/chant for every flag. This runtime does
|
|
59
|
+
not evaluate chant.config.ts, so --env is not checked against the
|
|
60
|
+
declared environments.
|
|
61
|
+
`;
|
|
62
|
+
/** Parse, dispatch and return the exit code. Exported for tests. */
|
|
63
|
+
export async function runRuntime(argv) {
|
|
64
|
+
let args;
|
|
65
|
+
try {
|
|
66
|
+
args = parseArgs(argv);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err) }));
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
const match = resolveCommand(args, RUNTIME_COMMANDS);
|
|
73
|
+
if (args.version && (!args.command || match)) {
|
|
74
|
+
console.log(CHANT_VERSION);
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
if (args.help || !args.command) {
|
|
78
|
+
console.log(HELP);
|
|
79
|
+
return args.help ? 0 : 1;
|
|
80
|
+
}
|
|
81
|
+
if (!match) {
|
|
82
|
+
const name = args.path && args.path !== "." ? `${args.command} ${args.path}` : args.command;
|
|
83
|
+
console.error(formatError({
|
|
84
|
+
message: `"${name}" is not part of chant's wave-job runtime`,
|
|
85
|
+
hint: "It runs run wave, run resume, approve and workspace points. Every other command needs the full @intentius/chant CLI.",
|
|
86
|
+
}));
|
|
87
|
+
return 1;
|
|
88
|
+
}
|
|
89
|
+
if (args.env)
|
|
90
|
+
process.env[ENV_VAR] = args.env;
|
|
91
|
+
initRuntime();
|
|
92
|
+
return match.def.handler({ args, plugins: [], serializers: [] });
|
|
93
|
+
}
|
|
94
|
+
if (isEntryPoint(process.argv[1], import.meta.url)) {
|
|
95
|
+
runRuntime(process.argv.slice(2)).then(flushAndExit, async (err) => {
|
|
96
|
+
const verbose = process.argv.includes("--verbose") || process.argv.includes("-v");
|
|
97
|
+
if (verbose && err instanceof Error && err.stack)
|
|
98
|
+
console.error(err.stack);
|
|
99
|
+
else
|
|
100
|
+
console.error(formatError({ message: err instanceof Error ? err.message : String(err) }));
|
|
101
|
+
await flushAndExit(1);
|
|
102
|
+
});
|
|
103
|
+
}
|