@antelopejs/tooling-configs 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/sync.mjs +3 -3
- package/dist/bin/verify.mjs +554 -521
- package/dist/{map-COx26Bu6.mjs → map-B23_WMGE.mjs} +52 -51
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as skillFolder } from "./shared-igPpEDpS.mjs";
|
|
2
|
-
import { f as parseJson, i as isObject } from "./json-CG2L7YFl.mjs";
|
|
2
|
+
import { c as object, f as parseJson, i as isObject, o as list, p as str, s as num } 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
4
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { basename, delimiter, dirname, join, relative, resolve } from "node:path";
|
|
@@ -95,7 +95,7 @@ async function openWorkspace(root, kind) {
|
|
|
95
95
|
function stateFile(dir) {
|
|
96
96
|
return join(dir, "run.json");
|
|
97
97
|
}
|
|
98
|
-
/** Reads a run created by `new`, failing with the reason when it is missing, and marks it active by touching run.json. */
|
|
98
|
+
/** Reads a run created by `new`, failing with the reason when it is missing, and marks it active by touching run.json. Its processes are those run.json records and those of every command's records file. */
|
|
99
99
|
function loadRun(dir) {
|
|
100
100
|
const file = stateFile(resolve(dir));
|
|
101
101
|
if (!existsSync(file)) throw new Error(`No run at ${dir}: run.json is missing. Create one with \`new\`.`);
|
|
@@ -104,6 +104,7 @@ function loadRun(dir) {
|
|
|
104
104
|
const stored = JSON.parse(readFileSync(file, "utf8"));
|
|
105
105
|
return {
|
|
106
106
|
...stored,
|
|
107
|
+
processes: [...stored.processes, ...commandRecords(stored.dir)],
|
|
107
108
|
timings: stored.timings ?? [],
|
|
108
109
|
all: stored.all === true
|
|
109
110
|
};
|
|
@@ -118,67 +119,67 @@ function writeWhole(file, text) {
|
|
|
118
119
|
rmSync(staging, { force: true });
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
/** Persists the run state. */
|
|
122
|
+
/** Persists the run state; the processes a command's records file holds stay in that file only. */
|
|
122
123
|
function saveRun(state) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
124
|
+
const commands = new Set(commandRecords(state.dir).map((record) => record.pid));
|
|
125
|
+
writeWhole(stateFile(state.dir), `${JSON.stringify({
|
|
126
|
+
...state,
|
|
127
|
+
processes: state.processes.filter((record) => !commands.has(record.pid))
|
|
128
|
+
}, null, 2)}\n`);
|
|
129
|
+
}
|
|
130
|
+
/** A command's records file in the run folder: the command's PID, a random suffix that keeps a later command with a reused PID from overwriting it, and `.json`. */
|
|
131
|
+
const RECORDS_FILE = /^processes-(\d+)-[0-9a-f]+\.json$/;
|
|
132
|
+
/** This command's records file in each run it started processes in, and the records it holds. */
|
|
133
|
+
const ownRecords = /* @__PURE__ */ new Map();
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
135
|
+
* The processes the commands of the run in `dir` recorded in their own
|
|
136
|
+
* files: every command's, or only those of the command whose PID is
|
|
137
|
+
* `command`. A file that does not hold a list of records records nothing,
|
|
138
|
+
* and a temporary file a crashed command left is not read.
|
|
138
139
|
*/
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
let holder = NaN;
|
|
140
|
+
function commandRecords(dir, command) {
|
|
141
|
+
let names;
|
|
142
|
+
try {
|
|
143
|
+
names = readdirSync(dir);
|
|
144
|
+
} catch {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
return names.flatMap((name) => {
|
|
148
|
+
const match = RECORDS_FILE.exec(name);
|
|
149
|
+
if (match === null || command !== void 0 && Number(match[1]) !== command) return [];
|
|
150
150
|
try {
|
|
151
|
-
|
|
151
|
+
return list(parseJson(readFileSync(join(dir, name), "utf8")), name).map((entry) => {
|
|
152
|
+
const record = object(entry, name);
|
|
153
|
+
return {
|
|
154
|
+
name: str(record, "name"),
|
|
155
|
+
pid: num(record, "pid")
|
|
156
|
+
};
|
|
157
|
+
});
|
|
152
158
|
} catch {
|
|
153
|
-
|
|
159
|
+
return [];
|
|
154
160
|
}
|
|
155
|
-
|
|
156
|
-
else Atomics.wait(pause, 0, 0, 2);
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
body();
|
|
160
|
-
} finally {
|
|
161
|
-
rmSync(lock, { force: true });
|
|
162
|
-
}
|
|
161
|
+
});
|
|
163
162
|
}
|
|
164
163
|
/**
|
|
165
164
|
* Adds `add` to the processes the run records and drops the records of the
|
|
166
|
-
* PIDs in `drop`, in `state` and in
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
165
|
+
* PIDs in `drop`, in `state` and in this command's records file, which
|
|
166
|
+
* {@link loadRun} reads with run.json and every other command's file.
|
|
167
|
+
* Several `journey` commands of one run may start and stop processes at
|
|
168
|
+
* once; each writes only its own file, whole, so none can lose a record
|
|
169
|
+
* another made, and none waits for another. The file goes once it records
|
|
170
|
+
* nothing.
|
|
171
171
|
*/
|
|
172
172
|
function recordProcesses(state, change) {
|
|
173
173
|
const apply = (records) => [...records.filter((record) => !change.drop?.includes(record.pid)), ...change.add ?? []];
|
|
174
174
|
state.processes = apply(state.processes);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
});
|
|
175
|
+
const own = ownRecords.get(state.dir) ?? {
|
|
176
|
+
file: join(state.dir, `processes-${process.pid}-${randomBytes(6).toString("hex")}.json`),
|
|
177
|
+
records: []
|
|
178
|
+
};
|
|
179
|
+
own.records = apply(own.records);
|
|
180
|
+
ownRecords.set(state.dir, own);
|
|
181
|
+
if (own.records.length === 0) rmSync(own.file, { force: true });
|
|
182
|
+
else writeWhole(own.file, `${JSON.stringify(own.records)}\n`);
|
|
182
183
|
}
|
|
183
184
|
/** Allocates the folders of a new run under the system temp folder. */
|
|
184
185
|
function allocateRun(workspace, baseRef, title, all) {
|
|
@@ -493,4 +494,4 @@ function planFor(workspace, baseRef, all = false) {
|
|
|
493
494
|
};
|
|
494
495
|
}
|
|
495
496
|
//#endregion
|
|
496
|
-
export {
|
|
497
|
+
export { removeTree as _, readFeatures as a, writeWhole as b, allocateRun as c, isolatedEnv as d, loadRun as f, recordProcesses as g, operatorTmpdir as h, planFor as i, commandRecords as l, operatorEnv as m, SMOKE_FEATURE as n, CACHE_DIR as o, openWorkspace as p, checkMap as r, RUNS_DIR as s, DEFAULT_SHARED as t, git as u, saveRun as v, matchesPath as x, withLocalBins as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
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",
|