@antelopejs/tooling-configs 0.7.0 → 0.7.2
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 +5 -3
- package/dist/bin/api-diff.mjs +22 -1
- package/dist/bin/body-check.mjs +1 -1
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/comment-proof.mjs +1 -1
- package/dist/bin/garden.mjs +1 -16
- package/dist/bin/ratchet.mjs +2 -2
- package/dist/bin/suppressions.mjs +1 -1
- package/dist/bin/sync.mjs +122 -45
- package/dist/bin/verify.mjs +21 -21
- package/dist/{checks-BefrkjiT.mjs → checks-DvND3Ngb.mjs} +248 -34
- package/dist/{docs-compat-CSljVi3O.mjs → docs-compat-BAZiPLZt.mjs} +5 -7
- package/dist/eslint.mjs +2 -2
- package/dist/{guardrails-BfGwehVj.mjs → guardrails-PoMIcyGb.mjs} +714 -26
- package/dist/npm-CIIqL5SG.mjs +18 -0
- package/dist/oxc/guardrails/index.d.mts +1 -1
- package/dist/oxc/guardrails/index.mjs +1 -1
- package/dist/oxc/lint.d.mts +6 -2
- package/dist/oxc/lint.mjs +2 -1
- package/dist/{oxlint-CkHhK5K_.mjs → oxlint-CIeonWMB.mjs} +5 -1
- package/dist/pack-tarball-Cn4zGKn7.mjs +40 -0
- package/dist/{ratchet-2FeMs1kh.mjs → ratchet-DLCfeaPY.mjs} +2 -1
- package/dist/{type-aware-rules-Da3769fI.mjs → type-aware-rules-BxhHbizU.mjs} +15 -2
- package/dist/{typescript-CxfNxyr2.mjs → typescript-QfxkJYzd.mjs} +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
|
|
2
2
|
import { l as serializeManifest, o as packageManager, s as parseManifest } from "./package-DDG3YH7W.mjs";
|
|
3
|
+
import { a as isString, f as parseJson, i as isObject, u as optStr } from "./json-CG2L7YFl.mjs";
|
|
3
4
|
import { a as gitFiles, u as trackedManifests } from "./files-C-JJhExM.mjs";
|
|
4
|
-
import { n as workspaceDirectories } from "./docs-compat-
|
|
5
|
+
import { i as DMS_PACKAGES, n as workspaceDirectories } from "./docs-compat-BAZiPLZt.mjs";
|
|
5
6
|
import { n as shimInvocation, t as runCommand } from "./run-command-BlFRPORx.mjs";
|
|
7
|
+
import { n as tagVersion } from "./npm-CIIqL5SG.mjs";
|
|
8
|
+
import { n as packTarball } from "./pack-tarball-Cn4zGKn7.mjs";
|
|
6
9
|
import { t as accepting } from "./ports-DAeEJsYh.mjs";
|
|
7
10
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
11
|
import { basename, dirname, join, posix, relative, resolve, sep } from "node:path";
|
|
@@ -11,8 +14,8 @@ import { isMap, isScalar, isSeq, parseAllDocuments, parseDocument, stringify } f
|
|
|
11
14
|
import ts from "@typescript/typescript6";
|
|
12
15
|
import { createHash } from "node:crypto";
|
|
13
16
|
import { tmpdir } from "node:os";
|
|
17
|
+
import { Range, gtr, minVersion, prerelease, satisfies, valid, validRange } from "semver";
|
|
14
18
|
import { gunzipSync } from "node:zlib";
|
|
15
|
-
import { satisfies, validRange } from "semver";
|
|
16
19
|
import { minimatch } from "minimatch";
|
|
17
20
|
//#region src/guardrails/run-pnpm.ts
|
|
18
21
|
/** Runs pnpm, the only manager the pack's CI installs with, with `args` quietly; returns its output only when it failed. */
|
|
@@ -40,7 +43,8 @@ function runPnpm(root, args) {
|
|
|
40
43
|
* module whose range that copy falls outside, so a pin breaks startup at the
|
|
41
44
|
* next patch release.
|
|
42
45
|
*/
|
|
43
|
-
const ANTELOPEJS_SCOPE = "@antelopejs/";
|
|
46
|
+
const ANTELOPEJS_SCOPE$1 = "@antelopejs/";
|
|
47
|
+
const INTERFACE_PREFIX = `${ANTELOPEJS_SCOPE$1}interface-`;
|
|
44
48
|
/** A linked folder is the copy the dependent builds against, not a release it resolves. */
|
|
45
49
|
const LINK_SPEC_PREFIXES = ["file:", "link:"];
|
|
46
50
|
/** pnpm replaces a `workspace:` spec with a range on the sibling's version when it publishes the package. */
|
|
@@ -139,6 +143,15 @@ function isCapped(bounds, local) {
|
|
|
139
143
|
if (compareVersions(ceiling, nextMinor(floor)) !== 0) return false;
|
|
140
144
|
return local === void 0 || compareVersions(local, floor) >= 0 && compareVersions(local, ceiling) < 0;
|
|
141
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* The range to use in place of `spec` on the minor of `newest`, or `undefined` when `spec` already stops below the
|
|
148
|
+
* next minor of its floor and admits `newest`.
|
|
149
|
+
*/
|
|
150
|
+
function cappedReplacement(spec, newest) {
|
|
151
|
+
const version = readFloor(newest);
|
|
152
|
+
if (version === void 0 || isCapped(readBounds(spec.trim()), version)) return void 0;
|
|
153
|
+
return cappedRange(version);
|
|
154
|
+
}
|
|
142
155
|
function isLinkSpec(spec) {
|
|
143
156
|
return LINK_SPEC_PREFIXES.some((prefix) => spec.startsWith(prefix));
|
|
144
157
|
}
|
|
@@ -177,7 +190,7 @@ function checkEntry(manifest, field, [name, spec], local) {
|
|
|
177
190
|
}
|
|
178
191
|
/** Whether `manifest` declares an `@antelopejs/*` package in a field this check reads. */
|
|
179
192
|
function declaresAntelopePackage(manifest) {
|
|
180
|
-
return CHECKED_FIELDS.some((field) => Object.keys(manifest[field] ?? {}).some((name) => name.startsWith(ANTELOPEJS_SCOPE)));
|
|
193
|
+
return CHECKED_FIELDS.some((field) => Object.keys(manifest[field] ?? {}).some((name) => name.startsWith(ANTELOPEJS_SCOPE$1)));
|
|
181
194
|
}
|
|
182
195
|
/**
|
|
183
196
|
* The version of each named package among `manifests`, the packages that sit
|
|
@@ -207,17 +220,101 @@ function checkDependencyRanges(manifest, localVersions = /* @__PURE__ */ new Map
|
|
|
207
220
|
const violations = [];
|
|
208
221
|
for (const field of CHECKED_FIELDS) for (const entry of Object.entries(manifest[field] ?? {})) {
|
|
209
222
|
const [name, spec] = entry;
|
|
210
|
-
if (!name.startsWith(ANTELOPEJS_SCOPE) || isLinkSpec(spec)) continue;
|
|
223
|
+
if (!name.startsWith(ANTELOPEJS_SCOPE$1) || isLinkSpec(spec)) continue;
|
|
211
224
|
const violation = checkEntry(manifest, field, entry, localVersions.get(name));
|
|
212
225
|
if (violation) violations.push(violation);
|
|
213
226
|
}
|
|
214
227
|
return violations;
|
|
215
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* The `@antelopejs/interface-*` ranges of `manifest` that resolve from the registry: neither a linked folder nor a
|
|
231
|
+
* `workspace:` sibling.
|
|
232
|
+
*/
|
|
233
|
+
function interfaceRanges(manifest) {
|
|
234
|
+
return CHECKED_FIELDS.flatMap((field) => Object.entries(manifest[field] ?? {}).filter(([name, spec]) => name.startsWith(INTERFACE_PREFIX) && !isLinkSpec(spec) && !spec.startsWith(WORKSPACE_PREFIX)).map(([name, spec]) => ({
|
|
235
|
+
field,
|
|
236
|
+
name,
|
|
237
|
+
spec
|
|
238
|
+
})));
|
|
239
|
+
}
|
|
216
240
|
function describeViolation(violation) {
|
|
217
241
|
const { field, name, spec, local, expected } = violation;
|
|
218
242
|
return `${field}["${name}"] is "${spec}": AntelopeJS packages ship breaking changes in minor releases, so it must stop below the next minor${local === void 0 ? "" : ` and admit ${local}, the version in this repository`}; ${expected ? `use "${expected}"` : "declare it as >=<floor> <next minor> on 0.x or ~<floor> from 1.0"}`;
|
|
219
243
|
}
|
|
220
244
|
//#endregion
|
|
245
|
+
//#region src/guardrails/registry.ts
|
|
246
|
+
const DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
247
|
+
/** How long one registry read may take before it counts as failed. */
|
|
248
|
+
const REGISTRY_TIMEOUT_MS = 3e3;
|
|
249
|
+
/** How many times a read that failed or timed out is made before the document counts as unreadable. */
|
|
250
|
+
const REGISTRY_ATTEMPTS = 2;
|
|
251
|
+
/** The dependency fields a release resolves an interface it implements from. */
|
|
252
|
+
const RELEASE_FIELDS = [
|
|
253
|
+
"dependencies",
|
|
254
|
+
"peerDependencies",
|
|
255
|
+
"optionalDependencies"
|
|
256
|
+
];
|
|
257
|
+
/** The registry npm is configured with, ending in `/`. */
|
|
258
|
+
function registry() {
|
|
259
|
+
const configured = process.env.npm_config_registry || process.env.NPM_CONFIG_REGISTRY;
|
|
260
|
+
if (!configured) return DEFAULT_REGISTRY;
|
|
261
|
+
return configured.endsWith("/") ? configured : `${configured}/`;
|
|
262
|
+
}
|
|
263
|
+
/** What {@link readRegistry} returns when the registry answers that nothing is published at a path. */
|
|
264
|
+
const UNPUBLISHED = "unpublished";
|
|
265
|
+
/** The document at `path` under the {@link registry}, {@link UNPUBLISHED} when the registry answers 404, or `undefined` when it cannot be read within {@link REGISTRY_ATTEMPTS} reads of {@link REGISTRY_TIMEOUT_MS} each. */
|
|
266
|
+
async function readRegistry(path, accept) {
|
|
267
|
+
for (let attempt = 0; attempt < REGISTRY_ATTEMPTS; attempt++) try {
|
|
268
|
+
const response = await fetch(new URL(path, registry()), {
|
|
269
|
+
headers: { accept },
|
|
270
|
+
signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS)
|
|
271
|
+
});
|
|
272
|
+
if (response.status === 404) return UNPUBLISHED;
|
|
273
|
+
if (!response.ok) return void 0;
|
|
274
|
+
return { document: parseJson(await response.text()) };
|
|
275
|
+
} catch {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const encodedName = (name) => name.replace("/", "%2f");
|
|
280
|
+
/** The `latest` dist-tag of `name` on the {@link registry}, or `undefined` when it cannot be read. */
|
|
281
|
+
async function publishedVersion(name) {
|
|
282
|
+
const packument = await readRegistry(encodedName(name), "application/vnd.npm.install-v1+json");
|
|
283
|
+
return packument === void 0 || packument === UNPUBLISHED ? void 0 : tagVersion(packument.document, "latest");
|
|
284
|
+
}
|
|
285
|
+
function declaredRange(release, name) {
|
|
286
|
+
for (const field of RELEASE_FIELDS) {
|
|
287
|
+
const dependencies = Object.hasOwn(release, field) ? release[field] : void 0;
|
|
288
|
+
const range = dependencies !== void 0 && isObject(dependencies) ? optStr(dependencies, name) : void 0;
|
|
289
|
+
if (range !== void 0) return range;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
function implementedNames(release) {
|
|
293
|
+
const config = Object.hasOwn(release, "antelopeJs") ? release.antelopeJs : void 0;
|
|
294
|
+
if (config === void 0 || !isObject(config)) return [];
|
|
295
|
+
const names = Object.hasOwn(config, "implements") ? config.implements : void 0;
|
|
296
|
+
return Array.isArray(names) ? names.filter(isString) : [];
|
|
297
|
+
}
|
|
298
|
+
/** The release the `latest` dist-tag of `name` points at, `"unpublished"` when the registry has none, or `undefined` when it cannot be read. */
|
|
299
|
+
async function implementingRelease(name) {
|
|
300
|
+
const read = await readRegistry(`${encodedName(name)}/latest`, "application/json");
|
|
301
|
+
if (read === UNPUBLISHED) return UNPUBLISHED;
|
|
302
|
+
const release = read?.document;
|
|
303
|
+
if (release === void 0 || !isObject(release)) return void 0;
|
|
304
|
+
const version = optStr(release, "version");
|
|
305
|
+
if (version === void 0) return void 0;
|
|
306
|
+
const implemented = /* @__PURE__ */ new Map();
|
|
307
|
+
for (const interfaceName of implementedNames(release)) {
|
|
308
|
+
const range = declaredRange(release, interfaceName);
|
|
309
|
+
if (range !== void 0) implemented.set(interfaceName, range);
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
name,
|
|
313
|
+
version,
|
|
314
|
+
implements: implemented
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
221
318
|
//#region src/guardrails/dependency-ranges-sync.ts
|
|
222
319
|
/** Each tracked manifest that parses; a fixture that is not JSON is not a package this repository releases. */
|
|
223
320
|
function tracked(root) {
|
|
@@ -289,11 +386,93 @@ function moveDependencyRanges(root, check) {
|
|
|
289
386
|
function hasDependencyRanges(root) {
|
|
290
387
|
return tracked(root).some(({ manifest }) => declaresAntelopePackage(manifest));
|
|
291
388
|
}
|
|
292
|
-
|
|
293
|
-
|
|
389
|
+
function belowNewest(spec, version) {
|
|
390
|
+
if (version === void 0 || valid(version) === null || prerelease(version) !== null || !gtr(version, spec)) return void 0;
|
|
391
|
+
const expected = cappedReplacement(spec, version);
|
|
392
|
+
return expected === void 0 ? void 0 : {
|
|
393
|
+
reason: `which stops below ${version}, its newest published version`,
|
|
394
|
+
expected
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
/** The lowest release `range` admits, without the prerelease suffix a floor such as `^0.10.0-rc.1` carries. */
|
|
398
|
+
function stableFloor(range) {
|
|
399
|
+
const floor = minVersion(range);
|
|
400
|
+
return floor === null ? void 0 : `${floor.major}.${floor.minor}.${floor.patch}`;
|
|
401
|
+
}
|
|
402
|
+
/** Whether one release admitted by `a` is also admitted by `b`, counting releases only, as an install resolves them. */
|
|
403
|
+
function sharesRelease(a, b) {
|
|
404
|
+
return new Range(a).set.some((left) => new Range(b).set.some((right) => {
|
|
405
|
+
const both = [...left, ...right].join(" ");
|
|
406
|
+
const floor = stableFloor(both);
|
|
407
|
+
return floor !== void 0 && satisfies(floor, both);
|
|
408
|
+
}));
|
|
409
|
+
}
|
|
410
|
+
/** The implementation of `name` in each of `releases` that is not a prerelease and declares a range semver reads. */
|
|
411
|
+
function implementations(name, releases) {
|
|
412
|
+
return releases.flatMap((release) => {
|
|
413
|
+
const range = release.implements.get(name);
|
|
414
|
+
return range === void 0 || prerelease(release.version) !== null || validRange(range) === null ? [] : [{
|
|
415
|
+
release,
|
|
416
|
+
range
|
|
417
|
+
}];
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function outsideImplemented(spec, { release, range }) {
|
|
421
|
+
if (sharesRelease(spec, range)) return void 0;
|
|
422
|
+
const floor = stableFloor(range);
|
|
423
|
+
const expected = floor === void 0 ? void 0 : cappedReplacement(spec, floor);
|
|
424
|
+
return expected === void 0 ? void 0 : {
|
|
425
|
+
reason: `which excludes "${range}", the range ${release.name} ${release.version}, its newest release, implements it on`,
|
|
426
|
+
expected
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
/** The newest release of each DMS package outside this repository that could be read, and whether every published one could. */
|
|
430
|
+
async function dmsReleases(local) {
|
|
431
|
+
const reads = await Promise.all(DMS_PACKAGES.filter((name) => !local.has(name)).map(implementingRelease));
|
|
432
|
+
return {
|
|
433
|
+
releases: reads.filter((read) => read !== void 0 && read !== "unpublished"),
|
|
434
|
+
complete: !reads.includes(void 0)
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* One line per range among `ranges` that shares no release with the range the newest release of a DMS package outside
|
|
439
|
+
* `local` implements its interface on, since a project loads the interface version that release is built against. An
|
|
440
|
+
* interface no such release implements is held instead to the `latest` dist-tag of its package: one line when every
|
|
441
|
+
* release the range admits sits below it, and only when every published DMS release could be read, since an unread one
|
|
442
|
+
* may implement it. A line that gives the fix an earlier one gave is skipped. A package whose release cannot be read,
|
|
443
|
+
* or whose `latest` is a prerelease, is skipped, so a registry outage leaves only the cap rule deciding the step.
|
|
444
|
+
*/
|
|
445
|
+
async function staleRanges(ranges, local) {
|
|
446
|
+
if (!ranges.length) return [];
|
|
447
|
+
const names = [...new Set(ranges.map(({ name }) => name))];
|
|
448
|
+
const [newest, { releases, complete }] = await Promise.all([Promise.all(names.map(async (name) => [name, await publishedVersion(name)])).then((entries) => new Map(entries)), dmsReleases(local)]);
|
|
449
|
+
return ranges.flatMap(({ path, field, name, spec }) => {
|
|
450
|
+
if (validRange(spec) === null) return [];
|
|
451
|
+
const implemented = implementations(name, releases);
|
|
452
|
+
const findings = (implemented.length ? implemented.map((implementation) => outsideImplemented(spec, implementation)) : complete ? [belowNewest(spec, newest.get(name))] : []).filter((finding) => finding !== void 0);
|
|
453
|
+
return findings.filter(({ expected }, index) => findings.findIndex((finding) => finding.expected === expected) === index).map(({ reason, expected }) => `${path}: ${field}["${name}"] is "${spec}", ${reason}, and @antelopejs/core loads one copy of each interface; use "${expected}"\n`);
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Each `@antelopejs/*` range in a tracked manifest that does not stop below the next minor, and each capped
|
|
458
|
+
* `@antelopejs/interface-*` range on a package outside this repository that the newest DMS release implementing it, or
|
|
459
|
+
* else its newest published release, does not admit, one line each; empty when every range passes.
|
|
460
|
+
*/
|
|
461
|
+
async function checkRepositoryRanges(root) {
|
|
294
462
|
const manifests = tracked(root);
|
|
295
463
|
const versions = localVersions(manifests.map(({ manifest }) => manifest));
|
|
296
|
-
|
|
464
|
+
const capped = [];
|
|
465
|
+
const published = [];
|
|
466
|
+
for (const { path, manifest } of manifests) {
|
|
467
|
+
const violations = checkDependencyRanges(manifest, versions);
|
|
468
|
+
capped.push(...violations.map((violation) => `${path}: ${describeViolation(violation)}\n`));
|
|
469
|
+
published.push(...interfaceRanges(manifest).filter(({ field, name }) => !versions.has(name) && !violations.some((violation) => violation.field === field && violation.name === name)).map((range) => ({
|
|
470
|
+
path,
|
|
471
|
+
...range
|
|
472
|
+
})));
|
|
473
|
+
}
|
|
474
|
+
const local = new Set(manifests.flatMap(({ manifest: { name } }) => name ? [name] : []));
|
|
475
|
+
return [...capped, ...await staleRanges(published, local)].join("");
|
|
297
476
|
}
|
|
298
477
|
//#endregion
|
|
299
478
|
//#region src/guardrails/git-identity.ts
|
|
@@ -498,21 +677,14 @@ function packedManifest(destination) {
|
|
|
498
677
|
manifest: parseManifest(text)
|
|
499
678
|
};
|
|
500
679
|
}
|
|
501
|
-
/** Packs the package `name` once per run
|
|
680
|
+
/** Packs the package `name` once per run through {@link packTarball} and reads the manifest its tarball holds. */
|
|
502
681
|
async function pack(run, name) {
|
|
503
682
|
const cached = run.packs.get(name);
|
|
504
683
|
if (cached) return cached;
|
|
505
684
|
const slot = String(run.packs.size);
|
|
506
685
|
const destination = join(run.scratch, "tarballs", slot);
|
|
507
686
|
mkdirSync(destination, { recursive: true });
|
|
508
|
-
const result = await
|
|
509
|
-
"pack",
|
|
510
|
-
"--pack-destination",
|
|
511
|
-
destination
|
|
512
|
-
], {
|
|
513
|
-
cwd: join(run.root, run.members.get(name) ?? ""),
|
|
514
|
-
signal: run.signal
|
|
515
|
-
});
|
|
687
|
+
const result = await packTarball(run.manager, join(run.root, run.members.get(name) ?? ""), destination, run.signal);
|
|
516
688
|
const packed = result.status === 0 ? packedManifest(destination) : { failure: `Packing ${name} failed:\n${result.output}` };
|
|
517
689
|
run.packs.set(name, packed);
|
|
518
690
|
return packed;
|
|
@@ -663,6 +835,7 @@ async function checkPublishedTypes(root, signal) {
|
|
|
663
835
|
//#region src/guardrails/readme-version.ts
|
|
664
836
|
/** An object literal holding no other, such as a config example's `source: { package, version }`. */
|
|
665
837
|
const FLAT_OBJECT = /\{[^{}]*\}/g;
|
|
838
|
+
const ANTELOPEJS_SCOPE = "@antelopejs/";
|
|
666
839
|
function stringField(body, key) {
|
|
667
840
|
return new RegExp(String.raw`(?<![\w$-])["']?${key}["']?\s*:\s*["']([^"'\n]+)["']`).exec(body);
|
|
668
841
|
}
|
|
@@ -688,33 +861,57 @@ function ownPackages(root) {
|
|
|
688
861
|
function examplesIn(readme, text, packages) {
|
|
689
862
|
return [...text.matchAll(FLAT_OBJECT)].flatMap((object) => {
|
|
690
863
|
const name = stringField(object[0], "package")?.[1];
|
|
691
|
-
const owner = name === void 0 ? void 0 : packages.get(name);
|
|
692
864
|
const field = stringField(object[0], "version");
|
|
693
865
|
const range = field?.[1];
|
|
694
|
-
if (!name || !
|
|
866
|
+
if (!name?.startsWith(ANTELOPEJS_SCOPE) || !field || range === void 0) return [];
|
|
695
867
|
return [{
|
|
696
868
|
readme,
|
|
697
869
|
line: text.slice(0, object.index + field.index).split("\n").length,
|
|
698
870
|
name,
|
|
699
871
|
range,
|
|
700
|
-
owner
|
|
872
|
+
owner: packages.get(name)
|
|
701
873
|
}];
|
|
702
874
|
});
|
|
703
875
|
}
|
|
704
|
-
/** The config examples in the `README.md` of the root and of each workspace package that give
|
|
876
|
+
/** The config examples in the `README.md` of the root and of each workspace package that give an `@antelopejs/*` package a `version`. */
|
|
705
877
|
function readmeExamples(root) {
|
|
706
878
|
const readmes = packageDirectories(root).map((directory) => relative$1(directory, "README.md")).filter((readme) => existsSync(join(root, readme)));
|
|
707
879
|
if (!readmes.length) return [];
|
|
708
880
|
const packages = ownPackages(root);
|
|
709
881
|
return readmes.flatMap((readme) => examplesIn(readme, readFileSync(join(root, readme), "utf8"), packages));
|
|
710
882
|
}
|
|
883
|
+
async function newestVersions(examples) {
|
|
884
|
+
const names = [...new Set(examples.map(({ name }) => name))];
|
|
885
|
+
const entries = await Promise.all(names.map(async (name) => {
|
|
886
|
+
const owner = examples.find((example) => example.name === name)?.owner;
|
|
887
|
+
if (owner) return [name, {
|
|
888
|
+
version: owner.version,
|
|
889
|
+
source: `the version in ${owner.manifest}`
|
|
890
|
+
}];
|
|
891
|
+
const version = await publishedVersion(name);
|
|
892
|
+
return [name, version === void 0 ? void 0 : {
|
|
893
|
+
version,
|
|
894
|
+
source: "its newest published version"
|
|
895
|
+
}];
|
|
896
|
+
}));
|
|
897
|
+
return new Map(entries);
|
|
898
|
+
}
|
|
899
|
+
function describe({ readme, line, name, range }, newest) {
|
|
900
|
+
if (newest === void 0) return `${readme}:${line} gives ${name} the version range "${range}", but its newest published version could not be read from ${registry()}.\n`;
|
|
901
|
+
const expected = cappedReplacement(range, newest.version);
|
|
902
|
+
if (expected === void 0) return "";
|
|
903
|
+
return `${readme}:${line} gives ${name} the version range "${range}", which does not stop below the next minor of ${newest.version}, ${newest.source}. Use "${expected}".\n`;
|
|
904
|
+
}
|
|
711
905
|
/**
|
|
712
|
-
* Fails for each README config example whose `version` range
|
|
713
|
-
*
|
|
714
|
-
*
|
|
906
|
+
* Fails for each README config example whose `@antelopejs/*` `version` range does not stop below the next minor of the
|
|
907
|
+
* package's newest version and admit it, naming the README line and the range to use. The newest version is the one in
|
|
908
|
+
* the repository's own `package.json` for its own packages, and the registry's `latest` dist-tag for any other. A value
|
|
909
|
+
* that is not a range, such as a dist-tag, passes.
|
|
715
910
|
*/
|
|
716
|
-
function checkReadmeVersion(root) {
|
|
717
|
-
|
|
911
|
+
async function checkReadmeVersion(root) {
|
|
912
|
+
const examples = readmeExamples(root).filter(({ range }) => validRange(range) !== null);
|
|
913
|
+
const newest = await newestVersions(examples);
|
|
914
|
+
return examples.map((example) => describe(example, newest.get(example.name))).join("");
|
|
718
915
|
}
|
|
719
916
|
//#endregion
|
|
720
917
|
//#region src/guardrails/services.ts
|
|
@@ -1131,21 +1328,38 @@ function declaresWorkspaces(path) {
|
|
|
1131
1328
|
throw error;
|
|
1132
1329
|
}
|
|
1133
1330
|
}
|
|
1331
|
+
/** Whether a `pnpm-workspace.yaml` lists `packages`, or cannot be read and so might; an empty one, or one without them, holds its own folder only. */
|
|
1332
|
+
function declaresPackages(path) {
|
|
1333
|
+
if (!existsSync(path)) return false;
|
|
1334
|
+
const document = parseDocument(readFileSync(path, "utf8"));
|
|
1335
|
+
if (document.errors.length > 0) return true;
|
|
1336
|
+
const { contents } = document;
|
|
1337
|
+
if (contents === null || isScalar(contents) && contents.value === null) return false;
|
|
1338
|
+
return !isMap(contents) || contents.has("packages");
|
|
1339
|
+
}
|
|
1134
1340
|
/**
|
|
1135
|
-
* Whether a folder above `folder` holds a workspace that may list it, a `pnpm-workspace.yaml`
|
|
1136
|
-
* `workspaces`: its membership then follows patterns this check does not evaluate, and that workspace's
|
|
1341
|
+
* Whether a folder above `folder` holds a workspace that may list it, a `pnpm-workspace.yaml` with `packages` or a
|
|
1342
|
+
* `package.json` with `workspaces`: its membership then follows patterns this check does not evaluate, and that workspace's
|
|
1343
|
+
* lockfile may hold it.
|
|
1137
1344
|
*/
|
|
1138
1345
|
function inWorkspace(root, folder) {
|
|
1139
|
-
return ancestors(folder).some((above) =>
|
|
1346
|
+
return ancestors(folder).some((above) => declaresPackages(join(root, above, PNPM_WORKSPACE)) || declaresWorkspaces(join(root, above, MANIFEST)));
|
|
1140
1347
|
}
|
|
1141
1348
|
function fixCommand(root, folder, lockfile) {
|
|
1142
1349
|
if (lockfile === NPM_LOCK) return `npm install --package-lock-only --prefix ${folder}`;
|
|
1143
1350
|
return existsSync(join(root, folder, PNPM_WORKSPACE)) ? `pnpm install --dir ${folder} --lockfile-only` : `pnpm install --dir ${folder} --ignore-workspace --lockfile-only`;
|
|
1144
1351
|
}
|
|
1352
|
+
/** The lockfile an install writes in a folder that holds none: `package-lock.json` when a folder above holds one, `pnpm-lock.yaml` otherwise. */
|
|
1353
|
+
function unlockedLockfile(root, folder) {
|
|
1354
|
+
return ancestors(folder).some((above) => existsSync(join(root, above, NPM_LOCK))) ? NPM_LOCK : PNPM_LOCK$1;
|
|
1355
|
+
}
|
|
1356
|
+
/** Whether pnpm installs `folder`: it holds a `pnpm-lock.yaml`, or no lockfile and no folder above it holds a `package-lock.json`. */
|
|
1357
|
+
function installsWithPnpm(root, folder) {
|
|
1358
|
+
return (lockfileIn(join(root, folder)) ?? unlockedLockfile(root, folder)) === PNPM_LOCK$1;
|
|
1359
|
+
}
|
|
1145
1360
|
function unlocked(root, folder) {
|
|
1146
1361
|
if (inWorkspace(root, folder)) return "";
|
|
1147
|
-
|
|
1148
|
-
return `${folder}/${MANIFEST} has dependencies and no lockfile: run \`${fixCommand(root, folder, manager)}\`.\n`;
|
|
1362
|
+
return `${folder}/${MANIFEST} has dependencies and no lockfile: run \`${fixCommand(root, folder, unlockedLockfile(root, folder))}\`.\n`;
|
|
1149
1363
|
}
|
|
1150
1364
|
function checkFolder(root, { folder, lockfile }) {
|
|
1151
1365
|
if (lockfile === "other") return "";
|
|
@@ -1619,9 +1833,9 @@ const OWN_STEPS = /* @__PURE__ */ new Map([
|
|
|
1619
1833
|
["verify:types", typecheckLayers],
|
|
1620
1834
|
["verify:lockfiles", (root) => Promise.resolve(checkLockfiles(root))],
|
|
1621
1835
|
["lockfile:singletons", (root) => Promise.resolve(checkSingletonPackages(root))],
|
|
1622
|
-
["dependency:ranges",
|
|
1836
|
+
["dependency:ranges", checkRepositoryRanges],
|
|
1623
1837
|
["git:identity", checkGitIdentity],
|
|
1624
|
-
["readme:version",
|
|
1838
|
+
["readme:version", checkReadmeVersion],
|
|
1625
1839
|
["published:types", checkPublishedTypes]
|
|
1626
1840
|
]);
|
|
1627
1841
|
function hasWork(root, step) {
|
|
@@ -1788,4 +2002,4 @@ async function runChecks(root, options = {}) {
|
|
|
1788
2002
|
};
|
|
1789
2003
|
}
|
|
1790
2004
|
//#endregion
|
|
1791
|
-
export { stepsOf as a, matchingScripts as i, droppedChecksSteps as n,
|
|
2005
|
+
export { stepsOf as a, installsWithPnpm as c, runPnpm as d, matchingScripts as i, verifyLayers as l, droppedChecksSteps as n, pnpmLockfiles as o, runChecks as r, inWorkspace as s, CHECKS_SKIP_ENV as t, moveDependencyRanges as u };
|
|
@@ -141,12 +141,8 @@ const ORGANIZATION = "https://github.com/AntelopeJS";
|
|
|
141
141
|
/** The AntelopeJS DMS modules in display order. Every README holding the markers lists exactly these. */
|
|
142
142
|
const MODULES = [
|
|
143
143
|
{
|
|
144
|
-
repo: "dms-
|
|
145
|
-
row: "
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
repo: "dms-ai",
|
|
149
|
-
row: "An assistant chat in the dashboard, on your own Claude Code or Codex"
|
|
144
|
+
repo: "dms-assistant",
|
|
145
|
+
row: "An assistant chat in the dashboard and its onboarding, on your own Claude Code or Codex"
|
|
150
146
|
},
|
|
151
147
|
{
|
|
152
148
|
repo: "dms-database",
|
|
@@ -185,6 +181,8 @@ const MODULES = [
|
|
|
185
181
|
row: "The `ajs dms` CLI, the Vue renderer and the SDK every frontend module builds on"
|
|
186
182
|
}
|
|
187
183
|
];
|
|
184
|
+
/** The npm package of the DMS core and of each DMS module, each published under its repository's name. */
|
|
185
|
+
const DMS_PACKAGES = ["@antelopejs/dms", ...MODULES.map(({ repo }) => `@antelopejs/${repo}`)];
|
|
188
186
|
/** The generated block, formatted as oxfmt leaves it. */
|
|
189
187
|
function modulesBlock() {
|
|
190
188
|
return [
|
|
@@ -478,4 +476,4 @@ function planDocs(root, manager) {
|
|
|
478
476
|
return plan;
|
|
479
477
|
}
|
|
480
478
|
//#endregion
|
|
481
|
-
export { workspaceDirectories as n, workspacePatterns as r, planDocs as t };
|
|
479
|
+
export { DMS_PACKAGES as i, workspaceDirectories as n, workspacePatterns as r, planDocs as t };
|
package/dist/eslint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as typeAwareRuleSetting, t as TYPE_AWARE_RULES } from "./type-aware-rules-
|
|
2
|
-
import { t as guardrailsPlugin } from "./guardrails-
|
|
1
|
+
import { n as typeAwareRuleSetting, t as TYPE_AWARE_RULES } from "./type-aware-rules-BxhHbizU.mjs";
|
|
2
|
+
import { t as guardrailsPlugin } from "./guardrails-PoMIcyGb.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. */
|