uniweb 1.31.5 → 1.31.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.
@@ -8,14 +8,20 @@
8
8
  * (`backend/foundation-bring-along.js`).
9
9
  *
10
10
  * If the foundation's `dist/` is missing or stale — no build, a version bump
11
- * since it, a source file newer than it, no SSR bundle (`foundationNeedsBuild`)
11
+ * since it, a source file or a library's newer than it, no SSR bundle (`foundationNeedsBuild`)
12
12
  * — `register` builds it first. Preview paths (`--dry-run`, `-o`) never write to
13
13
  * `dist/`; they require a pre-built foundation.
14
14
  *
15
- * Run from a foundation, or from a schemas-only package — a package that exports
16
- * schemas (e.g. `@uniweb/schemas`, any `@org/schemas`) or a bare `schemas/*.yml`
17
- * folder. The schemas-only package is auto-detected and submits its data schemas
18
- * standalone (foundation-less); same flags, `--scope` names them.
15
+ * Run from a foundation, or from a schemas-only package — a package holding a
16
+ * `schemas/*.yml` folder (a library's), or one that exports schemas (e.g.
17
+ * `@uniweb/schemas`, any `@org/schemas`). The schemas-only package is auto-detected
18
+ * and submits its data schemas standalone (foundation-less); same flags, `--scope`
19
+ * names them.
20
+ *
21
+ * A foundation's register first registers the types it names that a library
22
+ * defines, from the library (`backend/library-types.js`): the registry takes a
23
+ * foundation only once the types it names are registered. So `push` and `publish`,
24
+ * which release a site's foundation with this command, register them too.
19
25
  *
20
26
  * Usage:
21
27
  * uniweb register Build the .uwx, submit it, then deliver
@@ -63,7 +69,6 @@ import {
63
69
  existsSync,
64
70
  readFileSync,
65
71
  writeFileSync,
66
- readdirSync,
67
72
  statSync
68
73
  } from 'node:fs'
69
74
  import { execSync } from 'node:child_process'
@@ -93,6 +98,9 @@ import { deriveScope, publishScope, belongsToScope } from '../utils/registry-org
93
98
  import { BackendClient } from '../backend/client.js'
94
99
  import { resolveWorkspace, scopeOfWorkspace, topOfChildHandle, SOURCE_LABEL } from '../backend/workspace.js'
95
100
  import { writeJsonPreservingStyleAsync } from '../utils/json-file.js'
101
+ import { newerInput } from '../utils/foundation-freshness.js'
102
+ import { unregisteredLocalTypes } from '../backend/unregistered-types.js'
103
+ import { typesFromLibraries } from '../backend/library-types.js'
96
104
  import {
97
105
  findWorkspaceRoot,
98
106
  findFoundations,
@@ -188,6 +196,152 @@ function readPkgName(dir) {
188
196
  }
189
197
  }
190
198
 
199
+ // Whether the account is a member of `scope`: true, false, or null when that can't be told. Read to
200
+ // explain a refusal, never to gate one; a 401 is the credential itself, so it asks nothing.
201
+ async function memberOfScope(res, scope, client) {
202
+ return res.status === 401 ? null : belongsToScope(scope, await client.fetchOrgs().catch(() => null))
203
+ }
204
+
205
+ /**
206
+ * Say why the registry refused a submission: a foundation's, a schemas package's, or a library's
207
+ * registered before its foundation.
208
+ *
209
+ * ⭐ NOT A MEMBER OF THE SCOPE IS SAID AS THAT *[Diego, 2026-10-06]*. The registry decides who may
210
+ * release into a scope — its account, or an org's members — and when the orgs read says you are
211
+ * neither, that is the refusal to name. ⛔ Until then a 403 here printed "log in again", the wrong
212
+ * advice for a scope that is not yours.
213
+ *
214
+ * @param {object} o
215
+ * @param {Response} o.res
216
+ * @param {object|null} o.parsedBody
217
+ * @param {string} o.rawBody
218
+ * @param {string} o.scope
219
+ * @param {boolean|null} o.member - `memberOfScope`
220
+ * @param {string} o.what - what was refused, for the not-a-member sentence
221
+ */
222
+ function sayRefused({ res, parsedBody, rawBody, scope, member, what }) {
223
+ if (member === false) {
224
+ error(`You can't release ${what}: you're not a member of ${scope}.`)
225
+ log(
226
+ ` ${colors.dim}A member of ${scope} can release it. (The registry answered HTTP ${res.status}.)${colors.reset}`
227
+ )
228
+ } else {
229
+ error(
230
+ `Registry rejected the submission: HTTP ${res.status} ${res.statusText}`
231
+ )
232
+ }
233
+ if (member !== false && (res.status === 401 || res.status === 403)) {
234
+ log(
235
+ ` ${colors.dim}The registry didn't accept your credentials — it may use different ones than \`uniweb login\`.${colors.reset}`
236
+ )
237
+ log(
238
+ ` ${colors.dim}Log in again (uniweb login --server <url>), or check UNIWEB_TOKEN — an existing one may be wrong or expired.${colors.reset}`
239
+ )
240
+ }
241
+ // ⭐ **Surface `detail` as a sentence, not as a JSON dump.** The registry
242
+ // answers with problem+json (RFC 9457), and its `detail` is written for a
243
+ // human — it carries the actual next step, which for a rejected
244
+ // re-register is "bump the version". Printing the whole body dimmed put
245
+ // that sentence inside a blob, at the end of a 500-char truncation, in the
246
+ // one moment the reader most needs it.
247
+ //
248
+ // ⚖️ Keyed on the SHAPE, not on any particular code: a new refusal the CLI
249
+ // has never seen explains itself the day the backend ships it, with no
250
+ // release here. That is the property worth having — this branch exists
251
+ // because a 422 the CLI did not know about arrived exactly that way.
252
+ if (parsedBody?.detail) {
253
+ log(` ${parsedBody.detail}`)
254
+ const code = parsedBody.code ?? parsedBody.reason
255
+ if (code) {
256
+ log(` ${colors.dim}(${code})${colors.reset}`)
257
+ }
258
+ } else if (rawBody) {
259
+ log(` ${colors.dim}${rawBody.slice(0, 500)}${colors.reset}`)
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Register the data schemas a library defines, before the foundation that names them
265
+ * (`backend/library-types.js`): the library's package whole, as `uniweb register` there sends it.
266
+ *
267
+ * ⚖️ A library of a scope the account isn't a member of can't be registered from here, and needn't
268
+ * be once its types are: the foundation is released against them as the registry holds them, which
269
+ * only that scope's members change. A library made by another org, kept in this workspace, is used
270
+ * so.
271
+ *
272
+ * @param {{ dir: string, scope: string, refs: string[] }} lib - its folder, scope, and the types the
273
+ * foundation names from it
274
+ * @param {object} o
275
+ * @param {BackendClient} o.client
276
+ * @param {object} o.exporter - the `.uwx` envelope's exporter
277
+ * @param {string} o.at - its folder as the person sees it
278
+ * @returns {Promise<{ names: string[], body: object|null }|null>} the names sent and the registry's
279
+ * answer; null when the release stops, which is said already
280
+ */
281
+ async function registerLibraryTypes(lib, { client, exporter, at }) {
282
+ let doc
283
+ try {
284
+ doc = buildSchemaOnlyPackage({
285
+ schemas: await collectStandaloneSchemas(lib.dir),
286
+ scope: lib.scope,
287
+ exporter
288
+ })
289
+ } catch (err) {
290
+ error(`Could not read the data schemas in ${at}: ${err.message}`)
291
+ return null
292
+ }
293
+ const names = doc.entities.map((e) => e.name)
294
+ info(`Registering the data schemas in ${at} (${names.join(', ')}) …`)
295
+ let res
296
+ try {
297
+ res = await client.register(JSON.stringify(doc, null, 2))
298
+ } catch (err) {
299
+ error(`Could not reach the registry at ${client.origin}: ${err.message}`)
300
+ return null
301
+ }
302
+ const rawBody = await res.text().catch(() => '')
303
+ let body = null
304
+ try {
305
+ body = rawBody ? JSON.parse(rawBody) : null
306
+ } catch {
307
+ body = null
308
+ }
309
+ if (res.ok) {
310
+ const answers = Array.isArray(body?.data_schemas) ? body.data_schemas : []
311
+ if (answers.length === names.length && answers.every((a) => a?.unchanged === true)) {
312
+ log(` ${colors.dim}Unchanged: the registry holds them as they are.${colors.reset}`)
313
+ } else {
314
+ success(`Registered ${names.length} data schema(s) under ${lib.scope}, from ${at}`)
315
+ }
316
+ return { names, body }
317
+ }
318
+ const member = await memberOfScope(res, lib.scope, client)
319
+ if (member === false) {
320
+ const held = await Promise.all(
321
+ lib.refs.map((ref) => client.readDataSchema(ref).catch(() => undefined))
322
+ )
323
+ if (held.every(Boolean)) {
324
+ const one = lib.refs.length === 1
325
+ info(
326
+ `${lib.refs.join(', ')} ${one ? 'is' : 'are'} registered under ${lib.scope}, whose members change ${one ? 'it' : 'them'}: the foundation is released against ${one ? 'it' : 'them'} as registered.`
327
+ )
328
+ return { names: [], body: null }
329
+ }
330
+ }
331
+ sayRefused({
332
+ res,
333
+ parsedBody: body,
334
+ rawBody,
335
+ scope: lib.scope,
336
+ member,
337
+ what: `data schemas under ${lib.scope}`
338
+ })
339
+ log(
340
+ ` ${colors.dim}The foundation was not submitted: the registry takes a foundation only once the types it names are registered.${colors.reset}`
341
+ )
342
+ return null
343
+ }
344
+
191
345
  /**
192
346
  * Resolve which foundation to register: the cwd if it's a foundation, else the
193
347
  * single foundation in the workspace, else prompt (or error in non-interactive).
@@ -458,46 +612,6 @@ async function deriveScopeFromLogin(client, args) {
458
612
  return derived ? `@${derived}` : null
459
613
  }
460
614
 
461
- // Directories that are never foundation source. `dist` is the output we compare
462
- // against; the rest are tooling. Dotted entries are skipped wholesale.
463
- const NON_SOURCE_DIRS = new Set(['dist', 'node_modules'])
464
-
465
- /**
466
- * The newest mtime under `dir`, skipping build output and tooling. `0` when the
467
- * tree is unreadable — which reads as "no source is newer", i.e. it degrades to
468
- * the pre-existing behaviour rather than forcing a build on an fs error.
469
- *
470
- * @param {string} dir
471
- * @returns {number} epoch ms
472
- */
473
- function newestSourceMtime(dir) {
474
- let newest = 0
475
- const walk = (d) => {
476
- let entries
477
- try {
478
- entries = readdirSync(d, { withFileTypes: true })
479
- } catch {
480
- return
481
- }
482
- for (const e of entries) {
483
- if (e.name.startsWith('.') || NON_SOURCE_DIRS.has(e.name)) continue
484
- const p = join(d, e.name)
485
- if (e.isDirectory()) {
486
- walk(p)
487
- continue
488
- }
489
- try {
490
- const m = statSync(p).mtimeMs
491
- if (m > newest) newest = m
492
- } catch {
493
- /* unreadable file — ignore */
494
- }
495
- }
496
- }
497
- walk(dir)
498
- return newest
499
- }
500
-
501
615
  /**
502
616
  * Does the foundation's `dist/` need a (re)build before we can register it?
503
617
  *
@@ -509,7 +623,9 @@ function newestSourceMtime(dir) {
509
623
  * so the artifact encodes the OLD version while the register intends the
510
624
  * NEW one (we'd otherwise submit a schema whose version disagrees with the
511
625
  * code we deliver).
512
- * - STALE SOURCE: a source file is newer than `dist/entry.js`.
626
+ * - STALE SOURCE: a file its build reads is newer than `dist/entry.js`: its own,
627
+ * or one of a library it bundles (`newerInput`, the rule `uniweb build`
628
+ * follows too).
513
629
  *
514
630
  * ⛔ **The source signal was missing until 2026-08-16, and its absence shipped the
515
631
  * PREVIOUS bundle silently.** Edit a component's rendered output, re-run
@@ -593,9 +709,14 @@ export function foundationNeedsBuild(targetDir) {
593
709
  const entryPath = existsSync(join(distDir, 'entry.js'))
594
710
  ? join(distDir, 'entry.js')
595
711
  : join(distDir, 'foundation.js')
596
- const builtAt = statSync(entryPath).mtimeMs
597
- if (newestSourceMtime(targetDir) > builtAt)
598
- return { needs: true, reason: 'a source file is newer than dist/entry.js' }
712
+ const newer = newerInput(targetDir, statSync(entryPath).mtimeMs)
713
+ if (newer)
714
+ return {
715
+ needs: true,
716
+ reason: newer.library
717
+ ? `a file of ${newer.library}, a library it bundles, is newer than dist/entry.js`
718
+ : 'a source file is newer than dist/entry.js'
719
+ }
599
720
  } catch {
600
721
  // Can't compare — leave the other signals to decide rather than forcing a
601
722
  // build on an fs error.
@@ -764,6 +885,18 @@ async function runRegister(args = []) {
764
885
  }
765
886
  }
766
887
 
888
+ // ⭐ The types it names that a library defines: registered from the library before the
889
+ // foundation, which the registry refuses while a type it names is missing (`library-types.js`).
890
+ const fromLibraries = standalone
891
+ ? []
892
+ : await typesFromLibraries({
893
+ named: Object.keys(schema?.dataSchemas || {}),
894
+ foundationDir: targetDir
895
+ }).catch(() => [])
896
+ // Where each is, said from the workspace root, which is where its person is.
897
+ const workspaceRoot = standalone ? null : findWorkspaceRoot(targetDir) || targetDir
898
+ const shownAt = (dir) => `${relative(workspaceRoot, dir) || '.'}/`
899
+
767
900
  // A schemas-only package with no scope, on a real submit → the workspace you work in,
768
901
  // else derived from your orgs (`deriveScopeFromLogin`), and persisted to package.json.
769
902
  // (A foundation's was settled before its build — `settleFoundationScope`.)
@@ -838,6 +971,11 @@ async function runRegister(args = []) {
838
971
  log(
839
972
  ` ${colors.dim}data schemas ${standalone ? 'registered' : 'defined'}: ${defined.length ? defined.join(', ') : '(none)'}${colors.reset}`
840
973
  )
974
+ for (const lib of fromLibraries) {
975
+ log(
976
+ ` ${colors.dim}data schemas from ${shownAt(lib.dir)}: ${lib.refs.join(', ')} — ${isPreview ? 'would be registered' : 'registered'} from there first${colors.reset}`
977
+ )
978
+ }
841
979
  if (scope)
842
980
  log(` ${colors.dim}scope: ${scope} (${scopeSource})${colors.reset}`)
843
981
  if (digest) log(` ${colors.dim}digest: ${digest}${colors.reset}`)
@@ -881,6 +1019,14 @@ async function runRegister(args = []) {
881
1019
  )
882
1020
  return { exitCode: 2 }
883
1021
  }
1022
+ // The libraries' types first: the registry checks a foundation's types when it takes it.
1023
+ const fromLibrariesSent = []
1024
+ for (const lib of fromLibraries) {
1025
+ const sent = await registerLibraryTypes(lib, { client, exporter, at: shownAt(lib.dir) })
1026
+ if (!sent) return { exitCode: 1 }
1027
+ fromLibrariesSent.push(sent)
1028
+ }
1029
+
884
1030
  // Submit — the client carries the bearer (UNIWEB_TOKEN › stored
885
1031
  // session › login), resolved lazily on this first authed call.
886
1032
  info(`Submitting to ${colors.dim}${client.origin}${colors.reset} …`)
@@ -925,53 +1071,37 @@ async function runRegister(args = []) {
925
1071
  `${colors.dim}Schema for this version is already registered — resuming code delivery.${colors.reset}`
926
1072
  )
927
1073
  } else {
928
- // ⭐ NOT A MEMBER OF THE SCOPE IS SAID AS THAT *[Diego, 2026-10-06]*. The registry
929
- // decides who may release into a scope — its account, or an org's members — and
930
- // when the orgs read says you are neither, that is the refusal to name. ⛔ Until then
931
- // a 403 here printed "log in again", the wrong advice for a scope that is not yours.
932
- // Read to explain a refusal, never to gate one; a 401 is the credential itself.
933
- const member =
934
- res.status === 401 ? null : belongsToScope(scope, await client.fetchOrgs().catch(() => null))
935
- if (member === false) {
936
- const what = standalone
1074
+ const member = await memberOfScope(res, scope, client)
1075
+ sayRefused({
1076
+ res,
1077
+ parsedBody,
1078
+ rawBody,
1079
+ scope,
1080
+ member,
1081
+ what: standalone
937
1082
  ? `data schemas under ${scope}`
938
1083
  : doc.entities.find((e) => e.model === '@uniweb/foundation-schema')?.info?.name || `a foundation under ${scope}`
939
- error(`You can't release ${what}: you're not a member of ${scope}.`)
940
- log(
941
- ` ${colors.dim}A member of ${scope} can release it. (The registry answered HTTP ${res.status}.)${colors.reset}`
942
- )
943
- } else {
944
- error(
945
- `Registry rejected the submission: HTTP ${res.status} ${res.statusText}`
946
- )
947
- }
948
- if (member !== false && (res.status === 401 || res.status === 403)) {
949
- log(
950
- ` ${colors.dim}The registry didn't accept your credentials — it may use different ones than \`uniweb login\`.${colors.reset}`
951
- )
952
- log(
953
- ` ${colors.dim}Log in again (uniweb login --server <url>), or check UNIWEB_TOKEN — an existing one may be wrong or expired.${colors.reset}`
954
- )
955
- }
956
- // ⭐ **Surface `detail` as a sentence, not as a JSON dump.** The registry
957
- // answers with problem+json (RFC 9457), and its `detail` is written for a
958
- // human — it carries the actual next step, which for a rejected
959
- // re-register is "bump the version". Printing the whole body dimmed put
960
- // that sentence inside a blob, at the end of a 500-char truncation, in the
961
- // one moment the reader most needs it.
962
- //
963
- // ⚖️ Keyed on the SHAPE, not on any particular code: a new refusal the CLI
964
- // has never seen explains itself the day the backend ships it, with no
965
- // release here. That is the property worth having — this branch exists
966
- // because a 422 the CLI did not know about arrived exactly that way.
967
- if (parsedBody?.detail) {
968
- log(` ${parsedBody.detail}`)
969
- const code = parsedBody.code ?? parsedBody.reason
970
- if (code) {
971
- log(` ${colors.dim}(${code})${colors.reset}`)
1084
+ })
1085
+ // ⭐ A type it names that another foundation here defines, and the registry doesn't hold:
1086
+ // that foundation registers it first (`unregistered-types.js`). A library's were sent above.
1087
+ if (!standalone && member !== false) {
1088
+ const missing = await unregisteredLocalTypes({
1089
+ named: Object.keys(schema?.dataSchemas || {}),
1090
+ defined,
1091
+ foundationDir: targetDir,
1092
+ client
1093
+ }).catch(() => [])
1094
+ if (missing.length) {
1095
+ // ⚖️ From the workspace root: `push` and `publish` run this in the foundation's folder,
1096
+ // which is not where their person is.
1097
+ const root = findWorkspaceRoot(targetDir) || targetDir
1098
+ log('')
1099
+ for (const { ref, dir } of missing) {
1100
+ const at = relative(root, dir) || '.'
1101
+ log(` ${ref} is defined in ${at}/, which has not registered it. Register it there first, from the workspace root:`)
1102
+ log(` ${colors.blue}cd ${at} && npx uniweb register${colors.reset}`)
1103
+ }
972
1104
  }
973
- } else if (rawBody) {
974
- log(` ${colors.dim}${rawBody.slice(0, 500)}${colors.reset}`)
975
1105
  }
976
1106
  return { exitCode: 1 }
977
1107
  }
@@ -1082,7 +1212,10 @@ async function runRegister(args = []) {
1082
1212
  ` ${colors.dim}Delivery is separate: a foundation that binds ${scope}/<name> resolves it from${colors.reset}`
1083
1213
  )
1084
1214
  log(
1085
- ` ${colors.dim}disk — an ${scope}/schemas package, or a folder routed in schemas.config.js.${colors.reset}`
1215
+ ` ${colors.dim}disk — a package of its workspace or a library it bundles that defines it, an${colors.reset}`
1216
+ )
1217
+ log(
1218
+ ` ${colors.dim}${scope}/schemas package, or a folder routed in schemas.config.js.${colors.reset}`
1086
1219
  )
1087
1220
  }
1088
1221
 
@@ -1108,7 +1241,12 @@ async function runRegister(args = []) {
1108
1241
  parsedBody.data_schemas.forEach(addMint)
1109
1242
  if (parsedBody.foundation_schema) addMint(parsedBody.foundation_schema)
1110
1243
  }
1244
+ for (const sent of fromLibrariesSent) {
1245
+ if (Array.isArray(sent.body?.data_schemas)) sent.body.data_schemas.forEach(addMint)
1246
+ }
1111
1247
  const names = [
1248
+ // A library's types, registered first (and none for one registered by its own scope's members).
1249
+ ...fromLibrariesSent.flatMap((sent) => sent.names),
1112
1250
  ...doc.entities
1113
1251
  .filter((e) => e.model === '@uniweb/data-schema')
1114
1252
  .map((e) => e.name),
@@ -43,7 +43,7 @@
43
43
  */
44
44
 
45
45
  import { execFileSync } from 'node:child_process'
46
- import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
46
+ import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs'
47
47
  import { basename, dirname, join, posix, relative, resolve, sep } from 'node:path'
48
48
  import yaml from 'js-yaml'
49
49
 
@@ -1169,6 +1169,92 @@ function workspaceLine(ws) {
1169
1169
  return `${parts.slice(0, -1).join(', ')} and ${parts.at(-1)} in this workspace${from}.`
1170
1170
  }
1171
1171
 
1172
+ /**
1173
+ * ⭐ THE LIBRARY `cwd` IS IN, when it is one: a package of the workspace that is neither a site nor a
1174
+ * foundation, and that a foundation or an extension of the workspace bundles (`librariesOf`, the one
1175
+ * rule). With the foundations that bundle it and the sites each serves, which is what a change in it
1176
+ * reaches. Null for anything else, which `status` answers as before.
1177
+ */
1178
+ async function libraryAround(cwd) {
1179
+ const root = findWorkspaceRoot(cwd)
1180
+ if (!root) return null
1181
+ let dir = resolve(cwd)
1182
+ while (!existsSync(join(dir, 'package.json')) && dir !== root && dirname(dir) !== dir) dir = dirname(dir)
1183
+ if (dir === resolve(root) || !existsSync(join(dir, 'package.json'))) return null
1184
+ if (await classifyPackage(dir)) return null
1185
+ const { librariesOf } = await import('@uniweb/build')
1186
+ let real = dir
1187
+ try {
1188
+ real = realpathSync(dir)
1189
+ } catch {
1190
+ // as it is
1191
+ }
1192
+ const ws = await workspaceFacts(root)
1193
+ const bundling = [
1194
+ ...ws.foundations.map((f) => ({ ...f, extension: false })),
1195
+ ...ws.extensions.map((f) => ({ ...f, extension: true }))
1196
+ ].filter((f) => librariesOf(resolve(root, f.path)).some((lib) => lib.dir === real))
1197
+ if (!bundling.length) return null
1198
+ let name = basename(dir)
1199
+ try {
1200
+ name = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).name || name
1201
+ } catch {
1202
+ // named for its folder
1203
+ }
1204
+ const foundations = []
1205
+ for (const f of bundling) {
1206
+ const abs = resolve(root, f.path)
1207
+ const sites = []
1208
+ for (const site of ws.sites) {
1209
+ const siteDir = resolve(root, site.path)
1210
+ const yml = readSiteYml(siteDir)
1211
+ if (f.extension) {
1212
+ const exts = await extensionsOf(siteDir, yml, root)
1213
+ if (exts.some((e) => e.kind === 'local' && resolve(root, e.path) === abs)) sites.push(site.path)
1214
+ } else {
1215
+ const fnd = await foundationOf(siteDir, yml, root)
1216
+ if (fnd.kind === 'local' && fnd.abs === abs) sites.push(site.path)
1217
+ }
1218
+ }
1219
+ foundations.push({ name: f.name, path: f.path, extension: f.extension, sites })
1220
+ }
1221
+ return { root, path: relative(root, dir) || '.', name, foundations }
1222
+ }
1223
+
1224
+ /** `status` in a library: what bundles it, and so what a change in it reaches. */
1225
+ function libraryOverview(lib, { json }) {
1226
+ const { path, name, foundations } = lib
1227
+ const kinds = foundations.some((f) => f.extension) ? 'foundations and extensions' : 'foundations'
1228
+ const summary = `${name} — a library in ${path}/, bundled by ${count(foundations.length, foundations.some((f) => f.extension) ? 'package' : 'foundation')}`
1229
+ const sites = [...new Set(foundations.flatMap((f) => f.sites))]
1230
+ const reach =
1231
+ 'A change here reaches each of those sites when its foundation next builds, and a hosted site when its foundation releases again (`uniweb publish` from the site).'
1232
+ if (json) {
1233
+ console.log(
1234
+ JSON.stringify({
1235
+ schema: STATUS_SCHEMA,
1236
+ uniweb: getCliVersion(),
1237
+ scope: 'library',
1238
+ summary,
1239
+ library: { name, path },
1240
+ foundations,
1241
+ sites,
1242
+ checks: [],
1243
+ next: []
1244
+ })
1245
+ )
1246
+ return { exitCode: 0 }
1247
+ }
1248
+ const out = ['', `${c.bold}${summary}${c.reset}`, '']
1249
+ for (const f of foundations) {
1250
+ const what = `${f.extension ? 'extension' : 'foundation'} ${f.name} (${f.path}/)`
1251
+ out.push(` ${what} — ${f.sites.length ? `${f.sites.length === 1 ? 'site' : 'sites'} ${f.sites.join(', ')}` : 'no site in this workspace'}`)
1252
+ }
1253
+ out.push('', sites.length ? reach : `No site in this workspace uses those ${kinds} yet.`, '')
1254
+ console.log(out.join('\n'))
1255
+ return { exitCode: 0 }
1256
+ }
1257
+
1172
1258
  /**
1173
1259
  * A site's foundation, as the build finds it — the one resolver (`detectFoundationType`), so
1174
1260
  * what status names is what the build would build. A catalog ref, which a build refuses, is
@@ -1265,11 +1351,18 @@ async function projectChecks(siteDir, siteYml) {
1265
1351
  : `Extension \`${e.value}\` names ${e.name ? `\`${e.name}\`, which no folder here holds` : 'nothing this site can find'}.`
1266
1352
  )
1267
1353
  if (extensions.some((e) => e.kind === 'unresolved')) state = 'attention'
1354
+ // And the libraries it bundles (`librariesOf`): a change in one reaches this site too.
1355
+ let libraries = []
1356
+ if (fnd.kind === 'local') {
1357
+ const { librariesOf } = await import('@uniweb/build')
1358
+ libraries = librariesOf(fnd.abs).map((lib) => ({ name: lib.name, path: relative(root, lib.dir) || '.' }))
1359
+ }
1360
+ const libraryLines = libraries.map((lib) => `Library ${lib.name}, in ${lib.path}/ — the foundation bundles it, so a change there reaches this site too.`)
1268
1361
  checks.push({
1269
1362
  id: 'project.foundation',
1270
1363
  state,
1271
1364
  summary,
1272
- lines: extensionLines,
1365
+ lines: [...extensionLines, ...libraryLines],
1273
1366
  detail: {
1274
1367
  kind: fnd.kind,
1275
1368
  name: fnd.name ?? null,
@@ -1277,7 +1370,8 @@ async function projectChecks(siteDir, siteYml) {
1277
1370
  url: fnd.url ?? null,
1278
1371
  editable: fnd.kind === 'local',
1279
1372
  sharedWith,
1280
- extensions: extensions.map(({ value, kind, name, path }) => ({ value, kind, name: name ?? null, path: path ?? null }))
1373
+ extensions: extensions.map(({ value, kind, name, path }) => ({ value, kind, name: name ?? null, path: path ?? null })),
1374
+ libraries
1281
1375
  }
1282
1376
  })
1283
1377
 
@@ -1772,6 +1866,10 @@ export async function status(args = []) {
1772
1866
  const json = args.includes('--json')
1773
1867
  const offline = args.includes('--offline')
1774
1868
 
1869
+ // In a library, what bundles it: its foundations and their sites.
1870
+ const library = await libraryAround(process.cwd())
1871
+ if (library) return libraryOverview(library, { json })
1872
+
1775
1873
  const found = await findSite(process.cwd())
1776
1874
  if (!found.siteDir) {
1777
1875
  // ⭐ A WORKSPACE OF SEVERAL SITES IS ANSWERED, not refused: what each one is, from its
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-10T03:51:29.247Z",
3
+ "generatedAt": "2026-11-10T14:14:47.610Z",
4
4
  "packages": {
5
5
  "@uniweb/api": {
6
6
  "version": "1.7.0"
7
7
  },
8
8
  "@uniweb/build": {
9
- "version": "1.20.5"
9
+ "version": "1.20.7"
10
10
  },
11
11
  "@uniweb/content-reader": {
12
12
  "version": "1.5.9"
@@ -33,7 +33,7 @@
33
33
  "version": "1.2.2"
34
34
  },
35
35
  "@uniweb/projections": {
36
- "version": "1.2.15"
36
+ "version": "1.2.16"
37
37
  },
38
38
  "@uniweb/runtime": {
39
39
  "version": "1.5.6"