@antelopejs/tooling-configs 0.3.1 → 0.3.3
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/README.md +26 -14
- package/dist/api-CCOiLN3w.mjs +185 -0
- package/dist/bin/checks.mjs +253 -27
- package/dist/bin/garden.mjs +6 -171
- package/dist/bin/lease.mjs +3 -279
- package/dist/bin/sync.mjs +8 -8
- package/dist/bin/triage.d.mts +1 -0
- package/dist/bin/triage.mjs +108 -0
- package/dist/bin/verify.mjs +155 -11
- package/dist/{ci-workflow-mc0vywUV.mjs → ci-workflow-CXcAZj6g.mjs} +55 -1
- package/dist/ports-DGP6bPJy.mjs +282 -0
- package/package.json +2 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { c as object, h as time, n as children, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
3
|
+
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
4
|
+
import { i as ghToken, r as createGraphql } from "../api-CCOiLN3w.mjs";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
|
+
//#region src/triage/triage.ts
|
|
7
|
+
/** Open, unassigned issues labelled `needs-triage` in the organization's public, non-archived repositories. */
|
|
8
|
+
const SEARCH = "org:AntelopeJS is:issue is:open is:public archived:false label:needs-triage no:assignee";
|
|
9
|
+
const LIMIT = 10;
|
|
10
|
+
const FIRST_LINE_LENGTH = 200;
|
|
11
|
+
const HEADING = /^#{1,6}(?:\s|$)/;
|
|
12
|
+
const KIND_ORDER = {
|
|
13
|
+
bug: 0,
|
|
14
|
+
feature: 1,
|
|
15
|
+
other: 2
|
|
16
|
+
};
|
|
17
|
+
const QUERY = `query($q: String!, $after: String) {
|
|
18
|
+
search(type: ISSUE, query: $q, first: 100, after: $after) {
|
|
19
|
+
pageInfo { hasNextPage endCursor }
|
|
20
|
+
nodes {
|
|
21
|
+
... on Issue {
|
|
22
|
+
number title url body createdAt
|
|
23
|
+
repository { nameWithOwner }
|
|
24
|
+
labels(first: 20) { nodes { name } }
|
|
25
|
+
issueType { name }
|
|
26
|
+
reactions(content: THUMBS_UP) { totalCount }
|
|
27
|
+
closedByPullRequestsReferences(first: 1, includeClosedPrs: false) { totalCount }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}`;
|
|
32
|
+
/** The `bug` label, or the `feature` or `enhancement` label, decides; without one, the issue type does. */
|
|
33
|
+
function kind(labels, type) {
|
|
34
|
+
if (labels.includes("bug")) return "bug";
|
|
35
|
+
if (labels.includes("feature") || labels.includes("enhancement")) return "feature";
|
|
36
|
+
if (type === "Bug") return "bug";
|
|
37
|
+
if (type === "Feature") return "feature";
|
|
38
|
+
return "other";
|
|
39
|
+
}
|
|
40
|
+
/** The first line that carries text: blank lines, Markdown headings, HTML comments and an issue form's `_No response_` are skipped. */
|
|
41
|
+
function firstLine(body) {
|
|
42
|
+
const line = body.replace(/<!--[\s\S]*?-->/g, "").split(/\r?\n/).map((entry) => entry.trim()).find((entry) => entry !== "" && !HEADING.test(entry) && entry !== "_No response_");
|
|
43
|
+
return Array.from(line ?? "").slice(0, FIRST_LINE_LENGTH).join("");
|
|
44
|
+
}
|
|
45
|
+
function issue(value) {
|
|
46
|
+
const source = object(value, "issue");
|
|
47
|
+
const labels = children(child(source, "labels"), "nodes").map((label) => str(label, "name"));
|
|
48
|
+
const type = Object.hasOwn(source, "issueType") ? source.issueType : null;
|
|
49
|
+
return {
|
|
50
|
+
ref: `${str(child(source, "repository"), "nameWithOwner")}#${num(source, "number")}`,
|
|
51
|
+
url: str(source, "url"),
|
|
52
|
+
kind: kind(labels, type === null ? void 0 : optStr(object(type, "issueType"), "name")),
|
|
53
|
+
title: str(source, "title"),
|
|
54
|
+
firstLine: firstLine(optStr(source, "body") ?? ""),
|
|
55
|
+
createdAt: time(source, "createdAt"),
|
|
56
|
+
thumbsUp: num(child(source, "reactions"), "totalCount"),
|
|
57
|
+
linkedOpenPulls: num(child(source, "closedByPullRequestsReferences"), "totalCount")
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Bugs before features before the rest, then most 👍 first, then oldest first; the reference breaks a tie. */
|
|
61
|
+
function compare(a, b) {
|
|
62
|
+
return KIND_ORDER[a.kind] - KIND_ORDER[b.kind] || b.thumbsUp - a.thumbsUp || a.createdAt - b.createdAt || (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0);
|
|
63
|
+
}
|
|
64
|
+
/** Drops issues an open pull request is linked to, ranks the rest and keeps the first {@link LIMIT}. */
|
|
65
|
+
function rank(issues) {
|
|
66
|
+
const open = issues.filter((entry) => entry.linkedOpenPulls === 0).sort(compare);
|
|
67
|
+
return {
|
|
68
|
+
items: open.slice(0, LIMIT).map((entry) => ({
|
|
69
|
+
ref: entry.ref,
|
|
70
|
+
url: entry.url,
|
|
71
|
+
kind: entry.kind,
|
|
72
|
+
title: entry.title,
|
|
73
|
+
firstLine: entry.firstLine,
|
|
74
|
+
created: new Date(entry.createdAt).toISOString().slice(0, 10)
|
|
75
|
+
})),
|
|
76
|
+
notShown: Math.max(open.length - LIMIT, 0)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** Reads every page of the search and ranks it. */
|
|
80
|
+
async function triage(graphql) {
|
|
81
|
+
const issues = [];
|
|
82
|
+
for (let after, more = true; more;) {
|
|
83
|
+
const search = child(object(await graphql(QUERY, after === void 0 ? { q: SEARCH } : {
|
|
84
|
+
q: SEARCH,
|
|
85
|
+
after
|
|
86
|
+
}), "data"), "search");
|
|
87
|
+
issues.push(...children(search, "nodes").filter((node) => Object.keys(node).length > 0).map(issue));
|
|
88
|
+
const page = child(search, "pageInfo");
|
|
89
|
+
after = optStr(page, "endCursor");
|
|
90
|
+
more = flag(page, "hasNextPage") && after !== void 0;
|
|
91
|
+
}
|
|
92
|
+
return rank(issues);
|
|
93
|
+
}
|
|
94
|
+
/** One line per shortlisted issue and one for the rest; nothing when no issue waits. */
|
|
95
|
+
function lines(shortlist) {
|
|
96
|
+
return [...shortlist.items.map((entry) => `${entry.ref} ${entry.kind} ${entry.created} ${entry.title}`), ...shortlist.notShown > 0 ? [`${shortlist.notShown} more not shown`] : []];
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/bin/triage.ts
|
|
100
|
+
await runCliAsync(async () => {
|
|
101
|
+
const { values } = parseArgs({ options: { json: { type: "boolean" } } });
|
|
102
|
+
const shortlist = await triage(createGraphql(ghToken()));
|
|
103
|
+
if (values.json) process.stdout.write(`${JSON.stringify(shortlist, null, 2)}\n`);
|
|
104
|
+
else for (const line of lines(shortlist)) process.stdout.write(`${line}\n`);
|
|
105
|
+
return 0;
|
|
106
|
+
});
|
|
107
|
+
//#endregion
|
|
108
|
+
export {};
|
package/dist/bin/verify.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as VERIFY_KINDS, c as isVerifyKind, l as skillFolder } from "../shared-igPpEDpS.mjs";
|
|
3
|
-
import { a as isString, f as parseJson, i as isObject, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
3
|
+
import { a as isString, c as object, f as parseJson, i as isObject, n as children, p as str, s as num, u as optStr } from "../json-CG2L7YFl.mjs";
|
|
4
4
|
import { a as exitIs, c as interrupted, i as exists, r as equal, u as refused } from "../checks-CxkSu2E6.mjs";
|
|
5
5
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
6
6
|
import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
|
|
7
|
-
import { appendFileSync, closeSync, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { appendFileSync, chmodSync, closeSync, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, rmdirSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { basename, dirname, extname, join, matchesGlob, posix, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
10
10
|
import { pathToFileURL } from "node:url";
|
|
11
11
|
import ts from "typescript";
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
|
-
import { homedir, tmpdir } from "node:os";
|
|
13
|
+
import { constants as constants$1, homedir, tmpdir } from "node:os";
|
|
14
14
|
import { parseArgs } from "node:util";
|
|
15
15
|
import { createServer } from "node:net";
|
|
16
16
|
//#region src/verify/doors.ts
|
|
@@ -338,6 +338,27 @@ function emitFingerprint(repo, sha, files) {
|
|
|
338
338
|
* published packages. Nothing a journey asserts on lives here.
|
|
339
339
|
*/
|
|
340
340
|
const CACHE_DIR = join(process.env.XDG_CACHE_HOME ?? join(homedir(), ".cache"), "antelopejs-verify");
|
|
341
|
+
/** The folder that holds every run, one subfolder per repository. */
|
|
342
|
+
const RUNS_DIR = join(tmpdir(), "antelopejs-verify");
|
|
343
|
+
function makeWritable(folder) {
|
|
344
|
+
chmodSync(folder, lstatSync(folder).mode | 448);
|
|
345
|
+
for (const entry of readdirSync(folder, { withFileTypes: true })) if (entry.isDirectory()) makeWritable(join(folder, entry.name));
|
|
346
|
+
}
|
|
347
|
+
/** Deletes a folder this run wrote, including folders an install left read-only. */
|
|
348
|
+
function removeTree(folder) {
|
|
349
|
+
try {
|
|
350
|
+
rmSync(folder, {
|
|
351
|
+
recursive: true,
|
|
352
|
+
force: true
|
|
353
|
+
});
|
|
354
|
+
} catch {
|
|
355
|
+
makeWritable(folder);
|
|
356
|
+
rmSync(folder, {
|
|
357
|
+
recursive: true,
|
|
358
|
+
force: true
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
341
362
|
/** Runs git in `cwd` and returns its trimmed output. */
|
|
342
363
|
function git(cwd, args) {
|
|
343
364
|
return execFileSync("git", args, {
|
|
@@ -375,10 +396,12 @@ async function openWorkspace(root, kind) {
|
|
|
375
396
|
function stateFile(dir) {
|
|
376
397
|
return join(dir, "run.json");
|
|
377
398
|
}
|
|
378
|
-
/** Reads a run created by `new`, failing with the reason when it is missing. */
|
|
399
|
+
/** Reads a run created by `new`, failing with the reason when it is missing, and marks it active by touching run.json. */
|
|
379
400
|
function loadRun(dir) {
|
|
380
401
|
const file = stateFile(resolve(dir));
|
|
381
402
|
if (!existsSync(file)) throw new Error(`No run at ${dir}: run.json is missing. Create one with \`new\`.`);
|
|
403
|
+
const now = /* @__PURE__ */ new Date();
|
|
404
|
+
utimesSync(file, now, now);
|
|
382
405
|
return JSON.parse(readFileSync(file, "utf8"));
|
|
383
406
|
}
|
|
384
407
|
/** Persists the run state. */
|
|
@@ -388,7 +411,7 @@ function saveRun(state) {
|
|
|
388
411
|
/** Allocates the folders of a new run under the system temp folder. */
|
|
389
412
|
function allocateRun(workspace, baseRef, title) {
|
|
390
413
|
const id = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").slice(0, 15)}-${randomBytes(3).toString("hex")}`;
|
|
391
|
-
const dir = join(
|
|
414
|
+
const dir = join(RUNS_DIR, workspace.name, id);
|
|
392
415
|
const evidence = join(dir, "evidence");
|
|
393
416
|
mkdirSync(evidence, { recursive: true });
|
|
394
417
|
return {
|
|
@@ -1858,26 +1881,65 @@ function writeCommand(folder, spec) {
|
|
|
1858
1881
|
mkdirSync(folder, { recursive: true });
|
|
1859
1882
|
writeFileSync(join(folder, "command.txt"), `cd ${shellQuote(spec.cwd)}\n${describe(spec)}\n`);
|
|
1860
1883
|
}
|
|
1884
|
+
const foreground = /* @__PURE__ */ new Set();
|
|
1885
|
+
const releases = /* @__PURE__ */ new Set();
|
|
1886
|
+
const INTERRUPTS = [
|
|
1887
|
+
"SIGINT",
|
|
1888
|
+
"SIGTERM",
|
|
1889
|
+
"SIGHUP",
|
|
1890
|
+
"SIGQUIT"
|
|
1891
|
+
];
|
|
1892
|
+
let listening = false;
|
|
1893
|
+
/** On the first interrupt, kills the process group of every foreground command, runs every registered release (one that throws is reported and the others still run), and exits with the shell's code for the signal. */
|
|
1894
|
+
function listenForInterrupts() {
|
|
1895
|
+
if (listening) return;
|
|
1896
|
+
listening = true;
|
|
1897
|
+
for (const signal of INTERRUPTS) process.once(signal, () => {
|
|
1898
|
+
for (const child of foreground) if (child.pid !== void 0) killOwnGroup(child.pid);
|
|
1899
|
+
for (const release of releases) try {
|
|
1900
|
+
release();
|
|
1901
|
+
} catch (error) {
|
|
1902
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
1903
|
+
}
|
|
1904
|
+
process.exit(128 + constants$1.signals[signal]);
|
|
1905
|
+
});
|
|
1906
|
+
}
|
|
1907
|
+
/**
|
|
1908
|
+
* Until the returned function is called, an interrupt calls `release` after
|
|
1909
|
+
* killing the process group of every command still running in the
|
|
1910
|
+
* foreground, the processes it started included.
|
|
1911
|
+
*/
|
|
1912
|
+
function onInterrupt(release) {
|
|
1913
|
+
listenForInterrupts();
|
|
1914
|
+
releases.add(release);
|
|
1915
|
+
return () => releases.delete(release);
|
|
1916
|
+
}
|
|
1861
1917
|
/** Runs a command to completion and writes command.txt, stdout.txt, stderr.txt and exit-code.txt into `folder`. */
|
|
1862
1918
|
function runRecorded(folder, spec) {
|
|
1863
1919
|
writeCommand(folder, spec);
|
|
1920
|
+
listenForInterrupts();
|
|
1864
1921
|
return new Promise((resolve) => {
|
|
1865
1922
|
const child = spawn(spec.program, spec.args, {
|
|
1866
1923
|
cwd: spec.cwd,
|
|
1867
1924
|
env: spec.env,
|
|
1925
|
+
detached: true,
|
|
1868
1926
|
stdio: [
|
|
1869
1927
|
"ignore",
|
|
1870
1928
|
"pipe",
|
|
1871
1929
|
"pipe"
|
|
1872
1930
|
]
|
|
1873
1931
|
});
|
|
1932
|
+
foreground.add(child);
|
|
1874
1933
|
const out = [];
|
|
1875
1934
|
const err = [];
|
|
1876
1935
|
child.stdout.on("data", (chunk) => out.push(chunk));
|
|
1877
1936
|
child.stderr.on("data", (chunk) => err.push(chunk));
|
|
1878
|
-
const timer = setTimeout(() =>
|
|
1937
|
+
const timer = setTimeout(() => {
|
|
1938
|
+
if (child.pid !== void 0) killOwnGroup(child.pid);
|
|
1939
|
+
}, spec.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
1879
1940
|
const finish = (code, signal, failure = "") => {
|
|
1880
1941
|
clearTimeout(timer);
|
|
1942
|
+
foreground.delete(child);
|
|
1881
1943
|
const result = {
|
|
1882
1944
|
folder,
|
|
1883
1945
|
command: describe(spec),
|
|
@@ -1930,6 +1992,14 @@ function startRecorded(folder, spec) {
|
|
|
1930
1992
|
exited
|
|
1931
1993
|
};
|
|
1932
1994
|
}
|
|
1995
|
+
/** Kills the process group a detached command leads, never a lone PID the system may have reused since the command exited. */
|
|
1996
|
+
function killOwnGroup(pid) {
|
|
1997
|
+
try {
|
|
1998
|
+
process.kill(-pid, "SIGKILL");
|
|
1999
|
+
} catch {
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
1933
2003
|
/** Kills the process group of `pid`, or `pid` alone, ignoring a process already gone. */
|
|
1934
2004
|
function killGroup(pid) {
|
|
1935
2005
|
try {
|
|
@@ -2192,6 +2262,56 @@ async function packInterface(workspace, state) {
|
|
|
2192
2262
|
linkDependencies(root, workspace.root);
|
|
2193
2263
|
return root;
|
|
2194
2264
|
}
|
|
2265
|
+
/** How long a run may sit untouched before the next `new` deletes it. */
|
|
2266
|
+
const RUN_TTL_MS = 6048e5;
|
|
2267
|
+
function lastActivity(dir) {
|
|
2268
|
+
const file = join(dir, "run.json");
|
|
2269
|
+
return statSync(existsSync(file) ? file : dir).mtimeMs;
|
|
2270
|
+
}
|
|
2271
|
+
/** The leftovers a run recorded; none when its run.json is missing or unreadable. */
|
|
2272
|
+
function recorded(dir) {
|
|
2273
|
+
try {
|
|
2274
|
+
const state = object(parseJson(readFileSync(join(dir, "run.json"), "utf8")), "run.json");
|
|
2275
|
+
return {
|
|
2276
|
+
pids: children(state, "processes").map((entry) => num(entry, "pid")),
|
|
2277
|
+
containers: children(state, "containers").map((entry) => str(entry, "name"))
|
|
2278
|
+
};
|
|
2279
|
+
} catch {
|
|
2280
|
+
return {
|
|
2281
|
+
pids: [],
|
|
2282
|
+
containers: []
|
|
2283
|
+
};
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
function entries(folder) {
|
|
2287
|
+
try {
|
|
2288
|
+
return readdirSync(folder, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join(folder, entry.name));
|
|
2289
|
+
} catch {
|
|
2290
|
+
return [];
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
function pruneRun(dir, now) {
|
|
2294
|
+
try {
|
|
2295
|
+
if (now - lastActivity(dir) < RUN_TTL_MS) return;
|
|
2296
|
+
const { pids, containers } = recorded(dir);
|
|
2297
|
+
if (pids.some(alive)) return;
|
|
2298
|
+
for (const name of containers) removeContainer(name);
|
|
2299
|
+
removeTree(dir);
|
|
2300
|
+
} catch (error) {
|
|
2301
|
+
if (existsSync(dir)) process.stderr.write(`could not prune ${dir}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Deletes every run under the runs folder, of any repository, that nothing
|
|
2306
|
+
* touched for seven days and whose recorded processes are all gone, with the
|
|
2307
|
+
* containers it recorded. A run a command loaded since then, or one with a
|
|
2308
|
+
* live process, is still in progress and stays. A run it cannot delete is
|
|
2309
|
+
* reported on stderr and never stops the new run.
|
|
2310
|
+
*/
|
|
2311
|
+
function pruneRuns() {
|
|
2312
|
+
const now = Date.now();
|
|
2313
|
+
for (const repo of entries(RUNS_DIR)) for (const dir of entries(repo)) pruneRun(dir, now);
|
|
2314
|
+
}
|
|
2195
2315
|
/**
|
|
2196
2316
|
* Creates an isolated run: runs the setup (the build by default), then
|
|
2197
2317
|
* prepares what the kind drives. An interface is packed as npm would publish
|
|
@@ -2199,6 +2319,7 @@ async function packInterface(workspace, state) {
|
|
|
2199
2319
|
* kind's backing `services` start in Docker on free ports.
|
|
2200
2320
|
*/
|
|
2201
2321
|
async function createRun(workspace, baseRef, title) {
|
|
2322
|
+
pruneRuns();
|
|
2202
2323
|
const state = allocateRun(workspace, baseRef, title);
|
|
2203
2324
|
saveRun(state);
|
|
2204
2325
|
await runSetup(workspace, state);
|
|
@@ -2303,10 +2424,7 @@ function clean(state) {
|
|
|
2303
2424
|
saveRun(state);
|
|
2304
2425
|
for (const entry of readdirSync(state.dir)) {
|
|
2305
2426
|
if (entry === "evidence" || entry === "run.json") continue;
|
|
2306
|
-
|
|
2307
|
-
recursive: true,
|
|
2308
|
-
force: true
|
|
2309
|
-
});
|
|
2427
|
+
removeTree(join(state.dir, entry));
|
|
2310
2428
|
}
|
|
2311
2429
|
return lines;
|
|
2312
2430
|
}
|
|
@@ -2324,7 +2442,7 @@ const VERIFICATION_LAYER = [
|
|
|
2324
2442
|
".claude/**",
|
|
2325
2443
|
".github/**"
|
|
2326
2444
|
];
|
|
2327
|
-
/** Tests are user-facing in a template,
|
|
2445
|
+
/** Tests are user-facing in a template, since `ajs` copies its whole tree except `.agents/` and `.claude/skills/`. */
|
|
2328
2446
|
const NOT_USER_FACING = {
|
|
2329
2447
|
interface: [
|
|
2330
2448
|
"**/*.test.ts",
|
|
@@ -3103,8 +3221,34 @@ function statusOf(context, failure) {
|
|
|
3103
3221
|
if (failure.notVerified !== null) return "NOT VERIFIED";
|
|
3104
3222
|
return failure.error !== null || context.steps.some((step) => step.checks.some((check) => !check.pass)) || context.steps.length === 0 ? "FAIL" : "PASS";
|
|
3105
3223
|
}
|
|
3224
|
+
/** Deletes a journey's scratch folder and HOME, and their parents once empty; the evidence stays. A folder it cannot delete is reported on stderr and left for the next prune. */
|
|
3225
|
+
function discard(context) {
|
|
3226
|
+
for (const folder of [context.work, context.home]) try {
|
|
3227
|
+
removeTree(folder);
|
|
3228
|
+
for (let parent = dirname(folder); parent !== context.state.dir && readdirSync(parent).length === 0; parent = dirname(parent)) rmdirSync(parent);
|
|
3229
|
+
} catch (error) {
|
|
3230
|
+
process.stderr.write(`could not delete ${folder}: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3106
3233
|
async function runOne(workspace, state, feature, id, journey) {
|
|
3107
3234
|
const context = new VerifyContext(workspace, state, feature, id);
|
|
3235
|
+
const others = new Set(state.processes.map((record) => record.pid));
|
|
3236
|
+
const release = onInterrupt(() => {
|
|
3237
|
+
const own = state.processes.filter((record) => !others.has(record.pid));
|
|
3238
|
+
for (const record of own) killGroup(record.pid);
|
|
3239
|
+
discard(context);
|
|
3240
|
+
state.processes = state.processes.filter((record) => others.has(record.pid));
|
|
3241
|
+
saveRun(state);
|
|
3242
|
+
});
|
|
3243
|
+
try {
|
|
3244
|
+
return await driveJourney(context, feature, id, journey);
|
|
3245
|
+
} finally {
|
|
3246
|
+
release();
|
|
3247
|
+
discard(context);
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
async function driveJourney(context, feature, id, journey) {
|
|
3251
|
+
const { state } = context;
|
|
3108
3252
|
let failure = {
|
|
3109
3253
|
error: null,
|
|
3110
3254
|
notVerified: null
|
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { Scalar, isMap, isPair, isScalar, isSeq, parseDocument, visit } from "yaml";
|
|
4
|
+
//#region src/guardrails/renovate.ts
|
|
5
|
+
/** The Renovate config file sync writes when a repository has none. */
|
|
6
|
+
const RENOVATE_PATH = "renovate.json";
|
|
7
|
+
/** The config files Renovate's `detectConfigFile` reads, in its lookup order (`getConfigFileNames()` in its `lib/config/app-strings.ts`, called without a platform), before the `renovate` key of `package.json`. */
|
|
8
|
+
const RENOVATE_CONFIGS = [
|
|
9
|
+
RENOVATE_PATH,
|
|
10
|
+
"renovate.jsonc",
|
|
11
|
+
"renovate.json5",
|
|
12
|
+
".github/renovate.json",
|
|
13
|
+
".github/renovate.jsonc",
|
|
14
|
+
".github/renovate.json5",
|
|
15
|
+
".gitlab/renovate.json",
|
|
16
|
+
".gitlab/renovate.jsonc",
|
|
17
|
+
".gitlab/renovate.json5",
|
|
18
|
+
".renovaterc",
|
|
19
|
+
".renovaterc.json",
|
|
20
|
+
".renovaterc.jsonc",
|
|
21
|
+
".renovaterc.json5"
|
|
22
|
+
];
|
|
23
|
+
const PRESET = "github>AntelopeJS/.github:renovate.json5";
|
|
24
|
+
/** Matches a config that extends the AntelopeJS shared Renovate preset. */
|
|
25
|
+
const RENOVATE_PRESET = /github>AntelopeJS\/\.github(?::|\/)/;
|
|
26
|
+
const RENOVATE_JSON = `{
|
|
27
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
28
|
+
"extends": ["${PRESET}"]
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
/**
|
|
32
|
+
* Writes `renovate.json` when the repository has no Renovate config, keeps an existing one byte for byte,
|
|
33
|
+
* and fails one that does not extend the AntelopeJS preset, since rewriting it would drop the repository's settings.
|
|
34
|
+
* `managed` is false for a project scaffolded from a template, whose Renovate setup is its own.
|
|
35
|
+
*/
|
|
36
|
+
function renovateArtifacts(root, manifest, managed) {
|
|
37
|
+
if (!managed) return [];
|
|
38
|
+
const file = RENOVATE_CONFIGS.find((path) => existsSync(join(root, path)));
|
|
39
|
+
const path = file ?? "package.json";
|
|
40
|
+
const text = file === void 0 ? manifest.renovate ? JSON.stringify(manifest.renovate) : void 0 : readFileSync(join(root, file), "utf8");
|
|
41
|
+
if (text === void 0) return [{
|
|
42
|
+
kind: "write",
|
|
43
|
+
path: RENOVATE_PATH,
|
|
44
|
+
content: RENOVATE_JSON,
|
|
45
|
+
mode: void 0
|
|
46
|
+
}];
|
|
47
|
+
if (RENOVATE_PRESET.test(text)) return [{
|
|
48
|
+
kind: "unchanged",
|
|
49
|
+
path
|
|
50
|
+
}];
|
|
51
|
+
return [{
|
|
52
|
+
kind: "error",
|
|
53
|
+
path,
|
|
54
|
+
message: `${file ?? "package.json \"renovate\""}: extend "${PRESET}" in its extends, then rerun antelopejs-sync.`
|
|
55
|
+
}];
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
4
58
|
//#region src/guardrails/workflow.ts
|
|
5
59
|
const CI_NODE_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-node\.yml@\S+$/;
|
|
6
60
|
const CI_RENOVATE_SYNC_PATTERN = /^AntelopeJS\/\.github\/\.github\/workflows\/ci-renovate-sync\.yml@\S+$/;
|
|
@@ -344,4 +398,4 @@ function ciWorkflow(current, callers, syncCallers, docsFiles) {
|
|
|
344
398
|
});
|
|
345
399
|
}
|
|
346
400
|
//#endregion
|
|
347
|
-
export { ciWorkflow as a, ciRenovateSyncCallers as c, CI_RENOVATE_SYNC_REF as i, hasChecksWorkflow as l, CI_NODE_REF as n, MISSING_CHECKS_WORKFLOW as o, CI_PATH as r, ciNodeCallers as s, CI_CONTEXT as t };
|
|
401
|
+
export { ciWorkflow as a, ciRenovateSyncCallers as c, RENOVATE_PRESET as d, renovateArtifacts as f, CI_RENOVATE_SYNC_REF as i, hasChecksWorkflow as l, CI_NODE_REF as n, MISSING_CHECKS_WORKFLOW as o, CI_PATH as r, ciNodeCallers as s, CI_CONTEXT as t, RENOVATE_CONFIGS as u };
|