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.
- package/package.json +5 -5
- package/partials/agents.md +1 -0
- package/partials/guides/data.md +2 -2
- package/partials/guides/foundation.md +12 -2
- package/src/backend/foundation-bring-along.js +5 -2
- package/src/backend/library-types.js +64 -0
- package/src/backend/unregistered-types.js +56 -0
- package/src/commands/add-library.js +400 -0
- package/src/commands/add.js +26 -9
- package/src/commands/build.js +11 -70
- package/src/commands/clone.js +1 -1
- package/src/commands/doctor.js +18 -0
- package/src/commands/publish.js +1 -1
- package/src/commands/push.js +1 -1
- package/src/commands/register.js +233 -95
- package/src/commands/status.js +101 -3
- package/src/framework-index.json +3 -3
- package/src/index.js +33 -2
- package/src/utils/closed-reader.js +6 -1
- package/src/utils/foundation-freshness.js +89 -0
- package/src/utils/placement.js +36 -12
- package/src/utils/stale-export.js +33 -0
- package/templates/workspace/README.md.hbs +2 -1
package/src/commands/add.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add Command
|
|
3
3
|
*
|
|
4
|
-
* Adds foundations, sites, extensions, section types, or co-located projects to an existing workspace.
|
|
4
|
+
* Adds foundations, sites, extensions, libraries, section types, or co-located projects to an existing workspace.
|
|
5
5
|
*
|
|
6
6
|
* Usage:
|
|
7
7
|
* uniweb add project [name] [--from <template>]
|
|
8
8
|
* uniweb add foundation [name] [--from <template>] [--path <dir>] [--project <name>]
|
|
9
9
|
* uniweb add site [name] [--from <template>] [--foundation <name>] [--path <dir>] [--project <name>]
|
|
10
10
|
* uniweb add extension [name] [--from <template>] [--site <name>] [--path <dir>]
|
|
11
|
+
* uniweb add library <name> [--foundation <a>,<b>] [--schemas] [--scope <@org>] [--path <dir>]
|
|
11
12
|
* uniweb add section <name> [--foundation <name>]
|
|
12
13
|
* uniweb add version <name> [--in <folder>] [--label <text>] [--keep-in-search] [--dry-run] [--site <name>]
|
|
13
14
|
*/
|
|
@@ -39,6 +40,7 @@ import {
|
|
|
39
40
|
import { registerWorkspacePackage, addRootScripts } from '../utils/config.js'
|
|
40
41
|
import { discoverFoundations, discoverSites } from '../utils/discover.js'
|
|
41
42
|
import { generateStarter, reportStarter, declarationFor } from './starter.js'
|
|
43
|
+
import { addLibrary } from './add-library.js'
|
|
42
44
|
import {
|
|
43
45
|
validatePackageName,
|
|
44
46
|
getExistingPackageNames,
|
|
@@ -141,12 +143,15 @@ function parseArgs(args) {
|
|
|
141
143
|
in: null,
|
|
142
144
|
label: null,
|
|
143
145
|
keepInSearch: false,
|
|
144
|
-
dryRun: false
|
|
146
|
+
dryRun: false,
|
|
147
|
+
// `add library` only: a `schemas/` folder for data types, and the scope they are named under.
|
|
148
|
+
schemas: false,
|
|
149
|
+
scope: null
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
// Booleans (no value) consumed up-front so the value-flag loop below
|
|
148
153
|
// doesn't accidentally swallow the next positional.
|
|
149
|
-
const BOOLEAN_FLAGS = new Set(['--force', '--no-previews', '--starter', '--json', '--keep-in-search', '--dry-run'])
|
|
154
|
+
const BOOLEAN_FLAGS = new Set(['--force', '--no-previews', '--starter', '--json', '--keep-in-search', '--dry-run', '--schemas'])
|
|
150
155
|
|
|
151
156
|
// Value flags, mapped to their result key. Both spellings are accepted:
|
|
152
157
|
// `--host github-pages` and `--host=github-pages`.
|
|
@@ -170,7 +175,8 @@ function parseArgs(args) {
|
|
|
170
175
|
'--preset': 'preset',
|
|
171
176
|
'--write': 'write',
|
|
172
177
|
'--in': 'in',
|
|
173
|
-
'--label': 'label'
|
|
178
|
+
'--label': 'label',
|
|
179
|
+
'--scope': 'scope'
|
|
174
180
|
}
|
|
175
181
|
|
|
176
182
|
/** Split `--flag=value` into [flag, value]; `--flag` into [flag, null]. */
|
|
@@ -216,6 +222,8 @@ function parseArgs(args) {
|
|
|
216
222
|
result.keepInSearch = true
|
|
217
223
|
} else if (flag === '--dry-run') {
|
|
218
224
|
result.dryRun = true
|
|
225
|
+
} else if (flag === '--schemas') {
|
|
226
|
+
result.schemas = true
|
|
219
227
|
}
|
|
220
228
|
}
|
|
221
229
|
|
|
@@ -258,6 +266,7 @@ export async function add(rawArgs) {
|
|
|
258
266
|
},
|
|
259
267
|
{ label: 'site', description: 'Content site' },
|
|
260
268
|
{ label: 'extension', description: 'Additional component package' },
|
|
269
|
+
{ label: 'library', description: 'Components and data types foundations share' },
|
|
261
270
|
{ label: 'section', description: 'Section type in a foundation' },
|
|
262
271
|
{ label: 'version', description: 'Freeze a site\'s docs as an older version' },
|
|
263
272
|
{
|
|
@@ -268,7 +277,7 @@ export async function add(rawArgs) {
|
|
|
268
277
|
)
|
|
269
278
|
log('')
|
|
270
279
|
log(
|
|
271
|
-
`Usage: ${prefix} add <project|foundation|site|extension|section|ci> [name]`
|
|
280
|
+
`Usage: ${prefix} add <project|foundation|site|extension|library|section|ci> [name]`
|
|
272
281
|
)
|
|
273
282
|
process.exit(1)
|
|
274
283
|
}
|
|
@@ -295,6 +304,11 @@ export async function add(rawArgs) {
|
|
|
295
304
|
value: 'extension',
|
|
296
305
|
description: 'Additional component package'
|
|
297
306
|
},
|
|
307
|
+
{
|
|
308
|
+
title: 'Library',
|
|
309
|
+
value: 'library',
|
|
310
|
+
description: 'Components and data types foundations share'
|
|
311
|
+
},
|
|
298
312
|
{
|
|
299
313
|
title: 'Section',
|
|
300
314
|
value: 'section',
|
|
@@ -368,6 +382,9 @@ export async function add(rawArgs) {
|
|
|
368
382
|
case 'extension':
|
|
369
383
|
await addExtension(rootDir, projectName, parsed, pm)
|
|
370
384
|
break
|
|
385
|
+
case 'library':
|
|
386
|
+
await addLibrary(rootDir, projectName, parsed, pm)
|
|
387
|
+
break
|
|
371
388
|
case 'section':
|
|
372
389
|
await addSection(rootDir, parsed)
|
|
373
390
|
break
|
|
@@ -380,7 +397,7 @@ export async function add(rawArgs) {
|
|
|
380
397
|
default:
|
|
381
398
|
error(`Unknown subcommand: ${parsed.subcommand}`)
|
|
382
399
|
log(
|
|
383
|
-
`Valid subcommands: project, foundation, site, extension, section, ci, version`
|
|
400
|
+
`Valid subcommands: project, foundation, site, extension, library, section, ci, version`
|
|
384
401
|
)
|
|
385
402
|
process.exit(1)
|
|
386
403
|
}
|
|
@@ -401,7 +418,7 @@ async function addFoundation(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
401
418
|
const placement = resolvePlacement(rootDir, name, opts, FOUNDATION_KIND)
|
|
402
419
|
refuseProjectConflict(placement, 'foundation', name, opts)
|
|
403
420
|
if (placement.outsideRoot) {
|
|
404
|
-
error(
|
|
421
|
+
error(`A package's folder must be inside the workspace: ${placement.outsideRoot}`)
|
|
405
422
|
log('')
|
|
406
423
|
log(`The workspace root is ${colors.bright}${rootDir}${colors.reset}.`)
|
|
407
424
|
log(`A package outside it cannot be a workspace member.`)
|
|
@@ -557,7 +574,7 @@ async function addSite(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
557
574
|
const placement = resolvePlacement(rootDir, name, opts, SITE_KIND)
|
|
558
575
|
refuseProjectConflict(placement, 'site', name, opts)
|
|
559
576
|
if (placement.outsideRoot) {
|
|
560
|
-
error(
|
|
577
|
+
error(`A package's folder must be inside the workspace: ${placement.outsideRoot}`)
|
|
561
578
|
log('')
|
|
562
579
|
log(`The workspace root is ${colors.bright}${rootDir}${colors.reset}.`)
|
|
563
580
|
log(`A package outside it cannot be a workspace member.`)
|
|
@@ -741,7 +758,7 @@ async function addExtension(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
741
758
|
const placement = resolvePlacement(rootDir, name, opts, EXTENSION_KIND)
|
|
742
759
|
refuseProjectConflict(placement, 'extension', name, opts)
|
|
743
760
|
if (placement.outsideRoot) {
|
|
744
|
-
error(
|
|
761
|
+
error(`A package's folder must be inside the workspace: ${placement.outsideRoot}`)
|
|
745
762
|
log('')
|
|
746
763
|
log(`The workspace root is ${colors.bright}${rootDir}${colors.reset}.`)
|
|
747
764
|
log(`A package outside it cannot be a workspace member.`)
|
package/src/commands/build.js
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
* --bundle # Full vite pipeline (third-party / self-contained; deploy --host / export)
|
|
56
56
|
*/
|
|
57
57
|
|
|
58
|
-
import { existsSync, readFileSync,
|
|
58
|
+
import { existsSync, readFileSync, statSync } from 'node:fs'
|
|
59
59
|
import { resolve, join, dirname, basename, relative } from 'node:path'
|
|
60
60
|
import { runRelayed } from '../utils/closed-reader.js'
|
|
61
61
|
import { writeFile, mkdir } from 'node:fs/promises'
|
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
} from '@uniweb/build'
|
|
73
73
|
import { readSiteConfig } from '@uniweb/build/site'
|
|
74
74
|
import { workspacePackages } from '../utils/workspace-packages.js'
|
|
75
|
+
import { newerInput } from '../utils/foundation-freshness.js'
|
|
75
76
|
|
|
76
77
|
// Colors for terminal output
|
|
77
78
|
const colors = {
|
|
@@ -279,13 +280,10 @@ async function buildFoundation(projectDir, options = {}) {
|
|
|
279
280
|
* without rebuilding. So calling it inside `buildSite()` does not
|
|
280
281
|
* double-build under `buildWorkspace()`.
|
|
281
282
|
*
|
|
282
|
-
* Freshness
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* nested — `isFoundationSourceNewerThan`), plus root-level `package.json`,
|
|
287
|
-
* `foundation.js`, `meta.js` (the structural files that drive entry
|
|
288
|
-
* generation and schema). Build outputs and node_modules are skipped.
|
|
283
|
+
* Freshness: a built artifact (`dist/entry.js` or the legacy `dist/foundation.js`)
|
|
284
|
+
* exists, and nothing its build reads is newer: the foundation's sources and
|
|
285
|
+
* those of every library it bundles (`newerInput`, `utils/foundation-freshness.js`,
|
|
286
|
+
* the rule `register` follows too).
|
|
289
287
|
*
|
|
290
288
|
* Both artifact names are accepted because the foundation build emitter
|
|
291
289
|
* was renamed `dist/foundation.js → dist/entry.js` in `@uniweb/build`
|
|
@@ -306,12 +304,13 @@ export async function ensureFoundationFresh(foundationDir, label = 'foundation')
|
|
|
306
304
|
return { built: true, reason: 'missing' }
|
|
307
305
|
}
|
|
308
306
|
|
|
309
|
-
const
|
|
310
|
-
const stale = isFoundationSourceNewerThan(foundationDir, distMtime)
|
|
307
|
+
const newer = newerInput(foundationDir, statSync(distArtifact).mtimeMs)
|
|
311
308
|
|
|
312
|
-
if (
|
|
309
|
+
if (newer) {
|
|
313
310
|
info(
|
|
314
|
-
|
|
311
|
+
newer.library
|
|
312
|
+
? `${newer.library}, a library it bundles, changed — rebuilding ${basename(foundationDir)}`
|
|
313
|
+
: `Local ${label} sources changed — rebuilding ${basename(foundationDir)}`
|
|
315
314
|
)
|
|
316
315
|
log('')
|
|
317
316
|
await buildFoundation(foundationDir)
|
|
@@ -335,64 +334,6 @@ function findFoundationDistArtifact(foundationDir) {
|
|
|
335
334
|
return null
|
|
336
335
|
}
|
|
337
336
|
|
|
338
|
-
/**
|
|
339
|
-
* Returns true if any tracked foundation source file has an mtime newer
|
|
340
|
-
* than `referenceMtime`. Walks the package's source root — the folder
|
|
341
|
-
* `package.json::main` names (`resolveFoundationSrcPath`): the package itself
|
|
342
|
-
* for a flat package, `src/` for a nested one — recursively, skipping dotfiles,
|
|
343
|
-
* node_modules, dist and the generated entry. Also stats the root structural
|
|
344
|
-
* files.
|
|
345
|
-
*
|
|
346
|
-
* ⛔ Until 2026-10-13 it walked `<foundationDir>/src/` whatever the layout, and
|
|
347
|
-
* every package scaffolded since the flat layout keeps its sources at its root —
|
|
348
|
-
* so an edit to a section never made one stale. Measured: touching a section of
|
|
349
|
-
* a flat foundation and building its site rebuilt nothing, and prerender rendered
|
|
350
|
-
* the static HTML with the foundation as last built.
|
|
351
|
-
*/
|
|
352
|
-
export function isFoundationSourceNewerThan(foundationDir, referenceMtime) {
|
|
353
|
-
const rootFiles = ['package.json', 'foundation.js', 'meta.js']
|
|
354
|
-
for (const f of rootFiles) {
|
|
355
|
-
const p = join(foundationDir, f)
|
|
356
|
-
if (existsSync(p) && statSync(p).mtimeMs > referenceMtime) return true
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const srcDir = resolveFoundationSrcPath(foundationDir)
|
|
360
|
-
if (!existsSync(srcDir)) return false
|
|
361
|
-
|
|
362
|
-
const stack = [srcDir]
|
|
363
|
-
while (stack.length) {
|
|
364
|
-
const dir = stack.pop()
|
|
365
|
-
let entries
|
|
366
|
-
try {
|
|
367
|
-
entries = readdirSync(dir, { withFileTypes: true })
|
|
368
|
-
} catch {
|
|
369
|
-
continue
|
|
370
|
-
}
|
|
371
|
-
for (const e of entries) {
|
|
372
|
-
if (
|
|
373
|
-
e.name === 'node_modules' ||
|
|
374
|
-
e.name === 'dist' ||
|
|
375
|
-
e.name === '_entry.generated.js' ||
|
|
376
|
-
e.name.startsWith('.')
|
|
377
|
-
)
|
|
378
|
-
continue
|
|
379
|
-
const full = join(dir, e.name)
|
|
380
|
-
if (e.isDirectory()) {
|
|
381
|
-
stack.push(full)
|
|
382
|
-
continue
|
|
383
|
-
}
|
|
384
|
-
if (!e.isFile()) continue
|
|
385
|
-
try {
|
|
386
|
-
if (statSync(full).mtimeMs > referenceMtime) return true
|
|
387
|
-
} catch {
|
|
388
|
-
/* ignore */
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return false
|
|
394
|
-
}
|
|
395
|
-
|
|
396
337
|
/**
|
|
397
338
|
* Load site i18n configuration
|
|
398
339
|
*
|
package/src/commands/clone.js
CHANGED
|
@@ -366,7 +366,7 @@ export async function clone(args = [], deps = {}) {
|
|
|
366
366
|
return { exitCode: 1 }
|
|
367
367
|
}
|
|
368
368
|
if (placement.outsideRoot) {
|
|
369
|
-
error(
|
|
369
|
+
error(`A site's folder must be inside the workspace: ${placement.outsideRoot}`)
|
|
370
370
|
note(
|
|
371
371
|
`The workspace root is ${existingRoot}. A package outside it cannot be a ` +
|
|
372
372
|
`workspace member — the directory and the manifests would disagree.`
|
package/src/commands/doctor.js
CHANGED
|
@@ -957,6 +957,23 @@ export async function checkUnreadFolders({ foundationName, srcDir, issues }) {
|
|
|
957
957
|
for (const { line } of unread) log(` ${line}`)
|
|
958
958
|
}
|
|
959
959
|
|
|
960
|
+
/**
|
|
961
|
+
* A library the foundation bundles whose classes no `@source` reads (`unreadLibraries`, `@uniweb/build`):
|
|
962
|
+
* missing from the foundation's own CSS, which a hosted site loads with it, and from a site build's.
|
|
963
|
+
* Loaded here for the same reason.
|
|
964
|
+
*/
|
|
965
|
+
export async function checkUnreadLibraries({ foundationName, srcDir, foundationDir, issues }) {
|
|
966
|
+
const { unreadLibraries } = await import('@uniweb/build')
|
|
967
|
+
const unread = unreadLibraries?.(join(srcDir, 'styles.css'), foundationDir) || []
|
|
968
|
+
if (unread.length === 0) return
|
|
969
|
+
const id = 'unread-library'
|
|
970
|
+
const named = unread.map(({ name }) => name).join(', ')
|
|
971
|
+
issues.push({ id, type: 'warn', foundation: foundationName, message: `${foundationName} bundles ${named}, whose classes its styles.css does not read` })
|
|
972
|
+
warn(`[${id}] ${foundationName} bundles ${named}, whose classes its styles.css does not read, so they are missing from its CSS and from its sites'`)
|
|
973
|
+
log(` Add to styles.css:`)
|
|
974
|
+
for (const { line } of unread) log(` ${line}`)
|
|
975
|
+
}
|
|
976
|
+
|
|
960
977
|
/**
|
|
961
978
|
* Source with its comments removed.
|
|
962
979
|
*
|
|
@@ -2062,6 +2079,7 @@ async function runDoctor(args = []) {
|
|
|
2062
2079
|
for (const f of checkedFoundations) {
|
|
2063
2080
|
await checkStaleSources({ foundationName: f.name, srcDir: resolveFoundationSrcPath(f.path), issues })
|
|
2064
2081
|
await checkUnreadFolders({ foundationName: f.name, srcDir: resolveFoundationSrcPath(f.path), issues })
|
|
2082
|
+
await checkUnreadLibraries({ foundationName: f.name, srcDir: resolveFoundationSrcPath(f.path), foundationDir: f.path, issues })
|
|
2065
2083
|
}
|
|
2066
2084
|
|
|
2067
2085
|
// A modifier kit's prose layer does not have — `prose-slate`, `prose-invert`
|
package/src/commands/publish.js
CHANGED
|
@@ -562,7 +562,7 @@ export async function publish(args = []) {
|
|
|
562
562
|
}
|
|
563
563
|
// A scope you are not a member of is said as that, with the ways on (`explainReleaseFailure`).
|
|
564
564
|
say.err(err.notMember ? err.message : `Foundation release failed: ${err.message}`)
|
|
565
|
-
for (const line of err.notMember ? err.ways : ['
|
|
565
|
+
for (const line of err.notMember ? err.ways : ['Nothing was sent. Settle what the release said above, then re-run `uniweb publish`.']) say.dim(line)
|
|
566
566
|
return { exitCode: 1 }
|
|
567
567
|
}
|
|
568
568
|
|
package/src/commands/push.js
CHANGED
|
@@ -340,7 +340,7 @@ export async function push(args = [], deps = {}) {
|
|
|
340
340
|
}
|
|
341
341
|
// A scope you are not a member of is said as that, with the ways on (`explainReleaseFailure`).
|
|
342
342
|
error(err.notMember ? err.message : `Foundation release failed: ${err.message}`)
|
|
343
|
-
for (const line of err.notMember ? err.ways : ['
|
|
343
|
+
for (const line of err.notMember ? err.ways : ['Nothing was sent. Settle what the release said above, then re-run `uniweb push`.']) note(line)
|
|
344
344
|
return { exitCode: 1 }
|
|
345
345
|
}
|
|
346
346
|
if (!fnd.proceed) return { exitCode: 1 }
|