@antelopejs/tooling-configs 0.2.15 → 0.2.16
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/garden.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { a as isString, c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-BqvuCkqr.mjs";
|
|
3
3
|
import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
|
|
4
|
-
import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT, u as ciRenovateSyncCallers } from "../ci-workflow-
|
|
4
|
+
import { i as CI_RENOVATE_SYNC_REF, l as ciNodeCallers, n as CI_NODE_REF, r as CI_PATH, t as CI_CONTEXT, u as ciRenovateSyncCallers } from "../ci-workflow-DIsoEgMd.mjs";
|
|
5
5
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { execFileSync, spawnSync } from "node:child_process";
|
package/dist/bin/sync.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { o as repositoryRoot } from "../files-2FikHZ9F.mjs";
|
|
|
5
5
|
import { a as repositoryTools, i as parseManifest, n as managedPackage, o as toolingVersions, r as packageManager, t as execCommand } from "../package-Dtjt_lSa.mjs";
|
|
6
6
|
import { t as measureBaseline } from "../ratchet-DRdIYwmv.mjs";
|
|
7
7
|
import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-Yyf5_J5l.mjs";
|
|
8
|
-
import { a as MUTATION_PATH, c as MISSING_CHECKS_WORKFLOW, d as hasChecksWorkflow, l as ciNodeCallers, o as ciWorkflow, r as CI_PATH, s as mutationCaller, u as ciRenovateSyncCallers } from "../ci-workflow-
|
|
8
|
+
import { a as MUTATION_PATH, c as MISSING_CHECKS_WORKFLOW, d as hasChecksWorkflow, l as ciNodeCallers, o as ciWorkflow, r as CI_PATH, s as mutationCaller, u as ciRenovateSyncCallers } from "../ci-workflow-DIsoEgMd.mjs";
|
|
9
9
|
import { a as skillFolder, i as isVerifyKind, n as claudeLink, r as claudeLinkTarget, t as VERIFY_KINDS } from "../kinds-Bzyyi9yk.mjs";
|
|
10
10
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, rmdirSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { dirname, join, resolve } from "node:path";
|
package/dist/bin/verify.mjs
CHANGED
|
@@ -88,7 +88,7 @@ function publicPart(declaration) {
|
|
|
88
88
|
}
|
|
89
89
|
/** Walks the types a set of signatures reaches and prints every declaration of the package among them. */
|
|
90
90
|
var DeclarationWalk = class {
|
|
91
|
-
|
|
91
|
+
declarations = /* @__PURE__ */ new Map();
|
|
92
92
|
seen = /* @__PURE__ */ new Set();
|
|
93
93
|
printer = ts.createPrinter({ removeComments: true });
|
|
94
94
|
checker;
|
|
@@ -97,14 +97,23 @@ var DeclarationWalk = class {
|
|
|
97
97
|
this.checker = checker;
|
|
98
98
|
this.isLocal = isLocal;
|
|
99
99
|
}
|
|
100
|
+
get found() {
|
|
101
|
+
return [...this.declarations.values()];
|
|
102
|
+
}
|
|
100
103
|
signature(signature) {
|
|
104
|
+
for (const parameter of signature.getTypeParameters() ?? []) this.type(parameter);
|
|
101
105
|
for (const parameter of signature.getParameters()) this.type(this.checker.getTypeOfSymbol(parameter));
|
|
102
106
|
this.type(signature.getReturnType());
|
|
103
107
|
}
|
|
104
108
|
record(symbol) {
|
|
105
|
-
if (this.
|
|
109
|
+
if (this.declarations.has(symbol) || (symbol.flags & NAMED) === 0 || !this.isLocal(symbol)) return;
|
|
106
110
|
const texts = (symbol.declarations ?? []).map((declaration) => this.printer.printNode(ts.EmitHint.Unspecified, publicPart(declaration), declaration.getSourceFile()).replace(/\s+/g, " ").replace(/^(?:export )?(?:declare )?/, ""));
|
|
107
|
-
this.
|
|
111
|
+
this.declarations.set(symbol, texts.join(" "));
|
|
112
|
+
for (const declaration of symbol.declarations ?? []) this.generics(declaration);
|
|
113
|
+
}
|
|
114
|
+
generics(declaration) {
|
|
115
|
+
if (ts.isClassDeclaration(declaration) || ts.isInterfaceDeclaration(declaration) || ts.isTypeAliasDeclaration(declaration)) for (const parameter of declaration.typeParameters ?? []) this.type(this.checker.getTypeAtLocation(parameter));
|
|
116
|
+
if (ts.isClassDeclaration(declaration) || ts.isInterfaceDeclaration(declaration)) for (const clause of declaration.heritageClauses ?? []) for (const base of clause.types) this.type(this.checker.getTypeAtLocation(base));
|
|
108
117
|
}
|
|
109
118
|
members(type) {
|
|
110
119
|
for (const property of this.checker.getPropertiesOfType(type)) this.type(this.checker.getTypeOfSymbol(property));
|
|
@@ -117,11 +126,20 @@ var DeclarationWalk = class {
|
|
|
117
126
|
for (const part of type.types) this.type(part);
|
|
118
127
|
return;
|
|
119
128
|
}
|
|
129
|
+
if (type.flags & ts.TypeFlags.TypeParameter) {
|
|
130
|
+
this.type(type.getConstraint() ?? type);
|
|
131
|
+
this.type(type.getDefault() ?? type);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
120
134
|
if (type.aliasSymbol) this.record(type.aliasSymbol);
|
|
121
135
|
for (const argument of type.aliasTypeArguments ?? []) this.type(argument);
|
|
122
136
|
if (isObjectType$1(type) && isReference(type)) for (const argument of this.checker.getTypeArguments(type)) this.type(argument);
|
|
123
137
|
const symbol = type.getSymbol();
|
|
124
138
|
if (symbol === void 0 || !this.isLocal(symbol)) return;
|
|
139
|
+
for (const declaration of symbol.declarations ?? []) {
|
|
140
|
+
const owner = ts.isEnumMember(declaration) ? this.checker.getSymbolAtLocation(declaration.parent.name) : void 0;
|
|
141
|
+
if (owner) this.record(owner);
|
|
142
|
+
}
|
|
125
143
|
this.record(symbol);
|
|
126
144
|
this.members(type);
|
|
127
145
|
}
|
|
@@ -135,7 +153,7 @@ var DeclarationWalk = class {
|
|
|
135
153
|
function referencedDeclarations(checker, isLocal, signatures) {
|
|
136
154
|
const walk = new DeclarationWalk(checker, isLocal);
|
|
137
155
|
for (const signature of signatures) walk.signature(signature);
|
|
138
|
-
return
|
|
156
|
+
return walk.found.sort((left, right) => left.localeCompare(right));
|
|
139
157
|
}
|
|
140
158
|
//#endregion
|
|
141
159
|
//#region src/verify/surface.ts
|
|
@@ -2263,13 +2281,13 @@ function isPropertyName(node) {
|
|
|
2263
2281
|
return (ts.isPropertyAccessExpression(parent) || ts.isPropertyAssignment(parent) || ts.isMethodDeclaration(parent) || ts.isPropertyDeclaration(parent) || ts.isGetAccessor(parent) || ts.isSetAccessor(parent) || ts.isEnumMember(parent)) && parent.name === node;
|
|
2264
2282
|
}
|
|
2265
2283
|
/**
|
|
2266
|
-
* A binding
|
|
2267
|
-
* declaration, which may move between covered
|
|
2268
|
-
* otherwise, so a variable or class of one file
|
|
2269
|
-
* name in another.
|
|
2284
|
+
* A binding is its name alone when that module declares it as a function
|
|
2285
|
+
* declaration no other covered file declares, which may move between covered
|
|
2286
|
+
* files, and `module#name` otherwise, so a variable or class of one file, or a
|
|
2287
|
+
* function of the same name in another, never reads as it.
|
|
2270
2288
|
*/
|
|
2271
2289
|
function bindingOrigin(covered, module, name) {
|
|
2272
|
-
return covered.
|
|
2290
|
+
return covered.functions.get(module)?.has(name) && !covered.duplicated.has(name) ? name : `${module}#${name}`;
|
|
2273
2291
|
}
|
|
2274
2292
|
function importedBindings(clause, module, covered) {
|
|
2275
2293
|
const named = clause.namedBindings;
|
|
@@ -2281,9 +2299,8 @@ function importedBindings(clause, module, covered) {
|
|
|
2281
2299
|
}
|
|
2282
2300
|
function reexportTexts(statement, module, covered) {
|
|
2283
2301
|
const exported = statement.exportClause;
|
|
2284
|
-
|
|
2285
|
-
if (exported
|
|
2286
|
-
if (ts.isNamespaceExport(exported)) return inside ? [] : [`export * as ${exported.name.text} from ${module}`];
|
|
2302
|
+
if (exported === void 0) return [`export * from ${module}`];
|
|
2303
|
+
if (ts.isNamespaceExport(exported)) return [`export * as ${exported.name.text} from ${module}`];
|
|
2287
2304
|
return exported.elements.flatMap((element) => {
|
|
2288
2305
|
const origin = bindingOrigin(covered, module, (element.propertyName ?? element.name).text);
|
|
2289
2306
|
return origin === element.name.text ? [] : [`export ${origin} as ${element.name.text}`];
|
|
@@ -2311,13 +2328,14 @@ function localExportTexts(statement, bindings, locals) {
|
|
|
2311
2328
|
* what a use refers to. A binding from a covered module is its name alone
|
|
2312
2329
|
* when it is a function declaration, so moving the declaration between
|
|
2313
2330
|
* covered files keeps every use the same; any other binding is keyed by its
|
|
2314
|
-
* module.
|
|
2331
|
+
* module. A side-effect import keeps its order in the file relative to the binding imports before it, and `export *` is an entry like any re-export. Re-exports and
|
|
2315
2332
|
* renamed or imported exports become entries keyed by the origin they export.
|
|
2316
2333
|
*/
|
|
2317
2334
|
function originsOf(path, covered, file, locals) {
|
|
2318
2335
|
const bindings = /* @__PURE__ */ new Map();
|
|
2319
2336
|
const texts = [];
|
|
2320
2337
|
const ordered = [];
|
|
2338
|
+
const earlier = [];
|
|
2321
2339
|
const exports = [];
|
|
2322
2340
|
for (const statement of file.statements) {
|
|
2323
2341
|
if (!(ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement))) continue;
|
|
@@ -2327,9 +2345,10 @@ function originsOf(path, covered, file, locals) {
|
|
|
2327
2345
|
const module = moduleKey(path, specifier.text);
|
|
2328
2346
|
if (ts.isImportDeclaration(statement)) {
|
|
2329
2347
|
if (statement.importClause === void 0) {
|
|
2330
|
-
ordered.push(`import ${module}`);
|
|
2348
|
+
ordered.push(`import ${module} after ${earlier.join(",")}`);
|
|
2331
2349
|
continue;
|
|
2332
2350
|
}
|
|
2351
|
+
earlier.push(module);
|
|
2333
2352
|
for (const [name, origin] of importedBindings(statement.importClause, module, covered)) bindings.set(name, origin);
|
|
2334
2353
|
} else texts.push(...reexportTexts(statement, module, covered));
|
|
2335
2354
|
}
|
|
@@ -2398,17 +2417,18 @@ function declaredNames(name) {
|
|
|
2398
2417
|
function isFunctionDeclaration(statement) {
|
|
2399
2418
|
return ts.isFunctionDeclaration(statement) && Boolean(statement.body) && statement.name !== void 0;
|
|
2400
2419
|
}
|
|
2401
|
-
/** The top-level variables, classes and enums of a script, each keyed by its file and name: what a function moved into another file must not pick up by name. */
|
|
2402
|
-
function localsOf(script) {
|
|
2420
|
+
/** The top-level variables, classes and enums of a script, and its functions that another covered file also declares, each keyed by its file and name: what a function moved into another file must not pick up by name. */
|
|
2421
|
+
function localsOf(script, covered) {
|
|
2403
2422
|
const file = script.path.replace(MODULE_EXTENSION, "");
|
|
2404
2423
|
const names = script.file.statements.flatMap((statement) => {
|
|
2405
2424
|
if (ts.isVariableStatement(statement)) return statement.declarationList.declarations.flatMap((declaration) => declaredNames(declaration.name));
|
|
2406
2425
|
return (ts.isClassDeclaration(statement) || ts.isEnumDeclaration(statement)) && statement.name ? [statement.name.text] : [];
|
|
2407
2426
|
});
|
|
2408
|
-
|
|
2427
|
+
const clashing = [...covered.functions.get(file) ?? []].filter((name) => covered.duplicated.has(name));
|
|
2428
|
+
return new Map([...names, ...clashing].map((name) => [name, `${file}#${name}`]));
|
|
2409
2429
|
}
|
|
2410
2430
|
function scriptItems(script, covered) {
|
|
2411
|
-
const locals = localsOf(script);
|
|
2431
|
+
const locals = localsOf(script, covered);
|
|
2412
2432
|
const origins = originsOf(script.path, covered, script.file, locals);
|
|
2413
2433
|
const inFunctions = new Map([...locals, ...origins.bindings]);
|
|
2414
2434
|
const statements = script.file.statements.filter((statement) => !ts.isImportDeclaration(statement) && !ts.isExportDeclaration(statement)).map((statement) => {
|
|
@@ -2478,9 +2498,12 @@ function emitFingerprint(repo, sha, files) {
|
|
|
2478
2498
|
const source = fileAt(repo, sha, path);
|
|
2479
2499
|
return source === null ? [] : [parsedFile(path, source)];
|
|
2480
2500
|
});
|
|
2501
|
+
const functions = new Map(parsed.map(({ path, scripts }) => [path.replace(MODULE_EXTENSION, ""), new Set(scripts.flatMap(({ file }) => file.statements.filter(isFunctionDeclaration).map(({ name }) => name.text)))]));
|
|
2502
|
+
const declarations = [...functions.values()].flatMap((names) => [...names]);
|
|
2481
2503
|
const covered = {
|
|
2482
2504
|
modules: new Set(files.map((path) => path.replace(MODULE_EXTENSION, ""))),
|
|
2483
|
-
functions
|
|
2505
|
+
functions,
|
|
2506
|
+
duplicated: new Set(declarations.filter((name, index) => declarations.indexOf(name) !== index))
|
|
2484
2507
|
};
|
|
2485
2508
|
for (const { path, scripts, others } of parsed) {
|
|
2486
2509
|
const items = [...scripts.flatMap((script) => scriptItems(script, covered)), ...others];
|
|
@@ -3631,8 +3654,7 @@ function runSeededDoors(workspace) {
|
|
|
3631
3654
|
function runContainmentCheck(workspace, baseRef) {
|
|
3632
3655
|
const results = runContainments(workspace, process.argv[1], baseRef);
|
|
3633
3656
|
for (const result of results) print(`${result.outcome} ${result.kind} ${result.containment}: ${result.detail}${result.run ? ` (evidence ${result.run}, control ${result.controlRun})` : ""}`);
|
|
3634
|
-
|
|
3635
|
-
return results.length > 0 && results.every((result) => result.outcome === "CONTAINED") ? 0 : 1;
|
|
3657
|
+
return results.every((result) => result.outcome === "CONTAINED") ? 0 : 1;
|
|
3636
3658
|
}
|
|
3637
3659
|
const PROOF_COMMANDS = /* @__PURE__ */ new Set([
|
|
3638
3660
|
"seeded",
|
|
@@ -155,6 +155,24 @@ function renameNeeds(document, from, to) {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
+
function escapeRegExp(text) {
|
|
159
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
160
|
+
}
|
|
161
|
+
function renameNeedsReferences(text, from, to) {
|
|
162
|
+
const id = escapeRegExp(from);
|
|
163
|
+
const reference = new RegExp(`(?<![\\w.'"-])needs(?:\\.${id}(?![\\w-])|\\[\\s*(['"])${id}\\1\\s*\\])`, "g");
|
|
164
|
+
return text.replace(reference, (_match, quote) => quote === void 0 ? `needs.${to}` : `needs[${quote}${to}${quote}]`);
|
|
165
|
+
}
|
|
166
|
+
function isText(value) {
|
|
167
|
+
return String(value) === value;
|
|
168
|
+
}
|
|
169
|
+
function renameNeedsExpressions(document, from, to) {
|
|
170
|
+
visit(document, { Scalar(key, node, path) {
|
|
171
|
+
if (key === "key" || !isText(node.value)) return;
|
|
172
|
+
const parent = path.at(-1);
|
|
173
|
+
node.value = isPair(parent) && isScalar(parent.key) && parent.key.value === "if" ? renameNeedsReferences(node.value, from, to) : node.value.replace(/\$\{\{[\s\S]*?\}\}/g, (expression) => renameNeedsReferences(expression, from, to));
|
|
174
|
+
} });
|
|
175
|
+
}
|
|
158
176
|
function hasDispatch(document) {
|
|
159
177
|
const trigger = document.get("on", true);
|
|
160
178
|
if (isMap(trigger)) return trigger.has("workflow_dispatch");
|
|
@@ -238,6 +256,7 @@ function ciWorkflow(current, callers, syncCallers) {
|
|
|
238
256
|
if (caller.id !== "ci") {
|
|
239
257
|
if (isScalar(pair.key)) pair.key.value = "ci";
|
|
240
258
|
renameNeeds(document, caller.id, "ci");
|
|
259
|
+
renameNeedsExpressions(document, caller.id, "ci");
|
|
241
260
|
changed = true;
|
|
242
261
|
}
|
|
243
262
|
changed = grant(document, pair.value, { contents: "read" }) || changed;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
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",
|