@elytracms/cli 0.0.91 → 0.0.93

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.
@@ -1,329 +1,50 @@
1
- import { existsSync } from 'node:fs'
2
- import { join } from 'node:path'
3
- import { fileURLToPath, pathToFileURL } from 'node:url'
4
- import {
5
- createRouter,
6
- declaredMounts,
7
- hierarchyMountConflicts,
8
- isHierarchyTemplate,
9
- routeRecordSchema,
10
- routeReachabilityIssues,
11
- } from '@elytracms/core/cms-core'
1
+ import { createRouter, declaredMounts } from '@elytracms/core/cms-core'
12
2
 
13
3
  /**
14
- * `elytra doctor`'s route check (EC-469) — the CODE side of route validation.
15
- *
16
- * `createRouter` computes real structural issues and, before this, no surface showed
17
- * them: the studio has had no Routes screen since EC-303 (correctly — routes are
18
- * code), and doctor deferred structure to "the studio boot and `elytra build`",
19
- * neither of which checked routes. A route conflict shipped silently.
20
- *
21
- * **What lives here and why only this.** `createRouter` produces exactly two codes —
22
- * `route-conflict` (from routes alone) and `redirect-loop` (from redirects). Since
23
- * EC-303 redirects are editorial DATA in the backend, so a bundler-less, session-less
24
- * CLI cannot see them; and `unknown-route-target` is not a router issue at all — the
25
- * *resolver* raises it per URL against the documents that exist
26
- * (`core/src/content/client.ts`). So the honest CLI-side answer is **route conflicts**,
27
- * and the other two are the studio's (which holds both the routes and the redirects).
28
- * The `redirect-loops` check below says exactly that, as an `unknown` — the same
29
- * convention `config-valid` already uses for a fact the CLI cannot gather.
30
- *
31
- * EC-482 adds the half the router structurally cannot see: **hierarchy mounts**. They
32
- * are filtered OUT of the router (below, and identically in delivery), so two mounts
33
- * fighting over the same URLs were invisible to every surface. `hierarchyMountConflicts`
34
- * judges them by declaration instead of by pattern shape; the second check row reports
35
- * it. Both checks are code-side and mutually exclusive by construction — a mount never
36
- * reaches the router, an ordinary route never reaches the mount detector.
37
- *
38
- * EC-484 adds the third row, `unreachable-routes`, for the case where nothing is in
39
- * conflict and the declaration simply does not work: a `/:slug`-shaped route that
40
- * matches every URL at a depth the mount serves (so the mount is never reached and
41
- * existing pages 404), a mount whose collection cannot compose nested paths, and a
42
- * catch-all with a dynamic prefix that every router drops and no mount is built from.
43
- * All three were measured to resolve `notFound` with zero issues on every surface.
44
- *
45
- * **Loading the routes.** This check runs with NO bundler and NO installed deps: a
46
- * project's `cms/` tree is React-free by convention — measured across `apps/demo`, the
47
- * scaffold template, and both real consumer repos: every external import is
48
- * `import type`, erased by Node's own TypeScript support. So doctor imports
49
- * `cms/index.ts` natively and reads the same `collections` + `routes` that
50
- * `elytra.config.ts` passes straight through. (`elytra.config.ts` itself is NOT
51
- * loadable this way — it imports `.tsx` component barrels, which no Node version
52
- * executes, EC-474. Where the consumer's deps ARE installed, EC-495's Vite harness
53
- * executes the full config and `runDoctor` hands the ROUTES and collections it resolved
54
- * to these checks in place of the `cms/index.ts` re-export — EC-603; before, only the
55
- * collections were swapped in. This loader stays the floor, and the first row says
56
- * which of the two was judged.)
57
- *
58
- * Two things stand in the way, and both are handled rather than assumed away:
59
- *
60
- * 1. **Node floor.** Native TS needs Node ≥22.18 (measured: 22.13 → `ERR_UNKNOWN_
61
- * FILE_EXTENSION`, 22.21 → loads). Below the floor the check reports `unknown`
62
- * with the version as its reason — the CLI's own `engines` promise (>=20) is not
63
- * quietly broken.
64
- * 2. **Bundler-style specifiers.** Real `cms/` trees write `from './collections'` —
65
- * extensionless, and a directory at that. Plain Node ESM resolves neither, at any
66
- * version. {@link withBundlerResolution} registers a *fallback* resolve hook that
67
- * supplies the extension/index a bundler would, and only after Node's own
68
- * resolution has already failed — so it can never hijack a specifier that already
69
- * resolves.
70
- *
71
- * Executing consumer code in a tool that otherwise only does HTTP is a change in
72
- * kind, so it is bounded: one conventional file, read-only, no writes, and every
73
- * failure mode (missing file, throwing module, unresolvable import, non-erasable TS,
74
- * a `routes` export of the wrong shape, a derive that throws) degrades to a reported
75
- * `unknown` carrying its reason. There is no path here that crashes the doctor and
76
- * none that reports a pass it did not establish.
77
- */
78
-
79
- // --- Loading the project's routes (impure) -----------------------------------
80
-
81
- /** Where the route set is read from, by convention (AD-11: structure is code, in-repo). */
82
- export const CMS_ENTRY = join('cms', 'index.ts')
83
-
84
- /** Relative-specifier suffixes a bundler would try, in the order it tries them. */
85
- const RESOLVE_CANDIDATES = ['.ts', '.tsx', '/index.ts', '/index.tsx', '.js', '.mjs', '/index.js']
86
-
87
- /**
88
- * Run `load` with a FALLBACK module-resolution hook that supplies the extension or
89
- * `/index` a bundler would for a relative specifier — but only for specifiers Node
90
- * itself could not resolve, so an already-valid specifier is never rewritten. The
91
- * hook is deregistered before returning, in success and in failure alike: doctor
92
- * never leaves process-wide resolution patched.
93
- *
94
- * `module.registerHooks` is Node ≥22.15. Where it is absent the load simply runs
95
- * unhooked (a `cms/` tree with explicit extensions still works) — never an error.
96
- */
97
- export async function withBundlerResolution(load) {
98
- let handle
99
- try {
100
- const { registerHooks } = await import('node:module')
101
- if (typeof registerHooks === 'function') {
102
- handle = registerHooks({
103
- resolve(specifier, context, nextResolve) {
104
- try {
105
- return nextResolve(specifier, context)
106
- } catch (error) {
107
- if (!specifier.startsWith('./') && !specifier.startsWith('../')) throw error
108
- if (!context.parentURL) throw error
109
- for (const suffix of RESOLVE_CANDIDATES) {
110
- const url = new URL(specifier + suffix, context.parentURL)
111
- if (url.protocol === 'file:' && existsSync(fileURLToPath(url))) {
112
- return { url: url.href, shortCircuit: true }
113
- }
114
- }
115
- throw error
116
- }
117
- },
118
- })
119
- }
120
- } catch {
121
- // No resolve-hook support in this runtime — load unhooked.
122
- }
123
- try {
124
- return await load()
125
- } finally {
126
- handle?.deregister()
127
- }
128
- }
129
-
130
- /**
131
- * Silence ONE Node warning for the duration of `run`:
132
- * `MODULE_TYPELESS_PACKAGE_JSON`, which fires for every consumer repo whose root
133
- * `package.json` omits `"type": "module"` (both real ones). It is unrelated to route
134
- * validity and would print into the middle of the doctor report. Every other warning
135
- * still prints, and the original listeners are restored unconditionally.
4
+ * `elytra doctor`'s route checks (EC-469, EC-482, EC-484) — READING the one router's
5
+ * issue set (EC-590; EC-565 Round 3, 3h).
6
+ *
7
+ * `createRouter` (cms-core `router.ts`) owns the project's ONE route issue set — exact
8
+ * ties between ordinary routes (`route-conflict`), the one normalised redirect set
9
+ * (`redirect-loop`, `invalid-redirect`), hierarchy-mount ties, and reachability — and
10
+ * the studio and the delivery host read the same set. This module only reports it, in
11
+ * the four rows a reader needs, from the router's `issueGroups`.
12
+ *
13
+ * **The routes are the resolved config's** (EC-583/EC-590, RESIDUE-4a/4b): the routes and
14
+ * collections `elytra.config.ts` resolves to through the consumer studio's own Vite
15
+ * (EC-495) — what the studio mounts and delivery serves. The bundler-free `cms/index.ts`
16
+ * floor (a native import of the scaffold's own convention, with its own copy of the
17
+ * routes materialisation) is gone: when the config cannot be resolved here, the rows say
18
+ * so as `unknown`, never a judgement over a second reading of the routes.
19
+ *
20
+ * **The redirects are the deployment's** (EC-590): the enabled editorial redirects the
21
+ * public delivery snapshot serves, read on the same request `published-orphans` makes.
22
+ * Without a deployment to read (playground, no URL) `redirect-loops` is an honest
23
+ * `unknown`.
136
24
  */
137
- async function withoutTypelessModuleWarning(run) {
138
- const listeners = process.listeners('warning')
139
- process.removeAllListeners('warning')
140
- const passthrough = (warning) => {
141
- if (warning?.code === 'MODULE_TYPELESS_PACKAGE_JSON') return
142
- for (const listener of listeners) listener(warning)
143
- }
144
- process.on('warning', passthrough)
145
- try {
146
- return await run()
147
- } finally {
148
- process.off('warning', passthrough)
149
- for (const listener of listeners) process.on('warning', listener)
150
- }
151
- }
152
-
153
- /** The first line of an error, safe for a one-line report row. */
154
- function reason(error) {
155
- const text = error instanceof Error ? error.message : String(error)
156
- return text.split('\n')[0].trim()
157
- }
158
25
 
159
26
  /**
160
- * Materialize a `routes` config value against the declared collections — the same
161
- * rule `studio-core`'s `materializeRecords` applies (EC-207): a derive function runs
162
- * once, a static array passes through. Both real consumer repos declare the array
163
- * form; the demo and the scaffold declare the derive.
27
+ * @typedef {{ routes: readonly import('@elytracms/core/cms-core').RouteRecord[];
28
+ * collections?: readonly import('@elytracms/core/cms-core').CollectionDef[];
29
+ * locales?: import('@elytracms/core/cms-core').LocaleConfig }} RouteProject
30
+ * @typedef {{ project: RouteProject;
31
+ * redirects?: readonly import('@elytracms/core/cms-core').RedirectRecord[];
32
+ * redirectsUnavailable?: string } | { unavailable: string; fix?: string }} RouteFacts
164
33
  */
165
- function materializeRoutes(routes, collections) {
166
- return typeof routes === 'function' ? routes(collections) : [...routes]
167
- }
168
-
169
- /**
170
- * Load the project's declared route set. Returns either `{ routes, routeCount }` or
171
- * `{ unavailable, fix? }` — an honest reason the routes could not be read. Never
172
- * throws.
173
- *
174
- * `importModule` is injectable for tests (the default is a native dynamic import).
175
- */
176
- export async function loadProjectRoutes(root, { importModule } = {}) {
177
- const entry = join(root, CMS_ENTRY)
178
- if (!existsSync(entry)) {
179
- return {
180
- // EC-533: state what this FALLBACK looked for, not what a project must contain.
181
- // Elytra requires one thing of a repo — an `elytra.config.ts` of the right shape
182
- // — and no blessed module paths (EC-532). `cms/index.ts` is the scaffold's own
183
- // convention, which is all this bundler-free loader can find on its own; where
184
- // the project's deps are installed, EC-495's Vite harness executes the real
185
- // config and this floor is never reached.
186
- unavailable: `Routes not checked: no ${CMS_ENTRY} to read without a bundler (this is the scaffold's convention, not a requirement — your routes may be declared elsewhere).`,
187
- }
188
- }
189
-
190
- const load = importModule ?? ((path) => import(pathToFileURL(path).href))
191
- let mod
192
- try {
193
- mod = await withoutTypelessModuleWarning(() => withBundlerResolution(() => load(entry)))
194
- } catch (error) {
195
- if (error?.code === 'ERR_UNKNOWN_FILE_EXTENSION') {
196
- return {
197
- unavailable: `${CMS_ENTRY} could not be read: this Node (${process.version}) does not run TypeScript natively.`,
198
- fix: 'Use Node >=22.18 (the version the engine targets) to have `elytra doctor` check routes.',
199
- }
200
- }
201
- if (error?.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX') {
202
- return {
203
- unavailable: `${CMS_ENTRY} uses TypeScript syntax Node cannot strip (${reason(error)}).`,
204
- fix: 'Keep cms/ to erasable TypeScript (no enum/namespace/parameter properties) so build-time tools can read your structure.',
205
- }
206
- }
207
- return { unavailable: `${CMS_ENTRY} could not be loaded: ${reason(error)}` }
208
- }
209
-
210
- if (mod?.routes === undefined) {
211
- return {
212
- unavailable: `${CMS_ENTRY} exports no \`routes\` — the route set was not checked here.`,
213
- }
214
- }
215
- if (typeof mod.routes !== 'function' && !Array.isArray(mod.routes)) {
216
- return {
217
- unavailable: `${CMS_ENTRY} exports \`routes\` that is neither a RouteRecord[] nor a (collections) => RouteRecord[].`,
218
- }
219
- }
220
- // Distinguish "exports no collections" from "exports an empty array": the
221
- // reachability check must report NOT CHECKED rather than a pass when it cannot see
222
- // the collection set (a mount's target is judged against it).
223
- const collections = Array.isArray(mod.collections) ? mod.collections : undefined
224
-
225
- let records
226
- try {
227
- records = materializeRoutes(mod.routes, collections ?? [])
228
- } catch (error) {
229
- return { unavailable: `The \`routes\` derive in ${CMS_ENTRY} threw: ${reason(error)}` }
230
- }
231
- if (!Array.isArray(records)) {
232
- return { unavailable: `The \`routes\` derive in ${CMS_ENTRY} did not return an array.` }
233
- }
234
-
235
- // Shape-validate before handing records to the router: a malformed record (no
236
- // pattern) would otherwise fault inside pattern compilation. Config validity is
237
- // the studio boot's job, so this reports rather than duplicating that check.
238
- const invalid = records.filter((record) => !routeRecordSchema.safeParse(record).success)
239
- if (invalid.length > 0) {
240
- return {
241
- unavailable: `${invalid.length} of ${records.length} route record(s) are not valid RouteRecords — config validation reports the details.`,
242
- fix: 'Open the studio (or run your build) to see the config validation issues, then re-run `elytra doctor`.',
243
- }
244
- }
245
-
246
- return {
247
- routes: records,
248
- routeCount: records.length,
249
- ...(collections ? { collections } : {}),
250
- }
251
- }
252
-
253
- // --- Detection (pure) --------------------------------------------------------
254
-
255
- /**
256
- * The router issues of a declared route set — route conflicts, since a CLI passes
257
- * no redirects.
258
- *
259
- * Hierarchy-mount templates (`/:path*`, EC-218) are filtered out first, exactly as
260
- * the delivery resolver does (`core/src/content/client.ts:230`): a mount is resolved
261
- * per-request against the parent chain, not by the router, so counting it as a route
262
- * would report conflicts the runtime does not have. Running the same filter is what
263
- * makes doctor unable to disagree with delivery.
264
- *
265
- * The filter is NOT widened to cover EC-482 — {@link mountIssuesOf} answers that
266
- * question about the routes this one removes. Widening the router's signature
267
- * comparison instead would reinstate the `/:slug` + `/:path*` false positive the
268
- * filter exists to prevent (pinned in both this package's and cms-core's tests).
269
- */
270
- export function routeIssuesOf(routes) {
271
- return createRouter(routes.filter((route) => !isHierarchyTemplate(route)), []).issues
272
- }
273
-
274
- /**
275
- * The conflicts BETWEEN hierarchy mounts (EC-482) — the routes {@link routeIssuesOf}
276
- * filters away. `error` for two mounts on the same path (identical URL space, split
277
- * only by declaration order), `warning` for a nested pair (a real shadow, but only
278
- * where the outer collection's page tree actually reaches into the inner prefix — a
279
- * content fact a CLI cannot see).
280
- */
281
- export function mountIssuesOf(routes) {
282
- return hierarchyMountConflicts(routes)
283
- }
284
-
285
- /**
286
- * The declarations that can never serve content (EC-484) — the third question, after
287
- * "do two routes fight" and "do two mounts fight": **does this declaration work at
288
- * all?** An all-dynamic route (`/:slug`) matching every URL at a depth the mount
289
- * serves, a mount whose collection has no `parent` self-relation (or is not declared),
290
- * and a catch-all with a dynamic prefix (`/:lang/:path*`) that every router drops and
291
- * no mount is built from. All three were measured to resolve `notFound` with ZERO
292
- * issues anywhere before this.
293
- *
294
- * `collections` is passed through when the project exported them; without them the
295
- * mount-target half is skipped and {@link routesDoctorChecks} reports `unknown`
296
- * instead of a pass it did not establish.
297
- */
298
- export function reachabilityIssuesOf(routes, collections) {
299
- return routeReachabilityIssues(routes, collections)
300
- }
301
-
302
- // --- Doctor checks (pure) ----------------------------------------------------
303
34
 
304
35
  const CONFLICT_FIX =
305
- 'Two routes match the same URLs — give one a distinct pattern (or delete it) in cms/routes.ts.'
36
+ 'Two routes match the same URLs in the same locale scope — give one a distinct pattern (or delete it) where your routes are declared.'
306
37
 
307
38
  const MOUNT_CONFLICT_FIX =
308
- 'Two collections cannot be served from the same URL space — give one mount a distinct prefix (e.g. "/docs/:path*") in cms/routes.ts, or drop it.'
309
-
310
- const MOUNT_SHADOW_FIX =
311
- 'Mounts resolve in declaration order, not by specificity — declare the more specific mount first, and keep the outer collection\'s page tree clear of that prefix.'
39
+ 'Two collections cannot be served from the same URL space in the same locale scope — give one mount a distinct prefix (e.g. "/docs/:path*"), or drop it.'
312
40
 
313
41
  const UNREACHABLE_FIX =
314
- 'Give an all-dynamic route a static segment (e.g. "/blog/:slug"), mount only collections with a `parent` self-relation, and keep a mount prefix static — in cms/routes.ts.'
42
+ 'Give an all-dynamic route a static segment (e.g. "/blog/:slug"), mount only collections with a parent role, and keep a mount prefix static.'
315
43
 
316
- /**
317
- * Where the judged route set came from (EC-603, RESIDUE-4), appended to the first row so
318
- * the report says which reader it used: the executed config (what the studio and
319
- * delivery serve) or the bundler-free `cms/index.ts` floor. No `source` → no note.
320
- */
321
- const ROUTE_SOURCE_NOTE = {
322
- config: ' (Routes from the executed elytra.config.ts.)',
323
- native: ` (Routes read natively from ${CMS_ENTRY} — elytra.config.ts was not resolved here.)`,
324
- }
44
+ const REDIRECT_FIX =
45
+ 'Edit the redirects in the studio’s Redirects rail: break the loop, or delete one of the duplicate `from`s (`/old` and `/old/` are one URL).'
325
46
 
326
- /** An `unknown` check row carrying the reason the routes could not be read. */
47
+ /** An `unknown` check row carrying the reason the routes could not be judged. */
327
48
  function unavailableCheck(id, facts) {
328
49
  return {
329
50
  id,
@@ -335,90 +56,84 @@ function unavailableCheck(id, facts) {
335
56
  }
336
57
 
337
58
  /**
338
- * The doctor's route checks, for the `app` bucket. Consumes the already-loaded facts
339
- * (the {@link loadProjectRoutes} result) so the reporting shape is pure and directly
340
- * testable, like `formatReport` and `previewsDoctorChecks`.
59
+ * The doctor's route checks, for the `app` bucket — pure over the gathered facts (the
60
+ * resolved project and, when a deployment was read, its redirects), like `formatReport`.
341
61
  *
342
- * Four rows, in the order a reader needs them: the router's own conflicts, the
343
- * mount-vs-mount conflicts the router cannot see (EC-482), the declarations that serve
344
- * nothing at all (EC-484), then the redirects a CLI cannot see at all.
62
+ * `route-conflicts`, `mount-conflicts` and `redirect-loops` can FAIL (deterministic
63
+ * structural faults); `unreachable-routes` fails on a declaration that can never serve
64
+ * and warns on a precedence that depends on content (EC-488).
345
65
  *
346
- * `route-conflicts`, `mount-conflicts` and `unreachable-routes` are the checks here
347
- * that can FAIL — all deterministic in code, so failing the exit code is safe for CI.
348
- * The latter two can also `warn`, in both cases for the same reason: the finding only
349
- * costs content where a collection's tree actually reaches that far, which is CONTENT
350
- * a CLI cannot see, so naming it is honest where failing a build would not be.
351
- * `redirect-loops` is always `unknown`: they are editorial data, and saying so is how
352
- * the report stays honest about what a CLI can and cannot see.
66
+ * @param {RouteFacts | undefined} facts
353
67
  */
354
68
  export function routesDoctorChecks(facts) {
355
- const redirects = {
356
- id: 'redirect-loops',
357
- bucket: 'app',
358
- status: 'unknown',
359
- detail:
360
- 'Redirect loops were not evaluated here — redirects are editorial data in the backend; the studio checks them.',
361
- }
362
-
363
- if (!facts || facts.unavailable) {
69
+ if (!facts || 'unavailable' in facts) {
364
70
  return [
365
71
  unavailableCheck('route-conflicts', facts),
366
72
  unavailableCheck('mount-conflicts', facts),
367
73
  unavailableCheck('unreachable-routes', facts),
368
- redirects,
74
+ unavailableCheck('redirect-loops', facts),
369
75
  ]
370
76
  }
371
-
372
- const count = facts.routeCount ?? facts.routes.length
77
+ const router = createRouter(facts.project, { redirects: facts.redirects ?? [] })
78
+ const routes = facts.project.routes
79
+ const count = routes.length
373
80
  const plural = count === 1 ? '' : 's'
374
- const conflicts = routeIssuesOf(facts.routes).filter((issue) => issue.code === 'route-conflict')
375
- const source = ROUTE_SOURCE_NOTE[facts.source] ?? ''
376
-
81
+ const conflicts = router.issueGroups.routes
377
82
  const routeConflicts =
378
83
  conflicts.length === 0
379
- ? {
380
- id: 'route-conflicts',
381
- bucket: 'app',
382
- status: 'ok',
383
- detail: `${count} declared route${plural}, no URL conflicts.${source}`,
384
- }
84
+ ? { id: 'route-conflicts', bucket: 'app', status: 'ok', detail: `${count} declared route${plural}, no URL conflicts.` }
385
85
  : {
386
86
  id: 'route-conflicts',
387
87
  bucket: 'app',
388
88
  status: 'fail',
389
89
  detail:
390
90
  `${conflicts.length} route conflict(s) among ${count} declared route${plural}. ` +
391
- conflicts.map((issue) => issue.message).join(' ') +
392
- source,
91
+ conflicts.map((issue) => issue.message).join(' '),
393
92
  fix: CONFLICT_FIX,
394
93
  }
395
94
 
396
95
  return [
397
96
  routeConflicts,
398
- mountConflictsCheck(facts.routes),
399
- unreachableRoutesCheck(facts.routes, facts.collections),
400
- redirects,
97
+ mountConflictsCheck(routes, router.issueGroups.mounts),
98
+ unreachableRoutesCheck(routes, router.issueGroups.reachability),
99
+ redirectLoopsCheck(facts, router.issueGroups.redirects),
401
100
  ]
402
101
  }
403
102
 
103
+ /** The `redirect-loops` row: the deployment's redirects through the one normalised set. */
104
+ function redirectLoopsCheck(facts, issues) {
105
+ const base = { id: 'redirect-loops', bucket: 'app' }
106
+ if (facts.redirects === undefined) {
107
+ return {
108
+ ...base,
109
+ status: 'unknown',
110
+ detail:
111
+ facts.redirectsUnavailable ??
112
+ 'Redirects were not evaluated here — they are editorial data on the deployment, and no deployment was read.',
113
+ }
114
+ }
115
+ const n = facts.redirects.length
116
+ const scope = `${n} enabled redirect${n === 1 ? '' : 's'} on the deployment`
117
+ if (issues.length === 0) return { ...base, status: 'ok', detail: `${scope}, no loops or duplicates.` }
118
+ return {
119
+ ...base,
120
+ status: 'fail',
121
+ detail: `${issues.length} redirect issue(s) among ${scope}. ` + issues.map((issue) => issue.message).join(' '),
122
+ fix: REDIRECT_FIX,
123
+ }
124
+ }
125
+
404
126
  /**
405
- * The `unreachable-routes` row (EC-484): declarations that resolve to nothing.
406
- *
407
- * Like `mount-conflicts` it states what it LOOKED at when it passes — a bare "ok"
408
- * reads the same whether the check examined the mounts or skipped them. And when the
409
- * project exported no collections it reports `unknown` rather than `ok`: the
410
- * mount-target half could not run, and a pass it did not establish would be exactly
411
- * the silent failure this ticket exists to remove.
127
+ * The `unreachable-routes` row (EC-484): declarations that resolve to nothing. States what
128
+ * it LOOKED at when it passes — a bare "ok" reads the same whether it examined the mounts
129
+ * or skipped them.
412
130
  */
413
- function unreachableRoutesCheck(routes, collections) {
131
+ function unreachableRoutesCheck(routes, issues) {
414
132
  const mounts = declaredMounts(routes)
415
133
  const scope = `${routes.length} declared route${routes.length === 1 ? '' : 's'}, ${mounts.length} hierarchy mount${mounts.length === 1 ? '' : 's'}`
416
134
  const base = { id: 'unreachable-routes', bucket: 'app' }
417
-
418
- const issues = reachabilityIssuesOf(routes, collections)
419
135
  const errors = issues.filter((issue) => issue.severity === 'error')
420
136
  const warnings = issues.filter((issue) => issue.severity !== 'error')
421
-
422
137
  if (errors.length > 0) {
423
138
  return {
424
139
  ...base,
@@ -433,65 +148,31 @@ function unreachableRoutesCheck(routes, collections) {
433
148
  return {
434
149
  ...base,
435
150
  status: 'warn',
436
- detail:
437
- `${warnings.length} partially shadowed declaration(s), among ${scope}. ` +
438
- warnings.map((issue) => issue.message).join(' '),
151
+ detail: `${warnings.length} partially shadowed declaration(s), among ${scope}. ` + warnings.map((issue) => issue.message).join(' '),
439
152
  fix: UNREACHABLE_FIX,
440
153
  }
441
154
  }
442
- if (mounts.length > 0 && !collections) {
443
- return {
444
- ...base,
445
- status: 'unknown',
446
- detail: `${scope}: no route shadows a mount, but mount targets were not checked — ${CMS_ENTRY} exports no \`collections\`.`,
447
- fix: `Export \`collections\` from ${CMS_ENTRY} (the shape elytra.config.ts re-exports) so mounts can be checked against them.`,
448
- }
449
- }
450
155
  return { ...base, status: 'ok', detail: `${scope} — every declaration can serve content.` }
451
156
  }
452
157
 
453
158
  /**
454
- * The `mount-conflicts` row (EC-482). Reports the mount COUNT even when clean — a row
455
- * that says "1 hierarchy mount, no overlap" proves the check looked at the mounts,
456
- * where a bare "ok" would read the same whether it examined them or skipped them.
159
+ * The `mount-conflicts` row (EC-482, re-derived by EC-590): exact ties between mounts. Reports
160
+ * the mount COUNT even when clean, so a pass proves the check looked at the mounts.
457
161
  */
458
- function mountConflictsCheck(routes) {
162
+ function mountConflictsCheck(routes, issues) {
459
163
  const mounts = declaredMounts(routes)
460
164
  const mountPlural = mounts.length === 1 ? '' : 's'
461
165
  const base = { id: 'mount-conflicts', bucket: 'app' }
462
-
463
- if (mounts.length === 0) {
464
- return { ...base, status: 'ok', detail: 'No hierarchy mounts declared.' }
465
- }
466
-
467
- const issues = mountIssuesOf(routes)
468
- const errors = issues.filter((issue) => issue.severity === 'error')
469
- const warnings = issues.filter((issue) => issue.severity !== 'error')
470
- const among = `among ${mounts.length} hierarchy mount${mountPlural}`
471
-
472
- if (errors.length > 0) {
166
+ if (mounts.length === 0) return { ...base, status: 'ok', detail: 'No hierarchy mounts declared.' }
167
+ if (issues.length > 0) {
473
168
  return {
474
169
  ...base,
475
170
  status: 'fail',
476
171
  detail:
477
- `${errors.length} conflicting mount pair(s) ${among}. ` +
478
- [...errors, ...warnings].map((issue) => issue.message).join(' '),
172
+ `${issues.length} conflicting mount pair(s) among ${mounts.length} hierarchy mount${mountPlural}. ` +
173
+ issues.map((issue) => issue.message).join(' '),
479
174
  fix: MOUNT_CONFLICT_FIX,
480
175
  }
481
176
  }
482
- if (warnings.length > 0) {
483
- return {
484
- ...base,
485
- status: 'warn',
486
- detail:
487
- `${warnings.length} overlapping mount pair(s) ${among}. ` +
488
- warnings.map((issue) => issue.message).join(' '),
489
- fix: MOUNT_SHADOW_FIX,
490
- }
491
- }
492
- return {
493
- ...base,
494
- status: 'ok',
495
- detail: `${mounts.length} hierarchy mount${mountPlural}, no overlapping mounts.`,
496
- }
177
+ return { ...base, status: 'ok', detail: `${mounts.length} hierarchy mount${mountPlural}, no conflicting mounts.` }
497
178
  }