@mmerterden/multi-agent-pipeline 20.40.0 → 20.42.0
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/CHANGELOG.md +94 -0
- package/README.md +5 -2
- package/README.tr.md +5 -2
- package/docs/adr/0019-product-tree.md +143 -0
- package/docs/adr/README.md +1 -0
- package/docs/ecosystem.md +51 -14
- package/docs/facts.json +7 -7
- package/docs/features.md +15 -4
- package/install/claude.mjs +45 -3
- package/install/templates/claude-hooks.json +23 -1
- package/manifest.json +146 -107
- package/package.json +3 -2
- package/pipeline/commands/multi-agent/autopilot/SKILL.md +11 -0
- package/pipeline/commands/multi-agent/review-analysis/SKILL.md +1 -1
- package/pipeline/commands/multi-agent/setup/SKILL.md +1 -1
- package/pipeline/contract/types/index.d.ts +53 -49
- package/pipeline/lib/args.mjs +131 -4
- package/pipeline/lib/bg-launch.mjs +5 -2
- package/pipeline/lib/context-budget.mjs +5 -42
- package/pipeline/lib/credential-store.sh +11 -1
- package/pipeline/lib/hook-once.mjs +134 -0
- package/pipeline/lib/hook-registration.mjs +5 -0
- package/pipeline/lib/isotonic.mjs +73 -0
- package/pipeline/lib/low-disk.mjs +153 -0
- package/pipeline/lib/mcp-schema-load.mjs +90 -0
- package/pipeline/lib/md2confluence-v3.py +19 -10
- package/pipeline/lib/model-dispatch.sh +26 -2
- package/pipeline/lib/normalize-text.mjs +135 -0
- package/pipeline/lib/outbound-gate.mjs +21 -3
- package/pipeline/lib/plan-todos.sh +17 -4
- package/pipeline/lib/redact.mjs +12 -3
- package/pipeline/lib/risky-settings.mjs +198 -0
- package/pipeline/lib/route-state.sh +1 -0
- package/pipeline/lib/secret-patterns.generated.mjs +6 -2
- package/pipeline/lib/session-usage.mjs +232 -0
- package/pipeline/lib/source-digest.mjs +211 -0
- package/pipeline/lib/tdd-evidence.mjs +250 -17
- package/pipeline/lib/tiered-budget.mjs +87 -0
- package/pipeline/lib/untrusted-fence.mjs +132 -1
- package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
- package/pipeline/multi-agent-refs/analysis/review.md +23 -1
- package/pipeline/multi-agent-refs/features/code-graph.md +11 -1
- package/pipeline/multi-agent-refs/features/cost-analysis.md +37 -2
- package/pipeline/multi-agent-refs/features/doctor.md +82 -4
- package/pipeline/multi-agent-refs/features/model-fallback.md +25 -0
- package/pipeline/multi-agent-refs/features/plan-todos.md +4 -0
- package/pipeline/multi-agent-refs/features/product-tree.md +68 -0
- package/pipeline/multi-agent-refs/features/unattended-gates.md +5 -3
- package/pipeline/multi-agent-refs/features/unattended-security.md +88 -1
- package/pipeline/multi-agent-refs/features/usage-reporting.md +33 -0
- package/pipeline/multi-agent-refs/help/en.md +2 -1
- package/pipeline/multi-agent-refs/help/tr.md +2 -1
- package/pipeline/multi-agent-refs/knowledge.md +58 -0
- package/pipeline/multi-agent-refs/outside-the-pipeline.md +6 -0
- package/pipeline/multi-agent-refs/phases/phase-0-init.md +4 -0
- package/pipeline/multi-agent-refs/phases/phase-1-plan.md +5 -1
- package/pipeline/multi-agent-refs/phases/phase-2-dev.md +4 -4
- package/pipeline/multi-agent-refs/phases/phase-3-review.md +2 -2
- package/pipeline/multi-agent-refs/phases/phase-5-report.md +4 -0
- package/pipeline/multi-agent-refs/progress-contract.md +3 -1
- package/pipeline/office/index.html +13 -7
- package/pipeline/office/toolkit.json +1 -1
- package/pipeline/preferences-template.json +1 -0
- package/pipeline/rules/outside-the-pipeline.md +1 -1
- package/pipeline/schemas/doctor-report.schema.json +47 -0
- package/pipeline/schemas/learnings-ledger.schema.json +35 -2
- package/pipeline/schemas/office-archive.schema.json +225 -128
- package/pipeline/schemas/plan-todos.schema.json +29 -1
- package/pipeline/schemas/prefs.schema.json +146 -0
- package/pipeline/schemas/product-tree-overlay.schema.json +57 -0
- package/pipeline/schemas/product-tree.schema.json +136 -0
- package/pipeline/schemas/route-config.schema.json +51 -0
- package/pipeline/schemas/secret-patterns.json +17 -1
- package/pipeline/schemas/toolkit-path-params.json +15 -1
- package/pipeline/scripts/_cost-advise.mjs +357 -0
- package/pipeline/scripts/_cost-budget.mjs +78 -0
- package/pipeline/scripts/_cost.mjs +29 -0
- package/pipeline/scripts/_decode_text.py +107 -0
- package/pipeline/scripts/_eval-stats.mjs +182 -0
- package/pipeline/scripts/_guard-probe.mjs +406 -0
- package/pipeline/scripts/_guard_rules.py +336 -1
- package/pipeline/scripts/_learnings-promotion.mjs +229 -0
- package/pipeline/scripts/_locate.mjs +539 -0
- package/pipeline/scripts/_memory-policy.mjs +208 -33
- package/pipeline/scripts/_product-tree-extract.mjs +761 -0
- package/pipeline/scripts/_product-tree.mjs +923 -0
- package/pipeline/scripts/_retrieval.mjs +161 -4
- package/pipeline/scripts/_secret-scan.mjs +6 -1
- package/pipeline/scripts/_stack-routing.mjs +2 -0
- package/pipeline/scripts/_test-gaming.mjs +346 -0
- package/pipeline/scripts/_user_guard_rules.py +744 -0
- package/pipeline/scripts/agent-guard.py +69 -6
- package/pipeline/scripts/agent-guard.sh +8 -1
- package/pipeline/scripts/argv-secret-scan.mjs +2 -1
- package/pipeline/scripts/autopilot-loop.mjs +407 -0
- package/pipeline/scripts/autopilot-runner.mjs +38 -25
- package/pipeline/scripts/capture-resume.sh +9 -1
- package/pipeline/scripts/cost-analyze.mjs +66 -4
- package/pipeline/scripts/cost-budget-check.mjs +5 -13
- package/pipeline/scripts/disk-cleaner.mjs +1418 -0
- package/pipeline/scripts/doctor.mjs +324 -43
- package/pipeline/scripts/evidence-gate.mjs +90 -0
- package/pipeline/scripts/gate-ledger.mjs +76 -21
- package/pipeline/scripts/gc-tmp.sh +5 -0
- package/pipeline/scripts/graph-query.mjs +257 -17
- package/pipeline/scripts/guard-probe-known-holes.json +3 -0
- package/pipeline/scripts/learnings-ledger.mjs +680 -55
- package/pipeline/scripts/note-agent-event.mjs +2 -0
- package/pipeline/scripts/note-mcp-failure.mjs +363 -0
- package/pipeline/scripts/note-mcp-failure.sh +19 -0
- package/pipeline/scripts/note-skill-use.mjs +96 -23
- package/pipeline/scripts/office-archive.mjs +23 -10
- package/pipeline/scripts/office-memory.mjs +4 -1
- package/pipeline/scripts/persona-walk-anchors.mjs +443 -0
- package/pipeline/scripts/pre-commit-check.sh +2 -2
- package/pipeline/scripts/pre-push-check.sh +8 -1
- package/pipeline/scripts/product-tree-eval.mjs +685 -0
- package/pipeline/scripts/product-tree.mjs +544 -0
- package/pipeline/scripts/publish-staged.mjs +324 -0
- package/pipeline/scripts/route-learn.mjs +628 -0
- package/pipeline/scripts/run-scope-guard.mjs +55 -1
- package/pipeline/scripts/scan-agent-config.sh +1 -1
- package/pipeline/scripts/statusline.mjs +309 -0
- package/pipeline/scripts/test-integrity-gate.mjs +97 -2
- package/pipeline/scripts/triage-memory.mjs +12 -4
- package/pipeline/scripts/uninstall.mjs +1 -0
- package/pipeline/skills/.skill-manifest.json +15 -7
- package/pipeline/skills/.skills-index.json +25 -3
- package/pipeline/skills/shared/README.md +6 -4
- package/pipeline/skills/shared/core/google-play-compliance/references/examples.md +1 -1
- package/pipeline/skills/shared/core/multi-agent-review-analysis/SKILL.md +1 -1
- package/pipeline/skills/shared/external/backlog/SKILL.md +1 -1
- package/pipeline/skills/shared/external/disk-cleaner/SKILL.md +105 -0
- package/pipeline/skills/shared/external/disk-cleaner/evals/evals.json +62 -0
- package/pipeline/skills/shared/external/disk-cleaner/scripts/disk-cleaner.mjs +1418 -0
- package/pipeline/skills/shared/external/localization-reuse-map/SKILL.md +1 -1
- package/pipeline/skills/shared/external/spec-persona-walk/SKILL.md +118 -0
- package/pipeline/skills/shared/external/spec-persona-walk/evals/evals.json +50 -0
- package/pipeline/skills/shared/external/spec-persona-walk/scripts/persona-walk-anchors.mjs +443 -0
- package/pipeline/skills/shared/external/storekit/SKILL.md +1 -1
- package/pipeline/skills/shared/external/swiftdata/SKILL.md +1 -1
- package/pipeline/skills/skill-copies.json +9 -1
- package/pipeline/skills/skills-index.md +4 -2
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* publish-staged.mjs - publish an npm package so that `latest` only ever
|
|
4
|
+
* names a version the registry has been seen to serve and that installs.
|
|
5
|
+
*
|
|
6
|
+
* 1. pack `npm pack`, and the tarball's sha512 computed here; the two
|
|
7
|
+
* must agree
|
|
8
|
+
* 2. publish `npm publish <tarball> --tag candidate`. A version the
|
|
9
|
+
* registry already holds with these bytes is a resumed
|
|
10
|
+
* release and is not published again; with other bytes it
|
|
11
|
+
* is refused
|
|
12
|
+
* 3. visible poll the registry's packument until the version carries
|
|
13
|
+
* the local integrity and the candidate tag names it. Read
|
|
14
|
+
* over HTTP, never with `npm view`, whose cache answers
|
|
15
|
+
* before the registry does. A different integrity fails at
|
|
16
|
+
* once: waiting cannot fix it
|
|
17
|
+
* 4. tarball download the tarball the registry serves; its sha512 must
|
|
18
|
+
* be the local one
|
|
19
|
+
* 5. install `npm install <that tarball>` into an empty temp project,
|
|
20
|
+
* scripts off, and check the installed version and its bins
|
|
21
|
+
* 6. smoke `--smoke "<cmd>"`, run in that project, when given
|
|
22
|
+
* 7. promote `npm dist-tag add <name>@<version> latest`
|
|
23
|
+
* 8. latest poll until the registry's `latest` names the version
|
|
24
|
+
*
|
|
25
|
+
* A failure before step 2 publishes nothing (exit 1). A failure after it
|
|
26
|
+
* leaves the version on the candidate tag and `latest` where it was (exit 3);
|
|
27
|
+
* running the same command again resumes from step 3.
|
|
28
|
+
*
|
|
29
|
+
* Usage:
|
|
30
|
+
* publish-staged.mjs [--dir <package dir>] [--registry <url>] [--tag <dist-tag>]
|
|
31
|
+
* [--npm <npm bin>] [--userconfig <npmrc>] [--smoke "<cmd>"]
|
|
32
|
+
* [--timeout-s N] [--interval-ms N] [--dry-run] [--json]
|
|
33
|
+
*
|
|
34
|
+
* --tag never names `latest`: publishing there moves latest before any of the
|
|
35
|
+
* checks run, so it is refused (exit 2) in any letter case.
|
|
36
|
+
*
|
|
37
|
+
* --registry defaults to https://registry.npmjs.org, --tag to candidate,
|
|
38
|
+
* --timeout-s to 300 per poll and --interval-ms to 5000. --userconfig is
|
|
39
|
+
* passed to every npm call, so a token kept in a temporary npmrc never
|
|
40
|
+
* reaches argv. --dry-run stops after the pack.
|
|
41
|
+
*
|
|
42
|
+
* Exit: 0 promoted (or dry run packed); 1 nothing published; 2 usage error;
|
|
43
|
+
* 3 published to the candidate tag, not promoted.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
import { spawnSync } from "node:child_process";
|
|
47
|
+
import { createHash } from "node:crypto";
|
|
48
|
+
import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
49
|
+
import { tmpdir } from "node:os";
|
|
50
|
+
import { join, resolve } from "node:path";
|
|
51
|
+
|
|
52
|
+
import { ArgsError, parseArgs } from "../lib/args.mjs";
|
|
53
|
+
import { exitOnHelp } from "../lib/cli-help.mjs";
|
|
54
|
+
import { invokedDirectly } from "../lib/invoked-directly.mjs";
|
|
55
|
+
|
|
56
|
+
exitOnHelp(import.meta.url);
|
|
57
|
+
|
|
58
|
+
const DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
59
|
+
|
|
60
|
+
/** The packument URL of a package; a scope's slash is encoded. */
|
|
61
|
+
export function packumentUrl(registry, name) {
|
|
62
|
+
return `${String(registry).replace(/\/+$/, "")}/${String(name).replace("/", "%2f")}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Why a staging tag cannot be used, or null: `latest` is the tag only promote may move. */
|
|
66
|
+
export function stagingTagRefusal(tag) {
|
|
67
|
+
const t = String(tag ?? "").trim();
|
|
68
|
+
if (!t) return "--tag needs a dist-tag name";
|
|
69
|
+
if (t.toLowerCase() === "latest")
|
|
70
|
+
return "--tag latest would move latest before the release is verified; stage on another tag";
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const integrityOf = (buf) => `sha512-${createHash("sha512").update(buf).digest("base64")}`;
|
|
75
|
+
|
|
76
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
77
|
+
|
|
78
|
+
function npmRunner(bin, userconfig) {
|
|
79
|
+
const viaNode = /\.(mjs|cjs|js)$/.test(bin);
|
|
80
|
+
return (args, cwd) => {
|
|
81
|
+
const argv = [...args, ...(userconfig ? ["--userconfig", userconfig] : [])];
|
|
82
|
+
const r = spawnSync(viaNode ? process.execPath : bin, viaNode ? [bin, ...argv] : argv, {
|
|
83
|
+
cwd,
|
|
84
|
+
encoding: "utf8",
|
|
85
|
+
env: process.env,
|
|
86
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
87
|
+
timeout: 10 * 60 * 1000,
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
ok: r.status === 0,
|
|
91
|
+
stdout: r.stdout || "",
|
|
92
|
+
stderr: String(r.stderr || r.error?.message || "").trim(),
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function packument(registry, name) {
|
|
98
|
+
const res = await fetch(packumentUrl(registry, name), {
|
|
99
|
+
headers: { accept: "application/json" },
|
|
100
|
+
});
|
|
101
|
+
if (res.status === 404) return null;
|
|
102
|
+
if (!res.ok) throw new Error(`registry answered ${res.status}`);
|
|
103
|
+
return res.json();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function poll(check, { timeoutMs, intervalMs }) {
|
|
107
|
+
const end = Date.now() + timeoutMs;
|
|
108
|
+
let last;
|
|
109
|
+
for (;;) {
|
|
110
|
+
try {
|
|
111
|
+
last = await check();
|
|
112
|
+
if (last.done) return last;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
if (e.fatal) throw e;
|
|
115
|
+
last = { done: false, detail: e.message };
|
|
116
|
+
}
|
|
117
|
+
if (Date.now() >= end) return { ...last, done: false, timedOut: true };
|
|
118
|
+
await sleep(intervalMs);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The staged release. `steps` collects one {step, ok, detail} per step run.
|
|
124
|
+
*
|
|
125
|
+
* @returns {Promise<{code: number, report: object}>}
|
|
126
|
+
*/
|
|
127
|
+
export async function publishStaged(opts) {
|
|
128
|
+
const refusal = stagingTagRefusal(opts.tag);
|
|
129
|
+
if (refusal) throw new ArgsError(refusal, { kind: "unexpected", token: "--tag" });
|
|
130
|
+
const dir = resolve(opts.dir);
|
|
131
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
132
|
+
const npm = npmRunner(opts.npm, opts.userconfig);
|
|
133
|
+
const steps = [];
|
|
134
|
+
const report = {
|
|
135
|
+
name: pkg.name,
|
|
136
|
+
version: pkg.version,
|
|
137
|
+
tag: opts.tag,
|
|
138
|
+
registry: opts.registry,
|
|
139
|
+
integrity: null,
|
|
140
|
+
promoted: false,
|
|
141
|
+
steps,
|
|
142
|
+
};
|
|
143
|
+
const work = mkdtempSync(join(tmpdir(), "publish-staged-"));
|
|
144
|
+
const done = (code) => {
|
|
145
|
+
rmSync(work, { recursive: true, force: true });
|
|
146
|
+
return { code, report };
|
|
147
|
+
};
|
|
148
|
+
const step = (name, ok, detail) => {
|
|
149
|
+
steps.push({ step: name, ok, detail });
|
|
150
|
+
return ok;
|
|
151
|
+
};
|
|
152
|
+
const timing = { timeoutMs: opts.timeoutS * 1000, intervalMs: opts.intervalMs };
|
|
153
|
+
|
|
154
|
+
const packed = npm(["pack", "--json", "--pack-destination", work], dir);
|
|
155
|
+
let tarball;
|
|
156
|
+
try {
|
|
157
|
+
const entry = JSON.parse(packed.stdout)[0];
|
|
158
|
+
tarball = join(work, entry.filename);
|
|
159
|
+
const local = integrityOf(readFileSync(tarball));
|
|
160
|
+
report.integrity = local;
|
|
161
|
+
if (entry.integrity && entry.integrity !== local) {
|
|
162
|
+
step("pack", false, `npm reported ${entry.integrity}, the tarball hashes to ${local}`);
|
|
163
|
+
return done(1);
|
|
164
|
+
}
|
|
165
|
+
step("pack", true, `${entry.filename} ${statSync(tarball).size} bytes`);
|
|
166
|
+
} catch (e) {
|
|
167
|
+
step("pack", false, packed.ok ? `unreadable pack output: ${e.message}` : packed.stderr);
|
|
168
|
+
return done(1);
|
|
169
|
+
}
|
|
170
|
+
if (opts.dryRun) return done(0);
|
|
171
|
+
|
|
172
|
+
let existing;
|
|
173
|
+
try {
|
|
174
|
+
existing = (await packument(opts.registry, pkg.name))?.versions?.[pkg.version];
|
|
175
|
+
} catch (e) {
|
|
176
|
+
step("publish", false, `the registry could not be read before publishing: ${e.message}`);
|
|
177
|
+
return done(1);
|
|
178
|
+
}
|
|
179
|
+
if (existing) {
|
|
180
|
+
if (existing.dist?.integrity !== report.integrity) {
|
|
181
|
+
step("publish", false, `${pkg.version} is already on the registry with other bytes`);
|
|
182
|
+
return done(1);
|
|
183
|
+
}
|
|
184
|
+
step("publish", true, "already on the registry with these bytes");
|
|
185
|
+
} else {
|
|
186
|
+
const pub = npm(["publish", tarball, "--tag", opts.tag, "--registry", opts.registry], dir);
|
|
187
|
+
if (!step("publish", pub.ok, pub.ok ? `tag ${opts.tag}` : pub.stderr)) return done(1);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const visible = await poll(async () => {
|
|
191
|
+
const doc = await packument(opts.registry, pkg.name);
|
|
192
|
+
const v = doc?.versions?.[pkg.version];
|
|
193
|
+
if (v && v.dist?.integrity && v.dist.integrity !== report.integrity) {
|
|
194
|
+
throw Object.assign(new Error(`the registry serves ${v.dist.integrity}`), { fatal: true });
|
|
195
|
+
}
|
|
196
|
+
const tagged = doc?.["dist-tags"]?.[opts.tag] === pkg.version;
|
|
197
|
+
return {
|
|
198
|
+
done: Boolean(v) && tagged,
|
|
199
|
+
url: v?.dist?.tarball,
|
|
200
|
+
detail: v ? "tag not yet moved" : "version not yet listed",
|
|
201
|
+
};
|
|
202
|
+
}, timing).catch((e) => ({ done: false, detail: e.message }));
|
|
203
|
+
if (!visible.done) {
|
|
204
|
+
step("visible", false, visible.timedOut ? `timed out: ${visible.detail}` : visible.detail);
|
|
205
|
+
return done(3);
|
|
206
|
+
}
|
|
207
|
+
step("visible", true, `${opts.tag} -> ${pkg.version}`);
|
|
208
|
+
|
|
209
|
+
const served = join(work, "served.tgz");
|
|
210
|
+
try {
|
|
211
|
+
const res = await fetch(visible.url);
|
|
212
|
+
if (!res.ok) throw new Error(`tarball answered ${res.status}`);
|
|
213
|
+
writeFileSync(served, Buffer.from(await res.arrayBuffer()));
|
|
214
|
+
} catch (e) {
|
|
215
|
+
step("tarball", false, e.message);
|
|
216
|
+
return done(3);
|
|
217
|
+
}
|
|
218
|
+
const servedIntegrity = integrityOf(readFileSync(served));
|
|
219
|
+
if (!step("tarball", servedIntegrity === report.integrity, servedIntegrity)) return done(3);
|
|
220
|
+
|
|
221
|
+
const project = join(work, "install");
|
|
222
|
+
mkdirSync(project, { recursive: true });
|
|
223
|
+
writeFileSync(join(project, "package.json"), JSON.stringify({ private: true }));
|
|
224
|
+
const inst = npm(
|
|
225
|
+
["install", served, "--ignore-scripts", "--no-audit", "--no-fund", "--no-package-lock"],
|
|
226
|
+
project,
|
|
227
|
+
);
|
|
228
|
+
if (!inst.ok) {
|
|
229
|
+
step("install", false, inst.stderr);
|
|
230
|
+
return done(3);
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
const installed = join(project, "node_modules", pkg.name);
|
|
234
|
+
const got = JSON.parse(readFileSync(join(installed, "package.json"), "utf8"));
|
|
235
|
+
if (got.version !== pkg.version) throw new Error(`installed ${got.version}`);
|
|
236
|
+
const bins = typeof got.bin === "string" ? [got.bin] : Object.values(got.bin || {});
|
|
237
|
+
for (const b of bins) statSync(join(installed, b));
|
|
238
|
+
step("install", true, `${pkg.version}, ${bins.length} bin(s) present`);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
step("install", false, e.message);
|
|
241
|
+
return done(3);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (opts.smoke) {
|
|
245
|
+
const r = spawnSync("/bin/sh", ["-c", opts.smoke], {
|
|
246
|
+
cwd: project,
|
|
247
|
+
encoding: "utf8",
|
|
248
|
+
timeout: 5 * 60 * 1000,
|
|
249
|
+
});
|
|
250
|
+
const detail = `${opts.smoke}: exit ${r.status}${r.stderr ? ` ${r.stderr.trim().slice(0, 200)}` : ""}`;
|
|
251
|
+
if (!step("smoke", r.status === 0, detail)) return done(3);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const tagged = npm(
|
|
255
|
+
["dist-tag", "add", `${pkg.name}@${pkg.version}`, "latest", "--registry", opts.registry],
|
|
256
|
+
dir,
|
|
257
|
+
);
|
|
258
|
+
if (!step("promote", tagged.ok, tagged.ok ? "latest" : tagged.stderr)) return done(3);
|
|
259
|
+
const latest = await poll(async () => {
|
|
260
|
+
const doc = await packument(opts.registry, pkg.name);
|
|
261
|
+
return { done: doc?.["dist-tags"]?.latest === pkg.version, detail: "latest not yet moved" };
|
|
262
|
+
}, timing);
|
|
263
|
+
if (!step("latest", latest.done, latest.done ? pkg.version : latest.detail)) return done(3);
|
|
264
|
+
report.promoted = true;
|
|
265
|
+
return done(0);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
async function main() {
|
|
269
|
+
let flags;
|
|
270
|
+
try {
|
|
271
|
+
({ flags } = parseArgs(process.argv.slice(2), {
|
|
272
|
+
unknown: "error",
|
|
273
|
+
positionals: false,
|
|
274
|
+
booleans: ["dry-run", "json"],
|
|
275
|
+
strings: ["dir", "registry", "tag", "npm", "userconfig", "smoke", "timeout-s", "interval-ms"],
|
|
276
|
+
}));
|
|
277
|
+
} catch (e) {
|
|
278
|
+
if (!(e instanceof ArgsError)) throw e;
|
|
279
|
+
process.stderr.write(`publish-staged: ${e.message}\n`);
|
|
280
|
+
process.exitCode = 2;
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const timeoutS = Number(flags["timeout-s"] ?? 300);
|
|
284
|
+
const intervalMs = Number(flags["interval-ms"] ?? 5000);
|
|
285
|
+
const refusal = stagingTagRefusal(flags.tag ?? "candidate");
|
|
286
|
+
if (refusal) {
|
|
287
|
+
process.stderr.write(`publish-staged: ${refusal}\n`);
|
|
288
|
+
process.exitCode = 2;
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (!(timeoutS > 0) || !(intervalMs > 0)) {
|
|
292
|
+
process.stderr.write("publish-staged: --timeout-s and --interval-ms take positive numbers\n");
|
|
293
|
+
process.exitCode = 2;
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const { code, report } = await publishStaged({
|
|
297
|
+
dir: flags.dir ?? process.cwd(),
|
|
298
|
+
registry: flags.registry ?? DEFAULT_REGISTRY,
|
|
299
|
+
tag: flags.tag ?? "candidate",
|
|
300
|
+
npm: flags.npm ?? "npm",
|
|
301
|
+
userconfig: flags.userconfig ?? null,
|
|
302
|
+
smoke: flags.smoke ?? null,
|
|
303
|
+
timeoutS,
|
|
304
|
+
intervalMs,
|
|
305
|
+
dryRun: flags["dry-run"] === true,
|
|
306
|
+
});
|
|
307
|
+
if (flags.json) {
|
|
308
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
309
|
+
} else {
|
|
310
|
+
for (const s of report.steps) {
|
|
311
|
+
process.stdout.write(`${s.ok ? "ok " : "FAIL"} ${s.step.padEnd(8)} ${s.detail ?? ""}\n`);
|
|
312
|
+
}
|
|
313
|
+
process.stdout.write(
|
|
314
|
+
report.promoted
|
|
315
|
+
? `${report.name}@${report.version} is latest\n`
|
|
316
|
+
: code === 3
|
|
317
|
+
? `${report.name}@${report.version} stays on ${report.tag}; latest is unchanged\n`
|
|
318
|
+
: "",
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
process.exitCode = code;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (invokedDirectly(import.meta.url)) await main();
|