@antelopejs/tooling-configs 0.5.5 → 0.5.7
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 +16 -4
- package/dist/bin/api-diff.mjs +1 -1
- package/dist/bin/check-interface-ranges.mjs +3 -112
- package/dist/bin/checks.mjs +1 -1
- package/dist/bin/comment-proof.mjs +1 -1
- package/dist/bin/sync.mjs +140 -26
- package/dist/bin/verify.mjs +4 -3
- package/dist/{checks-DqTjyKCC.mjs → checks-CD2oFGrt.mjs} +2 -471
- package/dist/docs-compat-Ft1r2sf0.mjs +476 -0
- package/dist/interface-ranges-CcVSr59f.mjs +116 -0
- package/dist/{typescript-DhavwHb7.mjs → typescript-CqcOaci8.mjs} +19 -6
- package/dist/verify/index.d.mts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { s as parseManifest } from "./package-DnxZ2CXZ.mjs";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { isMap, isScalar, isSeq, parseDocument } from "yaml";
|
|
5
|
+
//#region src/guardrails/marker-block.ts
|
|
6
|
+
/** The comment pair sync writes a generated block between. */
|
|
7
|
+
function markers(name) {
|
|
8
|
+
return {
|
|
9
|
+
name,
|
|
10
|
+
start: `<!-- ${name}:start -->`,
|
|
11
|
+
end: `<!-- ${name}:end -->`
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/** The README with `block` between its markers. A README without markers comes back as it is. */
|
|
15
|
+
function placeMarkedBlock(current, { name, start, end }, block) {
|
|
16
|
+
const starts = current.split(start).length - 1;
|
|
17
|
+
const ends = current.split(end).length - 1;
|
|
18
|
+
if (starts === 0 && ends === 0) return current;
|
|
19
|
+
const from = current.indexOf(start);
|
|
20
|
+
const to = current.indexOf(end);
|
|
21
|
+
if (starts !== 1 || ends !== 1 || to < from) throw new Error(`invalid ${name} markers: a README holds exactly one start marker followed by one end marker. Repair or delete them, then rerun antelopejs-sync.`);
|
|
22
|
+
return `${current.slice(0, from)}${block}${current.slice(to + end.length).replace(/^\r?\n/, "")}`;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/guardrails/markdown-table.ts
|
|
26
|
+
/** The lines of a Markdown table whose first row is the header, columns padded as oxfmt leaves them. */
|
|
27
|
+
function tableLines(table) {
|
|
28
|
+
const widths = table[0].map((_, column) => Math.max(3, ...table.map((row) => row[column].length)));
|
|
29
|
+
const line = (cells) => `| ${cells.map((cell, column) => cell.padEnd(widths[column])).join(" | ")} |`;
|
|
30
|
+
return [
|
|
31
|
+
line(table[0]),
|
|
32
|
+
line(widths.map((width) => "-".repeat(width))),
|
|
33
|
+
...table.slice(1).map(line)
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/guardrails/docs-framework-modules.ts
|
|
38
|
+
const FRAMEWORK_MODULES = markers("antelopejs-framework-modules");
|
|
39
|
+
const FRAMEWORK_MODULES_START = FRAMEWORK_MODULES.start;
|
|
40
|
+
const FRAMEWORK_MODULES_END = FRAMEWORK_MODULES.end;
|
|
41
|
+
const ORGANIZATION$1 = "https://github.com/AntelopeJS";
|
|
42
|
+
const SCOPE$1 = "@antelopejs/";
|
|
43
|
+
/** The framework areas in display order. Every README holding the markers lists exactly these. */
|
|
44
|
+
const AREAS = [
|
|
45
|
+
{
|
|
46
|
+
area: "API",
|
|
47
|
+
contracts: [
|
|
48
|
+
"interface-api",
|
|
49
|
+
"interface-api-util",
|
|
50
|
+
"interface-data-api"
|
|
51
|
+
],
|
|
52
|
+
providers: ["api"]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
area: "Auth",
|
|
56
|
+
contracts: ["interface-auth"],
|
|
57
|
+
providers: ["auth-jwt"]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
area: "Database",
|
|
61
|
+
contracts: [
|
|
62
|
+
"interface-database",
|
|
63
|
+
"interface-database-decorators",
|
|
64
|
+
"interface-database-catalog",
|
|
65
|
+
"interface-mongodb",
|
|
66
|
+
"interface-rethinkdb"
|
|
67
|
+
],
|
|
68
|
+
providers: [
|
|
69
|
+
"postgres",
|
|
70
|
+
"mysql",
|
|
71
|
+
"mongodb",
|
|
72
|
+
"rethinkdb"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
area: "Redis",
|
|
77
|
+
contracts: ["interface-redis", "interface-redis-scheduler"],
|
|
78
|
+
providers: ["redis"]
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
area: "Email",
|
|
82
|
+
contracts: ["interface-email"],
|
|
83
|
+
providers: ["nodemailer", "brevo"]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
area: "File storage",
|
|
87
|
+
contracts: ["interface-file-storage"],
|
|
88
|
+
providers: ["file-storage-local", "file-storage-s3"]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
area: "Payments",
|
|
92
|
+
contracts: [
|
|
93
|
+
"interface-payment",
|
|
94
|
+
"interface-subscriptions",
|
|
95
|
+
"interface-stripe"
|
|
96
|
+
],
|
|
97
|
+
providers: [
|
|
98
|
+
"stripe",
|
|
99
|
+
"mollie",
|
|
100
|
+
"checkout-com",
|
|
101
|
+
"payment-subscriptions"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
function cell(repos, current) {
|
|
106
|
+
return repos.map((repo) => repo === current ? `**\`${repo}\`**` : `[\`${repo}\`](${ORGANIZATION$1}/${repo})`).join(" · ");
|
|
107
|
+
}
|
|
108
|
+
/** The generated block, the README's own repository in bold, formatted as oxfmt leaves it. */
|
|
109
|
+
function frameworkModulesBlock(current) {
|
|
110
|
+
return [
|
|
111
|
+
FRAMEWORK_MODULES_START,
|
|
112
|
+
"",
|
|
113
|
+
...tableLines([[
|
|
114
|
+
"Area",
|
|
115
|
+
"Contracts",
|
|
116
|
+
"Providers"
|
|
117
|
+
], ...AREAS.map(({ area, contracts, providers }) => [
|
|
118
|
+
area,
|
|
119
|
+
cell(contracts, current),
|
|
120
|
+
cell(providers, current)
|
|
121
|
+
])]),
|
|
122
|
+
"",
|
|
123
|
+
FRAMEWORK_MODULES_END,
|
|
124
|
+
""
|
|
125
|
+
].join("\n");
|
|
126
|
+
}
|
|
127
|
+
/** The repository a package lives in: its name without the `@antelopejs/` scope, as every framework package is named. */
|
|
128
|
+
function frameworkRepo(packageName) {
|
|
129
|
+
return packageName?.startsWith(SCOPE$1) ? packageName.slice(12) : void 0;
|
|
130
|
+
}
|
|
131
|
+
/** The README with the block between its markers rewritten for the package named `packageName`. A README without markers comes back as it is. */
|
|
132
|
+
function placeFrameworkModulesBlock(current, packageName) {
|
|
133
|
+
return placeMarkedBlock(current, FRAMEWORK_MODULES, frameworkModulesBlock(frameworkRepo(packageName)));
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/guardrails/docs-modules.ts
|
|
137
|
+
const DMS_MODULES = markers("antelopejs-dms-modules");
|
|
138
|
+
const DMS_MODULES_START = DMS_MODULES.start;
|
|
139
|
+
const DMS_MODULES_END = DMS_MODULES.end;
|
|
140
|
+
const ORGANIZATION = "https://github.com/AntelopeJS";
|
|
141
|
+
/** The AntelopeJS DMS modules in display order. Every README holding the markers lists exactly these. */
|
|
142
|
+
const MODULES = [
|
|
143
|
+
{
|
|
144
|
+
repo: "dms-builder",
|
|
145
|
+
row: "Edit pages, tables and data sources by clicking, as TypeScript that compiles"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
repo: "dms-ai",
|
|
149
|
+
row: "An assistant chat in the dashboard, on your own Claude Code or Codex"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
repo: "dms-database",
|
|
153
|
+
row: "Schemas, relation diagrams, a data browser and a query console"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
repo: "dms-api",
|
|
157
|
+
row: "API health, request logs, per-route statistics and a request tester"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
repo: "dms-automation",
|
|
161
|
+
row: "Node-graph automations on schedules, webhooks and DMS events, with a trace for every run"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
repo: "dms-mailing",
|
|
165
|
+
row: "E-mail templates in a block editor, versions, a send log and delivery metrics"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
repo: "dms-lang",
|
|
169
|
+
row: "Translation coverage, a translation matrix and a translation queue"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
repo: "dms-media",
|
|
173
|
+
row: "A media library with folders, per-folder permissions, image sizes and light editing"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
repo: "dms-saas",
|
|
177
|
+
row: "Self-service sign-up, plans that gate features, and Stripe billing"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
repo: "dms-marketing",
|
|
181
|
+
row: "Traffic, conversion funnels with A/B splits and click heatmaps, without cookies"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
repo: "dms-frontend",
|
|
185
|
+
row: "The `ajs dms` CLI, the Vue renderer and the SDK every frontend module builds on"
|
|
186
|
+
}
|
|
187
|
+
];
|
|
188
|
+
/** The generated block, formatted as oxfmt leaves it. */
|
|
189
|
+
function modulesBlock() {
|
|
190
|
+
return [
|
|
191
|
+
DMS_MODULES_START,
|
|
192
|
+
"",
|
|
193
|
+
...tableLines([["Module", "What it adds"], ...MODULES.map(({ repo, row }) => [`[\`${repo}\`](${ORGANIZATION}/${repo})`, row])]),
|
|
194
|
+
"",
|
|
195
|
+
DMS_MODULES_END,
|
|
196
|
+
""
|
|
197
|
+
].join("\n");
|
|
198
|
+
}
|
|
199
|
+
/** The README with the block between its markers rewritten. A README without markers comes back as it is. */
|
|
200
|
+
function placeModulesBlock(current) {
|
|
201
|
+
return placeMarkedBlock(current, DMS_MODULES, modulesBlock());
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/guardrails/docs-compat.ts
|
|
205
|
+
const DOCS_COMPAT_START = "<!-- antelopejs-docs-compat:start -->";
|
|
206
|
+
const DOCS_COMPAT_END = "<!-- antelopejs-docs-compat:end -->";
|
|
207
|
+
const DOCS_NODE_START = "<!-- antelopejs-docs-node:start -->";
|
|
208
|
+
const DOCS_NODE_END = "<!-- antelopejs-docs-node:end -->";
|
|
209
|
+
const LOCKFILE = "pnpm-lock.yaml";
|
|
210
|
+
const REQUIREMENTS_HEADING = /^##\s+Requirements\s*$/i;
|
|
211
|
+
const SCOPE = "@antelopejs/";
|
|
212
|
+
const UNRESOLVED = "—";
|
|
213
|
+
const WORKSPACE = "workspace";
|
|
214
|
+
const LEGACY_MARKER = /^<!--\s*docs-compat:\s*\.\/package\.json#\w+\s*-->\s*$/;
|
|
215
|
+
const COMPATIBILITY_HEADING = /^##\s+Compatibility\s*$/i;
|
|
216
|
+
const RESOLVED_SECTIONS = [
|
|
217
|
+
"dependencies",
|
|
218
|
+
"optionalDependencies",
|
|
219
|
+
"devDependencies"
|
|
220
|
+
];
|
|
221
|
+
/** The generated block, rows sorted by package name, formatted as oxfmt leaves it. */
|
|
222
|
+
function compatBlock(rows) {
|
|
223
|
+
const sorted = [...rows].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
224
|
+
return [
|
|
225
|
+
DOCS_COMPAT_START,
|
|
226
|
+
"",
|
|
227
|
+
...tableLines([[
|
|
228
|
+
"Package",
|
|
229
|
+
"Supported",
|
|
230
|
+
"Tested with"
|
|
231
|
+
], ...sorted.map(({ name, supported, tested }) => [
|
|
232
|
+
`\`${name}\``,
|
|
233
|
+
`\`${supported.replaceAll("|", "\\|")}\``,
|
|
234
|
+
tested === void 0 ? UNRESOLVED : `\`${tested}\``
|
|
235
|
+
])]),
|
|
236
|
+
"",
|
|
237
|
+
DOCS_COMPAT_END,
|
|
238
|
+
""
|
|
239
|
+
].join("\n");
|
|
240
|
+
}
|
|
241
|
+
function legacySpanEnd(lines, marker) {
|
|
242
|
+
let index = marker + 1;
|
|
243
|
+
while (index < lines.length && !lines[index].trim()) index++;
|
|
244
|
+
while (index < lines.length && lines[index].trimStart().startsWith("|")) index++;
|
|
245
|
+
while (index < lines.length && !lines[index].trim()) index++;
|
|
246
|
+
return index;
|
|
247
|
+
}
|
|
248
|
+
function replaceLegacyTables(lines, block) {
|
|
249
|
+
const placed = [];
|
|
250
|
+
let replaced = false;
|
|
251
|
+
for (let index = 0; index < lines.length;) {
|
|
252
|
+
if (!LEGACY_MARKER.test(lines[index])) {
|
|
253
|
+
placed.push(lines[index]);
|
|
254
|
+
index++;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (!replaced) placed.push(...block.split("\n"));
|
|
258
|
+
replaced = true;
|
|
259
|
+
index = legacySpanEnd(lines, index);
|
|
260
|
+
}
|
|
261
|
+
return replaced ? placed : void 0;
|
|
262
|
+
}
|
|
263
|
+
function finalNewline(text) {
|
|
264
|
+
return text.endsWith("\n") ? text : `${text}\n`;
|
|
265
|
+
}
|
|
266
|
+
/** The README with the block in place: replacing the markers, a legacy `docs-compat` table, or under `## Compatibility`. */
|
|
267
|
+
function placeCompatBlock(current, block) {
|
|
268
|
+
const text = current ?? "";
|
|
269
|
+
const start = text.indexOf(DOCS_COMPAT_START);
|
|
270
|
+
const end = text.indexOf(DOCS_COMPAT_END);
|
|
271
|
+
if (start === -1 !== (end === -1) || end < start) throw new Error("incomplete antelopejs-docs-compat markers. Repair or delete them, then rerun antelopejs-sync.");
|
|
272
|
+
if (start !== -1) return `${text.slice(0, start)}${block}${text.slice(end + 35).replace(/^\r?\n/, "")}`;
|
|
273
|
+
const lines = text.split("\n");
|
|
274
|
+
const legacy = replaceLegacyTables(lines, block);
|
|
275
|
+
if (legacy) return finalNewline(legacy.join("\n"));
|
|
276
|
+
const heading = lines.findIndex((line) => COMPATIBILITY_HEADING.test(line));
|
|
277
|
+
if (heading !== -1) {
|
|
278
|
+
let rest = heading + 1;
|
|
279
|
+
while (rest < lines.length && !lines[rest].trim()) rest++;
|
|
280
|
+
return finalNewline([
|
|
281
|
+
...lines.slice(0, heading + 1),
|
|
282
|
+
"",
|
|
283
|
+
...block.split("\n"),
|
|
284
|
+
...lines.slice(rest)
|
|
285
|
+
].join("\n"));
|
|
286
|
+
}
|
|
287
|
+
const before = text.trimEnd();
|
|
288
|
+
return `${before}${before ? "\n\n" : ""}## Compatibility\n\n${block}`;
|
|
289
|
+
}
|
|
290
|
+
/** The generated Node prerequisite block for an `engines.node` range, formatted as oxfmt leaves it. */
|
|
291
|
+
function nodeBlock(range) {
|
|
292
|
+
return `${DOCS_NODE_START}\n\nThis package requires Node.js \`${range}\`.\n${DOCS_NODE_END}\n`;
|
|
293
|
+
}
|
|
294
|
+
/** The README with the Node block in place: between its markers, under `## Requirements`, or in a new `## Requirements` section at the end. */
|
|
295
|
+
function placeNodeBlock(current, block) {
|
|
296
|
+
const start = current.indexOf(DOCS_NODE_START);
|
|
297
|
+
const end = current.indexOf(DOCS_NODE_END);
|
|
298
|
+
if (start === -1 !== (end === -1) || end < start) throw new Error("incomplete antelopejs-docs-node markers. Repair or delete them, then rerun antelopejs-sync.");
|
|
299
|
+
if (start !== -1) return `${current.slice(0, start)}${block}${current.slice(end + 33).replace(/^\r?\n/, "")}`;
|
|
300
|
+
const lines = current.split("\n");
|
|
301
|
+
const heading = lines.findIndex((line) => REQUIREMENTS_HEADING.test(line));
|
|
302
|
+
if (heading !== -1) {
|
|
303
|
+
let rest = heading + 1;
|
|
304
|
+
while (rest < lines.length && !lines[rest].trim()) rest++;
|
|
305
|
+
return finalNewline([
|
|
306
|
+
...lines.slice(0, heading + 1),
|
|
307
|
+
"",
|
|
308
|
+
...block.trimEnd().split("\n"),
|
|
309
|
+
...rest < lines.length ? ["", ...lines.slice(rest)] : []
|
|
310
|
+
].join("\n"));
|
|
311
|
+
}
|
|
312
|
+
return `${current.trimEnd()}\n\n## Requirements\n\n${block}`;
|
|
313
|
+
}
|
|
314
|
+
function relative$1(directory, name) {
|
|
315
|
+
return directory ? `${directory}/${name}` : name;
|
|
316
|
+
}
|
|
317
|
+
function isDirectory(root, path) {
|
|
318
|
+
return statSync(join(root, path), { throwIfNoEntry: false })?.isDirectory() === true;
|
|
319
|
+
}
|
|
320
|
+
function subdirectories(root, directory) {
|
|
321
|
+
return readdirSync(join(root, directory), { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")).map((entry) => relative$1(directory, entry.name));
|
|
322
|
+
}
|
|
323
|
+
function descendants(root, directory) {
|
|
324
|
+
return subdirectories(root, directory).flatMap((child) => [child, ...descendants(root, child)]);
|
|
325
|
+
}
|
|
326
|
+
function globExpression(pattern) {
|
|
327
|
+
const source = pattern.split("/").map((segment) => segment === "**" ? "(?:.*)" : segment.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("*", "[^/]*").replaceAll("?", "[^/]")).join("/").replaceAll("(?:.*)/", "(?:.*/)?");
|
|
328
|
+
return new RegExp(`^${source}$`);
|
|
329
|
+
}
|
|
330
|
+
function expand(root, pattern) {
|
|
331
|
+
let directories = [""];
|
|
332
|
+
for (const segment of pattern.split("/")) if (segment === "**") directories = directories.flatMap((directory) => [directory, ...descendants(root, directory)]);
|
|
333
|
+
else if (/[*?]/.test(segment)) {
|
|
334
|
+
const expression = globExpression(segment);
|
|
335
|
+
directories = directories.flatMap((directory) => subdirectories(root, directory).filter((child) => expression.test(child.slice(child.lastIndexOf("/") + 1))));
|
|
336
|
+
} else directories = directories.map((directory) => relative$1(directory, segment)).filter((directory) => isDirectory(root, directory));
|
|
337
|
+
return directories;
|
|
338
|
+
}
|
|
339
|
+
function normalizePattern(pattern) {
|
|
340
|
+
return pattern.replace(/^(?:\.\/)+/, "").replace(/\/+$/, "").replace(/^\.$/, "");
|
|
341
|
+
}
|
|
342
|
+
function scalarItems(document, path) {
|
|
343
|
+
const node = document.getIn(path, true);
|
|
344
|
+
return isSeq(node) ? node.items.flatMap((item) => isScalar(item) ? [String(item.value)] : []) : [];
|
|
345
|
+
}
|
|
346
|
+
/** pnpm-workspace.yaml `packages`, else package.json `workspaces` as an array or as `{ packages }`; JSON parses as YAML. */
|
|
347
|
+
function workspacePatterns(root) {
|
|
348
|
+
const pnpm = join(root, "pnpm-workspace.yaml");
|
|
349
|
+
if (existsSync(pnpm)) return scalarItems(parseDocument(readFileSync(pnpm, "utf8")), ["packages"]);
|
|
350
|
+
const manifest = parseDocument(readFileSync(join(root, "package.json"), "utf8"));
|
|
351
|
+
return scalarItems(manifest, isMap(manifest.get("workspaces", true)) ? ["workspaces", "packages"] : ["workspaces"]);
|
|
352
|
+
}
|
|
353
|
+
/** The workspace package directories, relative to `root` and sorted, that `pnpm-workspace.yaml` or package.json `workspaces` list. */
|
|
354
|
+
function workspaceDirectories(root) {
|
|
355
|
+
const patterns = workspacePatterns(root);
|
|
356
|
+
const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => globExpression(normalizePattern(pattern.slice(1))));
|
|
357
|
+
const found = /* @__PURE__ */ new Set();
|
|
358
|
+
for (const pattern of patterns.filter((item) => !item.startsWith("!"))) {
|
|
359
|
+
const normalized = normalizePattern(pattern);
|
|
360
|
+
for (const directory of normalized ? expand(root, normalized) : [""]) if (directory && !excluded.some((expression) => expression.test(directory)) && existsSync(join(root, directory, "package.json"))) found.add(directory);
|
|
361
|
+
}
|
|
362
|
+
return [...found].sort();
|
|
363
|
+
}
|
|
364
|
+
function declaredRanges(manifest) {
|
|
365
|
+
const ranges = /* @__PURE__ */ new Map();
|
|
366
|
+
for (const field of [
|
|
367
|
+
manifest.optionalDependencies,
|
|
368
|
+
manifest.dependencies,
|
|
369
|
+
manifest.peerDependencies
|
|
370
|
+
]) for (const [name, range] of Object.entries(field ?? {})) if (name.startsWith(SCOPE)) ranges.set(name, range);
|
|
371
|
+
return ranges;
|
|
372
|
+
}
|
|
373
|
+
function readManifest(root, directory) {
|
|
374
|
+
return parseManifest(readFileSync(join(root, directory, "package.json"), "utf8"));
|
|
375
|
+
}
|
|
376
|
+
/** The version the lockfile resolves for a dependency; a `link:` resolves to `workspace`, so a release that bumps the linked package leaves this README unchanged. */
|
|
377
|
+
function resolvedVersion({ document, importer }, name) {
|
|
378
|
+
for (const section of RESOLVED_SECTIONS) {
|
|
379
|
+
const entry = document.getIn([
|
|
380
|
+
"importers",
|
|
381
|
+
importer,
|
|
382
|
+
section,
|
|
383
|
+
name
|
|
384
|
+
], true);
|
|
385
|
+
const version = isMap(entry) ? entry.get("version", true) : entry;
|
|
386
|
+
if (!isScalar(version)) continue;
|
|
387
|
+
const resolved = String(version.value).split("(")[0];
|
|
388
|
+
return resolved.startsWith("link:") ? WORKSPACE : resolved;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const UNSHARED_NPMRC = /^\s*shared-workspace-lockfile\s*=\s*false\s*(?:[#;].*)?$/m;
|
|
392
|
+
/** Whether the workspace keeps one root lockfile, or `shared-workspace-lockfile=false` gives each package its own. */
|
|
393
|
+
function sharesLockfile(root) {
|
|
394
|
+
const npmrc = join(root, ".npmrc");
|
|
395
|
+
if (existsSync(npmrc) && UNSHARED_NPMRC.test(readFileSync(npmrc, "utf8"))) return false;
|
|
396
|
+
const workspace = join(root, "pnpm-workspace.yaml");
|
|
397
|
+
return !(existsSync(workspace) && parseDocument(readFileSync(workspace, "utf8")).get("sharedWorkspaceLockfile") === false);
|
|
398
|
+
}
|
|
399
|
+
/** The lockfile path of a package, relative to the root. A shared lockfile is the root's, indexed by the package directory. */
|
|
400
|
+
function lockPath(shared, directory) {
|
|
401
|
+
return shared ? LOCKFILE : relative$1(directory, LOCKFILE);
|
|
402
|
+
}
|
|
403
|
+
function readLock(root, shared, directory, documents) {
|
|
404
|
+
const path = join(root, lockPath(shared, directory));
|
|
405
|
+
if (!documents.has(path) && existsSync(path)) documents.set(path, parseDocument(readFileSync(path, "utf8")));
|
|
406
|
+
const document = documents.get(path);
|
|
407
|
+
return document && {
|
|
408
|
+
document,
|
|
409
|
+
importer: shared ? directory || "." : "."
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/** Adds one package's `docs-files` lines and, when it needs one, its README with the generated blocks. */
|
|
413
|
+
function planPackage(root, plan, lock, standard, { directory, name, ranges, published, node }) {
|
|
414
|
+
const readme = relative$1(directory, "README.md");
|
|
415
|
+
const docs = relative$1(directory, "docs");
|
|
416
|
+
if (!published) return;
|
|
417
|
+
if (ranges.size > 0 || existsSync(join(root, readme))) plan.docsFiles.push(readme);
|
|
418
|
+
if (isDirectory(root, docs)) plan.docsFiles.push(docs);
|
|
419
|
+
const current = existsSync(join(root, readme)) ? readFileSync(join(root, readme), "utf8") : void 0;
|
|
420
|
+
const nodeRange = standard && current !== void 0 ? node : void 0;
|
|
421
|
+
if (ranges.size === 0 && current === void 0) return;
|
|
422
|
+
const rows = [...ranges].map(([name, supported]) => ({
|
|
423
|
+
name,
|
|
424
|
+
supported,
|
|
425
|
+
tested: lock && resolvedVersion(lock, name)
|
|
426
|
+
}));
|
|
427
|
+
try {
|
|
428
|
+
const withRequirements = nodeRange !== void 0 && current !== void 0 ? placeNodeBlock(current, nodeBlock(nodeRange)) : current;
|
|
429
|
+
plan.readmes.push({
|
|
430
|
+
path: readme,
|
|
431
|
+
current,
|
|
432
|
+
content: placeFrameworkModulesBlock(placeModulesBlock(rows.length > 0 ? placeCompatBlock(withRequirements, compatBlock(rows)) : withRequirements ?? ""), name)
|
|
433
|
+
});
|
|
434
|
+
} catch (error) {
|
|
435
|
+
plan.errors.push(`${readme}: ${error instanceof Error ? error.message : String(error)}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Plans the docs-compat block of the root and of every workspace package that is not private and declares an
|
|
440
|
+
* `@antelopejs/*` peer, runtime or optional dependency, and the `docs-files` lines covering the root and every workspace
|
|
441
|
+
* package that is not private.
|
|
442
|
+
* Tested with comes from pnpm-lock.yaml, each package's own when `shared-workspace-lockfile=false`, and is `workspace` for a `link:` dependency; other package managers get a dash.
|
|
443
|
+
*/
|
|
444
|
+
function planDocs(root, manager) {
|
|
445
|
+
const rootManifest = readManifest(root, "");
|
|
446
|
+
const packages = ["", ...workspaceDirectories(root)].map((directory) => {
|
|
447
|
+
const manifest = directory ? readManifest(root, directory) : rootManifest;
|
|
448
|
+
return {
|
|
449
|
+
directory,
|
|
450
|
+
name: manifest.name,
|
|
451
|
+
published: !directory || !manifest.private,
|
|
452
|
+
node: manifest.engines?.node,
|
|
453
|
+
ranges: manifest.private ? /* @__PURE__ */ new Map() : declaredRanges(manifest)
|
|
454
|
+
};
|
|
455
|
+
});
|
|
456
|
+
const qualifying = packages.filter(({ ranges }) => ranges.size > 0);
|
|
457
|
+
const plan = {
|
|
458
|
+
readmes: [],
|
|
459
|
+
docsFiles: [],
|
|
460
|
+
errors: [],
|
|
461
|
+
exists: (path) => existsSync(join(root, path))
|
|
462
|
+
};
|
|
463
|
+
const shared = sharesLockfile(root);
|
|
464
|
+
const documents = /* @__PURE__ */ new Map();
|
|
465
|
+
const locks = new Map(qualifying.map(({ directory }) => [directory, manager === "pnpm" ? readLock(root, shared, directory, documents) : void 0]));
|
|
466
|
+
const missing = manager === "pnpm" ? qualifying.filter(({ directory }) => !locks.get(directory)) : [];
|
|
467
|
+
if (missing.length) {
|
|
468
|
+
for (const path of new Set(missing.map(({ directory }) => lockPath(shared, directory)))) plan.errors.push(`${path} is missing, and the docs-compat block reads Tested with from it: run pnpm install, then rerun antelopejs-sync.`);
|
|
469
|
+
return plan;
|
|
470
|
+
}
|
|
471
|
+
const standard = rootManifest.antelopeJs?.docs?.standard === true;
|
|
472
|
+
for (const item of packages) planPackage(root, plan, locks.get(item.directory), standard, item);
|
|
473
|
+
return plan;
|
|
474
|
+
}
|
|
475
|
+
//#endregion
|
|
476
|
+
export { workspaceDirectories as n, workspacePatterns as r, planDocs as t };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
//#region src/interface-ranges.ts
|
|
2
|
+
/**
|
|
3
|
+
* At startup `@antelopejs/core` keeps one copy of each interface package, the
|
|
4
|
+
* one its implementing module installed, and refuses to start when any loaded
|
|
5
|
+
* module declares a range that copy falls outside. An exact pin (`0.1.7`) or a
|
|
6
|
+
* 0.x caret (`^0.1.2` means `<0.2.0`) therefore stops a module from starting
|
|
7
|
+
* as soon as the implementer resolves the next interface release, with no
|
|
8
|
+
* change to the module itself.
|
|
9
|
+
*
|
|
10
|
+
* A consumer accepts every release from its floor up to the next breaking one
|
|
11
|
+
* (`>=0.1.7 <1.0.0`). The module that implements an interface is the opposite
|
|
12
|
+
* case: it must never be handed a breaking minor it does not implement, so it
|
|
13
|
+
* caps the range below the next minor (`>=0.3.0 <0.4.0`) while the interface
|
|
14
|
+
* is 0.x.
|
|
15
|
+
*/
|
|
16
|
+
const INTERFACE_PACKAGE_PREFIX = "@antelopejs/interface-";
|
|
17
|
+
/** A module's own interface linked from the workspace is the copy it builds against, not a release it resolves. */
|
|
18
|
+
const LOCAL_SPEC_PREFIXES = [
|
|
19
|
+
"workspace:",
|
|
20
|
+
"file:",
|
|
21
|
+
"link:"
|
|
22
|
+
];
|
|
23
|
+
/** The fields `@antelopejs/core` checks at startup. */
|
|
24
|
+
const CHECKED_FIELDS = ["dependencies", "optionalDependencies"];
|
|
25
|
+
const BOUNDED_RANGE = /^>=(\d+)\.(\d+)\.(\d+) <(\d+)\.(\d+)\.(\d+)$/;
|
|
26
|
+
const SINGLE_VERSION = /^[\^~=]?v?(\d+)\.(\d+)\.(\d+)$/;
|
|
27
|
+
const formatVersion = ([major, minor, patch]) => `${major}.${minor}.${patch}`;
|
|
28
|
+
const sameVersion = (a, b) => a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
29
|
+
/** The first release a module declaring `floor` must not be handed. */
|
|
30
|
+
function rangeCeiling(floor, role) {
|
|
31
|
+
const [major, minor] = floor;
|
|
32
|
+
if (major > 0) return [
|
|
33
|
+
major + 1,
|
|
34
|
+
0,
|
|
35
|
+
0
|
|
36
|
+
];
|
|
37
|
+
return role === "implementer" ? [
|
|
38
|
+
0,
|
|
39
|
+
minor + 1,
|
|
40
|
+
0
|
|
41
|
+
] : [
|
|
42
|
+
1,
|
|
43
|
+
0,
|
|
44
|
+
0
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
function expectedRange(floor, role) {
|
|
48
|
+
return `>=${formatVersion(floor)} <${formatVersion(rangeCeiling(floor, role))}`;
|
|
49
|
+
}
|
|
50
|
+
function toVersion(match, offset) {
|
|
51
|
+
return [
|
|
52
|
+
Number(match[offset]),
|
|
53
|
+
Number(match[offset + 1]),
|
|
54
|
+
Number(match[offset + 2])
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
/** The lowest release `spec` accepts, when it is a shape this check reads. */
|
|
58
|
+
function readFloor(spec) {
|
|
59
|
+
const bounded = BOUNDED_RANGE.exec(spec);
|
|
60
|
+
if (bounded) return toVersion(bounded, 1);
|
|
61
|
+
const single = SINGLE_VERSION.exec(spec);
|
|
62
|
+
return single ? toVersion(single, 1) : void 0;
|
|
63
|
+
}
|
|
64
|
+
function compareVersions(a, b) {
|
|
65
|
+
return a[0] - b[0] || a[1] - b[1] || a[2] - b[2];
|
|
66
|
+
}
|
|
67
|
+
/** A range is accepted when it is bounded for its role and admits the interface this package builds against. */
|
|
68
|
+
function isAcceptedRange(spec, role, local) {
|
|
69
|
+
const bounded = BOUNDED_RANGE.exec(spec);
|
|
70
|
+
if (!bounded) return false;
|
|
71
|
+
const floor = toVersion(bounded, 1);
|
|
72
|
+
const ceiling = toVersion(bounded, 4);
|
|
73
|
+
if (!sameVersion(ceiling, rangeCeiling(floor, role))) return false;
|
|
74
|
+
return local === void 0 || compareVersions(local, floor) >= 0 && compareVersions(local, ceiling) < 0;
|
|
75
|
+
}
|
|
76
|
+
function isLocalSpec(spec) {
|
|
77
|
+
return LOCAL_SPEC_PREFIXES.some((prefix) => spec.startsWith(prefix));
|
|
78
|
+
}
|
|
79
|
+
/** The version of each named package among `manifests`, the packages that sit in the same repository. */
|
|
80
|
+
function localVersions(manifests) {
|
|
81
|
+
const versions = /* @__PURE__ */ new Map();
|
|
82
|
+
for (const { name, version } of manifests) if (name && version) versions.set(name, version);
|
|
83
|
+
return versions;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `localVersions` holds the versions of the packages that sit in the same
|
|
87
|
+
* repository. An implemented interface is usually one of them, and its
|
|
88
|
+
* version, rather than the declared floor, decides the minor to stop below.
|
|
89
|
+
*/
|
|
90
|
+
function checkInterfaceRanges(manifest, localVersions = /* @__PURE__ */ new Map()) {
|
|
91
|
+
const implemented = new Set(manifest.antelopeJs?.implements ?? []);
|
|
92
|
+
const violations = [];
|
|
93
|
+
for (const field of CHECKED_FIELDS) for (const [name, spec] of Object.entries(manifest[field] ?? {})) {
|
|
94
|
+
if (!name.startsWith(INTERFACE_PACKAGE_PREFIX) || isLocalSpec(spec)) continue;
|
|
95
|
+
const role = implemented.has(name) ? "implementer" : "consumer";
|
|
96
|
+
const localVersion = localVersions.get(name);
|
|
97
|
+
const local = role === "implementer" && localVersion !== void 0 ? readFloor(localVersion) : void 0;
|
|
98
|
+
if (isAcceptedRange(spec, role, local)) continue;
|
|
99
|
+
const floor = local ?? readFloor(spec);
|
|
100
|
+
violations.push({
|
|
101
|
+
field,
|
|
102
|
+
name,
|
|
103
|
+
spec,
|
|
104
|
+
role,
|
|
105
|
+
expected: floor ? expectedRange(floor, role) : void 0
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return violations;
|
|
109
|
+
}
|
|
110
|
+
function describeViolation(violation) {
|
|
111
|
+
const { field, name, spec, role, expected } = violation;
|
|
112
|
+
const fix = expected ? `use "${expected}"` : role === "implementer" ? "declare it as >=<floor> <next minor>" : "declare it as >=<floor> <1.0.0";
|
|
113
|
+
return `${field}["${name}"] is "${spec}": ${role === "implementer" ? "this package implements it, so it must stop below the next minor" : "it must accept every release up to the next breaking one"}; ${fix}`;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { describeViolation as n, localVersions as r, checkInterfaceRanges as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { s as parseManifest } from "./package-DnxZ2CXZ.mjs";
|
|
2
2
|
import { u as trackedManifests } from "./files-DJ0TeaTU.mjs";
|
|
3
|
+
import { n as workspaceDirectories, r as workspacePatterns } from "./docs-compat-Ft1r2sf0.mjs";
|
|
3
4
|
import { createRequire } from "node:module";
|
|
4
5
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { dirname, join, matchesGlob, relative, resolve, sep } from "node:path";
|
|
@@ -45,8 +46,9 @@ function describePackage(directory) {
|
|
|
45
46
|
function isExportPath(target) {
|
|
46
47
|
return typeof target === "string";
|
|
47
48
|
}
|
|
48
|
-
/** A proof analyses only packages that publish something: not private, and declaring at least one of `exports`, `main`, `types`, `typings` or `typesVersions`. */
|
|
49
|
-
function unpublishedReason(manifest) {
|
|
49
|
+
/** A proof analyses only packages that publish something: in the repository's workspace, not private, and declaring at least one of `exports`, `main`, `types`, `typings` or `typesVersions`. */
|
|
50
|
+
function unpublishedReason(manifest, member) {
|
|
51
|
+
if (!member) return "not a workspace package";
|
|
50
52
|
if (manifest.private === true) return "private";
|
|
51
53
|
return [
|
|
52
54
|
manifest.exports,
|
|
@@ -56,23 +58,34 @@ function unpublishedReason(manifest) {
|
|
|
56
58
|
manifest.typesVersions
|
|
57
59
|
].some((field) => field != null) ? void 0 : "no exports, main or types";
|
|
58
60
|
}
|
|
61
|
+
/** Whether the package at `directory` belongs to the workspace at `root`: always when `root` declares none or lists a pattern with glob syntax beyond `*`, `?` and `**`, else when it is `root` or a listed member. */
|
|
62
|
+
function workspaceMember(root) {
|
|
63
|
+
const pnpm = existsSync(join(root, "pnpm-workspace.yaml"));
|
|
64
|
+
if (!pnpm && !existsSync(join(root, "package.json"))) return () => true;
|
|
65
|
+
const patterns = workspacePatterns(root);
|
|
66
|
+
if (!pnpm && !patterns.length || patterns.some((pattern) => /[{}[\]()]/u.test(pattern))) return () => true;
|
|
67
|
+
const members = new Set(workspaceDirectories(root));
|
|
68
|
+
return (directory) => directory === "." || members.has(directory);
|
|
69
|
+
}
|
|
59
70
|
function trackedPackages(root) {
|
|
71
|
+
const member = workspaceMember(root);
|
|
60
72
|
return trackedManifests(root).flatMap((file) => {
|
|
61
73
|
const directory = dirname(file);
|
|
62
74
|
if (!existsSync(join(root, directory, "tsconfig.json"))) return [];
|
|
63
75
|
return [{
|
|
64
76
|
directory,
|
|
65
|
-
manifest: JSON.parse(readFileSync(join(root, file), "utf8"))
|
|
77
|
+
manifest: JSON.parse(readFileSync(join(root, file), "utf8")),
|
|
78
|
+
member: member(directory)
|
|
66
79
|
}];
|
|
67
80
|
});
|
|
68
81
|
}
|
|
69
82
|
function packagesAt(root, publishedOnly) {
|
|
70
|
-
return trackedPackages(root).filter(({ manifest }) => !publishedOnly || unpublishedReason(manifest) === void 0);
|
|
83
|
+
return trackedPackages(root).filter(({ manifest, member }) => !publishedOnly || unpublishedReason(manifest, member) === void 0);
|
|
71
84
|
}
|
|
72
85
|
/** The packages a published-only proof leaves out, each with the reason, so a skip is reported rather than silent. */
|
|
73
86
|
function unpublishedAt(root) {
|
|
74
|
-
return trackedPackages(root).flatMap(({ directory, manifest }) => {
|
|
75
|
-
const reason = unpublishedReason(manifest);
|
|
87
|
+
return trackedPackages(root).flatMap(({ directory, manifest, member }) => {
|
|
88
|
+
const reason = unpublishedReason(manifest, member);
|
|
76
89
|
return reason === void 0 ? [] : [{
|
|
77
90
|
directory,
|
|
78
91
|
reason
|
package/dist/verify/index.d.mts
CHANGED
|
@@ -56,6 +56,8 @@ interface ServiceDefinition {
|
|
|
56
56
|
env?: {
|
|
57
57
|
[name: string]: string;
|
|
58
58
|
};
|
|
59
|
+
/** Passed after the image to `docker run`, in order, in place of the image's default command; an entrypoint such as MariaDB's or MySQL's hands arguments starting with `-` to its server, as in `["--performance-schema=ON", "--log-bin"]`. */
|
|
60
|
+
args?: string[];
|
|
59
61
|
/** Runs inside the container until it exits 0: the readiness probe. */
|
|
60
62
|
ready: string[];
|
|
61
63
|
/** Runs inside the container before each journey, so every journey starts from a clean state. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/tooling-configs",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "Shared tooling presets for AntelopeJS repositories: oxlint (with the vendored anti-slop rules), oxfmt, ESLint for Nuxt layers, Knip, and an interface range check",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|