@antelopejs/tooling-configs 0.2.16 → 0.2.18
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 +101 -52
- package/dist/bin/api-diff.mjs +430 -107
- package/dist/bin/body-check.d.mts +1 -0
- package/dist/bin/body-check.mjs +344 -0
- package/dist/bin/capture.d.mts +1 -0
- package/dist/bin/capture.mjs +559 -0
- package/dist/bin/check-size.mjs +3 -3
- package/dist/bin/checks.mjs +3 -3
- package/dist/bin/comment-proof.mjs +4 -3
- package/dist/bin/garden.mjs +6 -6
- package/dist/bin/ratchet.mjs +316 -10
- package/dist/bin/suppressions.mjs +118 -80
- package/dist/bin/sync.mjs +554 -153
- package/dist/bin/verify.mjs +240 -127
- package/dist/capture/index.d.mts +50 -0
- package/dist/capture/index.mjs +2 -0
- package/dist/{ceilings-BSw9p4YB.mjs → ceilings-B7KayYIG.mjs} +11 -3
- package/dist/{checks-BlWDFYio.mjs → checks-CxkSu2E6.mjs} +1 -1
- package/dist/{ci-workflow-DIsoEgMd.mjs → ci-workflow-ChW4He0r.mjs} +84 -3
- package/dist/{files-2FikHZ9F.mjs → files-DJ0TeaTU.mjs} +11 -5
- package/dist/formal/index.d.mts +40 -0
- package/dist/formal/index.mjs +205 -0
- package/dist/{json-BqvuCkqr.mjs → json-CG2L7YFl.mjs} +12 -8
- package/dist/oxc/anti-slop/index.mjs +869 -21
- package/dist/oxc/fmt.mjs +1 -1
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +736 -4
- package/dist/oxc/lint.d.mts +20 -3
- package/dist/oxc/lint.mjs +34 -10
- package/dist/oxlint-DIV-lLSS.mjs +98 -0
- package/dist/{package-Dtjt_lSa.mjs → package-BRTjkzt5.mjs} +29 -3
- package/dist/proof-stamp-DDDC0J6l.mjs +279 -0
- package/dist/ratchet-BAcLRYuM.mjs +448 -0
- package/dist/{renames-BGO4dWJ8.mjs → renames-L2owF5GD.mjs} +2 -2
- package/dist/scenes-DZVXkcxS.mjs +104 -0
- package/dist/shared-igPpEDpS.mjs +622 -0
- package/dist/{size-BVgNbLO6.mjs → size-DBatLT-F.mjs} +4 -4
- package/dist/suppression-base-9L8dlMQK.mjs +120 -0
- package/dist/suppression-budget-C0SkPO5R.mjs +535 -0
- package/dist/{suppressions-BJAngUxo.mjs → suppressions-DM60NkvL.mjs} +180 -18
- package/dist/templates-CypDm-j9.mjs +121 -0
- package/dist/typescript-CM0LrVP7.mjs +222 -0
- package/dist/verify/index.d.mts +6 -1
- package/dist/verify/index.mjs +1 -1
- package/package.json +31 -5
- package/dist/kinds-Bzyyi9yk.mjs +0 -25
- package/dist/ratchet-DRdIYwmv.mjs +0 -80
- package/dist/shared-CsXIMK3I.mjs +0 -34
- package/dist/staged-ratchet-CjoRfZaM.mjs +0 -236
- package/dist/suppression-budget-Yyf5_J5l.mjs +0 -283
- package/dist/typescript-C54ONh9m.mjs +0 -433
package/dist/bin/api-diff.mjs
CHANGED
|
@@ -1,102 +1,121 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { i as parseManifest, r as packageManager } from "../package-BRTjkzt5.mjs";
|
|
2
3
|
import { t as runCli } from "../cli-4Tv71vYk.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
import { a as
|
|
4
|
+
import { c as repositoryRoot, l as resolveRevision } from "../files-DJ0TeaTU.mjs";
|
|
5
|
+
import { a as DIRECTORY_LINK, c as revisionCounts, d as describeAllowance, f as fillStars, i as stampProof, l as allowedByGlob, o as compareRevisions, p as recordVerdict, u as createAddedPolicy } from "../proof-stamp-DDDC0J6l.mjs";
|
|
6
|
+
import { a as outputRoot, i as loadTypeScript, n as isExportPath, o as packagesAt, r as isTestSource, s as unpublishedAt, t as emitPackage } from "../typescript-CM0LrVP7.mjs";
|
|
6
7
|
import { createRequire } from "node:module";
|
|
7
|
-
import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
8
|
-
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
8
|
+
import { copyFileSync, cpSync, existsSync, globSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { basename, dirname, isAbsolute, join, parse, posix, relative, resolve } from "node:path";
|
|
9
10
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
10
|
-
import { parseArgs } from "node:util";
|
|
11
11
|
import { availableParallelism, freemem } from "node:os";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
`;
|
|
31
|
-
const DRIVER = `
|
|
32
|
-
const { spawn } = require("node:child_process");
|
|
33
|
-
const [flags, worker, ...jobs] = process.argv.slice(1);
|
|
34
|
-
let failed = false;
|
|
35
|
-
let pending = jobs.length;
|
|
36
|
-
for (const job of jobs) {
|
|
37
|
-
spawn(process.execPath, [...JSON.parse(flags), worker, job], { stdio: ["ignore", "inherit", "inherit"] }).on("exit", (code) => {
|
|
38
|
-
failed ||= code !== 0;
|
|
39
|
-
pending -= 1;
|
|
40
|
-
if (pending === 0) process.exit(failed ? 1 : 0);
|
|
41
|
-
});
|
|
12
|
+
import { parseArgs } from "node:util";
|
|
13
|
+
//#region src/guardrails/auto-import-globals.ts
|
|
14
|
+
/** Where the generated Vite config takes the dms-frontend auto-imports from, relative to the `@antelopejs/dms-frontend` package. */
|
|
15
|
+
const FRONTEND_MODULE = join("node_modules", "@antelopejs", "dms-frontend", "templates", "vue", "frontend-module.ts");
|
|
16
|
+
const NAME_SEPARATOR = /[-_.]/u;
|
|
17
|
+
const SOURCE_EXTENSION = /(?:\.d)?\.[cm]?[jt]sx?$/u;
|
|
18
|
+
/** The name unimport gives a default export: the file name, or its directory's for an index file, in camel case when it has a separator. */
|
|
19
|
+
function defaultExportName(file) {
|
|
20
|
+
const own = parse(file).name;
|
|
21
|
+
const name = own === "index" ? parse(dirname(file)).name : own;
|
|
22
|
+
if (!NAME_SEPARATOR.test(name)) return name;
|
|
23
|
+
return name.split(/[-_.]+/u).filter(Boolean).map((word, index) => index === 0 ? `${word.charAt(0).toLowerCase()}${word.slice(1)}` : `${word.charAt(0).toUpperCase()}${word.slice(1)}`).join("");
|
|
24
|
+
}
|
|
25
|
+
function frontendModule(moduleRoot) {
|
|
26
|
+
for (let directory = moduleRoot;; directory = dirname(directory)) {
|
|
27
|
+
if (existsSync(join(directory, FRONTEND_MODULE))) return join(directory, FRONTEND_MODULE);
|
|
28
|
+
if (dirname(directory) === directory) return void 0;
|
|
29
|
+
}
|
|
42
30
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
recursive: true,
|
|
51
|
-
filter: (path) => basename(path) !== "node_modules"
|
|
31
|
+
/** The modules besides the scanned files whose exports the frontend build auto-imports: dms-frontend's `frontend-module.ts` and the `vue` preset, each with the specifier a scanned file imports it by. */
|
|
32
|
+
function presetModules(compiler, moduleRoot, options) {
|
|
33
|
+
const presets = [];
|
|
34
|
+
const frontend = frontendModule(moduleRoot);
|
|
35
|
+
if (frontend !== void 0) presets.push({
|
|
36
|
+
file: frontend,
|
|
37
|
+
specifier: frontend.replace(SOURCE_EXTENSION, "")
|
|
52
38
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
const vue = compiler.resolveModuleName("vue", join(moduleRoot, "auto-imports.ts"), options, compiler.sys).resolvedModule?.resolvedFileName;
|
|
40
|
+
if (vue !== void 0) presets.push({
|
|
41
|
+
file: vue,
|
|
42
|
+
specifier: "vue"
|
|
43
|
+
});
|
|
44
|
+
return presets;
|
|
45
|
+
}
|
|
46
|
+
/** The names a file exports, as unimport names them. */
|
|
47
|
+
function exportedNames(checker, source) {
|
|
48
|
+
const owner = checker.getSymbolAtLocation(source);
|
|
49
|
+
if (owner === void 0) return [];
|
|
50
|
+
return checker.getExportsOfModule(owner).map((symbol) => ({
|
|
51
|
+
name: symbol.name === "default" ? defaultExportName(source.fileName) : symbol.name,
|
|
52
|
+
symbol
|
|
65
53
|
}));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
}
|
|
55
|
+
function bindingNames(compiler, name) {
|
|
56
|
+
if (compiler.isIdentifier(name)) return [name.text];
|
|
57
|
+
return name.elements.flatMap((element) => compiler.isOmittedExpression(element) ? [] : bindingNames(compiler, element.name));
|
|
58
|
+
}
|
|
59
|
+
function importedNames(compiler, statement) {
|
|
60
|
+
const clause = statement.importClause;
|
|
61
|
+
const bindings = clause?.namedBindings;
|
|
62
|
+
return [
|
|
63
|
+
...clause?.name === void 0 ? [] : [clause.name.text],
|
|
64
|
+
...bindings !== void 0 && compiler.isNamespaceImport(bindings) ? [bindings.name.text] : [],
|
|
65
|
+
...bindings !== void 0 && compiler.isNamedImports(bindings) ? bindings.elements.map((element) => element.name.text) : []
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function declaredName(compiler, statement) {
|
|
69
|
+
if (!(compiler.isFunctionDeclaration(statement) || compiler.isClassDeclaration(statement) || compiler.isInterfaceDeclaration(statement) || compiler.isTypeAliasDeclaration(statement) || compiler.isEnumDeclaration(statement) || compiler.isModuleDeclaration(statement) || compiler.isImportEqualsDeclaration(statement)) || statement.name === void 0 || !compiler.isIdentifier(statement.name)) return void 0;
|
|
70
|
+
return statement.name.text;
|
|
71
|
+
}
|
|
72
|
+
/** The names a file binds at its top level, which an auto-import never shadows. */
|
|
73
|
+
function localNames(compiler, source) {
|
|
74
|
+
return new Set(source.statements.flatMap((statement) => {
|
|
75
|
+
if (compiler.isImportDeclaration(statement)) return importedNames(compiler, statement);
|
|
76
|
+
if (compiler.isVariableStatement(statement)) return statement.declarationList.declarations.flatMap((declaration) => bindingNames(compiler, declaration.name));
|
|
77
|
+
const name = declaredName(compiler, statement);
|
|
78
|
+
return name === void 0 ? [] : [name];
|
|
71
79
|
}));
|
|
72
|
-
const worker = join(directory, "worker.cjs");
|
|
73
|
-
writeFileSync(worker, WORKER);
|
|
74
|
-
const run = spawnSync(process.execPath, [
|
|
75
|
-
"-e",
|
|
76
|
-
DRIVER,
|
|
77
|
-
JSON.stringify(WORKER_NODE_ARGS),
|
|
78
|
-
worker,
|
|
79
|
-
...jobs.map(({ file }) => file)
|
|
80
|
-
], {
|
|
81
|
-
encoding: "utf8",
|
|
82
|
-
stdio: [
|
|
83
|
-
"ignore",
|
|
84
|
-
"ignore",
|
|
85
|
-
"pipe"
|
|
86
|
-
]
|
|
87
|
-
});
|
|
88
|
-
if (run.error) throw run.error;
|
|
89
|
-
if (run.status !== 0) throw new Error(run.stderr || "A declaration bundling worker failed.");
|
|
90
|
-
const bundles = [];
|
|
91
|
-
for (const { indices, result } of jobs) for (const [position, bundle] of JSON.parse(readFileSync(result, "utf8")).entries()) bundles[indices[position]] = bundle;
|
|
92
|
-
return bundles;
|
|
93
80
|
}
|
|
94
|
-
/**
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
/** Every auto-import a scanned file may use without importing it: dms-frontend's composables, then vue's exports, then the module's own scanned exports; the first module to offer a name keeps it. */
|
|
82
|
+
function autoImports(checker, sources) {
|
|
83
|
+
const imports = /* @__PURE__ */ new Map();
|
|
84
|
+
for (const { source, specifier } of sources) for (const { name, symbol } of exportedNames(checker, source)) if (!imports.has(name)) imports.set(name, {
|
|
85
|
+
name,
|
|
86
|
+
imported: symbol.name,
|
|
87
|
+
specifier
|
|
88
|
+
});
|
|
89
|
+
return [...imports.values()];
|
|
90
|
+
}
|
|
91
|
+
/** The specifier a scanned file is imported by: its path without the source extension. */
|
|
92
|
+
function sourceSpecifier(file) {
|
|
93
|
+
return file.replace(SOURCE_EXTENSION, "");
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A compiler host that prepends to each scanned module the imports unimport
|
|
97
|
+
* would inject, so names a file uses without importing them type as they do
|
|
98
|
+
* in the frontend build instead of as `any`. Only names the file does not bind
|
|
99
|
+
* itself are injected, and scripts and declaration files are left as they are.
|
|
100
|
+
*/
|
|
101
|
+
function injectingHost(compiler, options, scanned, imports) {
|
|
102
|
+
const host = compiler.createCompilerHost(options, true);
|
|
103
|
+
const read = host.getSourceFile.bind(host);
|
|
104
|
+
host.getSourceFile = (fileName, language, onError, create) => {
|
|
105
|
+
const source = scanned.get(fileName);
|
|
106
|
+
if (source === void 0 || source.isDeclarationFile || !compiler.isExternalModule(source)) return read(fileName, language, onError, create);
|
|
107
|
+
const own = localNames(compiler, source);
|
|
108
|
+
const bySpecifier = /* @__PURE__ */ new Map();
|
|
109
|
+
for (const { name, imported, specifier } of imports) {
|
|
110
|
+
if (own.has(name) || specifier === sourceSpecifier(fileName)) continue;
|
|
111
|
+
const list = bySpecifier.get(specifier) ?? [];
|
|
112
|
+
list.push(imported === name ? name : `${imported} as ${name}`);
|
|
113
|
+
bySpecifier.set(specifier, list);
|
|
114
|
+
}
|
|
115
|
+
const prefix = [...bySpecifier].map(([specifier, names]) => `import { ${names.join(", ")} } from ${JSON.stringify(specifier)};\n`).join("");
|
|
116
|
+
return compiler.createSourceFile(fileName, `${prefix}${source.text}`, language, true);
|
|
117
|
+
};
|
|
118
|
+
return host;
|
|
100
119
|
}
|
|
101
120
|
//#endregion
|
|
102
121
|
//#region src/guardrails/declaration-order.ts
|
|
@@ -189,6 +208,289 @@ function normalizeBundle(compiler, text) {
|
|
|
189
208
|
}).printFile(normalized);
|
|
190
209
|
}
|
|
191
210
|
//#endregion
|
|
211
|
+
//#region src/guardrails/auto-imports.ts
|
|
212
|
+
/** The file in which a DMS frontend module declares the directories the generated Vite config auto-imports. */
|
|
213
|
+
const BUILD_FILE = "dms.frontend.build.ts";
|
|
214
|
+
/** A module's private code, which the frontend build never auto-imports, whatever its declaration says. */
|
|
215
|
+
const PRIVATE_DIRECTORY = /(?:^|\/)app\/build(?:\/|$)/u;
|
|
216
|
+
/** The extensions unimport's directory scan reads exports from. */
|
|
217
|
+
const SCANNED_FILE = /\.(?:mts|cts|ts|tsx|mjs|cjs|js|jsx)$/u;
|
|
218
|
+
const HINT = "Auto-imports: every export of a file under a directory that dms.frontend.build.ts passes to registerAutoImports is auto-imported into every frontend module, so a removed, added or changed name above changes what those modules compile against. @internal does not hide an auto-import and --allow-added does not apply to one. Keep removed and changed names (or release the change as breaking), and move a helper that must stay private under app/build/, which is never auto-imported.\n";
|
|
219
|
+
function moduleRoots(root, revision) {
|
|
220
|
+
return execFileSync("git", [
|
|
221
|
+
"ls-tree",
|
|
222
|
+
"-r",
|
|
223
|
+
"-z",
|
|
224
|
+
"--name-only",
|
|
225
|
+
revision
|
|
226
|
+
], {
|
|
227
|
+
cwd: root,
|
|
228
|
+
encoding: "utf8",
|
|
229
|
+
maxBuffer: 67108864
|
|
230
|
+
}).split("\0").filter((file) => (file === BUILD_FILE || file.endsWith(`/${BUILD_FILE}`)) && !file.split("/").includes("node_modules")).map((file) => dirname(file)).sort();
|
|
231
|
+
}
|
|
232
|
+
/** The directories a build declaration passes to `registerAutoImports`, read without running it; only string literals can be read. */
|
|
233
|
+
function declaredDirectories(compiler, file, label) {
|
|
234
|
+
const source = compiler.createSourceFile(file, readFileSync(file, "utf8"), compiler.ScriptTarget.Latest, true);
|
|
235
|
+
const directories = [];
|
|
236
|
+
const visit = (node) => {
|
|
237
|
+
if (compiler.isCallExpression(node) && compiler.isPropertyAccessExpression(node.expression) && node.expression.name.text === "registerAutoImports") {
|
|
238
|
+
const [entries] = node.arguments;
|
|
239
|
+
const elements = entries !== void 0 && compiler.isArrayLiteralExpression(entries) ? entries.elements : void 0;
|
|
240
|
+
if (elements === void 0 || !elements.every((element) => compiler.isStringLiteralLike(element))) throw new Error(`${label}: registerAutoImports is not given an array of string literals, so api-diff cannot read which directories are auto-imported. Write the directories inline, as in registerAutoImports(["app/composables", ...]).`);
|
|
241
|
+
for (const element of elements) if (compiler.isStringLiteralLike(element)) directories.push(element.text);
|
|
242
|
+
}
|
|
243
|
+
compiler.forEachChild(node, visit);
|
|
244
|
+
};
|
|
245
|
+
visit(source);
|
|
246
|
+
return directories;
|
|
247
|
+
}
|
|
248
|
+
/** Whether the frontend build scans a declared directory: inside the module and outside `app/build/`, as `@antelopejs/dms-frontend` decides. */
|
|
249
|
+
function isScanned(directory) {
|
|
250
|
+
const path = posix.normalize(directory.split("\\").join("/"));
|
|
251
|
+
return !isAbsolute(directory) && path !== ".." && !path.startsWith("../") && !PRIVATE_DIRECTORY.test(path);
|
|
252
|
+
}
|
|
253
|
+
function scannedFiles(moduleRoot, directories) {
|
|
254
|
+
const files = /* @__PURE__ */ new Set();
|
|
255
|
+
for (const directory of directories.filter(isScanned)) for (const file of globSync(`${directory}/**/*`, { cwd: moduleRoot })) {
|
|
256
|
+
const path = file.split("\\").join("/");
|
|
257
|
+
if (SCANNED_FILE.test(path) && !PRIVATE_DIRECTORY.test(path) && !path.split("/").includes("node_modules") && statSync(join(moduleRoot, path)).isFile()) files.add(join(moduleRoot, path));
|
|
258
|
+
}
|
|
259
|
+
return [...files].sort();
|
|
260
|
+
}
|
|
261
|
+
/** The `#<layer>/*` specifiers the frontend workspace maps to each `layers/<layer>` directory. */
|
|
262
|
+
function layerPaths(moduleRoot) {
|
|
263
|
+
const layers = join(moduleRoot, "layers");
|
|
264
|
+
if (!existsSync(layers)) return {};
|
|
265
|
+
return Object.fromEntries(readdirSync(layers, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => [`#${entry.name}/*`, [join(layers, entry.name, "*")]]));
|
|
266
|
+
}
|
|
267
|
+
function compilerOptions(compiler, moduleRoot) {
|
|
268
|
+
const paths = layerPaths(moduleRoot);
|
|
269
|
+
const config = join(moduleRoot, "tsconfig.json");
|
|
270
|
+
const scan = {
|
|
271
|
+
noEmit: true,
|
|
272
|
+
allowJs: true,
|
|
273
|
+
skipLibCheck: true
|
|
274
|
+
};
|
|
275
|
+
if (existsSync(config)) {
|
|
276
|
+
const read = compiler.readConfigFile(config, compiler.sys.readFile);
|
|
277
|
+
const parsed = compiler.parseJsonConfigFileContent(read.config ?? {}, compiler.sys, moduleRoot);
|
|
278
|
+
return {
|
|
279
|
+
...parsed.options,
|
|
280
|
+
...scan,
|
|
281
|
+
paths: parsed.options.paths ?? paths
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
...scan,
|
|
286
|
+
target: compiler.ScriptTarget.ESNext,
|
|
287
|
+
module: compiler.ModuleKind.ESNext,
|
|
288
|
+
moduleResolution: compiler.ModuleResolutionKind.Bundler,
|
|
289
|
+
strict: true,
|
|
290
|
+
allowImportingTsExtensions: true,
|
|
291
|
+
resolveJsonModule: true,
|
|
292
|
+
types: [],
|
|
293
|
+
paths
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
const FORMAT_FLAGS = (compiler) => compiler.TypeFormatFlags.NoTruncation | compiler.TypeFormatFlags.UseStructuralFallback | compiler.TypeFormatFlags.WriteTypeArgumentsOfSignature;
|
|
297
|
+
/** Prints a type the way the declaration half compares bundles: members and union constituents in canonical order, on one line. */
|
|
298
|
+
function canonical(compiler, text) {
|
|
299
|
+
return normalizeBundle(compiler, `type Surface = ${text};`).replace(/^type Surface = /u, "").replace(/;\s*$/u, "").replace(/\s+/gu, " ").replaceAll("[ ", "[").replaceAll(" ]", "]");
|
|
300
|
+
}
|
|
301
|
+
function memberList(compiler, checker, type, location) {
|
|
302
|
+
const flags = FORMAT_FLAGS(compiler);
|
|
303
|
+
const print = (value) => checker.typeToString(value, void 0, flags);
|
|
304
|
+
return `{ ${[
|
|
305
|
+
...checker.getSignaturesOfType(type, compiler.SignatureKind.Call).map((signature) => checker.signatureToString(signature, void 0, flags, compiler.SignatureKind.Call)),
|
|
306
|
+
...checker.getSignaturesOfType(type, compiler.SignatureKind.Construct).map((signature) => checker.signatureToString(signature, void 0, flags, compiler.SignatureKind.Construct)),
|
|
307
|
+
...checker.getIndexInfosOfType(type).map((info) => `${info.isReadonly ? "readonly " : ""}[key: ${print(info.keyType)}]: ${print(info.type)}`),
|
|
308
|
+
...checker.getPropertiesOfType(type).map((property) => {
|
|
309
|
+
const declaration = property.valueDeclaration;
|
|
310
|
+
const readonly = declaration !== void 0 && (compiler.getCombinedModifierFlags(declaration) & compiler.ModifierFlags.Readonly) !== 0;
|
|
311
|
+
const optional = (property.flags & compiler.SymbolFlags.Optional) !== 0;
|
|
312
|
+
return `${readonly ? "readonly " : ""}${JSON.stringify(property.name)}${optional ? "?" : ""}: ${print(checker.getTypeOfSymbolAtLocation(property, location))}`;
|
|
313
|
+
})
|
|
314
|
+
].join("; ")} }`;
|
|
315
|
+
}
|
|
316
|
+
function typeParameters(compiler, checker, declaration) {
|
|
317
|
+
if (declaration === void 0 || !(compiler.isTypeAliasDeclaration(declaration) || compiler.isInterfaceDeclaration(declaration) || compiler.isClassDeclaration(declaration)) || declaration.typeParameters === void 0) return "";
|
|
318
|
+
const flags = FORMAT_FLAGS(compiler);
|
|
319
|
+
const print = (node) => checker.typeToString(checker.getTypeFromTypeNode(node), void 0, flags);
|
|
320
|
+
return `<${declaration.typeParameters.map((parameter) => `${parameter.name.text}${parameter.constraint === void 0 ? "" : ` extends ${print(parameter.constraint)}`}${parameter.default === void 0 ? "" : ` = ${print(parameter.default)}`}`).join(", ")}>`;
|
|
321
|
+
}
|
|
322
|
+
/** One line per meaning of an auto-imported name: its value's type and, for a type, its declared structure. */
|
|
323
|
+
function describe(compiler, checker, name, exported, source) {
|
|
324
|
+
const symbol = (exported.flags & compiler.SymbolFlags.Alias) !== 0 ? checker.getAliasedSymbol(exported) : exported;
|
|
325
|
+
const declaration = symbol.valueDeclaration ?? symbol.declarations?.[0];
|
|
326
|
+
const location = declaration ?? source;
|
|
327
|
+
const flags = FORMAT_FLAGS(compiler);
|
|
328
|
+
const lines = [];
|
|
329
|
+
const structured = compiler.SymbolFlags.Class | compiler.SymbolFlags.Enum | compiler.SymbolFlags.ValueModule;
|
|
330
|
+
if ((symbol.flags & compiler.SymbolFlags.Value) !== 0) {
|
|
331
|
+
const type = checker.getTypeOfSymbolAtLocation(symbol, location);
|
|
332
|
+
const text = (symbol.flags & structured) !== 0 ? memberList(compiler, checker, type, location) : checker.typeToString(type, void 0, flags);
|
|
333
|
+
lines.push(`${name} (value): ${canonical(compiler, text)}`);
|
|
334
|
+
}
|
|
335
|
+
if ((symbol.flags & compiler.SymbolFlags.Type) !== 0 && (symbol.flags & compiler.SymbolFlags.Enum) === 0) {
|
|
336
|
+
const type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
337
|
+
const text = (symbol.flags & compiler.SymbolFlags.TypeAlias) !== 0 ? checker.typeToString(type, void 0, flags | compiler.TypeFormatFlags.InTypeAlias) : memberList(compiler, checker, type, location);
|
|
338
|
+
lines.push(`${name} (type)${typeParameters(compiler, checker, declaration)}: ${canonical(compiler, text)}`);
|
|
339
|
+
}
|
|
340
|
+
return lines;
|
|
341
|
+
}
|
|
342
|
+
/** The auto-import surface of one frontend module: one sorted line per name and meaning that unimport would expose from its scanned files. Exports are read with the module's compiler, so `export *` and inferred types resolve as the frontend workspace types them. */
|
|
343
|
+
function moduleSurface(worktree, directory) {
|
|
344
|
+
const moduleRoot = join(worktree, directory);
|
|
345
|
+
const { compiler, notice } = loadTypeScript(moduleRoot);
|
|
346
|
+
const files = scannedFiles(moduleRoot, declaredDirectories(compiler, join(moduleRoot, BUILD_FILE), posix.join(directory, BUILD_FILE)));
|
|
347
|
+
const options = compilerOptions(compiler, moduleRoot);
|
|
348
|
+
const presets = presetModules(compiler, moduleRoot, options);
|
|
349
|
+
const plain = compiler.createProgram([...files, ...presets.map(({ file }) => file)], options);
|
|
350
|
+
const scanned = new Map(files.flatMap((file) => {
|
|
351
|
+
const source = plain.getSourceFile(file);
|
|
352
|
+
return source === void 0 ? [] : [[source.fileName, source]];
|
|
353
|
+
}));
|
|
354
|
+
const sources = [...presets.flatMap(({ file, specifier }) => {
|
|
355
|
+
const source = plain.getSourceFile(file);
|
|
356
|
+
return source === void 0 ? [] : [{
|
|
357
|
+
source,
|
|
358
|
+
specifier
|
|
359
|
+
}];
|
|
360
|
+
}), ...[...scanned.values()].map((source) => ({
|
|
361
|
+
source,
|
|
362
|
+
specifier: sourceSpecifier(source.fileName)
|
|
363
|
+
}))];
|
|
364
|
+
const imports = autoImports(plain.getTypeChecker(), sources);
|
|
365
|
+
const program = compiler.createProgram(files, options, injectingHost(compiler, options, scanned, imports));
|
|
366
|
+
const checker = program.getTypeChecker();
|
|
367
|
+
const lines = /* @__PURE__ */ new Set();
|
|
368
|
+
for (const file of files) {
|
|
369
|
+
const source = program.getSourceFile(file);
|
|
370
|
+
if (source === void 0) continue;
|
|
371
|
+
for (const { name, symbol } of exportedNames(checker, source)) for (const line of describe(compiler, checker, name, symbol, source)) lines.add(line.split(worktree).join("<root>"));
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
lines: [...lines].sort(),
|
|
375
|
+
notice
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
/** Compares the names and signatures each DMS frontend module auto-imports (the exports of the directories its `dms.frontend.build.ts` declares, without `app/build/`) at the base and at committed HEAD. Undefined when neither revision has a frontend module. */
|
|
379
|
+
function autoImportDiff(root, baseRef) {
|
|
380
|
+
if ([baseRef, "HEAD"].every((ref) => moduleRoots(root, resolveRevision(root, ref)).length === 0)) return void 0;
|
|
381
|
+
const notices = /* @__PURE__ */ new Set();
|
|
382
|
+
const result = compareRevisions(root, baseRef, "Auto-imports", (worktree, output) => {
|
|
383
|
+
const directories = moduleRoots(worktree, "HEAD");
|
|
384
|
+
let entries = 0;
|
|
385
|
+
for (const directory of directories) {
|
|
386
|
+
const { lines, notice } = moduleSurface(worktree, directory);
|
|
387
|
+
if (notice !== void 0) notices.add(notice);
|
|
388
|
+
const path = join(output, directory === "." ? "_root" : directory, "auto-imports.txt");
|
|
389
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
390
|
+
writeFileSync(path, lines.map((line) => `${line}\n`).join(""));
|
|
391
|
+
entries += lines.length;
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
packages: directories,
|
|
395
|
+
entries
|
|
396
|
+
};
|
|
397
|
+
});
|
|
398
|
+
return {
|
|
399
|
+
different: result.different,
|
|
400
|
+
output: `${result.output}${result.different ? HINT : ""}${[...notices].sort().join("")}`
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region src/guardrails/declaration-bundle.ts
|
|
405
|
+
const ENTRIES_PER_WORKER = 16;
|
|
406
|
+
const MAX_WORKERS = 8;
|
|
407
|
+
const MIB = 1024 ** 2;
|
|
408
|
+
const WORKER_MEMORY = 1536 * MIB;
|
|
409
|
+
/** Node options that keep a worker inside `WORKER_MEMORY`: the old-space cap leaves room for the memory V8 holds outside the heap, so a worker's resident size stays under the budget that `workerCount` assumes. */
|
|
410
|
+
const WORKER_NODE_ARGS = [`--max-old-space-size=${(WORKER_MEMORY - 256 * MIB) / MIB}`];
|
|
411
|
+
const WORKER = `
|
|
412
|
+
const { readFileSync, writeFileSync } = require("node:fs");
|
|
413
|
+
const { createRequire } = require("node:module");
|
|
414
|
+
try {
|
|
415
|
+
const job = JSON.parse(readFileSync(process.argv[2], "utf8"));
|
|
416
|
+
const generate = createRequire(job.loader)("dts-bundle-generator").generateDtsBundle;
|
|
417
|
+
writeFileSync(job.result, JSON.stringify(generate(job.entries, job.options)));
|
|
418
|
+
} catch (error) {
|
|
419
|
+
process.stderr.write(String(error instanceof Error ? error.message : error));
|
|
420
|
+
process.exit(1);
|
|
421
|
+
}
|
|
422
|
+
`;
|
|
423
|
+
const DRIVER = `
|
|
424
|
+
const { spawn } = require("node:child_process");
|
|
425
|
+
const [flags, worker, ...jobs] = process.argv.slice(1);
|
|
426
|
+
let failed = false;
|
|
427
|
+
let pending = jobs.length;
|
|
428
|
+
for (const job of jobs) {
|
|
429
|
+
spawn(process.execPath, [...JSON.parse(flags), worker, job], { stdio: ["ignore", "inherit", "inherit"] }).on("exit", (code) => {
|
|
430
|
+
failed ||= code !== 0;
|
|
431
|
+
pending -= 1;
|
|
432
|
+
if (pending === 0) process.exit(failed ? 1 : 0);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
`;
|
|
436
|
+
/** Places a copy of `dts-bundle-generator` beside a `typescript` link to the package at `compilerRoot`, the compiler the target repository builds with. The generator requires `typescript` by name, so this makes it drive that compiler instead of the one it was installed with. Returns a path to require the copy from. */
|
|
437
|
+
function installGenerator(compilerRoot, scratch) {
|
|
438
|
+
const source = dirname(createRequire(import.meta.url).resolve("dts-bundle-generator/package.json"));
|
|
439
|
+
const modules = join(scratch, "generator", "node_modules");
|
|
440
|
+
mkdirSync(modules, { recursive: true });
|
|
441
|
+
cpSync(source, join(modules, "dts-bundle-generator"), {
|
|
442
|
+
recursive: true,
|
|
443
|
+
filter: (path) => basename(path) !== "node_modules"
|
|
444
|
+
});
|
|
445
|
+
symlinkSync(compilerRoot, join(modules, "typescript"), DIRECTORY_LINK);
|
|
446
|
+
return join(modules, "index.js");
|
|
447
|
+
}
|
|
448
|
+
/** Workers for `count` entries: each builds its own program, so a worker needs enough entries to repay that, and the bound keeps their combined heap inside the memory that is free. */
|
|
449
|
+
function workerCount(count, cpus = availableParallelism(), free = freemem()) {
|
|
450
|
+
return Math.max(1, Math.min(Math.floor(count / ENTRIES_PER_WORKER), cpus, MAX_WORKERS, Math.floor(free / WORKER_MEMORY)));
|
|
451
|
+
}
|
|
452
|
+
function generateInWorkers(loader, directory, entries, options, workers) {
|
|
453
|
+
const jobs = Array.from({ length: workers }, (_, worker) => ({
|
|
454
|
+
indices: entries.flatMap((_entry, index) => index % workers === worker ? [index] : []),
|
|
455
|
+
file: join(directory, `job-${worker}.json`),
|
|
456
|
+
result: join(directory, `result-${worker}.json`)
|
|
457
|
+
}));
|
|
458
|
+
for (const { indices, file, result } of jobs) writeFileSync(file, JSON.stringify({
|
|
459
|
+
loader,
|
|
460
|
+
result,
|
|
461
|
+
options,
|
|
462
|
+
entries: indices.map((index) => entries[index])
|
|
463
|
+
}));
|
|
464
|
+
const worker = join(directory, "worker.cjs");
|
|
465
|
+
writeFileSync(worker, WORKER);
|
|
466
|
+
const run = spawnSync(process.execPath, [
|
|
467
|
+
"-e",
|
|
468
|
+
DRIVER,
|
|
469
|
+
JSON.stringify(WORKER_NODE_ARGS),
|
|
470
|
+
worker,
|
|
471
|
+
...jobs.map(({ file }) => file)
|
|
472
|
+
], {
|
|
473
|
+
encoding: "utf8",
|
|
474
|
+
stdio: [
|
|
475
|
+
"ignore",
|
|
476
|
+
"ignore",
|
|
477
|
+
"pipe"
|
|
478
|
+
]
|
|
479
|
+
});
|
|
480
|
+
if (run.error) throw run.error;
|
|
481
|
+
if (run.status !== 0) throw new Error(run.stderr || "A declaration bundling worker failed.");
|
|
482
|
+
const bundles = [];
|
|
483
|
+
for (const { indices, result } of jobs) for (const [position, bundle] of JSON.parse(readFileSync(result, "utf8")).entries()) bundles[indices[position]] = bundle;
|
|
484
|
+
return bundles;
|
|
485
|
+
}
|
|
486
|
+
/** Bundles every entry's declarations with the compiler at `compilerRoot`. Large packages are split across worker processes by entry; each bundle depends only on its own entry, so the output is the same as one sequential call. */
|
|
487
|
+
function bundleDeclarations(compilerRoot, scratch, entries, options, workers = workerCount(entries.length)) {
|
|
488
|
+
const loader = installGenerator(compilerRoot, scratch);
|
|
489
|
+
if (workers > 1) return generateInWorkers(loader, join(scratch, "generator"), entries, options, workers);
|
|
490
|
+
const generate = createRequire(loader)("dts-bundle-generator").generateDtsBundle;
|
|
491
|
+
return generate(entries, options);
|
|
492
|
+
}
|
|
493
|
+
//#endregion
|
|
192
494
|
//#region src/guardrails/test-entries.ts
|
|
193
495
|
/** The line a proof half prints for a published test-helper entry it leaves out, so a skip is reported rather than silent. */
|
|
194
496
|
function testEntryNotice(half, directory, target) {
|
|
@@ -200,7 +502,7 @@ const DESCRIBE = `
|
|
|
200
502
|
const { readFileSync, existsSync } = require("node:fs");
|
|
201
503
|
const { dirname, join, extname } = require("node:path");
|
|
202
504
|
const { pathToFileURL } = require("node:url");
|
|
203
|
-
const file = process.argv[
|
|
505
|
+
const file = process.argv[2];
|
|
204
506
|
let directory = dirname(file);
|
|
205
507
|
while (!existsSync(join(directory, "package.json")) && dirname(directory) !== directory) directory = dirname(directory);
|
|
206
508
|
const manifest = existsSync(join(directory, "package.json")) ? JSON.parse(readFileSync(join(directory, "package.json"), "utf8")) : {};
|
|
@@ -236,9 +538,9 @@ function properties(object, observe) {
|
|
|
236
538
|
function runtimeTargets(target, entry = "exports", subpath = ".") {
|
|
237
539
|
if (target == null) return [];
|
|
238
540
|
if (Array.isArray(target)) return target.flatMap((value, index) => runtimeTargets(value, `${entry}/${index}`, subpath));
|
|
239
|
-
if (target
|
|
541
|
+
if (isExportPath(target)) return [{
|
|
240
542
|
entry,
|
|
241
|
-
target
|
|
543
|
+
target,
|
|
242
544
|
subpath
|
|
243
545
|
}];
|
|
244
546
|
return Object.entries(target).flatMap(([key, value]) => {
|
|
@@ -315,7 +617,7 @@ function childJson(args, cwd) {
|
|
|
315
617
|
if (result.status !== 0) throw new Error(result.stderr || `Runtime child exited with ${result.status ?? result.signal}.`);
|
|
316
618
|
return `${JSON.stringify(JSON.parse(result.stdout), null, 2)}\n`;
|
|
317
619
|
}
|
|
318
|
-
function buildPackage(directory, output, manifest) {
|
|
620
|
+
function buildPackage(directory, output, manifest, describe) {
|
|
319
621
|
const buildManifest = parseManifest(readFileSync(join(directory, "package.json"), "utf8"));
|
|
320
622
|
if (buildManifest.scripts?.build) execFileSync(packageManager(buildManifest), ["run", "build"], {
|
|
321
623
|
cwd: directory,
|
|
@@ -342,11 +644,7 @@ function buildPackage(directory, output, manifest) {
|
|
|
342
644
|
const { entries, skipped } = built;
|
|
343
645
|
for (const { entry, file } of entries) {
|
|
344
646
|
const destination = join(output, `${encodeURIComponent(entry)}.json`);
|
|
345
|
-
const metadata = childJson([
|
|
346
|
-
"-e",
|
|
347
|
-
DESCRIBE,
|
|
348
|
-
file
|
|
349
|
-
], directory);
|
|
647
|
+
const metadata = childJson([describe, file], directory);
|
|
350
648
|
mkdirSync(dirname(destination), { recursive: true });
|
|
351
649
|
writeFileSync(destination, metadata);
|
|
352
650
|
}
|
|
@@ -366,10 +664,13 @@ function runtimeDiff(root, baseRef, probe, policy) {
|
|
|
366
664
|
const packages = packagesAt(worktree, true);
|
|
367
665
|
const published = [];
|
|
368
666
|
let entries = 0;
|
|
667
|
+
mkdirSync(scratch, { recursive: true });
|
|
668
|
+
const describe = join(scratch, "describe.cjs");
|
|
669
|
+
writeFileSync(describe, DESCRIBE);
|
|
369
670
|
for (const { directory, manifest } of packages) {
|
|
370
671
|
const folder = encodeURIComponent(directory).replaceAll(".", "%2E");
|
|
371
672
|
try {
|
|
372
|
-
const built = buildPackage(join(worktree, directory), join(output, folder), manifest);
|
|
673
|
+
const built = buildPackage(join(worktree, directory), join(output, folder), manifest, describe);
|
|
373
674
|
if (built === void 0) skippedPackages.add(directory);
|
|
374
675
|
else {
|
|
375
676
|
entries += built.count;
|
|
@@ -390,7 +691,6 @@ function runtimeDiff(root, baseRef, probe, policy) {
|
|
|
390
691
|
force: true
|
|
391
692
|
});
|
|
392
693
|
if (probe !== void 0) {
|
|
393
|
-
mkdirSync(scratch, { recursive: true });
|
|
394
694
|
const script = join(scratch, "probe.cjs");
|
|
395
695
|
writeFileSync(script, probe);
|
|
396
696
|
writeFileSync(join(output, "probe.json"), childJson([script, worktree], worktree));
|
|
@@ -415,7 +715,7 @@ function entryPattern(value) {
|
|
|
415
715
|
return value.split("*").map(entrySegment).join("*");
|
|
416
716
|
}
|
|
417
717
|
function exportTargets(target, entry = "exports/root", subpath = ".") {
|
|
418
|
-
if (
|
|
718
|
+
if (isExportPath(target)) return [{
|
|
419
719
|
entry,
|
|
420
720
|
target,
|
|
421
721
|
subpath
|
|
@@ -462,6 +762,15 @@ function entryPatterns(manifest) {
|
|
|
462
762
|
function targetPattern(target) {
|
|
463
763
|
return new RegExp(`^${target.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")).join("(.*)")}$`, "u");
|
|
464
764
|
}
|
|
765
|
+
/** A published target outside the build output is no compiler emit; the package's own declaration at that path stands for it. */
|
|
766
|
+
function authoredDeclaration(directory, target, path, scratch) {
|
|
767
|
+
const source = resolve(directory, target);
|
|
768
|
+
if (!path.startsWith("../") || path.includes("*") || !existsSync(source)) return void 0;
|
|
769
|
+
const file = `.published/${relative(directory, source).split("\\").join("/")}`;
|
|
770
|
+
mkdirSync(dirname(join(scratch, file)), { recursive: true });
|
|
771
|
+
copyFileSync(source, join(scratch, file));
|
|
772
|
+
return file;
|
|
773
|
+
}
|
|
465
774
|
function publishedEntries(directory, manifest, emitted, scratch) {
|
|
466
775
|
const outputRoot = resolve(directory, emitted.options.outDir ?? ".");
|
|
467
776
|
const files = emitted.files.map((file) => relative(scratch, file).split("\\").join("/"));
|
|
@@ -475,6 +784,10 @@ function publishedEntries(directory, manifest, emitted, scratch) {
|
|
|
475
784
|
const path = relative(outputRoot, resolve(directory, target)).split("\\").join("/");
|
|
476
785
|
const pattern = targetPattern(path);
|
|
477
786
|
const found = files.filter((file) => pattern.test(file));
|
|
787
|
+
if (!found.length) {
|
|
788
|
+
const authored = authoredDeclaration(directory, target, path, scratch);
|
|
789
|
+
if (authored !== void 0) found.push(authored);
|
|
790
|
+
}
|
|
478
791
|
if (!found.length && !path.includes("*")) throw new Error(`${directory}: published target ${target} has no emitted declaration.`);
|
|
479
792
|
const matches = found.filter((file) => !isTestSource(outputRoot, join(outputRoot, file)));
|
|
480
793
|
if (matches.length < found.length) skipped.push(target);
|
|
@@ -610,26 +923,36 @@ function declarationDiff(root, baseRef, policy) {
|
|
|
610
923
|
output: (errors.size > 0 && !result.different ? result.output.replace(/^API:[^\n]*\n/u, "API: comparison incomplete due to execution errors.\n") : result.output) + [...unpublished].sort(([a], [b]) => a.localeCompare(b)).map(([directory, reason]) => `API: skipped ${directory}, ${reason}.\n`).join("") + [...skippedTests].sort().join("") + [...notices].sort().join("") + [...errors].join("")
|
|
611
924
|
};
|
|
612
925
|
}
|
|
613
|
-
/** Compares declarations
|
|
926
|
+
/** Compares declarations, built runtime exports and the auto-import surface of DMS frontend modules, with an optional behavioral probe captured before either build. Added entries whose subpath matches an `allowAdded` glob pass when their module is `@internal`. */
|
|
614
927
|
function apiDiff(root, baseRef, probeFile, allowAdded = []) {
|
|
615
928
|
const policy = allowAdded.length ? createAddedPolicy(allowAdded) : void 0;
|
|
616
929
|
const probe = probeFile === void 0 ? void 0 : readFileSync(resolve(root, probeFile));
|
|
617
930
|
const results = [];
|
|
618
931
|
const errors = [];
|
|
619
|
-
for (const compare of [
|
|
620
|
-
|
|
932
|
+
for (const compare of [
|
|
933
|
+
() => declarationDiff(root, baseRef, policy),
|
|
934
|
+
() => runtimeDiff(root, baseRef, probe, policy),
|
|
935
|
+
() => autoImportDiff(root, baseRef)
|
|
936
|
+
]) try {
|
|
937
|
+
const result = compare();
|
|
938
|
+
if (result !== void 0) results.push(result);
|
|
621
939
|
} catch (error) {
|
|
622
940
|
errors.push(`Execution error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
623
941
|
}
|
|
942
|
+
const command = [
|
|
943
|
+
`antelopejs-api-diff ${baseRef}`,
|
|
944
|
+
...probeFile === void 0 ? [] : [`--probe ${probeFile}`],
|
|
945
|
+
...allowAdded.map((glob) => `--allow-added '${glob}'`)
|
|
946
|
+
].join(" ");
|
|
624
947
|
return {
|
|
625
948
|
different: errors.length > 0 || results.some((result) => result.different) || (policy?.problems.size ?? 0) > 0,
|
|
626
|
-
output: results.map((result) => result.output).join("") + (policy === void 0 ? "" : describeAllowance(policy)) + errors.join("") + (probe === void 0 ? "No behavioural probe ran.\n" : "Behavioural probe supplied.\n") + revisionCounts(root, baseRef)
|
|
949
|
+
output: stampProof(root, command, baseRef, results.map((result) => result.output).join("") + (policy === void 0 ? "" : describeAllowance(policy)) + errors.join("") + (probe === void 0 ? "No behavioural probe ran.\n" : "Behavioural probe supplied.\n") + revisionCounts(root, baseRef))
|
|
627
950
|
};
|
|
628
951
|
}
|
|
629
952
|
//#endregion
|
|
630
953
|
//#region src/bin/api-diff.ts
|
|
631
954
|
const USAGE = "Usage: antelopejs-api-diff <base-ref> [--probe <file.cjs>] [--allow-added <glob>]...";
|
|
632
|
-
function parse(args) {
|
|
955
|
+
function parse$1(args) {
|
|
633
956
|
try {
|
|
634
957
|
const { positionals, values } = parseArgs({
|
|
635
958
|
args,
|
|
@@ -652,7 +975,7 @@ function parse(args) {
|
|
|
652
975
|
}
|
|
653
976
|
}
|
|
654
977
|
runCli(() => {
|
|
655
|
-
const { baseRef, probe, "allow-added": allowAdded } = parse(process.argv.slice(2));
|
|
978
|
+
const { baseRef, probe, "allow-added": allowAdded } = parse$1(process.argv.slice(2));
|
|
656
979
|
const result = apiDiff(repositoryRoot(), baseRef, probe, allowAdded);
|
|
657
980
|
process.stdout.write(result.output);
|
|
658
981
|
return result.different ? 1 : 0;
|