@antelopejs/tooling-configs 0.5.6 → 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.
@@ -3,7 +3,7 @@ import { o as packageManager, s as parseManifest } from "../package-DnxZ2CXZ.mjs
3
3
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
4
4
  import { c as repositoryRoot, l as resolveRevision } from "../files-DJ0TeaTU.mjs";
5
5
  import { a as DIRECTORY_LINK, c as revisionCounts, d as createAddedPolicy, f as describeAllowance, i as stampProof, l as workspaceManifests, m as recordVerdict, o as compareRevisions, p as fillStars, u as allowedByGlob } from "../proof-stamp-Kg-tkM6G.mjs";
6
- import { c as packagesAt, i as isTestSource, l as unpublishedAt, o as loadTypeScript, r as isExportPath, s as outputRoot, t as emitPackage } from "../typescript-DhavwHb7.mjs";
6
+ import { c as packagesAt, i as isTestSource, l as unpublishedAt, o as loadTypeScript, r as isExportPath, s as outputRoot, t as emitPackage } from "../typescript-CqcOaci8.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import { copyFileSync, cpSync, existsSync, globSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
9
9
  import { basename, dirname, isAbsolute, join, parse, posix, relative, resolve, sep } from "node:path";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
3
3
  import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
- import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-DqTjyKCC.mjs";
4
+ import { r as runChecks, t as CHECKS_SKIP_ENV } from "../checks-CD2oFGrt.mjs";
5
5
  import { parseArgs } from "node:util";
6
6
  //#region src/bin/checks.ts
7
7
  const SIGNAL_EXIT = /* @__PURE__ */ new Map([
@@ -2,7 +2,7 @@
2
2
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
3
3
  import { c as repositoryRoot } from "../files-DJ0TeaTU.mjs";
4
4
  import { c as revisionCounts, i as stampProof, o as compareRevisions } from "../proof-stamp-Kg-tkM6G.mjs";
5
- import { a as listsNoFiles, c as packagesAt, n as extendedConfigs, t as emitPackage } from "../typescript-DhavwHb7.mjs";
5
+ import { a as listsNoFiles, c as packagesAt, n as extendedConfigs, t as emitPackage } from "../typescript-CqcOaci8.mjs";
6
6
  import { copyFileSync, existsSync, mkdirSync } from "node:fs";
7
7
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
8
8
  //#region src/guardrails/comment-proof.ts
package/dist/bin/sync.mjs CHANGED
@@ -8,8 +8,9 @@ import { r as localVersions, t as checkInterfaceRanges } from "../interface-rang
8
8
  import { t as runCli } from "../cli-4Tv71vYk.mjs";
9
9
  import { c as CI_CONTEXT, f as ciWorkflow, i as hasChecksWorkflow, n as ciNodeCallers, p as placeholderTestScript, r as ciRenovateSyncCallers, s as renovateArtifacts, t as MISSING_CHECKS_WORKFLOW, u as CI_PATH } from "../workflow-CPcNc8KL.mjs";
10
10
  import { a as gitFiles, c as repositoryRoot, u as trackedManifests } from "../files-DJ0TeaTU.mjs";
11
- import { a as stepsOf, c as workspacePatterns, i as matchingScripts, n as droppedChecksSteps, o as planDocs, s as workspaceDirectories } from "../checks-DqTjyKCC.mjs";
11
+ import { n as workspaceDirectories, r as workspacePatterns, t as planDocs } from "../docs-compat-Ft1r2sf0.mjs";
12
12
  import { i as recordedRelease, t as measureBaseline } from "../ratchet-1O8k4Dxu.mjs";
13
+ import { a as stepsOf, i as matchingScripts, n as droppedChecksSteps } from "../checks-CD2oFGrt.mjs";
13
14
  import { n as SUPPRESSIONS_FILE, r as adoptedBudget } from "../suppression-budget-DgYdu6JK.mjs";
14
15
  import { u as typescript } from "../suppressions-CQTcKCi1.mjs";
15
16
  import { t as DEFAULT_SHARED } from "../map-DRyYz_Fw.mjs";
@@ -272,10 +273,16 @@ function agentsBlock(context) {
272
273
  //#endregion
273
274
  //#region src/guardrails/pnpm-workspace.ts
274
275
  const PATH = "pnpm-workspace.yaml";
275
- /** Whether the pinned pnpm reads settings from a `pnpm-workspace.yaml` without `packages`, which pnpm before 10.5 rejects. An unpinned pnpm counts as current. */
276
- function readsSettings(manifest) {
276
+ /** The first pnpm that keeps `pnpm --dir <nested> install` in the nested project when the root `pnpm-workspace.yaml` has no `packages`. Earlier pnpm installs the root instead. */
277
+ const SCOPED_NESTED_INSTALLS = "11.27.1";
278
+ /**
279
+ * What sync does for a repository without a `pnpm-workspace.yaml`, by its pinned pnpm. An unpinned pnpm counts as current.
280
+ * pnpm 10 and earlier only warn about an undecided build, so they get no file. pnpm 11 fails the install without one, and before 11.27.1 misroutes nested installs with one, so its pin must rise.
281
+ */
282
+ function creation(manifest) {
277
283
  const pinned = manifest.packageManager?.split("@")[1];
278
- return pinned === void 0 || admits(">=10.5.0", pinned);
284
+ if (pinned === void 0 || admits(`>=${SCOPED_NESTED_INSTALLS}`, pinned)) return "write";
285
+ return admits(">=11.0.0", pinned) ? "raise" : "skip";
279
286
  }
280
287
  /**
281
288
  * The dependency builds sync declares and pnpm 11 must be told to skip.
@@ -284,6 +291,14 @@ function readsSettings(manifest) {
284
291
  function skippedBuilds(captures) {
285
292
  return captures ? ["lefthook", "mongodb-memory-server"] : ["lefthook"];
286
293
  }
294
+ /** Whether `current` holds nothing but builds sync turns off, so pnpm reads it only to make the repository root a workspace. */
295
+ function onlyDecidedBuilds(current) {
296
+ const document = parseDocument(current);
297
+ const builds = document.get("allowBuilds");
298
+ if (document.errors.length || !isMap(document.contents) || document.contents.items.length !== 1 || !isMap(builds) || !builds.items.length) return false;
299
+ const synced = skippedBuilds(true);
300
+ return builds.items.every(({ key, value }) => isScalar(key) && synced.includes(String(key.value)) && isScalar(value) && value.value === false);
301
+ }
287
302
  /**
288
303
  * `current` with `allowBuilds.<name>` set to `false` for each of `names` the repository does not already decide.
289
304
  * pnpm 11 fails an install on a dependency build it was not told about.
@@ -315,10 +330,18 @@ function pnpmWorkspaceArtifacts(root, manifest, managed) {
315
330
  if (!managed || packageManager(manifest) !== "pnpm") return [];
316
331
  const file = join(root, PATH);
317
332
  const current = existsSync(file) ? readFileSync(file, "utf8") : void 0;
318
- if (current === void 0 && !readsSettings(manifest)) return [];
319
333
  const names = skippedBuilds(usesCaptures(root));
320
334
  try {
321
335
  const content = withBuildsDecided(names, current);
336
+ const action = creation(manifest);
337
+ if (action !== "write" && onlyDecidedBuilds(content)) {
338
+ if (action === "skip" && current === void 0) return [];
339
+ return [{
340
+ kind: "error",
341
+ path: PATH,
342
+ message: action === "skip" ? `${PATH} holds nothing but the allowBuilds that antelopejs-sync writes. pnpm before 11 does not need it, and it makes a nested \`pnpm install\` install the repository root. Delete ${PATH}, then rerun antelopejs-sync.` : `pnpm 11 needs a ${PATH} to install ${names.join(" and ")}, and before ${SCOPED_NESTED_INSTALLS} that file makes a nested \`pnpm install\` install the repository root. Set \`packageManager\` to \`pnpm@${SCOPED_NESTED_INSTALLS}\` or later, then rerun antelopejs-sync.`
343
+ }];
344
+ }
322
345
  return [content === current ? {
323
346
  kind: "unchanged",
324
347
  path: PATH
@@ -895,7 +918,7 @@ const KIND_TEXT = {
895
918
  - a plain function runs the \`interface.calls\` hook of \`verify.config.ts\` and must return its \`expect\`; one only providers call is listed in \`interface.providerSide\` with why.
896
919
  A declared function with none of these fails the journey.
897
920
  - \`minor-bump\`: reads the declared functions of the packed head and of the published version (\`npm pack <name>@<latest>\`). An added, changed or removed function needs a release of at least the next minor. The release is the head version when it is already bumped, otherwise what changelogen makes of the change title (\`new --title\`) or the commit subjects since the base.`,
898
- layer: `- \`services\`: image, port, readiness command and a \`reset\` command run before every journey, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\`.
921
+ layer: `- \`services\`: image, port, optional \`args\`, readiness command and a \`reset\` command run before every journey, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\`.
899
922
  - \`interface.provide(api, services)\` runs in the stub provider after the generic stubs attach, for example to hand a client pointed at \`services\` to \`internal.SetClient\`.
900
923
  - \`interface.calls["<entry>:<path>"]\` calls a plain exported function from the consumer and states the value it must return.
901
924
  - \`interface.providerSide["<entry>:<path>"]\` names a function only providers call, with the reason.`,
@@ -908,7 +931,7 @@ const KIND_TEXT = {
908
931
  user: "The user of a module is an app developer: they add it to `antelope.config.ts`, configure it, and other modules call the interfaces it implements.",
909
932
  launch: "`new` runs the setup (`pnpm run build` by default), then starts every `services` entry of `verify.config.ts` in its own Docker container on a free loopback port, named `<prefix>-<repo>-<service>-<run>` (`VERIFY_CONTAINER_PREFIX`, default `verify`), and waits for each readiness command. A provider with sandbox keys in `saas.env` records the missing ones.",
910
933
  builtins: "- `module-dev`: a fixture project installs the module as `local` with `moduleConfig(services)` as its config, plus the `companions(services)` modules and a consumer module. `ajs project dev` must answer, the consumer must load every implemented interface, Ctrl+C must exit 130 and the port must refuse afterwards.",
911
- layer: `- \`services\`: image, port, readiness command and a \`reset\` command run before every journey, so each starts from a clean state.
934
+ layer: `- \`services\`: image, port, readiness command and a \`reset\` command run before every journey, so each starts from a clean state. Optional \`args\` follow the image in \`docker run\` in place of its default command, such as \`["--performance-schema=ON", "--log-bin"]\` for MariaDB's server.
912
935
  - \`moduleConfig(services)\`: the module's configuration, pointing at the run's containers.
913
936
  - \`companions(services)\`: other modules the fixture project loads, keyed by name, each a \`source\` and an optional \`config\` as in \`antelope.config.ts\`. Add the provider of every interface the module imports that it does not implement, such as \`@antelopejs/api\` for \`@antelopejs/interface-api\`, or the module never finishes starting.
914
937
  - \`saas: { env, sandbox }\`: a SaaS module runs against the provider's sandbox with keys from these environment variables. Without every key, each journey is NOT VERIFIED and so is the verdict, never PASS or PASS+NOTES.
@@ -929,7 +952,7 @@ Both take their project from \`context.prepared("scaffolded", ...)\`, so the run
929
952
  layer: `- \`template.name\`: the listing name users pass to \`--template\`.
930
953
  - \`template.project\`: list it under \`projectTemplates\`.
931
954
  - \`template.module\`: a module template, listed under \`templates\` and created with \`ajs module init\`; it excludes \`template.project\`.
932
- - \`services\`: image, port, readiness command and \`reset\`, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\` and passes their endpoints to the project it starts through the \`env\` of \`context.dev\`.
955
+ - \`services\`: image, port, optional \`args\`, readiness command and \`reset\`, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\` and passes their endpoints to the project it starts through the \`env\` of \`context.dev\`.
933
956
  - \`context.dev(name, project, { command })\`: a template that is not an \`ajs\` project starts with its own command, such as \`["node", "ace", "serve"]\`, in place of \`ajs project dev\`. The harness records its PID, so \`context.stop\` and \`clean\` stop it, and \`template.probe\` decides when it is ready. Leave \`scaffold-dev\` and \`scaffold-checks\` out of its features: both run \`ajs\`.
934
957
  - \`template.probe\`: \`path\`, \`status\` and \`body\` for an HTTP welcome page or endpoint, or \`log\` and \`settleMs\` for a template that serves nothing.`,
935
958
  smoke: "`scaffold-dev` and `scaffold-checks`, or, for a template that is not an `ajs` project, its own journeys that start it with `context.dev(name, project, { command })`",
@@ -1343,8 +1343,8 @@ function waitReady$1(container, ready, folder) {
1343
1343
  /**
1344
1344
  * Starts every service of verify.config.ts in its own container, named
1345
1345
  * `<prefix>-<repo>-<service>-<run id>`, publishes its port on a free
1346
- * loopback port chosen by Docker, raises its open-file limit to 64000, and
1347
- * waits for its readiness command. Each
1346
+ * loopback port chosen by Docker, raises its open-file limit to 64000, passes
1347
+ * its `args` after the image, and waits for its readiness command. Each
1348
1348
  * container is recorded before it is probed, so `clean` removes it even when
1349
1349
  * it never became ready.
1350
1350
  */
@@ -1362,7 +1362,8 @@ function startServices(workspace, state, prefix) {
1362
1362
  "--ulimit",
1363
1363
  `nofile=${OPEN_FILES}:${OPEN_FILES}`,
1364
1364
  ...env,
1365
- definition.image
1365
+ definition.image,
1366
+ ...definition.args ?? []
1366
1367
  ];
1367
1368
  const folder = join(state.evidence, "services", service);
1368
1369
  const elapsed = stopwatch();
@@ -1,6 +1,7 @@
1
1
  import { t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
2
2
  import { o as packageManager, s as parseManifest } from "./package-DnxZ2CXZ.mjs";
3
3
  import { a as gitFiles } from "./files-DJ0TeaTU.mjs";
4
+ import { n as workspaceDirectories } from "./docs-compat-Ft1r2sf0.mjs";
4
5
  import { t as accepting } from "./ports-DGP6bPJy.mjs";
5
6
  import { createRequire } from "node:module";
6
7
  import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -11,476 +12,6 @@ import ts from "typescript";
11
12
  import { createHash } from "node:crypto";
12
13
  import { tmpdir } from "node:os";
13
14
  import { minimatch } from "minimatch";
14
- //#region src/guardrails/marker-block.ts
15
- /** The comment pair sync writes a generated block between. */
16
- function markers(name) {
17
- return {
18
- name,
19
- start: `<!-- ${name}:start -->`,
20
- end: `<!-- ${name}:end -->`
21
- };
22
- }
23
- /** The README with `block` between its markers. A README without markers comes back as it is. */
24
- function placeMarkedBlock(current, { name, start, end }, block) {
25
- const starts = current.split(start).length - 1;
26
- const ends = current.split(end).length - 1;
27
- if (starts === 0 && ends === 0) return current;
28
- const from = current.indexOf(start);
29
- const to = current.indexOf(end);
30
- 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.`);
31
- return `${current.slice(0, from)}${block}${current.slice(to + end.length).replace(/^\r?\n/, "")}`;
32
- }
33
- //#endregion
34
- //#region src/guardrails/markdown-table.ts
35
- /** The lines of a Markdown table whose first row is the header, columns padded as oxfmt leaves them. */
36
- function tableLines(table) {
37
- const widths = table[0].map((_, column) => Math.max(3, ...table.map((row) => row[column].length)));
38
- const line = (cells) => `| ${cells.map((cell, column) => cell.padEnd(widths[column])).join(" | ")} |`;
39
- return [
40
- line(table[0]),
41
- line(widths.map((width) => "-".repeat(width))),
42
- ...table.slice(1).map(line)
43
- ];
44
- }
45
- //#endregion
46
- //#region src/guardrails/docs-framework-modules.ts
47
- const FRAMEWORK_MODULES = markers("antelopejs-framework-modules");
48
- const FRAMEWORK_MODULES_START = FRAMEWORK_MODULES.start;
49
- const FRAMEWORK_MODULES_END = FRAMEWORK_MODULES.end;
50
- const ORGANIZATION$1 = "https://github.com/AntelopeJS";
51
- const SCOPE$1 = "@antelopejs/";
52
- /** The framework areas in display order. Every README holding the markers lists exactly these. */
53
- const AREAS = [
54
- {
55
- area: "API",
56
- contracts: [
57
- "interface-api",
58
- "interface-api-util",
59
- "interface-data-api"
60
- ],
61
- providers: ["api"]
62
- },
63
- {
64
- area: "Auth",
65
- contracts: ["interface-auth"],
66
- providers: ["auth-jwt"]
67
- },
68
- {
69
- area: "Database",
70
- contracts: [
71
- "interface-database",
72
- "interface-database-decorators",
73
- "interface-database-catalog",
74
- "interface-mongodb",
75
- "interface-rethinkdb"
76
- ],
77
- providers: [
78
- "postgres",
79
- "mongodb",
80
- "rethinkdb"
81
- ]
82
- },
83
- {
84
- area: "Redis",
85
- contracts: ["interface-redis", "interface-redis-scheduler"],
86
- providers: ["redis"]
87
- },
88
- {
89
- area: "Email",
90
- contracts: ["interface-email"],
91
- providers: ["nodemailer", "brevo"]
92
- },
93
- {
94
- area: "File storage",
95
- contracts: ["interface-file-storage"],
96
- providers: ["file-storage-local", "file-storage-s3"]
97
- },
98
- {
99
- area: "Payments",
100
- contracts: [
101
- "interface-payment",
102
- "interface-subscriptions",
103
- "interface-stripe"
104
- ],
105
- providers: [
106
- "stripe",
107
- "mollie",
108
- "checkout-com",
109
- "payment-subscriptions"
110
- ]
111
- }
112
- ];
113
- function cell(repos, current) {
114
- return repos.map((repo) => repo === current ? `**\`${repo}\`**` : `[\`${repo}\`](${ORGANIZATION$1}/${repo})`).join(" · ");
115
- }
116
- /** The generated block, the README's own repository in bold, formatted as oxfmt leaves it. */
117
- function frameworkModulesBlock(current) {
118
- return [
119
- FRAMEWORK_MODULES_START,
120
- "",
121
- ...tableLines([[
122
- "Area",
123
- "Contracts",
124
- "Providers"
125
- ], ...AREAS.map(({ area, contracts, providers }) => [
126
- area,
127
- cell(contracts, current),
128
- cell(providers, current)
129
- ])]),
130
- "",
131
- FRAMEWORK_MODULES_END,
132
- ""
133
- ].join("\n");
134
- }
135
- /** The repository a package lives in: its name without the `@antelopejs/` scope, as every framework package is named. */
136
- function frameworkRepo(packageName) {
137
- return packageName?.startsWith(SCOPE$1) ? packageName.slice(12) : void 0;
138
- }
139
- /** The README with the block between its markers rewritten for the package named `packageName`. A README without markers comes back as it is. */
140
- function placeFrameworkModulesBlock(current, packageName) {
141
- return placeMarkedBlock(current, FRAMEWORK_MODULES, frameworkModulesBlock(frameworkRepo(packageName)));
142
- }
143
- //#endregion
144
- //#region src/guardrails/docs-modules.ts
145
- const DMS_MODULES = markers("antelopejs-dms-modules");
146
- const DMS_MODULES_START = DMS_MODULES.start;
147
- const DMS_MODULES_END = DMS_MODULES.end;
148
- const ORGANIZATION = "https://github.com/AntelopeJS";
149
- /** The AntelopeJS DMS modules in display order. Every README holding the markers lists exactly these. */
150
- const MODULES = [
151
- {
152
- repo: "dms-builder",
153
- row: "Edit pages, tables and data sources by clicking, as TypeScript that compiles"
154
- },
155
- {
156
- repo: "dms-ai",
157
- row: "An assistant chat in the dashboard, on your own Claude Code or Codex"
158
- },
159
- {
160
- repo: "dms-database",
161
- row: "Schemas, relation diagrams, a data browser and a query console"
162
- },
163
- {
164
- repo: "dms-api",
165
- row: "API health, request logs, per-route statistics and a request tester"
166
- },
167
- {
168
- repo: "dms-automation",
169
- row: "Node-graph automations on schedules, webhooks and DMS events, with a trace for every run"
170
- },
171
- {
172
- repo: "dms-mailing",
173
- row: "E-mail templates in a block editor, versions, a send log and delivery metrics"
174
- },
175
- {
176
- repo: "dms-lang",
177
- row: "Translation coverage, a translation matrix and a translation queue"
178
- },
179
- {
180
- repo: "dms-media",
181
- row: "A media library with folders, per-folder permissions, image sizes and light editing"
182
- },
183
- {
184
- repo: "dms-saas",
185
- row: "Self-service sign-up, plans that gate features, and Stripe billing"
186
- },
187
- {
188
- repo: "dms-marketing",
189
- row: "Traffic, conversion funnels with A/B splits and click heatmaps, without cookies"
190
- },
191
- {
192
- repo: "dms-frontend",
193
- row: "The `ajs dms` CLI, the Vue renderer and the SDK every frontend module builds on"
194
- }
195
- ];
196
- /** The generated block, formatted as oxfmt leaves it. */
197
- function modulesBlock() {
198
- return [
199
- DMS_MODULES_START,
200
- "",
201
- ...tableLines([["Module", "What it adds"], ...MODULES.map(({ repo, row }) => [`[\`${repo}\`](${ORGANIZATION}/${repo})`, row])]),
202
- "",
203
- DMS_MODULES_END,
204
- ""
205
- ].join("\n");
206
- }
207
- /** The README with the block between its markers rewritten. A README without markers comes back as it is. */
208
- function placeModulesBlock(current) {
209
- return placeMarkedBlock(current, DMS_MODULES, modulesBlock());
210
- }
211
- //#endregion
212
- //#region src/guardrails/docs-compat.ts
213
- const DOCS_COMPAT_START = "<!-- antelopejs-docs-compat:start -->";
214
- const DOCS_COMPAT_END = "<!-- antelopejs-docs-compat:end -->";
215
- const DOCS_NODE_START = "<!-- antelopejs-docs-node:start -->";
216
- const DOCS_NODE_END = "<!-- antelopejs-docs-node:end -->";
217
- const LOCKFILE = "pnpm-lock.yaml";
218
- const REQUIREMENTS_HEADING = /^##\s+Requirements\s*$/i;
219
- const SCOPE = "@antelopejs/";
220
- const UNRESOLVED = "—";
221
- const WORKSPACE = "workspace";
222
- const LEGACY_MARKER = /^<!--\s*docs-compat:\s*\.\/package\.json#\w+\s*-->\s*$/;
223
- const COMPATIBILITY_HEADING = /^##\s+Compatibility\s*$/i;
224
- const RESOLVED_SECTIONS = [
225
- "dependencies",
226
- "optionalDependencies",
227
- "devDependencies"
228
- ];
229
- /** The generated block, rows sorted by package name, formatted as oxfmt leaves it. */
230
- function compatBlock(rows) {
231
- const sorted = [...rows].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
232
- return [
233
- DOCS_COMPAT_START,
234
- "",
235
- ...tableLines([[
236
- "Package",
237
- "Supported",
238
- "Tested with"
239
- ], ...sorted.map(({ name, supported, tested }) => [
240
- `\`${name}\``,
241
- `\`${supported.replaceAll("|", "\\|")}\``,
242
- tested === void 0 ? UNRESOLVED : `\`${tested}\``
243
- ])]),
244
- "",
245
- DOCS_COMPAT_END,
246
- ""
247
- ].join("\n");
248
- }
249
- function legacySpanEnd(lines, marker) {
250
- let index = marker + 1;
251
- while (index < lines.length && !lines[index].trim()) index++;
252
- while (index < lines.length && lines[index].trimStart().startsWith("|")) index++;
253
- while (index < lines.length && !lines[index].trim()) index++;
254
- return index;
255
- }
256
- function replaceLegacyTables(lines, block) {
257
- const placed = [];
258
- let replaced = false;
259
- for (let index = 0; index < lines.length;) {
260
- if (!LEGACY_MARKER.test(lines[index])) {
261
- placed.push(lines[index]);
262
- index++;
263
- continue;
264
- }
265
- if (!replaced) placed.push(...block.split("\n"));
266
- replaced = true;
267
- index = legacySpanEnd(lines, index);
268
- }
269
- return replaced ? placed : void 0;
270
- }
271
- function finalNewline(text) {
272
- return text.endsWith("\n") ? text : `${text}\n`;
273
- }
274
- /** The README with the block in place: replacing the markers, a legacy `docs-compat` table, or under `## Compatibility`. */
275
- function placeCompatBlock(current, block) {
276
- const text = current ?? "";
277
- const start = text.indexOf(DOCS_COMPAT_START);
278
- const end = text.indexOf(DOCS_COMPAT_END);
279
- if (start === -1 !== (end === -1) || end < start) throw new Error("incomplete antelopejs-docs-compat markers. Repair or delete them, then rerun antelopejs-sync.");
280
- if (start !== -1) return `${text.slice(0, start)}${block}${text.slice(end + 35).replace(/^\r?\n/, "")}`;
281
- const lines = text.split("\n");
282
- const legacy = replaceLegacyTables(lines, block);
283
- if (legacy) return finalNewline(legacy.join("\n"));
284
- const heading = lines.findIndex((line) => COMPATIBILITY_HEADING.test(line));
285
- if (heading !== -1) {
286
- let rest = heading + 1;
287
- while (rest < lines.length && !lines[rest].trim()) rest++;
288
- return finalNewline([
289
- ...lines.slice(0, heading + 1),
290
- "",
291
- ...block.split("\n"),
292
- ...lines.slice(rest)
293
- ].join("\n"));
294
- }
295
- const before = text.trimEnd();
296
- return `${before}${before ? "\n\n" : ""}## Compatibility\n\n${block}`;
297
- }
298
- /** The generated Node prerequisite block for an `engines.node` range, formatted as oxfmt leaves it. */
299
- function nodeBlock(range) {
300
- return `${DOCS_NODE_START}\n\nThis package requires Node.js \`${range}\`.\n${DOCS_NODE_END}\n`;
301
- }
302
- /** The README with the Node block in place: between its markers, under `## Requirements`, or in a new `## Requirements` section at the end. */
303
- function placeNodeBlock(current, block) {
304
- const start = current.indexOf(DOCS_NODE_START);
305
- const end = current.indexOf(DOCS_NODE_END);
306
- if (start === -1 !== (end === -1) || end < start) throw new Error("incomplete antelopejs-docs-node markers. Repair or delete them, then rerun antelopejs-sync.");
307
- if (start !== -1) return `${current.slice(0, start)}${block}${current.slice(end + 33).replace(/^\r?\n/, "")}`;
308
- const lines = current.split("\n");
309
- const heading = lines.findIndex((line) => REQUIREMENTS_HEADING.test(line));
310
- if (heading !== -1) {
311
- let rest = heading + 1;
312
- while (rest < lines.length && !lines[rest].trim()) rest++;
313
- return finalNewline([
314
- ...lines.slice(0, heading + 1),
315
- "",
316
- ...block.trimEnd().split("\n"),
317
- ...rest < lines.length ? ["", ...lines.slice(rest)] : []
318
- ].join("\n"));
319
- }
320
- return `${current.trimEnd()}\n\n## Requirements\n\n${block}`;
321
- }
322
- function relative$1(directory, name) {
323
- return directory ? `${directory}/${name}` : name;
324
- }
325
- function isDirectory(root, path) {
326
- return statSync(join(root, path), { throwIfNoEntry: false })?.isDirectory() === true;
327
- }
328
- function subdirectories(root, directory) {
329
- 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));
330
- }
331
- function descendants(root, directory) {
332
- return subdirectories(root, directory).flatMap((child) => [child, ...descendants(root, child)]);
333
- }
334
- function globExpression(pattern) {
335
- const source = pattern.split("/").map((segment) => segment === "**" ? "(?:.*)" : segment.replace(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("*", "[^/]*").replaceAll("?", "[^/]")).join("/").replaceAll("(?:.*)/", "(?:.*/)?");
336
- return new RegExp(`^${source}$`);
337
- }
338
- function expand(root, pattern) {
339
- let directories = [""];
340
- for (const segment of pattern.split("/")) if (segment === "**") directories = directories.flatMap((directory) => [directory, ...descendants(root, directory)]);
341
- else if (/[*?]/.test(segment)) {
342
- const expression = globExpression(segment);
343
- directories = directories.flatMap((directory) => subdirectories(root, directory).filter((child) => expression.test(child.slice(child.lastIndexOf("/") + 1))));
344
- } else directories = directories.map((directory) => relative$1(directory, segment)).filter((directory) => isDirectory(root, directory));
345
- return directories;
346
- }
347
- function normalizePattern(pattern) {
348
- return pattern.replace(/^(?:\.\/)+/, "").replace(/\/+$/, "").replace(/^\.$/, "");
349
- }
350
- function scalarItems(document, path) {
351
- const node = document.getIn(path, true);
352
- return isSeq(node) ? node.items.flatMap((item) => isScalar(item) ? [String(item.value)] : []) : [];
353
- }
354
- /** pnpm-workspace.yaml `packages`, else package.json `workspaces` as an array or as `{ packages }`; JSON parses as YAML. */
355
- function workspacePatterns(root) {
356
- const pnpm = join(root, "pnpm-workspace.yaml");
357
- if (existsSync(pnpm)) return scalarItems(parseDocument(readFileSync(pnpm, "utf8")), ["packages"]);
358
- const manifest = parseDocument(readFileSync(join(root, "package.json"), "utf8"));
359
- return scalarItems(manifest, isMap(manifest.get("workspaces", true)) ? ["workspaces", "packages"] : ["workspaces"]);
360
- }
361
- /** The workspace package directories, relative to `root` and sorted, that `pnpm-workspace.yaml` or package.json `workspaces` list. */
362
- function workspaceDirectories(root) {
363
- const patterns = workspacePatterns(root);
364
- const excluded = patterns.filter((pattern) => pattern.startsWith("!")).map((pattern) => globExpression(normalizePattern(pattern.slice(1))));
365
- const found = /* @__PURE__ */ new Set();
366
- for (const pattern of patterns.filter((item) => !item.startsWith("!"))) {
367
- const normalized = normalizePattern(pattern);
368
- 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);
369
- }
370
- return [...found].sort();
371
- }
372
- function declaredRanges(manifest) {
373
- const ranges = /* @__PURE__ */ new Map();
374
- for (const field of [
375
- manifest.optionalDependencies,
376
- manifest.dependencies,
377
- manifest.peerDependencies
378
- ]) for (const [name, range] of Object.entries(field ?? {})) if (name.startsWith(SCOPE)) ranges.set(name, range);
379
- return ranges;
380
- }
381
- function readManifest(root, directory) {
382
- return parseManifest(readFileSync(join(root, directory, "package.json"), "utf8"));
383
- }
384
- /** 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. */
385
- function resolvedVersion({ document, importer }, name) {
386
- for (const section of RESOLVED_SECTIONS) {
387
- const entry = document.getIn([
388
- "importers",
389
- importer,
390
- section,
391
- name
392
- ], true);
393
- const version = isMap(entry) ? entry.get("version", true) : entry;
394
- if (!isScalar(version)) continue;
395
- const resolved = String(version.value).split("(")[0];
396
- return resolved.startsWith("link:") ? WORKSPACE : resolved;
397
- }
398
- }
399
- const UNSHARED_NPMRC = /^\s*shared-workspace-lockfile\s*=\s*false\s*(?:[#;].*)?$/m;
400
- /** Whether the workspace keeps one root lockfile, or `shared-workspace-lockfile=false` gives each package its own. */
401
- function sharesLockfile(root) {
402
- const npmrc = join(root, ".npmrc");
403
- if (existsSync(npmrc) && UNSHARED_NPMRC.test(readFileSync(npmrc, "utf8"))) return false;
404
- const workspace = join(root, "pnpm-workspace.yaml");
405
- return !(existsSync(workspace) && parseDocument(readFileSync(workspace, "utf8")).get("sharedWorkspaceLockfile") === false);
406
- }
407
- /** The lockfile path of a package, relative to the root. A shared lockfile is the root's, indexed by the package directory. */
408
- function lockPath(shared, directory) {
409
- return shared ? LOCKFILE : relative$1(directory, LOCKFILE);
410
- }
411
- function readLock(root, shared, directory, documents) {
412
- const path = join(root, lockPath(shared, directory));
413
- if (!documents.has(path) && existsSync(path)) documents.set(path, parseDocument(readFileSync(path, "utf8")));
414
- const document = documents.get(path);
415
- return document && {
416
- document,
417
- importer: shared ? directory || "." : "."
418
- };
419
- }
420
- /** Adds one package's `docs-files` lines and, when it needs one, its README with the generated blocks. */
421
- function planPackage(root, plan, lock, standard, { directory, name, ranges, published, node }) {
422
- const readme = relative$1(directory, "README.md");
423
- const docs = relative$1(directory, "docs");
424
- if (!published) return;
425
- if (ranges.size > 0 || existsSync(join(root, readme))) plan.docsFiles.push(readme);
426
- if (isDirectory(root, docs)) plan.docsFiles.push(docs);
427
- const current = existsSync(join(root, readme)) ? readFileSync(join(root, readme), "utf8") : void 0;
428
- const nodeRange = standard && current !== void 0 ? node : void 0;
429
- if (ranges.size === 0 && current === void 0) return;
430
- const rows = [...ranges].map(([name, supported]) => ({
431
- name,
432
- supported,
433
- tested: lock && resolvedVersion(lock, name)
434
- }));
435
- try {
436
- const withRequirements = nodeRange !== void 0 && current !== void 0 ? placeNodeBlock(current, nodeBlock(nodeRange)) : current;
437
- plan.readmes.push({
438
- path: readme,
439
- current,
440
- content: placeFrameworkModulesBlock(placeModulesBlock(rows.length > 0 ? placeCompatBlock(withRequirements, compatBlock(rows)) : withRequirements ?? ""), name)
441
- });
442
- } catch (error) {
443
- plan.errors.push(`${readme}: ${error instanceof Error ? error.message : String(error)}`);
444
- }
445
- }
446
- /**
447
- * Plans the docs-compat block of the root and of every workspace package that is not private and declares an
448
- * `@antelopejs/*` peer, runtime or optional dependency, and the `docs-files` lines covering the root and every workspace
449
- * package that is not private.
450
- * 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.
451
- */
452
- function planDocs(root, manager) {
453
- const rootManifest = readManifest(root, "");
454
- const packages = ["", ...workspaceDirectories(root)].map((directory) => {
455
- const manifest = directory ? readManifest(root, directory) : rootManifest;
456
- return {
457
- directory,
458
- name: manifest.name,
459
- published: !directory || !manifest.private,
460
- node: manifest.engines?.node,
461
- ranges: manifest.private ? /* @__PURE__ */ new Map() : declaredRanges(manifest)
462
- };
463
- });
464
- const qualifying = packages.filter(({ ranges }) => ranges.size > 0);
465
- const plan = {
466
- readmes: [],
467
- docsFiles: [],
468
- errors: [],
469
- exists: (path) => existsSync(join(root, path))
470
- };
471
- const shared = sharesLockfile(root);
472
- const documents = /* @__PURE__ */ new Map();
473
- const locks = new Map(qualifying.map(({ directory }) => [directory, manager === "pnpm" ? readLock(root, shared, directory, documents) : void 0]));
474
- const missing = manager === "pnpm" ? qualifying.filter(({ directory }) => !locks.get(directory)) : [];
475
- if (missing.length) {
476
- 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.`);
477
- return plan;
478
- }
479
- const standard = rootManifest.antelopeJs?.docs?.standard === true;
480
- for (const item of packages) planPackage(root, plan, locks.get(item.directory), standard, item);
481
- return plan;
482
- }
483
- //#endregion
484
15
  //#region src/guardrails/run-command.ts
485
16
  const KILL_GRACE_MS = 5e3;
486
17
  function stopGroup(child, signal) {
@@ -1617,4 +1148,4 @@ async function runChecks(root, options = {}) {
1617
1148
  };
1618
1149
  }
1619
1150
  //#endregion
1620
- export { stepsOf as a, workspacePatterns as c, matchingScripts as i, droppedChecksSteps as n, planDocs as o, runChecks as r, workspaceDirectories as s, CHECKS_SKIP_ENV as t };
1151
+ export { stepsOf as a, matchingScripts as i, droppedChecksSteps as n, runChecks as r, CHECKS_SKIP_ENV as t };
@@ -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 };
@@ -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
@@ -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.6",
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",