@antelopejs/tooling-configs 0.3.5 → 0.3.7
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 +20 -2
- package/dist/bin/checks.mjs +348 -8
- package/dist/bin/garden.mjs +1 -1
- package/dist/bin/sync.mjs +490 -14
- package/dist/bin/verify.mjs +886 -367
- package/dist/{ci-workflow-C4mQ8QSp.mjs → ci-workflow-37qJa9LX.mjs} +33 -10
- package/dist/{map-s_jKqBQv.mjs → map-COx26Bu6.mjs} +107 -8
- package/dist/verify/index.d.mts +1 -0
- package/package.json +4 -2
|
@@ -352,14 +352,36 @@ function skipRenovateSync(document, job) {
|
|
|
352
352
|
else job.set("with", document.createNode({ "renovate-sync": false }));
|
|
353
353
|
return true;
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function setTestJob(document, job, placeholderTests) {
|
|
356
356
|
const inputs = job.get("with", true);
|
|
357
357
|
if (isMap(inputs)) {
|
|
358
|
-
if (inputs.has("test-job"))
|
|
359
|
-
|
|
360
|
-
|
|
358
|
+
if (!inputs.has("test-job")) {
|
|
359
|
+
inputs.set("test-job", !placeholderTests);
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
if (!placeholderTests || inputs.get("test-job") === false) return false;
|
|
363
|
+
inputs.set("test-job", false);
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
job.set("with", document.createNode({ "test-job": !placeholderTests }));
|
|
361
367
|
return true;
|
|
362
368
|
}
|
|
369
|
+
/** The caller sync writes into a repository without one, its test job off when the `test` script is a placeholder. */
|
|
370
|
+
function newCaller(placeholderTests) {
|
|
371
|
+
return placeholderTests ? CI_CALLER.replace("test-job: true", "test-job: false") : CI_CALLER;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Whether a `test` script only stands in for tests: made only of `echo` and
|
|
375
|
+
* `exit 0` commands, such as `echo 'No tests defined'`. A missing script is
|
|
376
|
+
* not a placeholder, since the shared test job may run tests another way. Such a
|
|
377
|
+
* repository gets `test-job: false`, since a test job would only spend runner
|
|
378
|
+
* time printing it.
|
|
379
|
+
*/
|
|
380
|
+
function placeholderTestScript(script) {
|
|
381
|
+
if (script === void 0) return false;
|
|
382
|
+
const commands = script.split(/&&|\|\||;/).map((command) => command.trim()).filter(Boolean);
|
|
383
|
+
return commands.length > 0 && commands.every((command) => /^echo(\s|$)/.test(command) || /^exit\s+0$/.test(command));
|
|
384
|
+
}
|
|
363
385
|
function lines(text) {
|
|
364
386
|
return text.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
365
387
|
}
|
|
@@ -426,8 +448,9 @@ function dropRedundantAggregator(jobs, syncCallers) {
|
|
|
426
448
|
* Keeps the shared CI caller on the job id `ci` with no `name`, so the shared workflow reports `ci / checks`,
|
|
427
449
|
* dispatchable and read-only, with the Renovate sync it would otherwise run turned off. The write permissions the sync
|
|
428
450
|
* needs to push and dispatch the caller live on a separate job calling ci-renovate-sync.yml, which is added when missing.
|
|
429
|
-
* A caller without a `test-job` input gets `test-job: true`, which runs the tests in their own job
|
|
430
|
-
*
|
|
451
|
+
* A caller without a `test-job` input gets `test-job: true`, which runs the tests in their own job, or `false` when
|
|
452
|
+
* `placeholderTests` says the `test` script only stands in for tests; that case also turns an existing `true` off. Any
|
|
453
|
+
* other explicit value is left as the repository set it.
|
|
431
454
|
* A `checks` job that only re-aggregates the caller (`needs: [ci]`, steps that `exit` on `needs` results) is removed
|
|
432
455
|
* when the workflow has no other job besides the caller and the Renovate sync, since the shared workflow already
|
|
433
456
|
* reports `ci / checks` and each `needs` hop adds to the critical path. A gate that also covers repository-specific
|
|
@@ -436,8 +459,8 @@ function dropRedundantAggregator(jobs, syncCallers) {
|
|
|
436
459
|
* When `docsFiles` computes paths, every caller's `docs-files` input lists them first, then keeps its hand-listed paths
|
|
437
460
|
* that still exist, so sync never drops coverage.
|
|
438
461
|
*/
|
|
439
|
-
function ciWorkflow(current, callers, syncCallers, docsFiles) {
|
|
440
|
-
if (current === void 0) return
|
|
462
|
+
function ciWorkflow(current, callers, syncCallers, docsFiles, placeholderTests = false) {
|
|
463
|
+
if (current === void 0) return newCaller(placeholderTests);
|
|
441
464
|
if (!callers.length) return current;
|
|
442
465
|
const document = parseDocument(current);
|
|
443
466
|
if (document.errors.length) throw new Error(`${CI_PATH}: ${document.errors.map(({ message }) => message).join("; ")}`);
|
|
@@ -460,7 +483,7 @@ function ciWorkflow(current, callers, syncCallers, docsFiles) {
|
|
|
460
483
|
}
|
|
461
484
|
changed = grant(document, pair.value, { contents: "read" }) || changed;
|
|
462
485
|
changed = skipRenovateSync(document, pair.value) || changed;
|
|
463
|
-
changed =
|
|
486
|
+
changed = setTestJob(document, pair.value, placeholderTests) || changed;
|
|
464
487
|
changed = ensureSyncJob(document, jobs, syncCallers) || changed;
|
|
465
488
|
const removed = dropRedundantAggregator(jobs, syncCallers);
|
|
466
489
|
changed = removed.length > 0 || changed;
|
|
@@ -478,4 +501,4 @@ function ciWorkflow(current, callers, syncCallers, docsFiles) {
|
|
|
478
501
|
});
|
|
479
502
|
}
|
|
480
503
|
//#endregion
|
|
481
|
-
export { ciWorkflow as a,
|
|
504
|
+
export { ciWorkflow as a, ciNodeCallers as c, RENOVATE_CONFIGS as d, RENOVATE_PRESET as f, CI_RENOVATE_SYNC_REF as i, ciRenovateSyncCallers as l, CI_NODE_REF as n, placeholderTestScript as o, renovateArtifacts as p, CI_PATH as r, MISSING_CHECKS_WORKFLOW as s, CI_CONTEXT as t, hasChecksWorkflow as u };
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { l as skillFolder } from "./shared-igPpEDpS.mjs";
|
|
2
2
|
import { f as parseJson, i as isObject } from "./json-CG2L7YFl.mjs";
|
|
3
3
|
import { c as leaseTmpDir, i as PARENT_TMPDIR, n as LEASE_DIR, r as LEASE_MARKER, t as DEV_STACK_VARIABLES } from "./env-DT0UJNeL.mjs";
|
|
4
|
-
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
5
|
-
import { basename, dirname, join,
|
|
4
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { basename, delimiter, dirname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
8
|
import { randomBytes } from "node:crypto";
|
|
9
9
|
import { homedir, tmpdir } from "node:os";
|
|
10
|
+
import { minimatch } from "minimatch";
|
|
11
|
+
//#region src/verify/glob.ts
|
|
12
|
+
/**
|
|
13
|
+
* Whether `file` matches `glob`, dotfiles and dot folders included: `src/**`
|
|
14
|
+
* matches `src/.env` and `**` matches `.prettierrc`, while braces, classes,
|
|
15
|
+
* extglobs and negations keep their meaning (`{.env,.npmrc}` matches `.env`,
|
|
16
|
+
* `[!.]*` does not). `path.matchesGlob` never lets a wildcard match a
|
|
17
|
+
* leading dot, so a diff touching only a dotfile would map to no feature.
|
|
18
|
+
*/
|
|
19
|
+
function matchesPath(file, glob) {
|
|
20
|
+
return minimatch(file, glob, { dot: true });
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
10
23
|
//#region src/verify/workspace.ts
|
|
11
24
|
/**
|
|
12
25
|
* Caches shared by every run: the warm pnpm store, the npm cache and the
|
|
@@ -95,9 +108,77 @@ function loadRun(dir) {
|
|
|
95
108
|
all: stored.all === true
|
|
96
109
|
};
|
|
97
110
|
}
|
|
111
|
+
/** Writes `text` to `file` through a sibling temporary file and one rename, so a reader in another process sees the old content or the new, never part of it. */
|
|
112
|
+
function writeWhole(file, text) {
|
|
113
|
+
const staging = `${file}.${randomBytes(6).toString("hex")}.tmp`;
|
|
114
|
+
try {
|
|
115
|
+
writeFileSync(staging, text);
|
|
116
|
+
renameSync(staging, file);
|
|
117
|
+
} finally {
|
|
118
|
+
rmSync(staging, { force: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
98
121
|
/** Persists the run state. */
|
|
99
122
|
function saveRun(state) {
|
|
100
|
-
|
|
123
|
+
writeWhole(stateFile(state.dir), `${JSON.stringify(state, null, 2)}\n`);
|
|
124
|
+
}
|
|
125
|
+
/** Whether the process `pid` still runs. */
|
|
126
|
+
function running(pid) {
|
|
127
|
+
try {
|
|
128
|
+
process.kill(pid, 0);
|
|
129
|
+
return true;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
return error instanceof Error && "code" in error && error.code === "EPERM";
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Runs `body` holding the run's lock, a file created exclusively that names
|
|
136
|
+
* its holder. A lock whose holder no longer runs, as after a crash, is taken
|
|
137
|
+
* over.
|
|
138
|
+
*/
|
|
139
|
+
function withRunLock(dir, body) {
|
|
140
|
+
const lock = join(dir, "run.json.lock");
|
|
141
|
+
const pause = new Int32Array(new SharedArrayBuffer(4));
|
|
142
|
+
for (;;) {
|
|
143
|
+
try {
|
|
144
|
+
writeFileSync(lock, String(process.pid), { flag: "wx" });
|
|
145
|
+
break;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (!(error instanceof Error && "code" in error && error.code === "EEXIST")) throw error;
|
|
148
|
+
}
|
|
149
|
+
let holder = NaN;
|
|
150
|
+
try {
|
|
151
|
+
holder = Number(readFileSync(lock, "utf8"));
|
|
152
|
+
} catch {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (Number.isInteger(holder) && holder > 0 && !running(holder)) rmSync(lock, { force: true });
|
|
156
|
+
else Atomics.wait(pause, 0, 0, 2);
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
body();
|
|
160
|
+
} finally {
|
|
161
|
+
rmSync(lock, { force: true });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Adds `add` to the processes the run records and drops the records of the
|
|
166
|
+
* PIDs in `drop`, in `state` and in run.json. Several `journey` commands of
|
|
167
|
+
* one run may start and stop processes at once, so run.json changes under a
|
|
168
|
+
* lock, from what it holds then: writing back `state` whole would drop the
|
|
169
|
+
* records another command made since this one loaded the run. `state` keeps
|
|
170
|
+
* only the records this command loaded or made.
|
|
171
|
+
*/
|
|
172
|
+
function recordProcesses(state, change) {
|
|
173
|
+
const apply = (records) => [...records.filter((record) => !change.drop?.includes(record.pid)), ...change.add ?? []];
|
|
174
|
+
state.processes = apply(state.processes);
|
|
175
|
+
withRunLock(state.dir, () => {
|
|
176
|
+
const stored = loadRun(state.dir);
|
|
177
|
+
saveRun({
|
|
178
|
+
...stored,
|
|
179
|
+
processes: apply(stored.processes)
|
|
180
|
+
});
|
|
181
|
+
});
|
|
101
182
|
}
|
|
102
183
|
/** Allocates the folders of a new run under the system temp folder. */
|
|
103
184
|
function allocateRun(workspace, baseRef, title, all) {
|
|
@@ -198,6 +279,20 @@ function isolatedEnv(workspace, home, extra = {}) {
|
|
|
198
279
|
...extra
|
|
199
280
|
};
|
|
200
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* `path` with the repository's `node_modules/.bin` first, as `pnpm exec`
|
|
284
|
+
* puts it, so setup commands, journeys and formal checks find the
|
|
285
|
+
* repository's own bins whether the CLI was started through `pnpm exec` or
|
|
286
|
+
* through `node_modules/.bin/antelopejs-verify`. A `path` that already lists
|
|
287
|
+
* that folder, as `pnpm exec` from a package of a workspace does after the
|
|
288
|
+
* package's own, is kept as it is, and so is an unset or empty one, which
|
|
289
|
+
* leaves children the system's default search path.
|
|
290
|
+
*/
|
|
291
|
+
function withLocalBins(root, path) {
|
|
292
|
+
if (!path) return path;
|
|
293
|
+
const bins = resolve(root, "node_modules", ".bin");
|
|
294
|
+
return path.split(delimiter).some((entry) => entry !== "" && resolve(root, entry) === bins) ? path : `${bins}${delimiter}${path}`;
|
|
295
|
+
}
|
|
201
296
|
//#endregion
|
|
202
297
|
//#region src/verify/map.ts
|
|
203
298
|
/** The feature that always runs, whatever the diff touches. */
|
|
@@ -236,10 +331,14 @@ const SHARED_BY_ALL = [
|
|
|
236
331
|
"tsconfig.*.json",
|
|
237
332
|
"antelope-lock/**"
|
|
238
333
|
];
|
|
239
|
-
/** The files whose change can break any feature, so a diff touching one runs them all. */
|
|
334
|
+
/** The files whose change can break any feature, so a diff touching one runs them all. A module declares its interfaces under `src/interfaces/` or, with a single one, `src/interface/`. */
|
|
240
335
|
const DEFAULT_SHARED = {
|
|
241
336
|
interface: SHARED_BY_ALL,
|
|
242
|
-
module: [
|
|
337
|
+
module: [
|
|
338
|
+
...SHARED_BY_ALL,
|
|
339
|
+
"src/interfaces/**",
|
|
340
|
+
"src/interface/**"
|
|
341
|
+
],
|
|
243
342
|
template: [
|
|
244
343
|
...SHARED_BY_ALL,
|
|
245
344
|
"antelope.config.*",
|
|
@@ -278,7 +377,7 @@ function readFeatures(workspace) {
|
|
|
278
377
|
});
|
|
279
378
|
}
|
|
280
379
|
function matches(file, globs) {
|
|
281
|
-
return globs.some((glob) =>
|
|
380
|
+
return globs.some((glob) => matchesPath(file, glob));
|
|
282
381
|
}
|
|
283
382
|
/** Whether a user can observe a change to `file`. */
|
|
284
383
|
function userFacing(workspace, file) {
|
|
@@ -304,7 +403,7 @@ function featureProblems(workspace, feature, known, tracked) {
|
|
|
304
403
|
if (!feature.body.includes(`\`${journey}\``)) problems.push(`${feature.file}: journey \`${journey}\` is not described`);
|
|
305
404
|
}
|
|
306
405
|
if (feature.name !== "smoke" && feature.covers.length === 0) problems.push(`${feature.file}: lists no covers globs`);
|
|
307
|
-
for (const glob of feature.covers) if (!tracked.some((file) =>
|
|
406
|
+
for (const glob of feature.covers) if (!tracked.some((file) => matchesPath(file, glob))) problems.push(`${feature.file}: glob ${glob} matches no tracked file`);
|
|
308
407
|
if (feature.docs.length === 0) problems.push(`${feature.file}: lists no docs pages`);
|
|
309
408
|
for (const doc of feature.docs) if (!existsSync(join(workspace.root, doc))) problems.push(`${feature.file}: docs path ${doc} does not exist`);
|
|
310
409
|
return problems;
|
|
@@ -394,4 +493,4 @@ function planFor(workspace, baseRef, all = false) {
|
|
|
394
493
|
};
|
|
395
494
|
}
|
|
396
495
|
//#endregion
|
|
397
|
-
export { readFeatures as a, allocateRun as c, loadRun as d, openWorkspace as f,
|
|
496
|
+
export { saveRun as _, readFeatures as a, matchesPath as b, allocateRun as c, loadRun as d, openWorkspace as f, removeTree as g, recordProcesses as h, planFor as i, git as l, operatorTmpdir as m, SMOKE_FEATURE as n, CACHE_DIR as o, operatorEnv as p, checkMap as r, RUNS_DIR as s, DEFAULT_SHARED as t, isolatedEnv as u, withLocalBins as v, writeWhole as y };
|
package/dist/verify/index.d.mts
CHANGED
|
@@ -39,6 +39,7 @@ interface FormalCheck {
|
|
|
39
39
|
files?: string[];
|
|
40
40
|
/** Runs from the repository root; exits 0 while every finding breaks as recorded. */
|
|
41
41
|
command: string[];
|
|
42
|
+
/** The first capture group names a rule the output reports as broken, and an optional group named `states`, after it, gives its counterexample length in decimal digits; a `states` group that is the first group, that captures anything but digits, or whose number is above `Number.MAX_SAFE_INTEGER` gives no length; a covered behaviour change keeps the base's findings as known only when every one has the same length at HEAD as on the base. Without `violation`, a non-zero exit is the one rule `property` broken. */
|
|
42
43
|
violation: RegExp | null;
|
|
43
44
|
/** The first capture group names a rule the output reports as holding; a base finding counts as fixed only when HEAD reports it so. Without `passing` and `violation`, a zero exit is the one rule `property` holding. */
|
|
44
45
|
passing?: RegExp | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and an interface range check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"lint:fix": "oxlint --fix",
|
|
62
62
|
"format": "oxfmt .",
|
|
63
63
|
"prepack": "pnpm run build",
|
|
64
|
-
"release": "pnpm run lint && pnpm run prepack && release-it",
|
|
64
|
+
"release": "pnpm run lint && pnpm run typecheck && pnpm run prepack && release-it",
|
|
65
65
|
"typecheck": "tsc --noEmit",
|
|
66
66
|
"test": "node --test \"src/**/*.test.ts\"",
|
|
67
67
|
"checks": "node src/bin/checks.ts",
|
|
@@ -80,12 +80,14 @@
|
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@oxlint/plugins": "1.81.0",
|
|
82
82
|
"dts-bundle-generator": "^9.5.1",
|
|
83
|
+
"minimatch": "^10.2.6",
|
|
83
84
|
"typescript": "^5.9.3",
|
|
84
85
|
"yaml": "^2.9.1"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
88
|
"@nuxt/eslint-config": "^1.17.0",
|
|
88
89
|
"@types/node": "^24.13.3",
|
|
90
|
+
"@types/semver": "^7.8.0",
|
|
89
91
|
"eslint-plugin-perfectionist": "^5.11.0",
|
|
90
92
|
"knip": "^6.34.0",
|
|
91
93
|
"lefthook": "^2.2.2",
|