@antelopejs/tooling-configs 0.6.0 → 0.7.0
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 +15 -15
- package/dist/{api-CCOiLN3w.mjs → api-BQLrI_S1.mjs} +19 -2
- package/dist/bin/body-check.mjs +1 -1
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/garden.mjs +9 -2
- package/dist/bin/ratchet.mjs +2 -2
- package/dist/bin/suppressions.mjs +7 -3
- package/dist/bin/sync.mjs +3 -3
- package/dist/bin/triage.mjs +1 -1
- package/dist/{checks-C_I0jCN4.mjs → checks-BefrkjiT.mjs} +350 -10
- package/dist/eslint.mjs +1 -1
- package/dist/{guardrails-C72rFG8J.mjs → guardrails-BfGwehVj.mjs} +480 -118
- package/dist/oxc/anti-slop/index.mjs +5 -4
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +1 -1
- package/dist/{oxlint-CCOJqj3d.mjs → oxlint-CkHhK5K_.mjs} +33 -11
- package/dist/{ratchet-qu2aLzQU.mjs → ratchet-2FeMs1kh.mjs} +1 -1
- package/package.json +1 -1
|
@@ -4,13 +4,14 @@ import { a as gitFiles, u as trackedManifests } from "./files-C-JJhExM.mjs";
|
|
|
4
4
|
import { n as workspaceDirectories } from "./docs-compat-CSljVi3O.mjs";
|
|
5
5
|
import { n as shimInvocation, t as runCommand } from "./run-command-BlFRPORx.mjs";
|
|
6
6
|
import { t as accepting } from "./ports-DAeEJsYh.mjs";
|
|
7
|
-
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { basename, dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
9
9
|
import { spawnSync } from "node:child_process";
|
|
10
|
-
import { isMap, isScalar, isSeq, parseAllDocuments, parseDocument } from "yaml";
|
|
10
|
+
import { isMap, isScalar, isSeq, parseAllDocuments, parseDocument, stringify } from "yaml";
|
|
11
11
|
import ts from "@typescript/typescript6";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
13
13
|
import { tmpdir } from "node:os";
|
|
14
|
+
import { gunzipSync } from "node:zlib";
|
|
14
15
|
import { satisfies, validRange } from "semver";
|
|
15
16
|
import { minimatch } from "minimatch";
|
|
16
17
|
//#region src/guardrails/run-pnpm.ts
|
|
@@ -326,6 +327,339 @@ async function checkGitIdentity(root, signal) {
|
|
|
326
327
|
return `The repository's git config sets a commit identity, so every checkout and agent sharing it commits as that identity:\n${shared.map((line) => ` ${line.split(" ").slice(1).join(" ")}\n`).join("")}Remove it with git config --local --unset-all user.name and git config --local --unset-all user.email (--worktree for a config.worktree), and set an identity with --global or per command with git -c.\n`;
|
|
327
328
|
}
|
|
328
329
|
//#endregion
|
|
330
|
+
//#region src/guardrails/published-entries.ts
|
|
331
|
+
/** The compiler options of the consumer: the strictest a consumer commonly sets, with every declaration file it loads checked. */
|
|
332
|
+
const CONSUMER_OPTIONS = {
|
|
333
|
+
module: "nodenext",
|
|
334
|
+
moduleResolution: "nodenext",
|
|
335
|
+
target: "esnext",
|
|
336
|
+
strict: true,
|
|
337
|
+
skipLibCheck: false,
|
|
338
|
+
noEmit: true,
|
|
339
|
+
types: ["node"]
|
|
340
|
+
};
|
|
341
|
+
/** The consumer files, an ES module that imports each entry and a CommonJS module that requires it, with the resolution mode TypeScript gives each. */
|
|
342
|
+
const CONSUMER_FILES = {
|
|
343
|
+
import: {
|
|
344
|
+
file: "consumer.mts",
|
|
345
|
+
mode: ts.ModuleKind.ESNext
|
|
346
|
+
},
|
|
347
|
+
require: {
|
|
348
|
+
file: "consumer.cts",
|
|
349
|
+
mode: ts.ModuleKind.CommonJS
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
const DECLARATION_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
353
|
+
ts.Extension.Dts,
|
|
354
|
+
ts.Extension.Dmts,
|
|
355
|
+
ts.Extension.Dcts
|
|
356
|
+
]);
|
|
357
|
+
const DECLARATION_FILE$1 = /\.d\.[cm]?ts$/;
|
|
358
|
+
/** An `exports` value that names declarations: a `types` condition or a `.d.ts`, `.d.mts` or `.d.cts` target. */
|
|
359
|
+
const NAMES_DECLARATIONS = /"types"\s*:|\.d\.[cm]?ts"/;
|
|
360
|
+
function isPath(target) {
|
|
361
|
+
return typeof target === "string";
|
|
362
|
+
}
|
|
363
|
+
/** Every path a subpath's value lists, under any condition. */
|
|
364
|
+
function targetPaths(target) {
|
|
365
|
+
if (target === null) return [];
|
|
366
|
+
if (isPath(target)) return [target];
|
|
367
|
+
return (Array.isArray(target) ? target : Object.values(target)).flatMap(targetPaths);
|
|
368
|
+
}
|
|
369
|
+
/** `exports` as a map of subpaths: a path, a list or a map of conditions stands for the `.` subpath. */
|
|
370
|
+
function subpaths(exports) {
|
|
371
|
+
if (exports === null || isPath(exports) || Array.isArray(exports)) return [[".", exports]];
|
|
372
|
+
const entries = Object.entries(exports);
|
|
373
|
+
return entries.every(([key]) => key.startsWith(".")) ? entries : [[".", exports]];
|
|
374
|
+
}
|
|
375
|
+
function patternMatcher(pattern) {
|
|
376
|
+
const [before = "", after = ""] = pattern.split("*");
|
|
377
|
+
const escape = (text) => text.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
378
|
+
return new RegExp(`^${escape(before)}(.+)${escape(after)}$`);
|
|
379
|
+
}
|
|
380
|
+
/** The subpaths a key stands for: itself, or, for a `*` key, one per shipped file a target of its value matches. */
|
|
381
|
+
function expanded(key, value, files) {
|
|
382
|
+
if (!key.includes("*")) return [key];
|
|
383
|
+
return targetPaths(value).flatMap((target) => {
|
|
384
|
+
const matcher = patternMatcher(target.replace(/^\.\//, ""));
|
|
385
|
+
return files.flatMap((file) => {
|
|
386
|
+
const star = matcher.exec(file)?.[1];
|
|
387
|
+
return star === void 0 ? [] : [key.replace("*", star)];
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
/** A specifier for each subpath of `exports`, with whether its value names declarations; a subpath naming a declaration file is left out, since no consumer imports one by name. */
|
|
392
|
+
function candidates(name, exports, files) {
|
|
393
|
+
const found = /* @__PURE__ */ new Map();
|
|
394
|
+
for (const [key, value] of subpaths(exports)) for (const subpath of expanded(key, value, files)) if (!DECLARATION_FILE$1.test(subpath)) found.set(`${name}${subpath.slice(1)}`, (found.get(`${name}${subpath.slice(1)}`) ?? false) || NAMES_DECLARATIONS.test(JSON.stringify(value)));
|
|
395
|
+
return found;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* The specifiers the consumer in `consumer` imports and requires from the package `name`, given the `files` it ships
|
|
399
|
+
* relative to its folder. Each `exports` subpath, a `*` subpath once per shipped file a target of it matches, is kept
|
|
400
|
+
* for a mode when TypeScript resolves it in that mode to a declaration file, or to JavaScript while its value names
|
|
401
|
+
* declarations, so a declaration file missing from the tarball fails. A subpath TypeScript does not resolve, such as one
|
|
402
|
+
* a `null` key hides or a stylesheet, is left out. A package without `exports` is imported by its bare name.
|
|
403
|
+
*/
|
|
404
|
+
function entrySpecifiers(name, exports, files, consumer) {
|
|
405
|
+
if (exports === void 0) return {
|
|
406
|
+
import: [name],
|
|
407
|
+
require: []
|
|
408
|
+
};
|
|
409
|
+
const { options } = ts.convertCompilerOptionsFromJson(CONSUMER_OPTIONS, consumer);
|
|
410
|
+
const found = [...candidates(name, exports, files)];
|
|
411
|
+
const kept = (mode) => found.flatMap(([specifier, namesDeclarations]) => {
|
|
412
|
+
const { resolvedModule } = ts.resolveModuleName(specifier, join(consumer, CONSUMER_FILES[mode].file), options, ts.sys, void 0, void 0, CONSUMER_FILES[mode].mode);
|
|
413
|
+
if (!resolvedModule) return [];
|
|
414
|
+
return DECLARATION_EXTENSIONS.has(resolvedModule.extension) || namesDeclarations ? [specifier] : [];
|
|
415
|
+
});
|
|
416
|
+
return {
|
|
417
|
+
import: kept("import"),
|
|
418
|
+
require: kept("require")
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/guardrails/published-types.ts
|
|
423
|
+
const DECLARATION_FILE = /\.d\.[cm]?ts$/;
|
|
424
|
+
/** An `exports` map that names declarations: a `types` condition or a `.d.ts`, `.d.mts` or `.d.cts` target. */
|
|
425
|
+
const TYPED_EXPORTS = /"types"\s*:|\.d\.[cm]?ts"/;
|
|
426
|
+
function declaresTypes(manifest) {
|
|
427
|
+
return manifest.types !== void 0 || manifest.typings !== void 0 || TYPED_EXPORTS.test(JSON.stringify(manifest.exports ?? null));
|
|
428
|
+
}
|
|
429
|
+
/** The root and workspace packages that are not `private`, with their manifests. */
|
|
430
|
+
function publicPackages(root) {
|
|
431
|
+
return ["", ...workspaceDirectories(root)].flatMap((directory) => {
|
|
432
|
+
const manifest = parseManifest(readFileSync(join(root, directory, "package.json"), "utf8"));
|
|
433
|
+
const { name } = manifest;
|
|
434
|
+
return name && manifest.private !== true ? [{
|
|
435
|
+
directory,
|
|
436
|
+
name,
|
|
437
|
+
manifest
|
|
438
|
+
}] : [];
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
/** The root and workspace packages that are not `private` and declare declarations through `types`, `typings` or `exports`. */
|
|
442
|
+
function typedPackages(root) {
|
|
443
|
+
return publicPackages(root).filter(({ manifest }) => declaresTypes(manifest)).map(({ directory, name }) => ({
|
|
444
|
+
directory,
|
|
445
|
+
name
|
|
446
|
+
}));
|
|
447
|
+
}
|
|
448
|
+
/** The arguments that install a consumer's dependencies without a lockfile and without running install scripts. */
|
|
449
|
+
const INSTALL_ARGUMENTS = {
|
|
450
|
+
pnpm: [
|
|
451
|
+
"install",
|
|
452
|
+
"--ignore-scripts",
|
|
453
|
+
"--prefer-offline",
|
|
454
|
+
"--no-frozen-lockfile"
|
|
455
|
+
],
|
|
456
|
+
npm: [
|
|
457
|
+
"install",
|
|
458
|
+
"--ignore-scripts",
|
|
459
|
+
"--prefer-offline",
|
|
460
|
+
"--no-audit",
|
|
461
|
+
"--no-fund"
|
|
462
|
+
]
|
|
463
|
+
};
|
|
464
|
+
/** The files under `directory`, relative to it with `/` separators, its `node_modules` left out. */
|
|
465
|
+
function shippedFiles(directory, prefix = "") {
|
|
466
|
+
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
467
|
+
const path = `${prefix}${entry.name}`;
|
|
468
|
+
if (entry.isDirectory()) return entry.name === "node_modules" ? [] : shippedFiles(join(directory, entry.name), `${path}/`);
|
|
469
|
+
return entry.isFile() ? [path] : [];
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
/** `output` with the consumer's own path and the package manager's store path before the package removed, so each error names the file as `<name>/<path>`. */
|
|
473
|
+
function readable(output, consumer, name) {
|
|
474
|
+
const store = new RegExp(String.raw`(?:node_modules/\.pnpm/[^/\s]+/)?node_modules/${name.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")}/`, "g");
|
|
475
|
+
return [consumer, consumer.replaceAll("\\", "/")].reduce((text, path) => text.split(`${path}/`).join(""), output).replace(store, `${name}/`);
|
|
476
|
+
}
|
|
477
|
+
const TAR_BLOCK = 512;
|
|
478
|
+
/** The text of the entry `path` in the gzipped tar archive `tarball`, read in Node so no `tar` binary, which differs across platforms, is needed. */
|
|
479
|
+
function tarEntry(tarball, path) {
|
|
480
|
+
const archive = gunzipSync(readFileSync(tarball));
|
|
481
|
+
for (let offset = 0; offset + TAR_BLOCK <= archive.length;) {
|
|
482
|
+
const header = archive.subarray(offset, offset + TAR_BLOCK);
|
|
483
|
+
const name = header.toString("utf8", 0, 100).replace(/\0.*$/s, "");
|
|
484
|
+
if (!name) return void 0;
|
|
485
|
+
const size = Number.parseInt(header.toString("utf8", 124, 136), 8) || 0;
|
|
486
|
+
const start = offset + TAR_BLOCK;
|
|
487
|
+
if (name === path) return archive.toString("utf8", start, start + size);
|
|
488
|
+
offset = start + Math.ceil(size / TAR_BLOCK) * TAR_BLOCK;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
function packedManifest(destination) {
|
|
492
|
+
const [file = ""] = readdirSync(destination);
|
|
493
|
+
const tarball = join(destination, file);
|
|
494
|
+
const text = tarEntry(tarball, "package/package.json");
|
|
495
|
+
return text === void 0 ? { failure: `${file} holds no package/package.json.\n` } : {
|
|
496
|
+
failure: "",
|
|
497
|
+
tarball,
|
|
498
|
+
manifest: parseManifest(text)
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
/** Packs the package `name` once per run, running its `prepack`, and reads the manifest its tarball holds. */
|
|
502
|
+
async function pack(run, name) {
|
|
503
|
+
const cached = run.packs.get(name);
|
|
504
|
+
if (cached) return cached;
|
|
505
|
+
const slot = String(run.packs.size);
|
|
506
|
+
const destination = join(run.scratch, "tarballs", slot);
|
|
507
|
+
mkdirSync(destination, { recursive: true });
|
|
508
|
+
const result = await runCommand(run.manager, [
|
|
509
|
+
"pack",
|
|
510
|
+
"--pack-destination",
|
|
511
|
+
destination
|
|
512
|
+
], {
|
|
513
|
+
cwd: join(run.root, run.members.get(name) ?? ""),
|
|
514
|
+
signal: run.signal
|
|
515
|
+
});
|
|
516
|
+
const packed = result.status === 0 ? packedManifest(destination) : { failure: `Packing ${name} failed:\n${result.output}` };
|
|
517
|
+
run.packs.set(name, packed);
|
|
518
|
+
return packed;
|
|
519
|
+
}
|
|
520
|
+
function dependencyNames(manifest) {
|
|
521
|
+
return [
|
|
522
|
+
manifest.dependencies,
|
|
523
|
+
manifest.optionalDependencies,
|
|
524
|
+
manifest.peerDependencies
|
|
525
|
+
].flatMap((ranges) => Object.keys(ranges ?? {}));
|
|
526
|
+
}
|
|
527
|
+
/** The tarball of each package of the repository that `name`'s packed manifest depends on, directly or through another such package, by name. */
|
|
528
|
+
async function siblingTarballs(run, name, manifest) {
|
|
529
|
+
const tarballs = /* @__PURE__ */ new Map();
|
|
530
|
+
const pending = [manifest];
|
|
531
|
+
for (let next = pending.pop(); next; next = pending.pop()) for (const dependency of dependencyNames(next)) {
|
|
532
|
+
if (dependency === name || tarballs.has(dependency)) continue;
|
|
533
|
+
if (!run.members.has(dependency)) continue;
|
|
534
|
+
const sibling = await pack(run, dependency);
|
|
535
|
+
if (!("tarball" in sibling)) return {
|
|
536
|
+
failure: sibling.failure,
|
|
537
|
+
tarballs
|
|
538
|
+
};
|
|
539
|
+
tarballs.set(dependency, `file:${sibling.tarball}`);
|
|
540
|
+
pending.push(sibling.manifest);
|
|
541
|
+
}
|
|
542
|
+
return {
|
|
543
|
+
failure: "",
|
|
544
|
+
tarballs
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
/** Writes the consumer's `package.json`, and for pnpm its `pnpm-workspace.yaml` in block style, which pnpm edits when it records a setting, so each sibling resolves to its tarball wherever it is required. */
|
|
548
|
+
function writeConsumer(consumer, manager, dependencies, overrides) {
|
|
549
|
+
const manifest = {
|
|
550
|
+
name: "published-types-consumer",
|
|
551
|
+
private: true,
|
|
552
|
+
dependencies
|
|
553
|
+
};
|
|
554
|
+
writeFileSync(join(consumer, "package.json"), JSON.stringify(manager === "npm" ? {
|
|
555
|
+
...manifest,
|
|
556
|
+
overrides
|
|
557
|
+
} : {
|
|
558
|
+
...manifest,
|
|
559
|
+
pnpm: { overrides }
|
|
560
|
+
}));
|
|
561
|
+
if (manager === "pnpm") writeFileSync(join(consumer, "pnpm-workspace.yaml"), stringify({
|
|
562
|
+
packages: ["."],
|
|
563
|
+
overrides
|
|
564
|
+
}));
|
|
565
|
+
}
|
|
566
|
+
async function typecheck(run, consumer, typed, manifest) {
|
|
567
|
+
const installed = realpathSync(join(consumer, "node_modules", typed.name));
|
|
568
|
+
const files = shippedFiles(installed);
|
|
569
|
+
const entries = entrySpecifiers(typed.name, manifest.exports, files, consumer);
|
|
570
|
+
const lines = {
|
|
571
|
+
import: entries.import.map((specifier, index) => `import type * as entry${index} from ${JSON.stringify(specifier)};\n`),
|
|
572
|
+
require: entries.require.map((specifier, index) => `import entry${index} = require(${JSON.stringify(specifier)});\n`)
|
|
573
|
+
};
|
|
574
|
+
const written = ["import", "require"].flatMap((mode) => {
|
|
575
|
+
if (!lines[mode].length) return [];
|
|
576
|
+
const { file } = CONSUMER_FILES[mode];
|
|
577
|
+
writeFileSync(join(consumer, file), lines[mode].join(""));
|
|
578
|
+
return [file];
|
|
579
|
+
});
|
|
580
|
+
const deep = manifest.exports === void 0 ? files.filter((file) => DECLARATION_FILE.test(file)).map((file) => relative(consumer, join(installed, file))) : [];
|
|
581
|
+
writeFileSync(join(consumer, "tsconfig.json"), JSON.stringify({
|
|
582
|
+
compilerOptions: CONSUMER_OPTIONS,
|
|
583
|
+
files: [...written, ...deep]
|
|
584
|
+
}));
|
|
585
|
+
const typescript = join(consumer, "node_modules", "typescript");
|
|
586
|
+
const { bin } = parseManifest(readFileSync(join(typescript, "package.json"), "utf8"));
|
|
587
|
+
const tsc = await runCommand(process.execPath, [
|
|
588
|
+
join(typescript, bin?.tsc ?? "bin/tsc"),
|
|
589
|
+
"-p",
|
|
590
|
+
".",
|
|
591
|
+
"--pretty",
|
|
592
|
+
"false"
|
|
593
|
+
], {
|
|
594
|
+
cwd: consumer,
|
|
595
|
+
signal: run.signal,
|
|
596
|
+
shell: false
|
|
597
|
+
});
|
|
598
|
+
return tsc.status === 0 ? "" : readable(tsc.output, consumer, typed.name);
|
|
599
|
+
}
|
|
600
|
+
async function consumerErrors(run, typed, slot) {
|
|
601
|
+
const packed = await pack(run, typed.name);
|
|
602
|
+
if (!("tarball" in packed)) return packed.failure;
|
|
603
|
+
const siblings = await siblingTarballs(run, typed.name, packed.manifest);
|
|
604
|
+
if (siblings.failure) return siblings.failure;
|
|
605
|
+
const consumer = join(run.scratch, `consumer-${slot}`);
|
|
606
|
+
mkdirSync(consumer);
|
|
607
|
+
const overrides = {
|
|
608
|
+
...Object.fromEntries(siblings.tarballs),
|
|
609
|
+
[typed.name]: `file:${packed.tarball}`
|
|
610
|
+
};
|
|
611
|
+
writeConsumer(consumer, run.manager, {
|
|
612
|
+
typescript: "latest",
|
|
613
|
+
"@types/node": "latest",
|
|
614
|
+
...packed.manifest.peerDependencies,
|
|
615
|
+
...overrides
|
|
616
|
+
}, overrides);
|
|
617
|
+
const install = await runCommand(run.manager, INSTALL_ARGUMENTS[run.manager], {
|
|
618
|
+
cwd: consumer,
|
|
619
|
+
signal: run.signal
|
|
620
|
+
});
|
|
621
|
+
if (install.status !== 0) return `Installing the tarball failed:\n${install.output}`;
|
|
622
|
+
return typecheck(run, consumer, typed, packed.manifest);
|
|
623
|
+
}
|
|
624
|
+
function packsWithPnpmOrNpm(manager) {
|
|
625
|
+
return manager === "pnpm" || manager === "npm";
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Packs each package `typedPackages` finds, running its `prepack`, and installs the tarball alone in a scratch
|
|
629
|
+
* directory with its peers, optional ones included, `typescript` and `@types/node` at the latest version unless it
|
|
630
|
+
* names them as peers, and the tarball of each package of the repository it depends on in place of the registry's.
|
|
631
|
+
* Then runs `tsc` with `skipLibCheck` off over a consumer file importing each entry its `exports` names, or, without
|
|
632
|
+
* `exports`, the package itself and every declaration file it ships. Returns what failed, each package's errors under
|
|
633
|
+
* its `package.json`, empty when every package passed.
|
|
634
|
+
*/
|
|
635
|
+
async function checkPublishedTypes(root, signal) {
|
|
636
|
+
const manager = packageManager(parseManifest(readFileSync(join(root, "package.json"), "utf8")));
|
|
637
|
+
if (!packsWithPnpmOrNpm(manager)) return `This check packs with pnpm or npm, not ${manager}.\n`;
|
|
638
|
+
const scratch = realpathSync.native(mkdtempSync(join(tmpdir(), "published-types-")));
|
|
639
|
+
const run = {
|
|
640
|
+
root,
|
|
641
|
+
manager,
|
|
642
|
+
scratch,
|
|
643
|
+
signal,
|
|
644
|
+
members: new Map(publicPackages(root).map(({ name, directory }) => [name, directory])),
|
|
645
|
+
packs: /* @__PURE__ */ new Map()
|
|
646
|
+
};
|
|
647
|
+
let failures = "";
|
|
648
|
+
try {
|
|
649
|
+
for (const [slot, typed] of typedPackages(root).entries()) {
|
|
650
|
+
if (signal?.aborted) break;
|
|
651
|
+
const failure = await consumerErrors(run, typed, slot);
|
|
652
|
+
if (failure) failures += `${join(typed.directory, "package.json")}: ${typed.name} as a consumer installs it, checked by tsc with skipLibCheck off:\n${failure}`;
|
|
653
|
+
}
|
|
654
|
+
} finally {
|
|
655
|
+
rmSync(scratch, {
|
|
656
|
+
recursive: true,
|
|
657
|
+
force: true
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return failures;
|
|
661
|
+
}
|
|
662
|
+
//#endregion
|
|
329
663
|
//#region src/guardrails/readme-version.ts
|
|
330
664
|
/** An object literal holding no other, such as a config example's `source: { package, version }`. */
|
|
331
665
|
const FLAT_OBJECT = /\{[^{}]*\}/g;
|
|
@@ -1277,7 +1611,8 @@ const CHECK_STEPS = [
|
|
|
1277
1611
|
"lockfile:singletons",
|
|
1278
1612
|
"dependency:ranges",
|
|
1279
1613
|
"git:identity",
|
|
1280
|
-
"readme:version"
|
|
1614
|
+
"readme:version",
|
|
1615
|
+
"published:types"
|
|
1281
1616
|
];
|
|
1282
1617
|
/** Steps `antelopejs-checks` runs itself, no package.json script behind them: each returns what failed, empty when it passed. */
|
|
1283
1618
|
const OWN_STEPS = /* @__PURE__ */ new Map([
|
|
@@ -1286,7 +1621,8 @@ const OWN_STEPS = /* @__PURE__ */ new Map([
|
|
|
1286
1621
|
["lockfile:singletons", (root) => Promise.resolve(checkSingletonPackages(root))],
|
|
1287
1622
|
["dependency:ranges", (root) => Promise.resolve(checkRepositoryRanges(root))],
|
|
1288
1623
|
["git:identity", checkGitIdentity],
|
|
1289
|
-
["readme:version", (root) => Promise.resolve(checkReadmeVersion(root))]
|
|
1624
|
+
["readme:version", (root) => Promise.resolve(checkReadmeVersion(root))],
|
|
1625
|
+
["published:types", checkPublishedTypes]
|
|
1290
1626
|
]);
|
|
1291
1627
|
function hasWork(root, step) {
|
|
1292
1628
|
if (step === "ratchet") return existsSync(join(root, CEILINGS_FILE));
|
|
@@ -1296,6 +1632,7 @@ function hasWork(root, step) {
|
|
|
1296
1632
|
if (step === "dependency:ranges") return isGitCheckout(root) && hasDependencyRanges(root);
|
|
1297
1633
|
if (step === "git:identity") return isGitCheckout(root);
|
|
1298
1634
|
if (step === "readme:version") return readmeExamples(root).length > 0;
|
|
1635
|
+
if (step === "published:types") return typedPackages(root).length > 0;
|
|
1299
1636
|
return true;
|
|
1300
1637
|
}
|
|
1301
1638
|
/** A command that runs a package script: the package manager, an optional `run`, then the script name. */
|
|
@@ -1325,18 +1662,21 @@ function droppedChecksSteps(current, synced) {
|
|
|
1325
1662
|
if (!dropped.length) return [];
|
|
1326
1663
|
return [`package.json: the checks script now runs ${command}, which does not run ${dropped.map((step) => `"${step}"`).join(", ")} from the replaced script. Call each from one of its steps, such as test or lint, or it no longer runs in checks.`];
|
|
1327
1664
|
}
|
|
1328
|
-
/**
|
|
1329
|
-
|
|
1665
|
+
/**
|
|
1666
|
+
* The steps that run after the others, each alone and in this order: tests often hold time limits that CPU contention
|
|
1667
|
+
* would break, and `published:types` packs each package, whose `prepack` rebuilds the output other steps and tests read.
|
|
1668
|
+
*/
|
|
1669
|
+
const RUNS_ALONE = ["test", "published:types"];
|
|
1330
1670
|
/** The step that runs before the others when it writes files, such as a workspace package's `dist`, that they read. */
|
|
1331
1671
|
const RUNS_FIRST = "typecheck";
|
|
1332
1672
|
/** The groups of steps that run one after another, the steps of a group at the same time. */
|
|
1333
1673
|
function phases(root, steps) {
|
|
1334
1674
|
const first = steps.includes(RUNS_FIRST) && typecheckWrites(root) ? [RUNS_FIRST] : [];
|
|
1335
|
-
const
|
|
1675
|
+
const alone = RUNS_ALONE.filter((step) => steps.includes(step));
|
|
1336
1676
|
return [
|
|
1337
1677
|
first,
|
|
1338
|
-
steps.filter((step) => !first.includes(step) && !
|
|
1339
|
-
|
|
1678
|
+
steps.filter((step) => !first.includes(step) && !alone.includes(step)),
|
|
1679
|
+
...alone.map((step) => [step])
|
|
1340
1680
|
].filter((phase) => phase.length > 0);
|
|
1341
1681
|
}
|
|
1342
1682
|
/** The environment variable naming, comma-separated, the steps `runChecks` leaves to another CI job. */
|
|
@@ -1399,7 +1739,7 @@ function summary(failures, passed, skipped) {
|
|
|
1399
1739
|
/**
|
|
1400
1740
|
* Runs the `checks:prepare` package script first when it exists and a step will run, and stops there if it fails.
|
|
1401
1741
|
* Then runs `typecheck` first when it writes files the other steps read (see `typecheckWrites`), every other check step
|
|
1402
|
-
* except `test` at the same time, then
|
|
1742
|
+
* except `test` and `published:types` at the same time, then each of those alone, and reports only what failed, each step's
|
|
1403
1743
|
* output buffered and listed in step order whichever step finishes first. `skipSetting` is the comma-separated value of
|
|
1404
1744
|
* `ANTELOPEJS_CHECKS_SKIP`: the steps it names are not run and are counted as skipped, never as passed, and a name that
|
|
1405
1745
|
* is not a step fails the run before any step starts so a typo cannot skip nothing. Unless `services` is false, the
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as typeAwareRuleSetting, t as TYPE_AWARE_RULES } from "./type-aware-rules-Da3769fI.mjs";
|
|
2
|
-
import { t as guardrailsPlugin } from "./guardrails-
|
|
2
|
+
import { t as guardrailsPlugin } from "./guardrails-BfGwehVj.mjs";
|
|
3
3
|
import { createConfigForNuxt } from "@nuxt/eslint-config/flat";
|
|
4
4
|
//#region src/eslint.ts
|
|
5
5
|
/** Whether every rule of `plugin` has the `create` function ESLint calls, which `eslintCompatPlugin` gives each oxlint rule. */
|