@unbase-app/cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -44,7 +44,7 @@ the framework's own file, [`agents/astro.md`](./agents/astro.md) or
44
44
 
45
45
  | Flag | |
46
46
  |---|---|
47
- | `--comments` / `--no-comments` | Comments on the live site, with `?comment` (`@jens4m/comment-modus`, inside `@unbase-app/astro`). Default: in, or as the site has it when Unbase is in it already |
47
+ | `--comments` / `--no-comments` | Comments on the live site, with `?comment` (`@unbase-app/layer`, inside `@unbase-app/astro`). Default: in, or as the site has it when Unbase is in it already |
48
48
  | `--project <id or slug>` | Link comment mode and analytics to an Unbase project now (see *Linking*) |
49
49
  | `--pointer[=AGENTS.md\|CLAUDE.md]` / `--no-pointer` | One line in the site's `AGENTS.md` (or `CLAUDE.md`) pointing its agent at this package's `AGENTS.md`. Default: no |
50
50
  | `--no-install` | Write `package.json` only; install yourself |
@@ -57,7 +57,7 @@ versions:
57
57
 
58
58
  | Package | Version | |
59
59
  |---|---|---|
60
- | `@unbase-app/astro` | 0.3.0 | Unbase in an Astro site, one integration: comment mode (`@jens4m/comment-modus` 1.9.0: comments on the live site; it writes the content schemas Unbase reads), the draft-pages kit (`@unbase-app/pages` 0.4.0: draft pages kept out of production builds, and the redirects a moved page leaves applied) and the analytics beacon (`@unbase-app/analytics` 0.1.0) |
60
+ | `@unbase-app/astro` | 0.4.0 | Unbase in an Astro site, one integration: comment mode (`@unbase-app/layer` 2.0.0: comments on the live site; it writes the content schemas Unbase reads), the draft-pages kit (`@unbase-app/pages` 0.4.1: draft pages kept out of production builds, and the redirects a moved page leaves applied) and the analytics beacon (`@unbase-app/analytics` 0.1.0) |
61
61
  | `@unbase-app/cli` | this one | devDependency: `AGENTS.md` and `doctor`, pinned |
62
62
 
63
63
  In `astro.config`, found and changed through its syntax tree, never by text substitution:
@@ -158,9 +158,12 @@ moves it across, and it is how Unbase's Update does it:
158
158
  - `unbase()` takes `commentModus()`'s place with its options as they are (a site's own `project`,
159
159
  `titles`, `language`…); the `commentModusConfig.project ? … : null` init wrote around it goes,
160
160
  since `unbase()` waits for the project itself. `unbasePages()` and its import go.
161
- - `@jens4m/comment-modus` goes too, unless the site uses it for itself: a name its config still
162
- imports from it, its CLI in a script or a workflow. Then it stays, moved to the version
163
- `@unbase-app/astro` brings, so there is one.
161
+ - Comment mode's own package goes too, under either name (`@unbase-app/layer`, or
162
+ `@jens4m/comment-modus` before 2.0), unless the site uses it for itself: a name its config still
163
+ imports from it, the package named in its code or a workflow, or the layer's CLI in a script.
164
+ The layer then stays, moved to the version `@unbase-app/astro` brings, so there is one;
165
+ `@jens4m/comment-modus` stays as it is, as the layer has no release under that name. Its CLI alone
166
+ keeps neither: the layer answers to `comment-modus` too.
164
167
  - The pointer line moves to `node_modules/@unbase-app/cli/AGENTS.md`.
165
168
  - With `--yes`, a site keeps its choice of comments. A second run changes nothing.
166
169
 
package/agents/astro.md CHANGED
@@ -20,7 +20,7 @@ first written.
20
20
  changes nothing, and a package that is older than the version init pins is moved up to it. It adds:
21
21
 
22
22
  - `@unbase-app/astro`, and one entry in `integrations`, `unbase({ … })`. It brings comment mode
23
- (`@jens4m/comment-modus`: comments on the live site with `?comment`; it also writes the content
23
+ (`@unbase-app/layer`: comments on the live site with `?comment`; it also writes the content
24
24
  schemas, step 4) and the draft-pages kit (`@unbase-app/pages`), and adds both after every other
25
25
  integration itself. Its options are comment mode's own. `--no-comments` writes
26
26
  `unbase({ comments: false })`, which leaves comment mode out, and with it page and site settings.
@@ -32,7 +32,8 @@ changes nothing, and a package that is older than the version init pins is moved
32
32
  A site installed before 03-11 has the pair instead (`@jens4m/comment-modus` and
33
33
  `@jens4m/unbase-pages`, `commentModus()` and `unbasePages()`) and the CLI as `@jens4m/unbase`. init
34
34
  moves it across: `unbase()` takes `commentModus()`'s place with its options as they are, and the old
35
- packages go. A site that imports something of comment-modus for itself, or runs its CLI, keeps it.
35
+ packages go. A site that imports something of comment mode for itself, or names its package in its
36
+ code or a workflow, keeps it.
36
37
 
37
38
  If init says it cannot edit `astro.config` safely, make the same change by hand: import `unbase`
38
39
  from `@unbase-app/astro` and `commentModusConfig` from `./comment-modus.json`, and add
package/bin/unbase.mjs CHANGED
@@ -17,6 +17,7 @@
17
17
  // ============================================================================
18
18
 
19
19
  import { createInterface } from "node:readline/promises";
20
+ import { renderContent } from "../lib/content.mjs";
20
21
  import { doctor } from "../lib/doctor.mjs";
21
22
  import { COULD_NOT_RUN, CouldNotRun } from "../lib/errors.mjs";
22
23
  import { FRAMEWORKS } from "../lib/frameworks/index.mjs";
@@ -118,6 +119,7 @@ function render(r) {
118
119
  if (c.detail && c.state !== "ok") out.push(...String(c.detail).split("\n").map((l) => ` | ${l}`));
119
120
  }
120
121
  }
122
+ out.push(...renderContent(r.content));
121
123
  const s = r.summary;
122
124
  out.push("", r.ok ? `Passed: ${s.on} on${s.waiting ? `, ${s.waiting} waiting on something outside this repository` : ""}${s.notInstalled ? `, ${s.notInstalled} not installed` : ""}.` : `Failed: ${s.off} feature(s) need a change in the site.`);
123
125
  } else if (r.command === "uninstall") {
@@ -20,18 +20,20 @@
20
20
 
21
21
  import { parse } from "@babel/parser";
22
22
  import { CouldNotRun } from "./errors.mjs";
23
- import { ASTRO, BEFORE, COMMENT_MODUS, LAYER_URL, PAGES, SELF } from "./versions.mjs";
23
+ import { ASTRO, BEFORE, COMMENT_NAMES, LAYER, LAYER_URL, PAGES, SELF } from "./versions.mjs";
24
24
 
25
25
  /** The modules init imports, and the entries it adds or moves. */
26
26
  export const SOURCES = {
27
27
  unbase: ASTRO.name,
28
- comments: COMMENT_MODUS.name,
28
+ comments: LAYER.name,
29
29
  pages: `${PAGES.name}/astro`,
30
30
  link: "./comment-modus.json",
31
31
  sitemap: "@astrojs/sitemap",
32
32
  };
33
33
  /** The kit's integration, under its name now and before K5, as a site may import it. */
34
34
  const PAGES_ALSO = new Set([`${PAGES.name}/astro`, PAGES.name, `${BEFORE.pages}/astro`, BEFORE.pages]);
35
+ /** Comment mode, under its name now and before 2.0. */
36
+ const COMMENTS_ALSO = new Set(COMMENT_NAMES);
35
37
  const NAMES = { unbase: "unbase", comments: "commentModus", pages: "unbasePages", link: "commentModusConfig" };
36
38
  /** The line init writes above unbase({ … }), with comments and without. */
37
39
  export const UNBASE_LINE = "// Unbase: comments with ?comment once comment-modus.json names the project, and drafts kept off Live.";
@@ -98,7 +100,7 @@ function importsOf(ast) {
98
100
  for (const n of ast.program.body) {
99
101
  if (n.type !== "ImportDeclaration") continue;
100
102
  const src = n.source.value;
101
- const kind = src === SOURCES.unbase ? "unbase" : src === SOURCES.comments ? "comments" : PAGES_ALSO.has(src) ? "pages" : src === SOURCES.link ? "link" : src === SOURCES.sitemap ? "sitemap" : null;
103
+ const kind = src === SOURCES.unbase ? "unbase" : COMMENTS_ALSO.has(src) ? "comments" : PAGES_ALSO.has(src) ? "pages" : src === SOURCES.link ? "link" : src === SOURCES.sitemap ? "sitemap" : null;
102
104
  if (!kind) continue;
103
105
  found.nodes.push({ kind, node: n });
104
106
  for (const s of n.specifiers) {
@@ -307,7 +309,7 @@ function reindent(text, indent) {
307
309
 
308
310
  /**
309
311
  * Splices that take a package's imports out: a declaration whose names all go is removed with its
310
- * line; one that keeps a name the site uses for itself (`import commentModus, { sleutelVanPad }`)
312
+ * line; one that keeps a name the site uses for itself (`import commentModus, { keyFromPath }`)
311
313
  * loses only the entry's name. Returns the splices and the first declaration removed whole, where
312
314
  * the new import can stand.
313
315
  */
@@ -0,0 +1,63 @@
1
+ // ============================================================================
2
+ // unbase doctor — the site's content: which code reads each collection, and
3
+ // which code holds an item's values written by hand (docs/plan-cms-release.md
4
+ // R3c). It runs the binding contract's own checks (`reads`,
5
+ // `noCopiedContent`), the code Unbase's CMS and the Operator's gate run, from
6
+ // lib/readers.mjs. It says what it finds and never fails the run: copied
7
+ // content is the site's choice until someone asks to manage it.
8
+ //
9
+ // A collection here is a folder of JSON items under src/content/ (a Next.js
10
+ // site's convention, and an Astro site's JSON collections). Markdown and YAML
11
+ // collections, and Astro collections kept elsewhere, are not listed yet.
12
+ // ============================================================================
13
+
14
+ import { binding } from "./readers.mjs";
15
+
16
+ const ITEM = /^src\/content\/([A-Za-z0-9_][\w-]*)\/([^/]+)\.json$/;
17
+ const CODE = /\.(astro|tsx?|jsx?|mts|mjs|cjs|cts|vue|svelte|mdx?|html)$/;
18
+
19
+ /** The content section of doctor's report, or null when the framework has no binding adapter. */
20
+ export function contentReport(site) {
21
+ const adapter = binding.ADAPTERS[site.framework?.id];
22
+ if (!adapter) return null;
23
+ const paths = site.appPaths;
24
+ /** @type {Map<string, { id: string, file: string, data: unknown }[]>} */
25
+ const items = new Map();
26
+ for (const p of paths) {
27
+ const m = ITEM.exec(p);
28
+ if (!m) continue;
29
+ let data;
30
+ try {
31
+ data = JSON.parse(site.text(p) ?? "null");
32
+ } catch {
33
+ continue;
34
+ }
35
+ if (!items.has(m[1])) items.set(m[1], []);
36
+ items.get(m[1]).push({ id: m[2], file: p, data });
37
+ }
38
+ const files = paths.filter((p) => CODE.test(p) && !p.startsWith("node_modules/")).map((path) => ({ path, text: site.text(path) ?? "" }));
39
+ const edges = binding.reads({ files, adapter });
40
+ // The values its schema fixes (a block's type, an option) are the schema's, not an item's content.
41
+ const fixed = (name) => {
42
+ try {
43
+ return binding.schemaValues(JSON.parse(site.text(`src/content/.schemas/${name}.schema.json`) ?? "null"));
44
+ } catch {
45
+ return [];
46
+ }
47
+ };
48
+ const collections = [...items.keys()].sort().map((name) => ({ name, items: items.get(name), fixed: fixed(name) }));
49
+ const copied = binding.noCopiedContent({ files, collections, adapter });
50
+ return {
51
+ collections: collections.map((c) => ({ name: c.name, items: c.items.length, readBy: [...new Set(edges.filter((r) => r.collection === c.name).map((r) => r.file))].sort() })),
52
+ copied: copied.map((f) => ({ file: f.file, line: f.line, collection: f.collection, item: f.item, field: f.field, value: f.value })),
53
+ };
54
+ }
55
+
56
+ /** The section as doctor prints it. */
57
+ export function renderContent(c) {
58
+ if (!c || (!c.collections.length && !c.copied.length)) return [];
59
+ const out = ["", "Content:"];
60
+ for (const k of c.collections) out.push(` ${k.name} (${k.items} item${k.items === 1 ? "" : "s"}): ${k.readBy.length ? `read by ${k.readBy.join(", ")}` : "no code reads it"}`);
61
+ for (const f of c.copied) out.push(` ! ${f.file}:${f.line} has ${f.collection}/${f.item}'s ${f.field.slice(1)} written in it ("${f.value}"): read it from the collection, so a change in the CMS shows here`);
62
+ return out;
63
+ }
package/lib/doctor.mjs CHANGED
@@ -3,10 +3,13 @@
3
3
  // with Unbase's own readers on the working tree, and one production build.
4
4
  // It never calls Unbase. The features and their checks are the framework's
5
5
  // (frameworks/*.mjs `doctor`); their shapes and states are feature.mjs's.
6
- // A feature that is off fails the run (exit 1).
6
+ // A feature that is off fails the run (exit 1). The site's content (which
7
+ // code reads each collection, and values copied into code) is content.mjs's,
8
+ // and never fails it.
7
9
  // ============================================================================
8
10
 
9
11
  import { buildSite } from "./build.mjs";
12
+ import { contentReport } from "./content.mjs";
10
13
  import { FAILED, PASSED } from "./errors.mjs";
11
14
  import { openSite, refresh } from "./site.mjs";
12
15
 
@@ -21,6 +24,7 @@ export async function doctor(flags, io) {
21
24
  await refresh(site);
22
25
  }
23
26
  const features = await site.framework.doctor(site, { build });
27
+ const content = contentReport(site);
24
28
 
25
29
  build?.dispose();
26
30
  const failed = features.some((f) => f.state === "off");
@@ -32,6 +36,7 @@ export async function doctor(flags, io) {
32
36
  site: site.root,
33
37
  built: build ? build.ok : null,
34
38
  features,
39
+ content,
35
40
  summary: { on: count("on"), off: count("off"), waiting: count("waiting"), notInstalled: count("not-installed") },
36
41
  };
37
42
  }
@@ -20,7 +20,7 @@ import { CouldNotRun } from "../errors.mjs";
20
20
  import { check, featureState } from "../feature.mjs";
21
21
  import { core, readSettings, registryFiles, registryOf } from "../readers.mjs";
22
22
  import { depsOf, installedVersion, uncommitted } from "../site.mjs";
23
- import { ASTRO, BEFORE, COMMENT_MODUS, compareVersions, MARKERS_PREVIEW, PAGES, SELF, UNLISTED_BUILD_FAILURE } from "../versions.mjs";
23
+ import { ASTRO, BEFORE, COMMENT_NAMES, compareVersions, LAYER, MARKERS_PREVIEW, PAGES, SELF, UNLISTED_BUILD_FAILURE, versionIn } from "../versions.mjs";
24
24
 
25
25
  /** The file with the steps init leaves, in this package. */
26
26
  const AGENTS = "agents/astro.md";
@@ -47,6 +47,8 @@ const CONTENT_CONFIG = /^src\/(content\.config|content\/config)\.(ts|js|mjs|mts)
47
47
  * comment-modus 1.9.0) or off (`false`). Without comment-modus a production build has none.
48
48
  * `when` is the config's componentMarker as config-edit reads it; null (not literal) counts as the
49
49
  * default, "always".
50
+ * @param {boolean} commentsInstalled
51
+ * @param {string | false | null} [when]
50
52
  */
51
53
  export const markersBelongInProduction = (commentsInstalled, when = "always") => commentsInstalled && when !== "preview" && when !== false;
52
54
 
@@ -139,30 +141,44 @@ function analyticsOption(site) {
139
141
 
140
142
  // ── The move (K5) ──────────────────────────────────────────────────────────
141
143
 
142
- /** Files that may name comment-modus for the site's own use: code, scripts and CI, not docs or lockfiles. */
144
+ /** Files that may name comment mode's package for the site's own use: code, scripts and CI, not docs or lockfiles. */
143
145
  const OWN_USE = /\.(astro|ts|tsx|js|jsx|mjs|cjs|mts|cts|yml|yaml)$/;
144
146
 
145
147
  /**
146
148
  * What init takes out of a site from before K5, once the one package is in: the kit and the CLI
147
- * under their old names, the kit under its own name (unbase() brings it), and comment-modus unless
148
- * the site still uses it for itself (a name its config imports, its CLI in a script or a workflow).
149
- * A comment-modus the site keeps is moved to the version the one package brings, so there is one.
149
+ * under their old names, the kit under its own name (unbase() brings it), and comment mode under
150
+ * either name unless the site still uses it for itself (a name its config imports, the package
151
+ * named in its code or CI, the layer's CLI in a script). The layer a site keeps is moved to the
152
+ * version the one package brings, so there is one. comment-modus under its name before 2.0 is left
153
+ * as the site has it when the site uses it for itself (the layer has no release under that name),
154
+ * and goes when only its CLI is used: the layer answers to `comment-modus` too.
150
155
  * `planned`: init's plan for the config, which tells what the config still imports.
151
156
  */
152
157
  function planReplaced(site, planned) {
153
158
  const deps = depsOf(site.pkg);
154
159
  const remove = [BEFORE.pages, BEFORE.cli, PAGES.name].filter((n) => deps[n] !== undefined);
155
160
  const keep = [];
156
- if (deps[COMMENT_MODUS.name] !== undefined) {
161
+ const listed = COMMENT_NAMES.filter((n) => deps[n] !== undefined);
162
+ if (listed.length) {
157
163
  const config = planned.find((f) => f.file === site.configFile)?.text ?? site.text(site.configFile) ?? "";
158
- let imported = false;
164
+ /** The comment mode packages the planned config still imports from. */
165
+ const imports = new Set();
159
166
  try {
160
- imported = inspectConfig(config, site.configFile).imports.nodes.some((n) => n.kind === "comments");
167
+ for (const { kind, node } of inspectConfig(config, site.configFile).imports.nodes) if (kind === "comments") imports.add(node.source.value);
161
168
  } catch {}
162
- const scripts = Object.values(site.pkg.scripts ?? {}).some((c) => /\bcomment-modus\b/.test(String(c)));
163
- const elsewhere = site.appPaths.some((p) => p !== site.configFile && OWN_USE.test(p) && !p.startsWith("node_modules/") && (site.text(p) ?? "").includes(COMMENT_MODUS.name));
164
- if (imported || scripts || elsewhere) keep.push(COMMENT_MODUS);
165
- else remove.push(COMMENT_MODUS.name);
169
+ const scripts = Object.values(site.pkg.scripts ?? {}).some((c) => /\b(comment-modus|unbase-layer)\b/.test(String(c)));
170
+ for (const name of listed) {
171
+ const ownUse = imports.has(name) || site.appPaths.some((p) => p !== site.configFile && OWN_USE.test(p) && !p.startsWith("node_modules/") && (site.text(p) ?? "").includes(name));
172
+ if (name === LAYER.name) {
173
+ if (ownUse || scripts) keep.push(LAYER);
174
+ else remove.push(name);
175
+ } else if (!ownUse) remove.push(name);
176
+ else {
177
+ // Kept at the version it has, so init's report names it.
178
+ const have = installedVersion(site, name) ?? versionIn(deps[name]);
179
+ if (have) keep.push({ name, version: have, dev: false });
180
+ }
181
+ }
166
182
  }
167
183
  return { remove, keep, by: ASTRO.name };
168
184
  }
@@ -170,7 +186,7 @@ function planReplaced(site, planned) {
170
186
  /** What of Unbase the site has now, for init's defaults: null without any of it; else whether comment mode is set up. */
171
187
  function currentOf(site) {
172
188
  const deps = depsOf(site.pkg);
173
- if (![ASTRO.name, COMMENT_MODUS.name, PAGES.name, BEFORE.pages].some((n) => deps[n] !== undefined) || !site.configFile) return null;
189
+ if (![ASTRO.name, ...COMMENT_NAMES, PAGES.name, BEFORE.pages].some((n) => deps[n] !== undefined) || !site.configFile) return null;
174
190
  try {
175
191
  return { comments: inspectConfig(site.text(site.configFile), site.configFile).has.commentMode };
176
192
  } catch {
@@ -182,7 +198,7 @@ function currentOf(site) {
182
198
  function planUninstall(site) {
183
199
  const config = site.configFile ? removeFromConfig(site.text(site.configFile), site.configFile) : { code: null, changes: [] };
184
200
  return {
185
- packages: [ASTRO.name, COMMENT_MODUS.name, PAGES.name, BEFORE.pages, SELF.name, BEFORE.cli],
201
+ packages: [ASTRO.name, ...COMMENT_NAMES, PAGES.name, BEFORE.pages, SELF.name, BEFORE.cli],
186
202
  files: config.changes.length ? [{ file: site.configFile, action: "changed", changes: config.changes, text: config.code }] : [],
187
203
  remove: [LINK_FILE, core.PAGE_FILE, SCHEMAS],
188
204
  };
@@ -203,7 +219,8 @@ function settingsCollections(site) {
203
219
  } catch {}
204
220
  const name = f.slice(0, -".schema.json".length);
205
221
  if (s?.properties?.pad && s?.properties?.seo && !out.route) out.route = name;
206
- if (s?.["x-instellingen"] === "site" && !out.site) out.site = name;
222
+ // comment-modus 1.11 reads x-settings; LEGACY-NL: x-instellingen before it, still read.
223
+ if ((s?.["x-settings"] ?? s?.["x-instellingen"]) === "site" && !out.site) out.site = name;
207
224
  }
208
225
  return out;
209
226
  }
@@ -248,6 +265,14 @@ async function doctorFeatures(site, { build }) {
248
265
  const known = build && !build.ok ? knownFailure(site, deps, build.output) : null;
249
266
  /** The one package (K5): comment mode and the kit come inside it, in node_modules without being listed. */
250
267
  const one = deps[ASTRO.name] !== undefined;
268
+ /**
269
+ * Comment mode's package as the site has it: inside the one package, the layer when it is there
270
+ * (@unbase-app/astro 0.4.0 on) and else comment-modus; otherwise the name package.json lists, or
271
+ * the one in node_modules.
272
+ */
273
+ const commentName = one
274
+ ? (COMMENT_NAMES.find((n) => installedVersion(site, n)) ?? LAYER.name)
275
+ : (COMMENT_NAMES.find((n) => deps[n] !== undefined) ?? COMMENT_NAMES.find((n) => installedVersion(site, n)) ?? LAYER.name);
251
276
  /** A package in node_modules (or in the config) that package.json does not list: Unbase reads package.json, and the build may not find it. */
252
277
  const unlisted = (p, usedInConfig) =>
253
278
  !one && !deps[p.name] && (installedVersion(site, p.name) || usedInConfig)
@@ -263,7 +288,7 @@ async function doctorFeatures(site, { build }) {
263
288
  const checks = [check("astro", "ok", `Astro ${installedVersion(site, "astro") ?? detection.framework.version ?? ""}, which Unbase reads with its Astro adapter: texts are edited where they are written, nothing installed.`)];
264
289
  if (!build) checks.push(check("build", "skipped", "Not built (--no-build)."));
265
290
  else if (built) checks.push(check("build", "ok", `A production build works (${build.html.size} pages).`));
266
- else if (known) checks.push(check("build", "missing", `The production build fails: ${known}`, { missing: `${COMMENT_MODUS.name} listed in package.json`, file: "package.json", step: STEPS.install, detail: tailOf(build.output, 6) }));
291
+ else if (known) checks.push(check("build", "missing", `The production build fails: ${known}`, { missing: `${UNLISTED_BUILD_FAILURE.package} listed in package.json`, file: "package.json", step: STEPS.install, detail: tailOf(build.output, 6) }));
267
292
  else checks.push(check("build", "missing", "The production build fails, so Unbase cannot start or check the site.", { missing: "a site that builds", file: site.configFile, detail: tailOf(build.output) }));
268
293
  const names = detection.settings.map((s) => s.name);
269
294
  if (names.length) checks.push(check("settings", "info", `The code reads ${names.length} setting(s) (${names.slice(0, 6).join(", ")}${names.length > 6 ? ", …" : ""}). If the site needs them to start, give them development values in Unbase.`));
@@ -291,13 +316,13 @@ async function doctorFeatures(site, { build }) {
291
316
  ? `No data-c markers in the production build (${setting}): they are in the dev server and previews only, so a pin on the live site is named after its section.`
292
317
  : `No data-c markers in the production build (${setting}).`,
293
318
  );
294
- const have = commentsInstalled ? installedVersion(site, COMMENT_MODUS.name) : null;
295
- const tooOld = when === "preview" && have && compareVersions(have, MARKERS_PREVIEW.since) < 0;
319
+ const have = commentsInstalled ? installedVersion(site, commentName) : null;
320
+ const tooOld = when === "preview" && commentName === MARKERS_PREVIEW.package && have && compareVersions(have, MARKERS_PREVIEW.since) < 0;
296
321
  const found = `${htmlWithMarkers.length} built page(s) carry data-c markers`;
297
322
  const where = `(e.g. ${htmlWithMarkers[0]})`;
298
323
  if (tooOld)
299
- return check("markers", "missing", `${found} ${where}: ${site.configFile} says ${setting}, which ${COMMENT_MODUS.name} ${have} does not know; ${MARKERS_PREVIEW.since} keeps them out of production builds.`, {
300
- missing: `${COMMENT_MODUS.name} ${MARKERS_PREVIEW.since} or later`,
324
+ return check("markers", "missing", `${found} ${where}: ${site.configFile} says ${setting}, which ${commentName} ${have} does not know; ${MARKERS_PREVIEW.since} keeps them out of production builds, and so does ${LAYER.name}.`, {
325
+ missing: `${LAYER.name}, or ${MARKERS_PREVIEW.package} ${MARKERS_PREVIEW.since} or later`,
301
326
  file: "package.json",
302
327
  step: STEPS.install,
303
328
  });
@@ -311,7 +336,7 @@ async function doctorFeatures(site, { build }) {
311
336
  ? check("markers", "ok", `${htmlWithMarkers.length} of ${build.html.size} built pages carry comment mode's data-c markers: a pin's title and source file come from them.`)
312
337
  : check("markers", "info", "No data-c markers in the build: comment mode marks the components in src/components, and found none on these pages.");
313
338
  };
314
- const notListed = unlisted(COMMENT_MODUS, !!config?.has.comments);
339
+ const notListed = unlisted({ name: commentName }, !!config?.has.comments);
315
340
  /** Where comment mode is set up: unbase() (K5), or commentModus() of its own. */
316
341
  const call = config?.has.unbase && config.unbaseComments !== false ? "unbase()" : "commentModus()";
317
342
  if (!commentsInstalled && notListed) {
@@ -324,7 +349,7 @@ async function doctorFeatures(site, { build }) {
324
349
  "info",
325
350
  one && config?.unbaseComments === false
326
351
  ? `Left out: unbase({ comments: false }); \`unbase init --comments\` turns it on. Comments on the canvas in Unbase work without it.`
327
- : `Not in the code: \`unbase init --comments\` adds it (${ASTRO.name}, with ${COMMENT_MODUS.name}). Comments on the canvas in Unbase work without it.`,
352
+ : `Not in the code: \`unbase init --comments\` adds it (${ASTRO.name}, with ${LAYER.name}). Comments on the canvas in Unbase work without it.`,
328
353
  ),
329
354
  );
330
355
  checks.push(markersCheck(false));
@@ -335,8 +360,8 @@ async function doctorFeatures(site, { build }) {
335
360
  "package",
336
361
  "ok",
337
362
  one
338
- ? `${ASTRO.name} ${installedVersion(site, ASTRO.name) ?? deps[ASTRO.name]} is a dependency, with ${[COMMENT_MODUS.name, installedVersion(site, COMMENT_MODUS.name)].filter(Boolean).join(" ")} in it.`
339
- : `${COMMENT_MODUS.name} ${installedVersion(site, COMMENT_MODUS.name) ?? deps[COMMENT_MODUS.name]} is a dependency.`,
363
+ ? `${ASTRO.name} ${installedVersion(site, ASTRO.name) ?? deps[ASTRO.name]} is a dependency, with ${[commentName, installedVersion(site, commentName)].filter(Boolean).join(" ")} in it.`
364
+ : `${commentName} ${installedVersion(site, commentName) ?? deps[commentName]} is a dependency.`,
340
365
  ),
341
366
  );
342
367
  if (configError) checks.push(check("config", "missing", configError, { file: site.configFile, step: STEPS.install }));
@@ -394,7 +419,7 @@ async function doctorFeatures(site, { build }) {
394
419
  }),
395
420
  );
396
421
  // A site from before K5 works as it is; the one package is where Update goes.
397
- const before = [COMMENT_MODUS.name, BEFORE.pages].filter((n) => deps[n] !== undefined);
422
+ const before = [...COMMENT_NAMES, BEFORE.pages].filter((n) => deps[n] !== undefined);
398
423
  if (!one && before.includes(BEFORE.pages))
399
424
  checks.push(check("moved", "info", `${before.join(" and ")} ${before.length > 1 ? "are" : "is"} one package since 03-11, ${ASTRO.name}: \`npx ${SELF.name} init\` moves the site across (one dependency, one line in ${site.configFile ?? "astro.config"}).`));
400
425
  if (config && config.has.pages && !config.orderOk)
@@ -448,7 +473,7 @@ async function doctorFeatures(site, { build }) {
448
473
  const source = site.text(contentConfig) ?? "";
449
474
  if (!/\bpad\s*:/.test(source) || !/\bseo\s*:/.test(source))
450
475
  checks.push(check("route-files", "missing", "No collection with `pad` and `seo`: page settings have no place per page.", { missing: "a route-file collection", file: contentConfig, step: STEPS.pageSettings }));
451
- if (!/x-instellingen/.test(source))
476
+ if (!/x-(settings|instellingen)/.test(source))
452
477
  checks.push(check("site-settings", "missing", 'No collection marked `"x-instellingen": "site"`: site settings have no place.', { missing: "a site-settings collection", file: contentConfig, step: STEPS.siteSettings }));
453
478
  }
454
479
  } else {
@@ -498,7 +523,7 @@ async function doctorFeatures(site, { build }) {
498
523
  configured: !!config?.has.unbase,
499
524
  option: config ? config.unbaseAnalytics : null,
500
525
  project: readLink(site) ?? config?.unbaseProject ?? null,
501
- before: !one && [COMMENT_MODUS.name, BEFORE.pages].some((n) => deps[n] !== undefined),
526
+ before: !one && [...COMMENT_NAMES, BEFORE.pages].some((n) => deps[n] !== undefined),
502
527
  step: STEPS.analytics,
503
528
  install: STEPS.install,
504
529
  config: site.configFile ?? "astro.config.mjs",
@@ -54,6 +54,7 @@ function requireOf(n) {
54
54
  */
55
55
  export function inspectNextConfig(code, file) {
56
56
  const ast = parseConfig(code, file);
57
+ /** @type {any[]} Babel's statements, narrowed by `type` below. */
57
58
  const body = ast.program.body;
58
59
  const exp = body.find((n) => n.type === "ExportDefaultDeclaration");
59
60
  const cjs = body.find(isModuleExports);