@wirecat/cli-base 0.107.0 → 0.109.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 +110 -0
- package/README.md +2 -1
- package/dist/codegen/fake.d.ts +64 -0
- package/dist/codegen/fake.js +341 -0
- package/dist/codegen/index.d.ts +12 -4
- package/dist/codegen/index.js +11 -3
- package/dist/codegen/manifest.d.ts +4 -1
- package/dist/codegen/manifest.js +69 -2
- package/dist/codegen/merge.d.ts +37 -0
- package/dist/codegen/merge.js +257 -0
- package/dist/codegen/model.d.ts +94 -0
- package/dist/codegen/openapi.d.ts +5 -1
- package/dist/codegen/openapi.js +102 -10
- package/dist/codegen/pagination.d.ts +14 -0
- package/dist/codegen/pagination.js +129 -0
- package/dist/codegen/patch.d.ts +28 -0
- package/dist/codegen/patch.js +75 -0
- package/dist/codegen/pipeline.d.ts +57 -1
- package/dist/codegen/pipeline.js +214 -6
- package/dist/codegen/skill.d.ts +35 -0
- package/dist/codegen/skill.js +171 -0
- package/dist/codegen/swagger.d.ts +7 -0
- package/dist/codegen/swagger.js +39 -0
- package/dist/credentials.d.ts +2 -2
- package/dist/credentials.js +17 -3
- package/dist/dev/conformance.d.ts +0 -2
- package/dist/dev/conformance.js +3 -9
- package/dist/dev/main.js +5 -1
- package/dist/dev/ready.d.ts +30 -0
- package/dist/dev/ready.js +310 -0
- package/dist/dev/slow-tests.d.ts +1 -0
- package/dist/http/fetch.js +21 -1
- package/dist/standards/audit.js +2 -1
- package/dist/standards/errors.js +6 -0
- package/dist/standards/index.d.ts +1 -0
- package/dist/standards/index.js +1 -0
- package/dist/standards/monthly.d.ts +5 -0
- package/dist/standards/monthly.js +12 -0
- package/docs/standards/ci.md +4 -2
- package/docs/standards/kit-surface.md +166 -0
- package/docs/standards/layout.md +1 -1
- package/docs/standards/new-cli.md +18 -7
- package/package.json +11 -1
package/dist/dev/main.js
CHANGED
|
@@ -29,6 +29,7 @@ import { changelogChange, landChange, landFold, newestTag, processShell, restore
|
|
|
29
29
|
import { baselineOf, judge, lintCommands, misfiled, RUN_LOG_COMMANDS, walk } from "./lint.js";
|
|
30
30
|
import { readSources } from "./network.js";
|
|
31
31
|
import { nextVersion } from "./next-version.js";
|
|
32
|
+
import { READY_USAGE, ready } from "./ready.js";
|
|
32
33
|
import { readDeclarations } from "./result-shape.js";
|
|
33
34
|
import { slowTests } from "./slow-tests.js";
|
|
34
35
|
import { matrixPage, matrixRows, parseArgvLog } from "./test-matrix.js";
|
|
@@ -105,7 +106,8 @@ const USAGE = `usage: cli-dev <command> [options]
|
|
|
105
106
|
--harmless names a third-party file whose import.meta or
|
|
106
107
|
__dirname was read and found harmless. Fails when a bundled
|
|
107
108
|
module would look for a file or package in the wrong place
|
|
108
|
-
${CONFORMANCE_USAGE}
|
|
109
|
+
${CONFORMANCE_USAGE}
|
|
110
|
+
${READY_USAGE}`;
|
|
109
111
|
const load = async (cwd, path) => (await import(pathToFileURL(isAbsolute(path) ? path : join(cwd, path)).href));
|
|
110
112
|
const report = (io, problems, ok) => {
|
|
111
113
|
for (const problem of problems)
|
|
@@ -957,6 +959,8 @@ export const main = async (argv, io) => {
|
|
|
957
959
|
return audit(args, io);
|
|
958
960
|
case "bundle":
|
|
959
961
|
return bundleCommand(args, io);
|
|
962
|
+
case "ready":
|
|
963
|
+
return ready(args, io, processShell(io.cwd));
|
|
960
964
|
case "adopt": {
|
|
961
965
|
const { values, positionals } = parseArgs({
|
|
962
966
|
args,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Shell } from "./land.js";
|
|
2
|
+
interface DevIo {
|
|
3
|
+
cwd: string;
|
|
4
|
+
out: (text: string) => void;
|
|
5
|
+
err: (text: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export type ReadyStatus = "verified" | "partially" | "not verified" | "unsupported";
|
|
8
|
+
export interface ReadyRow {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
status: ReadyStatus;
|
|
12
|
+
/** A passing script, a test file that runs a contract, a live-check record's line; why a row is not verified. */
|
|
13
|
+
evidence: string[];
|
|
14
|
+
/** The one thing to do for this row, when it is not verified. */
|
|
15
|
+
fix?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ReadyReport {
|
|
18
|
+
category?: string;
|
|
19
|
+
rows: ReadyRow[];
|
|
20
|
+
/** The fix of the first row that has one; a row partially verified only by excepted contracts has none. */
|
|
21
|
+
next?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const designCategory: (design: string) => string | undefined;
|
|
24
|
+
/** Where `ready` asks vitest for its JSON report; `coverage/` is git-ignored in every CLI. */
|
|
25
|
+
export declare const READY_TESTS = "coverage/ready-tests.json";
|
|
26
|
+
export declare const readyReport: (io: DevIo, shell: Shell) => ReadyReport;
|
|
27
|
+
export declare const readyText: (report: ReadyReport) => string;
|
|
28
|
+
export declare const ready: (args: string[], io: DevIo, shell: Shell) => number;
|
|
29
|
+
export declare const READY_USAGE = " ready [--json] runs the CLI's checks in order (typecheck and lint, tests and its\n category's cli-core contracts, the family audit, docs:check,\n generate:check, smoke, security:no-leak,\n deps:check) and reads the live-check record; prints each row as\n verified, partially, not verified or unsupported with its evidence,\n and the one next step; exits 1 while a row has a fix (a category\n contract excepted with its reason in lint/contract-exceptions.json\n shows partially and needs none)";
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cli-dev ready`: is this CLI ready to release? It runs the CLI's own scripts for each check in a fixed order and
|
|
3
|
+
* reports what each one proves. A row is verified only by a script that passed, or by a live-check record of exactly
|
|
4
|
+
* this code; nothing is inferred, and a script that is missing proves nothing.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
7
|
+
import { join, relative } from "node:path";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
9
|
+
import { packageVersion } from "../release/index.js";
|
|
10
|
+
import { LIVE_FILE, liveCheckProblems, parseLiveRecords } from "./conformance.js";
|
|
11
|
+
/**
|
|
12
|
+
* cli-core's contracts for each category `new` writes into `docs/dev/DESIGN.md`, by its value or its label. A
|
|
13
|
+
* category without contracts has none to run; one not listed here is unknown, never "none".
|
|
14
|
+
*/
|
|
15
|
+
const CATEGORY_CONTRACTS = [
|
|
16
|
+
{
|
|
17
|
+
names: ["crm", "crm (sales: deals, contacts, companies)"],
|
|
18
|
+
contracts: ["crmSourceContract", "crmSyncContract", "crmWriteContract"],
|
|
19
|
+
},
|
|
20
|
+
{ names: ["files", "files and documents"], contracts: ["documentCommandsContract", "documentSourceContract"] },
|
|
21
|
+
{ names: ["calendar"], contracts: ["calendarSourceContract", "calendarSyncContract", "calendarWriterContract"] },
|
|
22
|
+
{ names: ["mail"], contracts: ["mailSourceContract", "mailSyncContract"] },
|
|
23
|
+
{
|
|
24
|
+
names: ["meetings"],
|
|
25
|
+
contracts: [
|
|
26
|
+
"recordingTransferStorageContract",
|
|
27
|
+
"recordingSyncCheckpointStoreContract",
|
|
28
|
+
"eventStoreContract",
|
|
29
|
+
"meetingManagementContract",
|
|
30
|
+
"meetingTranscriptStoreContract",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{ names: ["messenger", "notes"], contracts: [] },
|
|
34
|
+
];
|
|
35
|
+
const DESIGN = "docs/dev/DESIGN.md";
|
|
36
|
+
export const designCategory = (design) => design.match(/^\s*[-*]\s*\*\*Category:\*\*\s*(.+?)\s*$/im)?.[1];
|
|
37
|
+
const testFiles = (cwd, folder) => {
|
|
38
|
+
const root = join(cwd, folder);
|
|
39
|
+
if (!existsSync(root))
|
|
40
|
+
return [];
|
|
41
|
+
const found = [];
|
|
42
|
+
const walk = (dir) => {
|
|
43
|
+
for (const name of readdirSync(dir)) {
|
|
44
|
+
if (name === "node_modules" || name.startsWith("."))
|
|
45
|
+
continue;
|
|
46
|
+
const path = join(dir, name);
|
|
47
|
+
if (statSync(path).isDirectory())
|
|
48
|
+
walk(path);
|
|
49
|
+
else if (/\.test\.[cm]?[jt]sx?$/.test(name))
|
|
50
|
+
found.push(path);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
walk(root);
|
|
54
|
+
return found.sort();
|
|
55
|
+
};
|
|
56
|
+
const contractCalls = (cwd, contracts) => ["src", "test"].flatMap((folder) => testFiles(cwd, folder).flatMap((file) => readFileSync(file, "utf8")
|
|
57
|
+
.split("\n")
|
|
58
|
+
.flatMap((text, index) => {
|
|
59
|
+
if (/^\s*(\/\/|\*|\/\*)/.test(text))
|
|
60
|
+
return [];
|
|
61
|
+
const contract = contracts.find((name) => new RegExp(`\\b${name}\\s*[(<]`).test(text));
|
|
62
|
+
return contract ? [{ file, line: index + 1, contract }] : [];
|
|
63
|
+
})));
|
|
64
|
+
/**
|
|
65
|
+
* A call in the source proves nothing until the test run shows it ran: the file's tests in vitest's report, at least
|
|
66
|
+
* one passed and none skipped, so a call under `describe.skip` or outside the vitest config does not count.
|
|
67
|
+
*/
|
|
68
|
+
const ranInReport = (report, file) => {
|
|
69
|
+
const result = report?.testResults.find((entry) => entry.name === file);
|
|
70
|
+
if (!result)
|
|
71
|
+
return "not in the test run's report";
|
|
72
|
+
const statuses = result.assertionResults.map((test) => test.status);
|
|
73
|
+
const skipped = statuses.filter((status) => status === "skipped" || status === "pending" || status === "todo");
|
|
74
|
+
if (skipped.length > 0)
|
|
75
|
+
return `${skipped.length} of its tests skipped`;
|
|
76
|
+
return statuses.includes("passed") ? undefined : "no test of it passed";
|
|
77
|
+
};
|
|
78
|
+
const lastLines = (out, count = 3) => out
|
|
79
|
+
.split("\n")
|
|
80
|
+
.map((line) => line.trimEnd())
|
|
81
|
+
.filter(Boolean)
|
|
82
|
+
.slice(-count)
|
|
83
|
+
.join(" | ");
|
|
84
|
+
const runScript = (io, shell, scripts, script, extra = []) => {
|
|
85
|
+
if (scripts[script] === undefined)
|
|
86
|
+
return { script, passed: false, missing: true, evidence: `no "${script}" script in package.json` };
|
|
87
|
+
io.err(`ready: pnpm ${script}`);
|
|
88
|
+
{
|
|
89
|
+
const result = shell.run("pnpm", ["run", "--silent", script, ...extra]);
|
|
90
|
+
return result.ok
|
|
91
|
+
? { script, passed: true, evidence: `pnpm ${script}: passed` }
|
|
92
|
+
: { script, passed: false, evidence: `pnpm ${script}: failed — ${lastLines(result.out) || "no output"}` };
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const scriptRow = (id, title, runs, extra = []) => {
|
|
96
|
+
const passed = runs.filter((run) => run.passed).length;
|
|
97
|
+
const failed = runs.find((run) => !run.passed);
|
|
98
|
+
const status = passed === runs.length ? "verified" : passed > 0 ? "partially" : "not verified";
|
|
99
|
+
return {
|
|
100
|
+
id,
|
|
101
|
+
title,
|
|
102
|
+
status,
|
|
103
|
+
evidence: [...runs.map((run) => run.evidence), ...extra],
|
|
104
|
+
...(failed
|
|
105
|
+
? {
|
|
106
|
+
fix: failed.missing
|
|
107
|
+
? `add the "${failed.script}" script from @wirecat/cli-template, then run cli-dev ready again`
|
|
108
|
+
: `pnpm ${failed.script}, and fix what it reports`,
|
|
109
|
+
}
|
|
110
|
+
: {}),
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
/** `[{ "contract": "crmSyncContract", "reason": "…" }]`: a category contract this CLI does not run, and why. */
|
|
114
|
+
const EXCEPTIONS = "lint/contract-exceptions.json";
|
|
115
|
+
const contractExceptions = (cwd) => {
|
|
116
|
+
const path = join(cwd, EXCEPTIONS);
|
|
117
|
+
if (!existsSync(path))
|
|
118
|
+
return { entries: [], problems: [] };
|
|
119
|
+
let parsed;
|
|
120
|
+
try {
|
|
121
|
+
parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return { entries: [], problems: [`is not valid JSON: ${error instanceof Error ? error.message : error}`] };
|
|
125
|
+
}
|
|
126
|
+
if (!Array.isArray(parsed))
|
|
127
|
+
return { entries: [], problems: ['is not a list of { "contract", "reason" }'] };
|
|
128
|
+
const entries = [];
|
|
129
|
+
const problems = [];
|
|
130
|
+
parsed.forEach((entry, index) => {
|
|
131
|
+
if (!isRecord(entry) || typeof entry.contract !== "string" || !entry.contract) {
|
|
132
|
+
problems.push(`entry ${index + 1} is not { "contract", "reason" }`);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (entries.some((seen) => seen.contract === entry.contract))
|
|
136
|
+
problems.push(`${entry.contract} is listed twice`);
|
|
137
|
+
entries.push({ contract: entry.contract, reason: typeof entry.reason === "string" ? entry.reason.trim() : "" });
|
|
138
|
+
});
|
|
139
|
+
return { entries, problems };
|
|
140
|
+
};
|
|
141
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
142
|
+
const CATEGORY_NAMES = CATEGORY_CONTRACTS.flatMap((entry) => entry.names);
|
|
143
|
+
const contractsRow = (cwd, category, runs, report) => {
|
|
144
|
+
const title = "Tests and category contracts";
|
|
145
|
+
const contracts = category
|
|
146
|
+
? CATEGORY_CONTRACTS.find((entry) => entry.names.includes(category.toLowerCase()))?.contracts
|
|
147
|
+
: undefined;
|
|
148
|
+
if (contracts === undefined)
|
|
149
|
+
return {
|
|
150
|
+
id: "contracts",
|
|
151
|
+
title,
|
|
152
|
+
status: "not verified",
|
|
153
|
+
evidence: [
|
|
154
|
+
category ? `"${category}" in ${DESIGN} is no category new writes` : `no "- **Category:**" line in ${DESIGN}`,
|
|
155
|
+
...runs.map((run) => run.evidence),
|
|
156
|
+
],
|
|
157
|
+
fix: `name the category in ${DESIGN} as one of ${CATEGORY_NAMES.join(", ")}, then run cli-dev ready again`,
|
|
158
|
+
};
|
|
159
|
+
if (contracts.length === 0)
|
|
160
|
+
return scriptRow("contracts", title, runs, [`cli-core has no category contract for "${category}"`]);
|
|
161
|
+
const calls = contractCalls(cwd, contracts);
|
|
162
|
+
const evidence = calls.map(({ file, line, contract }) => {
|
|
163
|
+
const notRun = ranInReport(report, file);
|
|
164
|
+
return `${relative(cwd, file)}:${line} calls ${contract}${notRun ? ` — not counted: ${notRun}` : ""}`;
|
|
165
|
+
});
|
|
166
|
+
const ran = new Set(calls.filter(({ file }) => ranInReport(report, file) === undefined).map((call) => call.contract));
|
|
167
|
+
const notRun = contracts.filter((contract) => !ran.has(contract));
|
|
168
|
+
const { entries: exceptions, problems } = contractExceptions(cwd);
|
|
169
|
+
const reasonOf = (contract) => exceptions.find((entry) => entry.contract === contract)?.reason;
|
|
170
|
+
const wrong = [
|
|
171
|
+
...problems,
|
|
172
|
+
...exceptions.filter((entry) => !entry.reason).map((entry) => `${entry.contract} has no reason`),
|
|
173
|
+
...exceptions
|
|
174
|
+
.filter((entry) => !contracts.includes(entry.contract))
|
|
175
|
+
.map((entry) => `${entry.contract} is no contract of "${category}"`),
|
|
176
|
+
...exceptions.filter((entry) => ran.has(entry.contract)).map((entry) => `${entry.contract} runs now`),
|
|
177
|
+
];
|
|
178
|
+
const excepted = notRun.filter((contract) => reasonOf(contract));
|
|
179
|
+
const missing = notRun.filter((contract) => !reasonOf(contract));
|
|
180
|
+
const row = scriptRow("contracts", title, runs, [
|
|
181
|
+
...evidence,
|
|
182
|
+
...excepted.map((contract) => `not run, excepted in ${EXCEPTIONS}: ${contract} — ${reasonOf(contract)}`),
|
|
183
|
+
...(missing.length > 0 ? [`not run: ${missing.join(", ")}`] : []),
|
|
184
|
+
...wrong.map((problem) => `${EXCEPTIONS}: ${problem}`),
|
|
185
|
+
]);
|
|
186
|
+
if (row.fix)
|
|
187
|
+
return row;
|
|
188
|
+
if (wrong.length > 0)
|
|
189
|
+
return { ...row, status: "not verified", fix: `correct ${EXCEPTIONS}: ${wrong[0]}, then run cli-dev ready again` };
|
|
190
|
+
if (missing.length > 0)
|
|
191
|
+
return {
|
|
192
|
+
...row,
|
|
193
|
+
status: ran.size > 0 ? "partially" : "not verified",
|
|
194
|
+
fix: `run cli-core's ${missing[0]} in a test (testing.md), or except it in ${EXCEPTIONS} with its reason, ` +
|
|
195
|
+
"then run cli-dev ready again",
|
|
196
|
+
};
|
|
197
|
+
// Every contract excepted leaves the row checking nothing.
|
|
198
|
+
if (ran.size === 0)
|
|
199
|
+
return {
|
|
200
|
+
...row,
|
|
201
|
+
status: "not verified",
|
|
202
|
+
fix: `run at least one of ${contracts.join(", ")} in a test (testing.md), then run cli-dev ready again`,
|
|
203
|
+
};
|
|
204
|
+
// An exception is a known gap, not a check that passed; it needs no fix, so it does not hold back `next`.
|
|
205
|
+
return excepted.length > 0 ? { ...row, status: "partially" } : row;
|
|
206
|
+
};
|
|
207
|
+
const liveRow = (cwd, shell, version) => {
|
|
208
|
+
const title = "Live check against the service";
|
|
209
|
+
const record = `cli-dev live record --script <its script>`;
|
|
210
|
+
// cli-template's own repository has no service to check (WC-REL-17's exception); `new` never copies kit/.
|
|
211
|
+
if (existsSync(join(cwd, "kit")))
|
|
212
|
+
return { id: "live", title, status: "unsupported", evidence: ["kit/ exists: cli-template has no service to check"] };
|
|
213
|
+
const text = existsSync(join(cwd, LIVE_FILE)) ? readFileSync(join(cwd, LIVE_FILE), "utf8") : "";
|
|
214
|
+
const lines = text.split("\n");
|
|
215
|
+
const lineOf = (wanted) => {
|
|
216
|
+
const index = lines.findLastIndex((line) => line.trim().split(/\s+/)[0] === wanted);
|
|
217
|
+
return index < 0 ? undefined : `${LIVE_FILE}:${index + 1}`;
|
|
218
|
+
};
|
|
219
|
+
const records = parseLiveRecords(text);
|
|
220
|
+
const problems = liveCheckProblems(shell, records, version);
|
|
221
|
+
const own = lineOf(version);
|
|
222
|
+
if (problems.length === 0 && own)
|
|
223
|
+
return { id: "live", title, status: "verified", evidence: [own] };
|
|
224
|
+
if (own)
|
|
225
|
+
return {
|
|
226
|
+
id: "live",
|
|
227
|
+
title,
|
|
228
|
+
status: "partially",
|
|
229
|
+
evidence: [own, ...problems],
|
|
230
|
+
fix: `run the live check on this code, then ${record}`,
|
|
231
|
+
};
|
|
232
|
+
const earlier = records.at(-1);
|
|
233
|
+
return {
|
|
234
|
+
id: "live",
|
|
235
|
+
title,
|
|
236
|
+
status: "not verified",
|
|
237
|
+
evidence: [
|
|
238
|
+
`no record for ${version} in ${LIVE_FILE}`,
|
|
239
|
+
...(earlier ? [`${lineOf(earlier.version)} is ${earlier.version}'s`] : []),
|
|
240
|
+
],
|
|
241
|
+
fix: `run the live check (the owner runs it against their account), then ${record}`,
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
/** Where `ready` asks vitest for its JSON report; `coverage/` is git-ignored in every CLI. */
|
|
245
|
+
export const READY_TESTS = "coverage/ready-tests.json";
|
|
246
|
+
export const readyReport = (io, shell) => {
|
|
247
|
+
const { cwd } = io;
|
|
248
|
+
const pkg = JSON.parse(readFileSync(join(cwd, "package.json"), "utf8"));
|
|
249
|
+
const scripts = pkg.scripts ?? {};
|
|
250
|
+
const design = existsSync(join(cwd, DESIGN)) ? readFileSync(join(cwd, DESIGN), "utf8") : "";
|
|
251
|
+
const category = designCategory(design);
|
|
252
|
+
const run = (...names) => names.map((name) => runScript(io, shell, scripts, name));
|
|
253
|
+
const reportFile = join(cwd, READY_TESTS);
|
|
254
|
+
rmSync(reportFile, { force: true });
|
|
255
|
+
const tests = runScript(io, shell, scripts, "test", [
|
|
256
|
+
"--reporter=default",
|
|
257
|
+
"--reporter=json",
|
|
258
|
+
`--outputFile.json=${reportFile}`,
|
|
259
|
+
]);
|
|
260
|
+
const report = existsSync(reportFile) ? JSON.parse(readFileSync(reportFile, "utf8")) : undefined;
|
|
261
|
+
const rows = [
|
|
262
|
+
scriptRow("types", "Typecheck and lint", run("typecheck", "lint")),
|
|
263
|
+
contractsRow(cwd, category, [tests, ...run("contracts:check")], report),
|
|
264
|
+
scriptRow("audit", "Family audit of the commands", run("audit:commands")),
|
|
265
|
+
scriptRow("docs", "Documents", run("docs:check")),
|
|
266
|
+
scriptRow("generated", "Generated files: commands page, manifest, API spec", run("generate:check")),
|
|
267
|
+
scriptRow("smoke", "Smoke run of the built CLI", run("smoke")),
|
|
268
|
+
scriptRow("no-leak", "No secret in output", run("security:no-leak")),
|
|
269
|
+
scriptRow("deps", "Dependencies", run("deps:check")),
|
|
270
|
+
liveRow(cwd, shell, packageVersion(cwd)),
|
|
271
|
+
];
|
|
272
|
+
const next = rows.find((row) => row.fix)?.fix;
|
|
273
|
+
return { ...(category ? { category } : {}), rows, ...(next ? { next } : {}) };
|
|
274
|
+
};
|
|
275
|
+
const MARK = {
|
|
276
|
+
verified: "verified",
|
|
277
|
+
partially: "partially",
|
|
278
|
+
"not verified": "NOT VERIFIED",
|
|
279
|
+
unsupported: "unsupported",
|
|
280
|
+
};
|
|
281
|
+
export const readyText = (report) => {
|
|
282
|
+
const width = report.rows.reduce((widest, row) => Math.max(widest, row.title.length), 0);
|
|
283
|
+
const lines = [`category: ${report.category ?? "not named"}`, ""];
|
|
284
|
+
for (const row of report.rows) {
|
|
285
|
+
lines.push(`${row.title.padEnd(width)} ${MARK[row.status]}`);
|
|
286
|
+
for (const evidence of row.evidence)
|
|
287
|
+
lines.push(`${" ".repeat(width + 2)}${evidence}`);
|
|
288
|
+
}
|
|
289
|
+
const excepted = report.rows.filter((row) => row.status === "partially").map((row) => row.title);
|
|
290
|
+
lines.push("", report.next
|
|
291
|
+
? `next: ${report.next}`
|
|
292
|
+
: excepted.length > 0
|
|
293
|
+
? `next: nothing to do; partially, by declared exceptions: ${excepted.join(", ")}`
|
|
294
|
+
: "next: nothing; every check is verified or does not apply");
|
|
295
|
+
return lines.join("\n");
|
|
296
|
+
};
|
|
297
|
+
export const ready = (args, io, shell) => {
|
|
298
|
+
const { values } = parseArgs({ args, options: { json: { type: "boolean", default: false } } });
|
|
299
|
+
const report = readyReport(io, shell);
|
|
300
|
+
io.out(values.json ? JSON.stringify(report, null, 2) : readyText(report));
|
|
301
|
+
return report.next ? 1 : 0;
|
|
302
|
+
};
|
|
303
|
+
export const READY_USAGE = ` ready [--json] runs the CLI's checks in order (typecheck and lint, tests and its
|
|
304
|
+
category's cli-core contracts, the family audit, docs:check,
|
|
305
|
+
generate:check, smoke, security:no-leak,
|
|
306
|
+
deps:check) and reads the live-check record; prints each row as
|
|
307
|
+
verified, partially, not verified or unsupported with its evidence,
|
|
308
|
+
and the one next step; exits 1 while a row has a fix (a category
|
|
309
|
+
contract excepted with its reason in lint/contract-exceptions.json
|
|
310
|
+
shows partially and needs none)`;
|
package/dist/dev/slow-tests.d.ts
CHANGED
package/dist/http/fetch.js
CHANGED
|
@@ -37,6 +37,20 @@ const checked = (url, hosts) => {
|
|
|
37
37
|
throw undeclared(url);
|
|
38
38
|
return url;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* A name lookup or a connection the host refused fails before a byte of the request leaves, so even a write may be sent
|
|
42
|
+
* again. Node's fetch puts the system's code on the cause, an AggregateError when it tried several addresses; a
|
|
43
|
+
* reset or a timeout may come after the request arrived.
|
|
44
|
+
*/
|
|
45
|
+
const NOT_SENT = new Set(["EAI_AGAIN", "ENOTFOUND", "ECONNREFUSED"]);
|
|
46
|
+
const neverSent = (error) => {
|
|
47
|
+
for (let at = error, depth = 0; at instanceof Error && depth < 4; at = at.cause, depth++) {
|
|
48
|
+
const code = at.code;
|
|
49
|
+
if (typeof code === "string" && NOT_SENT.has(code))
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
};
|
|
40
54
|
/** `fetch` that reaches only the declared hosts, checks every redirect hop, and gives up after `timeoutMs`. */
|
|
41
55
|
export const hostFetch = (options) => {
|
|
42
56
|
const problems = hostProblems(options.hosts);
|
|
@@ -53,8 +67,11 @@ export const hostFetch = (options) => {
|
|
|
53
67
|
let method = (init.method ?? request?.method ?? "GET").toUpperCase();
|
|
54
68
|
let body = init.body ?? request?.body ?? undefined;
|
|
55
69
|
const headers = new Headers(init.headers ?? request?.headers);
|
|
70
|
+
// A redirect means the first request arrived: a later hop's failure no longer proves nothing was sent.
|
|
71
|
+
let answered = false;
|
|
56
72
|
try {
|
|
57
73
|
let response = await send(input, { ...init, signal, ...(follow ? { redirect: "manual" } : {}) });
|
|
74
|
+
answered = true;
|
|
58
75
|
for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
|
|
59
76
|
const location = response.headers.get("location");
|
|
60
77
|
if (!location)
|
|
@@ -87,7 +104,10 @@ export const hostFetch = (options) => {
|
|
|
87
104
|
throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
|
|
88
105
|
if (timeout.signal.aborted)
|
|
89
106
|
throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
|
|
90
|
-
throw new CliError("network_error", `${url.hostname} could not be reached`, {
|
|
107
|
+
throw new CliError("network_error", `${url.hostname} could not be reached`, {
|
|
108
|
+
retryable: true,
|
|
109
|
+
...(!answered && neverSent(error) ? { sent: false } : {}),
|
|
110
|
+
});
|
|
91
111
|
}
|
|
92
112
|
};
|
|
93
113
|
};
|
package/dist/standards/audit.js
CHANGED
|
@@ -145,10 +145,11 @@ export const PARITY_GROUPS = defineParityGroups([
|
|
|
145
145
|
},
|
|
146
146
|
// bitrix24-cli's search is cli-core's CRM `search all`, and beeline-cli's and asterisk-cli's meetings take call
|
|
147
147
|
// recordings, not zoom-cli's: they are compared on the root commands every CLI shares, the way gcal and mail are.
|
|
148
|
+
// amo-cli shares them too, and its CRM commands are compared with b24 in `crm` below.
|
|
148
149
|
// notion-cli joins here until its documents commands ship; then it moves next to drive.
|
|
149
150
|
{
|
|
150
151
|
name: "shared-roots",
|
|
151
|
-
members: ["tg", "max", "memo", "drive", "zm", "wa", "b24", "beeline", "pbx", "notion"],
|
|
152
|
+
members: ["tg", "max", "memo", "drive", "zm", "wa", "b24", "beeline", "pbx", "notion", "amo"],
|
|
152
153
|
covers: ["commands", "doctor", "skill", "mcp", "upgrade"],
|
|
153
154
|
differences: [...MEMO_HAS_NO_PROFILES, MEMO_DOCTOR_DEEP],
|
|
154
155
|
},
|
package/dist/standards/errors.js
CHANGED
|
@@ -58,6 +58,12 @@ export const BASE_REASONS = defineReasons([
|
|
|
58
58
|
},
|
|
59
59
|
{ reason: "batch.output-budget", code: "validation_error", message: "batch output budget exhausted", details: [] },
|
|
60
60
|
{ reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
|
|
61
|
+
{
|
|
62
|
+
reason: "keyring.unreachable",
|
|
63
|
+
code: "configuration_error",
|
|
64
|
+
message: "the OS keyring did not answer, and no file holds the sign-in",
|
|
65
|
+
details: [],
|
|
66
|
+
},
|
|
61
67
|
{ reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
|
|
62
68
|
{ reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
|
|
63
69
|
{ reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { EFFECT_LEVELS, type EffectLevel, type Effects, effectsSchema, writes } from "./effects.js";
|
|
2
2
|
export { BASE_REASONS, COMMON_DETAILS, CRASH_CODE, CRASH_REASON, defineReasons, type ErrorObject, type ErrorReason, errorObjectSchema, } from "./errors.js";
|
|
3
3
|
export { defineLogEvents, isContentKey, LOG_ATTRIBUTE_KEYS, LOG_EVENTS, LOG_SEVERITIES, type LogEvent, type LogRecord, type LogSeverity, logAttributesJsonSchema, logEventProblems, logRecordSchema, traceIdOf, } from "./log.js";
|
|
4
|
+
export { takenMinutes } from "./monthly.js";
|
|
4
5
|
export { COMPACT_FLAG, clockMeta, type Issue, type ItemEnvelope, isoTime, issueSchema, itemEnvelopeSchema, jsonlEndSchema, jsonlItemSchema, jsonlOf, type ListEnvelope, type ListResult, listEnvelopeSchema, localTime, MAX_NEXT_STEPS, type Meta, type Missing, metaSchema, missingSchema, type NextStep, nextStepSchema, type Page, pageSchema, type Ranking, rankingSchema, reference, type Total, totalSchema, } from "./output.js";
|
|
5
6
|
export { fill, jsonSchemaOf, RegistryError } from "./registry.js";
|
|
6
7
|
export { defineSteps, SAME_COMMAND, STEPS, type StepDefinition, type StepInput, type StepTarget, stepOf, } from "./steps.js";
|
package/dist/standards/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { EFFECT_LEVELS, effectsSchema, writes } from "./effects.js";
|
|
2
2
|
export { BASE_REASONS, COMMON_DETAILS, CRASH_CODE, CRASH_REASON, defineReasons, errorObjectSchema, } from "./errors.js";
|
|
3
3
|
export { defineLogEvents, isContentKey, LOG_ATTRIBUTE_KEYS, LOG_EVENTS, LOG_SEVERITIES, logAttributesJsonSchema, logEventProblems, logRecordSchema, traceIdOf, } from "./log.js";
|
|
4
|
+
export { takenMinutes } from "./monthly.js";
|
|
4
5
|
export { COMPACT_FLAG, clockMeta, isoTime, issueSchema, itemEnvelopeSchema, jsonlEndSchema, jsonlItemSchema, jsonlOf, listEnvelopeSchema, localTime, MAX_NEXT_STEPS, metaSchema, missingSchema, nextStepSchema, pageSchema, rankingSchema, reference, totalSchema, } from "./output.js";
|
|
5
6
|
export { fill, jsonSchemaOf, RegistryError } from "./registry.js";
|
|
6
7
|
export { defineSteps, SAME_COMMAND, STEPS, stepOf, } from "./steps.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const CI_PAGE = join(dirname(fileURLToPath(import.meta.url)), "../../docs/standards/ci.md");
|
|
5
|
+
/**
|
|
6
|
+
* WC-CI-9's table of the WireCat repositories' monthly minutes, as `HH:MM → repository`: from the given text of
|
|
7
|
+
* `docs/standards/ci.md`, or from the copy this package ships.
|
|
8
|
+
*/
|
|
9
|
+
export const takenMinutes = (ciPage = readFileSync(CI_PAGE, "utf8")) => new Map([...ciPage.matchAll(/^\s*\|\s*(\d\d:\d\d)\s*\|\s*([\w.-]+)\s*\|\s*$/gm)].map(([, time, repo]) => [
|
|
10
|
+
time,
|
|
11
|
+
repo,
|
|
12
|
+
]));
|
package/docs/standards/ci.md
CHANGED
|
@@ -160,8 +160,9 @@ its prompt in cli-template says so from cli-template 0.8.0. A CLI on an older te
|
|
|
160
160
|
- **Why:** a repository with no merges for weeks still meets new advisories, new runner images and expired pins.
|
|
161
161
|
- **Enforced by:** `monthly.yml:validation` · `monthly.yml:security` · `<app>: pnpm repo:check`.
|
|
162
162
|
- **Example:** `monthly.yml`, from the community template, calls the repository's `ci.yml` and the pinned cli-base
|
|
163
|
-
`release-checks.yml`. Each repository has its own minute, between 02:17 and 03:20 UTC, so runs do not overlap.
|
|
164
|
-
|
|
163
|
+
`release-checks.yml`. Each repository has its own minute, between 02:17 and 03:20 UTC, so runs do not overlap. `new` in cli-template picks a free
|
|
164
|
+
minute for a new CLI (see [New CLI](new-cli.md)); `takenMinutes()` from `@wirecat/cli-base/standards` reads this
|
|
165
|
+
table. `cli-dev repo-check` refuses a minute held
|
|
165
166
|
by another repository in this list, and a day other than the first. Taken minutes, from each `monthly.yml` on the
|
|
166
167
|
default branch:
|
|
167
168
|
|
|
@@ -178,6 +179,7 @@ its prompt in cli-template says so from cli-template 0.8.0. A CLI on an older te
|
|
|
178
179
|
| 02:45 | drive-cli |
|
|
179
180
|
| 02:48 | asterisk-cli |
|
|
180
181
|
| 02:52 | cli-testing |
|
|
182
|
+
| 02:55 | amo-cli |
|
|
181
183
|
| 02:59 | max-cli |
|
|
182
184
|
| 03:02 | cli-template |
|
|
183
185
|
| 03:06 | tg-cli |
|