uniweb 1.31.7 → 1.31.9
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 +3 -3
- package/partials/agents.md +1 -0
- package/partials/guides/foundation.md +5 -3
- package/src/backend/library-types.js +67 -23
- package/src/backend/unregistered-types.js +3 -6
- package/src/commands/add-library.js +66 -26
- package/src/commands/doctor.js +22 -2
- package/src/commands/register.js +57 -31
- package/src/commands/status.js +8 -1
- package/src/framework-index.json +3 -3
- package/src/index.js +11 -2
- package/src/utils/foundation-freshness.js +25 -6
- package/src/utils/placement.js +5 -2
- package/src/utils/registry-orgs.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniweb",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.9",
|
|
4
4
|
"description": "Create structured Vite + React sites with content/code separation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"@uniweb/content-writer": "~1.3.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@uniweb/build": "~1.20.7",
|
|
51
50
|
"@uniweb/content-reader": "~1.5.9",
|
|
52
|
-
"@uniweb/semantic-parser": "~1.13.2"
|
|
51
|
+
"@uniweb/semantic-parser": "~1.13.2",
|
|
52
|
+
"@uniweb/build": "~1.20.8"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@uniweb/build": {
|
package/partials/agents.md
CHANGED
|
@@ -108,6 +108,7 @@ When a rule in §2 feels like friction, that is the moment you are about to take
|
|
|
108
108
|
| Helpers that take `{ content, params }` | Ordinary props. That signature is for section types only. | — |
|
|
109
109
|
| One section type per visual variant; or one with a conditional tree inside | A front desk (§1): one `type:`, a `variant` param, workers in `components/` with ordinary props. | author vocabulary bloats; variants invisible to the editor |
|
|
110
110
|
| Copy a worker, hook or data type into a second foundation | A library both depend on: `uniweb add library libraries/ui --foundation a,b`; types named in full (`@acme/plan`). `uniweb guide foundation` § Libraries. | silent: the copies drift; `doctor` names a type defined twice |
|
|
111
|
+
| Copy another site's records into this one, by hand or with a script | Mount that site's folder for the type in `site.yml`: `paths: { records/acme/plan: ../../hub/site/records/acme/plan }`. `uniweb guide data`. | silent: the copies drift |
|
|
111
112
|
| Validate, enumerate or warn on content the component doesn't use; treat `content:` as an exact schema | Take what you expect and don't touch the rest (§1). `content:` declares what the type reads. | — |
|
|
112
113
|
| `params: { theme, background, grid, sticky, query }` | Section settings — read from `block`, never declared. | build warns |
|
|
113
114
|
| Write `meta.js` as internal metadata | It is the visual editor's UI and other agents' catalog. Labels for people, defaults for everything, author words for params (`columns`, not `gridCols`). | — |
|
|
@@ -165,15 +165,17 @@ export default function Pricing({ content, params }) {
|
|
|
165
165
|
|
|
166
166
|
A section type is a front desk; a **library** is the back office several foundations share: workers, hooks, logic and data types, with no section type of its own. Each foundation keeps its own section types, layouts and look, and calls on the same library. Take the first of these that holds what differs between two sites: the site's `theme.yml` (colors, fonts), foundation vars (radius, shadow, density), a param and the workers it picks, and only then a second foundation sharing a library with the first. A foundation is the vocabulary a kind of site is made with, so a second one is for another vocabulary, never for a smaller bundle.
|
|
167
167
|
|
|
168
|
-
`uniweb add library libraries/ui --foundation classic,modern` makes it and wires each foundation: `"ui": "file:../../libraries/ui"` in its dependencies, and `@import "ui/styles.css";` in its `styles.css`. The library's own stylesheet holds `@source "./**/*.{js,jsx}";`, as kit's does, so Tailwind reads its classes wherever it is installed; without the import they are in no CSS at all, and the build says which line to add. Run it again with another `--foundation` to wire one more. A library is any local package a foundation depends on: one made by hand, cloned
|
|
168
|
+
`uniweb add library libraries/ui --foundation classic,modern` makes it and wires each foundation: `"ui": "file:../../libraries/ui"` in its dependencies, and `@import "ui/styles.css";` in its `styles.css`. The library's own stylesheet holds `@source "./**/*.{js,jsx}";`, as kit's does, so Tailwind reads its classes wherever it is installed; without the import they are in no CSS at all, and the build says which line to add. Run it again with another `--foundation` to wire one more. A library is any local package a foundation depends on: one made by hand, cloned, kept as a git submodule, or in a folder beside the workspace works the same, and `uniweb add library <its folder>` wires it.
|
|
169
169
|
|
|
170
170
|
- Export workers from its `index.js` and import them as from any package: `import { PlanCard } from 'ui'`.
|
|
171
171
|
- A worker takes ordinary props and reads every design decision from foundation vars and theme tokens (`var(--card-radius)`, `bg-card`), never a fixed radius or color. That is what lets one worker look classic in one foundation and modern in another.
|
|
172
172
|
- Import `@uniweb/core` by its bare name only, as kit does: a subpath bundles a second core.
|
|
173
|
-
- A section type the library holds stays each foundation's to offer: a directory in the foundation's `sections/` whose `index.jsx` is `export { default } from 'ui/sections/Banner/index.jsx'`, with a `meta.js` that re-exports the library's the same way.
|
|
173
|
+
- A section type the library holds stays each foundation's to offer: a directory in the foundation's `sections/` whose `index.jsx` is `export { default } from 'ui/sections/Banner/index.jsx'`, with a `meta.js` that re-exports the library's the same way, when both offer it alike. When only the component is the same, the foundation keeps its own `meta.js` and re-exports `index.jsx` alone. When the components differ, the type stays the foundation's whole, even with the same `meta.js`: a shared `meta.js` over two components shows each foundation's params in the other's editor.
|
|
174
|
+
- Moving copies in: a file moves only with every file it imports by path (`./`, `#components/`), the same in each foundation holding it; a component that imports its foundation's own `Button` stays until `Button` moves. In the library it keeps its path, and foundations import it by name and path (`ui/components/Button.jsx`); give the library the foundations' `imports` map when the moved files use `#components/`. Build the workspace before and after and `diff -r -x '*.map'` each `dist/` (a sourcemap names source paths, which the move changes): the same files mean nothing a visitor sees or a publish sends changed. Steps: [Libraries](https://uniweb.io/docs/development/libraries.md) § *Moving copies into a library*.
|
|
175
|
+
- Split shared code by the foundations that use it, a library per group (one all of them use, one for each pair that shares more): a foundation's `@import "ui/styles.css"` has Tailwind read every file of the library, so one library for everything puts other foundations' classes in each one's CSS. A library that uses another lists it in its own dependencies (`"ui": "file:../ui"`).
|
|
174
176
|
- Data types: `uniweb add library libraries/data --schemas --scope @acme` gives it a `schemas/` folder and its scope (`"uniweb": { "scope": "@acme" }` in its package.json). Foundations name its types in full (`data: { plans: '@acme/plan' }`), with nothing to configure (`uniweb guide data`). On a synced site, `register` in a foundation registers the types it names from the library first, since a foundation is taken only once they are; `push` and `publish` release the foundation through `register`, so they do too, and a change to a type releases each foundation that names it on its site's next push. `uniweb register` in the library registers them alone.
|
|
175
177
|
- Each foundation bundles the library, so a build after a change in the library rebuilds every foundation that uses it, and `uniweb status` run in the library names those foundations and their sites. A registered foundation version keeps the library as it was built, as it keeps kit: a fix reaches a hosted site when that site's foundation releases again, which `uniweb publish` from the site does.
|
|
176
|
-
-
|
|
178
|
+
- A library beside the workspace (`uniweb add library ../acme-shared`, another repository's folder) is listed in the workspace by that path (`- '../acme-shared'` in `pnpm-workspace.yaml`), so npm and pnpm link it and `uniweb update` moves its ranges; under npm the build resolves its imports (React, kit, its own dependencies) as the foundation's. Depend on it with `file:`. One wired but not listed is a copy under pnpm, which the build warns about, naming the line to add.
|
|
177
179
|
|
|
178
180
|
### The Front Desk pattern
|
|
179
181
|
|
|
@@ -6,23 +6,32 @@
|
|
|
6
6
|
* there first, and `push` and `publish`, which release a site's foundation with `register`, do too
|
|
7
7
|
* *[Diego, 2026-11-10: "yes, push and publish should register a library's types automatically"]*.
|
|
8
8
|
*
|
|
9
|
-
* A library here is what the build read the type from
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* A library here is what the build read the type from, in the build's order: a type
|
|
10
|
+
* `schemas.config.js` routes is read from where the route says, so it is no library's; otherwise the
|
|
11
|
+
* one schemas package (`isSchemasPackage`, not a foundation) that gives the type's scope and holds
|
|
12
|
+
* it, bundled by the foundation, a package of its workspace, or one inside the foundation's own
|
|
13
|
+
* folder. A type another FOUNDATION defines is registered when that foundation is, and a refused
|
|
14
|
+
* release names it (`unregistered-types.js`).
|
|
13
15
|
*
|
|
14
|
-
* ⚖️
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* ⚖️ Each library sends the types the foundation names from it, the ones its types reference among
|
|
17
|
+
* them, and nothing else: its other files may be another package's to register, or a copy of one the
|
|
18
|
+
* foundation defines. A changed definition replaces the registered one, which every site naming the
|
|
19
|
+
* type then reads, and the registry judges the change: one records of the type can't take it refuses
|
|
20
|
+
* (`destructive_republish`), and the release stops there. Libraries go in the order their types
|
|
21
|
+
* reference each other, a referenced one first, since the registry refuses a reference to a Model it
|
|
22
|
+
* doesn't hold yet.
|
|
18
23
|
*/
|
|
19
24
|
|
|
20
|
-
import { existsSync } from 'node:fs'
|
|
21
|
-
import { dirname,
|
|
25
|
+
import { existsSync, realpathSync } from 'node:fs'
|
|
26
|
+
import { dirname, join, resolve } from 'node:path'
|
|
27
|
+
import { collectNestedRefs } from '@uniweb/schemas/format'
|
|
22
28
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
29
|
+
const real = (path) => {
|
|
30
|
+
try {
|
|
31
|
+
return realpathSync(path)
|
|
32
|
+
} catch {
|
|
33
|
+
return resolve(path)
|
|
34
|
+
}
|
|
26
35
|
}
|
|
27
36
|
|
|
28
37
|
/** The package `file` is in: the nearest folder above it with a package.json. */
|
|
@@ -33,32 +42,67 @@ function packageDirOf(file) {
|
|
|
33
42
|
}
|
|
34
43
|
}
|
|
35
44
|
|
|
45
|
+
/** Libraries in an order where one whose types another's reference comes before it; else as found. */
|
|
46
|
+
function referencedFirst(libraries, schemas) {
|
|
47
|
+
const holder = new Map()
|
|
48
|
+
for (const lib of libraries) for (const ref of lib.refs) holder.set(ref, lib)
|
|
49
|
+
const before = new Map(libraries.map((lib) => [lib, new Set()]))
|
|
50
|
+
for (const lib of libraries) {
|
|
51
|
+
for (const ref of lib.refs) {
|
|
52
|
+
for (const target of collectNestedRefs(schemas[ref] || {})) {
|
|
53
|
+
const other = holder.get(target)
|
|
54
|
+
if (other && other !== lib) before.get(lib).add(other)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const out = []
|
|
59
|
+
const placed = new Set()
|
|
60
|
+
const place = (lib, path = new Set()) => {
|
|
61
|
+
if (placed.has(lib) || path.has(lib)) return
|
|
62
|
+
path.add(lib)
|
|
63
|
+
for (const other of before.get(lib)) place(other, path)
|
|
64
|
+
placed.add(lib)
|
|
65
|
+
out.push(lib)
|
|
66
|
+
}
|
|
67
|
+
for (const lib of libraries) place(lib)
|
|
68
|
+
return out
|
|
69
|
+
}
|
|
70
|
+
|
|
36
71
|
/**
|
|
37
72
|
* The libraries that define types the foundation names, each once, with the types it names from
|
|
38
|
-
* each. A type its own `schemas/` defines (`@/x`), one nothing local
|
|
39
|
-
* define (which the build refused)
|
|
73
|
+
* each, in the order they register in. A type its own `schemas/` defines (`@/x`), one nothing local
|
|
74
|
+
* defines, one two packages define (which the build refused) and one `schemas.config.js` routes are
|
|
75
|
+
* left out.
|
|
40
76
|
*
|
|
41
77
|
* @param {object} o
|
|
42
|
-
* @param {string
|
|
78
|
+
* @param {Record<string, object>} o.schemas - the foundation's built `dataSchemas`: every type it
|
|
79
|
+
* names, with its definition
|
|
43
80
|
* @param {string} o.foundationDir
|
|
44
|
-
* @returns {Promise<Array<{ dir: string, scope: string, refs: string[] }>>}
|
|
81
|
+
* @returns {Promise<Array<{ dir: string, scope: string, refs: string[] }>>}
|
|
82
|
+
* @throws {Error} `code: 'BUILD_TOO_OLD'` when the installed `@uniweb/build` can't tell
|
|
45
83
|
*/
|
|
46
|
-
export async function typesFromLibraries({
|
|
47
|
-
const
|
|
48
|
-
|
|
84
|
+
export async function typesFromLibraries({ schemas, foundationDir }) {
|
|
85
|
+
const build = await import('@uniweb/build')
|
|
86
|
+
const { workspaceTypeFiles, packageTypeScope, classifyPackage, isSchemasPackage, routedSchema, resolveFoundationSrcPath } = build
|
|
87
|
+
if ([workspaceTypeFiles, packageTypeScope, routedSchema].some((fn) => typeof fn !== 'function')) {
|
|
88
|
+
throw Object.assign(new Error('the installed @uniweb/build cannot tell which library defines a type'), { code: 'BUILD_TOO_OLD' })
|
|
89
|
+
}
|
|
90
|
+
const srcDir = resolveFoundationSrcPath(foundationDir)
|
|
91
|
+
const own = real(foundationDir)
|
|
49
92
|
const byDir = new Map()
|
|
50
|
-
for (const ref of
|
|
93
|
+
for (const ref of Object.keys(schemas || {})) {
|
|
51
94
|
// `@uniweb` is reserved, and nothing registers under it.
|
|
52
95
|
if (!/^@[^/]+\/./.test(ref) || ref.startsWith('@uniweb/')) continue
|
|
96
|
+
if (await routedSchema(ref, srcDir).catch(() => false)) continue
|
|
53
97
|
const files = await workspaceTypeFiles(ref, foundationDir).catch(() => [])
|
|
54
98
|
if (files.length !== 1) continue
|
|
55
99
|
const dir = packageDirOf(files[0])
|
|
56
|
-
if (!dir ||
|
|
100
|
+
if (!dir || real(dir) === own) continue
|
|
57
101
|
if (classifyPackage(dir) === 'foundation' || !isSchemasPackage(dir)) continue
|
|
58
102
|
const scope = await packageTypeScope(dir, 'schemas')
|
|
59
103
|
if (!scope) continue
|
|
60
104
|
if (!byDir.has(dir)) byDir.set(dir, { dir, scope, refs: [] })
|
|
61
105
|
byDir.get(dir).refs.push(ref)
|
|
62
106
|
}
|
|
63
|
-
return [...byDir.values()]
|
|
107
|
+
return referencedFirst([...byDir.values()], schemas || {})
|
|
64
108
|
}
|
|
@@ -12,12 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { existsSync } from 'node:fs'
|
|
15
|
-
import { dirname, join,
|
|
15
|
+
import { dirname, join, resolve } from 'node:path'
|
|
16
16
|
|
|
17
|
-
const within = (dir, path) => {
|
|
18
|
-
const rel = relative(resolve(dir), resolve(path))
|
|
19
|
-
return rel === '' || (!rel.startsWith(`..${sep}`) && rel !== '..' && !isAbsolute(rel))
|
|
20
|
-
}
|
|
21
17
|
|
|
22
18
|
/** The package `file` is in: the nearest folder above it with a package.json. */
|
|
23
19
|
function packageDirOf(file) {
|
|
@@ -48,7 +44,8 @@ export async function unregisteredLocalTypes({ named, defined, foundationDir, cl
|
|
|
48
44
|
const files = await workspaceTypeFiles(ref, foundationDir).catch(() => [])
|
|
49
45
|
if (files.length !== 1) continue
|
|
50
46
|
const dir = packageDirOf(files[0])
|
|
51
|
-
|
|
47
|
+
// The foundation's own package, not one inside its folder (`library-types.js` reads them the same way).
|
|
48
|
+
if (!dir || resolve(dir) === resolve(foundationDir)) continue
|
|
52
49
|
const held = await client.readDataSchema(ref).catch(() => undefined)
|
|
53
50
|
if (held === null) out.push({ ref, dir })
|
|
54
51
|
}
|
|
@@ -14,16 +14,24 @@
|
|
|
14
14
|
* package already, made by hand, cloned or kept as a git submodule, this wires it without making
|
|
15
15
|
* anything.
|
|
16
16
|
*
|
|
17
|
+
* ⭐ A library may be outside the workspace's folder: a folder beside it, another repository say.
|
|
18
|
+
* It is listed in the workspace by its path all the same (`../acme-shared`), so the package manager
|
|
19
|
+
* links it rather than copying it, pnpm installs its dependencies in its folder, and `uniweb update`
|
|
20
|
+
* moves its ranges with the rest; the build resolves what it imports as its foundations do
|
|
21
|
+
* (`@uniweb/build`'s `foundation/library-imports.js`). ⛔ Until 2026-11-10 an outside folder was
|
|
22
|
+
* refused, and for a few hours that day it was wired unlisted, which pnpm installs as a copy that a
|
|
23
|
+
* change to the folder doesn't reach. Never the workspace's own folder, or one that holds it.
|
|
24
|
+
*
|
|
17
25
|
* `--schemas` gives it a `schemas/` folder, whose files are data types its foundations name in full
|
|
18
26
|
* (`@acme/plan`), under the scope in its `package.json` (`uniweb.scope`): `--scope`, or the one the
|
|
19
27
|
* foundations it is wired into share.
|
|
20
28
|
*/
|
|
21
29
|
|
|
22
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
30
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs'
|
|
23
31
|
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
24
|
-
import { join, relative, sep } from 'node:path'
|
|
32
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
25
33
|
import prompts from 'prompts'
|
|
26
|
-
import { checkRegistrationScope, classifyPackage, readFoundationName, resolveFoundationSrcPath, splitFoundationName } from '@uniweb/build'
|
|
34
|
+
import { checkRegistrationScope, classifyPackage, libraryLine as buildLibraryLine, readFoundationName, resolveFoundationSrcPath, splitFoundationName } from '@uniweb/build'
|
|
27
35
|
import { resolvePlacement, LIBRARY_KIND } from '../utils/placement.js'
|
|
28
36
|
import { registerWorkspacePackage } from '../utils/config.js'
|
|
29
37
|
import { discoverFoundations } from '../utils/discover.js'
|
|
@@ -81,6 +89,19 @@ export function libraryManifest({ name, projectName, scope = null, versions = ge
|
|
|
81
89
|
}
|
|
82
90
|
}
|
|
83
91
|
|
|
92
|
+
/** `path` with links followed, as far as it exists: a folder still to be made keeps its own name. */
|
|
93
|
+
function realOrNearest(path) {
|
|
94
|
+
const rest = []
|
|
95
|
+
for (let at = path; ; at = dirname(at)) {
|
|
96
|
+
try {
|
|
97
|
+
return join(realpathSync(at), ...rest.reverse())
|
|
98
|
+
} catch {
|
|
99
|
+
if (dirname(at) === at) return path
|
|
100
|
+
rest.push(basename(at))
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
84
105
|
// The two example lines are aligned on the longer, which the library's name decides.
|
|
85
106
|
const INDEX = (name) => {
|
|
86
107
|
const here = `export { default as PlanCard } from './components/PlanCard.jsx'`
|
|
@@ -121,18 +142,10 @@ const USES_TAILWIND = /@import\s+["']tailwindcss/
|
|
|
121
142
|
* @returns {string}
|
|
122
143
|
*/
|
|
123
144
|
export function libraryLine({ libraryDir, libraryName, stylesDir }) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
// no manifest to refuse the import
|
|
129
|
-
}
|
|
130
|
-
const exp = pkg?.exports
|
|
131
|
-
// ⛔ An `exports` map without the stylesheet refuses the import, in Tailwind and in Node alike.
|
|
132
|
-
const importable = !exp || typeof exp !== 'object' || Object.keys(exp).some((k) => k === './styles.css' || k === './*')
|
|
133
|
-
if (existsSync(join(libraryDir, 'styles.css')) && importable) return `@import "${libraryName}/styles.css";`
|
|
134
|
-
const rel = posix(relative(stylesDir, libraryDir))
|
|
135
|
-
return `@source "${rel.startsWith('.') ? rel : `./${rel}`}";`
|
|
145
|
+
// ⭐ The build's one rule, which its stylesheet check names too: the library's stylesheet when it
|
|
146
|
+
// reads the library's files and the library exports it, else a `@source`. ⛔ Until 2026-11-10 this
|
|
147
|
+
// kept its own, which imported a stylesheet that read nothing and a string `exports` refused.
|
|
148
|
+
return buildLibraryLine({ name: libraryName, dir: libraryDir }, stylesDir)
|
|
136
149
|
}
|
|
137
150
|
|
|
138
151
|
/**
|
|
@@ -294,31 +307,50 @@ export async function addLibrary(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
294
307
|
}
|
|
295
308
|
|
|
296
309
|
const placement = resolvePlacement(rootDir, name, opts, LIBRARY_KIND)
|
|
297
|
-
|
|
310
|
+
// Outside the workspace's folder: made or wired there, and said by its path from the root.
|
|
311
|
+
const outside = !!placement.outsideRoot
|
|
312
|
+
// Its real path, so the `file:` path written from each foundation's real folder is the short one
|
|
313
|
+
// (on macOS `/tmp` and `/var` are links into `/private`).
|
|
314
|
+
const libraryDir = realOrNearest(outside ? resolve(rootDir, placement.outsideRoot) : join(rootDir, placement.relativePath))
|
|
315
|
+
const relativePath = outside ? relative(rootDir, libraryDir).split(sep).join('/') : placement.relativePath
|
|
316
|
+
// ⛔ The workspace itself, or a folder holding it, is no library of it: `add library .` from a
|
|
317
|
+
// package's folder named the root, which then read as a library of everything.
|
|
318
|
+
const fromLibrary = relative(libraryDir, rootDir)
|
|
319
|
+
if (fromLibrary === '' || (!fromLibrary.startsWith('..') && !isAbsolute(fromLibrary))) {
|
|
298
320
|
fail(
|
|
299
|
-
`A library's folder
|
|
300
|
-
''
|
|
301
|
-
`
|
|
302
|
-
`and \`${prefix} add library <its folder>\` lists it in the workspace and wires it.`
|
|
321
|
+
`A library's folder is a package of the workspace, never the workspace's own folder or one that holds it: ${relativePath || '.'}/`,
|
|
322
|
+
`Name the library's folder, from the workspace's root:`,
|
|
323
|
+
` ${prefix} add library libraries/<name>`
|
|
303
324
|
)
|
|
304
325
|
}
|
|
305
|
-
const { relativePath } = placement
|
|
306
|
-
const libraryDir = join(rootDir, relativePath)
|
|
307
326
|
|
|
308
|
-
let libraryName = placement.packageName
|
|
327
|
+
let libraryName = outside ? basename(libraryDir) : placement.packageName
|
|
309
328
|
let created = false
|
|
310
329
|
let scope = null
|
|
330
|
+
let ownScope = null
|
|
311
331
|
if (existsSync(libraryDir)) {
|
|
312
332
|
const kind = classifyPackage(libraryDir)
|
|
313
333
|
if (kind) fail(`${relativePath}/ is a ${kind}, not a library.`)
|
|
314
334
|
if (!existsSync(join(libraryDir, 'package.json'))) {
|
|
315
335
|
fail(`${relativePath}/ exists and holds no package.json, so it is no package to wire.`, `Pick another folder, or give it a package.json.`)
|
|
316
336
|
}
|
|
337
|
+
let manifest
|
|
317
338
|
try {
|
|
318
|
-
|
|
339
|
+
manifest = JSON.parse(readFileSync(join(libraryDir, 'package.json'), 'utf8'))
|
|
319
340
|
} catch {
|
|
320
341
|
fail(`${relativePath}/package.json does not parse.`)
|
|
321
342
|
}
|
|
343
|
+
libraryName = manifest.name || libraryName
|
|
344
|
+
ownScope = manifest.uniweb?.scope || null
|
|
345
|
+
// A package already there keeps its name, which another package of the workspace may have:
|
|
346
|
+
// listed, the workspace would hold two packages of one name, which npm refuses.
|
|
347
|
+
const taken = workspacePackageNames(rootDir).get(libraryName)
|
|
348
|
+
if (taken && resolve(rootDir, taken) !== libraryDir) {
|
|
349
|
+
fail(
|
|
350
|
+
`${relativePath}/ holds the package ${colors.bright}${libraryName}${colors.reset}, and a package of that name is in this workspace already, at ${taken}/.`,
|
|
351
|
+
`A foundation imports a library by its name: rename one of them in its package.json, then run this again.`
|
|
352
|
+
)
|
|
353
|
+
}
|
|
322
354
|
} else {
|
|
323
355
|
const valid = validatePackageName(libraryName)
|
|
324
356
|
if (valid !== true) fail(valid)
|
|
@@ -335,7 +367,8 @@ export async function addLibrary(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
335
367
|
const { wire, note } = await foundationsToWire(rootDir, opts.foundation, relativePath)
|
|
336
368
|
|
|
337
369
|
if (opts.schemas || opts.scope) {
|
|
338
|
-
|
|
370
|
+
// The scope given, else the one the library has already, else the one its foundations share.
|
|
371
|
+
scope = opts.scope ? `@${String(opts.scope).trim().replace(/^@/, '').replace(/\/.*$/, '')}` : ownScope || (await sharedScope(rootDir, wire))
|
|
339
372
|
if (!scope || scope === '@') {
|
|
340
373
|
fail(
|
|
341
374
|
`A library's data types are named in full, under its scope (${colors.bright}@acme/plan${colors.reset}), and none is known yet.`,
|
|
@@ -368,7 +401,8 @@ export async function addLibrary(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
368
401
|
await writeFile(join(libraryDir, 'schemas', 'README.md'), SCHEMAS_README(scope))
|
|
369
402
|
}
|
|
370
403
|
|
|
371
|
-
// Listed by its path, unless a pattern the workspace lists covers it already
|
|
404
|
+
// Listed by its path, unless a pattern the workspace lists covers it already: one outside the
|
|
405
|
+
// workspace's folder too, so the package manager links it.
|
|
372
406
|
await registerWorkspacePackage(rootDir, relativePath)
|
|
373
407
|
|
|
374
408
|
const wired = []
|
|
@@ -395,6 +429,12 @@ export async function addLibrary(rootDir, projectName, opts, pm = 'pnpm') {
|
|
|
395
429
|
info(` Export its components from ${relativePath}/index.js, and import them in a foundation: import { PlanCard } from '${libraryName}'`)
|
|
396
430
|
if (scope) info(` Its data types go in ${relativePath}/schemas/, named ${scope}/<file name>.`)
|
|
397
431
|
}
|
|
432
|
+
if (outside) {
|
|
433
|
+
log(
|
|
434
|
+
` ${colors.dim}${relativePath}/ is outside the workspace's folder, and listed in the workspace by that path, so the package manager links it;` +
|
|
435
|
+
` builds resolve what it imports as its foundations do.${colors.reset}`
|
|
436
|
+
)
|
|
437
|
+
}
|
|
398
438
|
log('')
|
|
399
439
|
log(`Next: ${colors.cyan}${installCmd(pm)}${colors.reset}`)
|
|
400
440
|
}
|
package/src/commands/doctor.js
CHANGED
|
@@ -963,8 +963,28 @@ export async function checkUnreadFolders({ foundationName, srcDir, issues }) {
|
|
|
963
963
|
* Loaded here for the same reason.
|
|
964
964
|
*/
|
|
965
965
|
export async function checkUnreadLibraries({ foundationName, srcDir, foundationDir, issues }) {
|
|
966
|
-
const { unreadLibraries } = await import('@uniweb/build')
|
|
967
|
-
|
|
966
|
+
const { unreadLibraries, copiedLibraries, copiedLibrariesWarning } = await import('@uniweb/build')
|
|
967
|
+
// ⛔ A check that throws stops nothing: until 2026-11-10 an unreadable folder in a library ended
|
|
968
|
+
// doctor here, every later check skipped.
|
|
969
|
+
let unread = []
|
|
970
|
+
try {
|
|
971
|
+
unread = unreadLibraries?.(join(srcDir, 'styles.css'), foundationDir) || []
|
|
972
|
+
} catch {
|
|
973
|
+
unread = []
|
|
974
|
+
}
|
|
975
|
+
// A library the package manager installed as a copy, which a change to its folder doesn't reach.
|
|
976
|
+
let copied = []
|
|
977
|
+
try {
|
|
978
|
+
copied = copiedLibraries?.(foundationDir) || []
|
|
979
|
+
} catch {
|
|
980
|
+
copied = []
|
|
981
|
+
}
|
|
982
|
+
if (copied.length) {
|
|
983
|
+
const id = 'copied-library'
|
|
984
|
+
const named = copied.map(({ name }) => name).join(', ')
|
|
985
|
+
issues.push({ id, type: 'warn', foundation: foundationName, message: `${foundationName} bundles ${named}, installed as a copy` })
|
|
986
|
+
warn(`[${id}] ${copiedLibrariesWarning(copied, findWorkspaceRoot(foundationDir) || undefined).replace(/^\[uniweb\] /, '')}`)
|
|
987
|
+
}
|
|
968
988
|
if (unread.length === 0) return
|
|
969
989
|
const id = 'unread-library'
|
|
970
990
|
const named = unread.map(({ name }) => name).join(', ')
|
package/src/commands/register.js
CHANGED
|
@@ -167,7 +167,10 @@ function readPkgScope(foundationDir) {
|
|
|
167
167
|
const pkg = JSON.parse(
|
|
168
168
|
readFileSync(join(foundationDir, 'package.json'), 'utf8')
|
|
169
169
|
)
|
|
170
|
-
|
|
170
|
+
// ⭐ Else the `@org` of a package named `@org/schemas`, as `packageTypeScope` and the build read
|
|
171
|
+
// it. ⛔ Until 2026-11-10 such a package with no `uniweb.scope` registered under the login's.
|
|
172
|
+
const named = /^@([^/]+)\/schemas$/.exec(typeof pkg?.name === 'string' ? pkg.name : '')
|
|
173
|
+
return pkg?.uniweb?.scope || (named ? `@${named[1]}` : null)
|
|
171
174
|
} catch {
|
|
172
175
|
return null
|
|
173
176
|
}
|
|
@@ -281,8 +284,12 @@ function sayRefused({ res, parsedBody, rawBody, scope, member, what }) {
|
|
|
281
284
|
async function registerLibraryTypes(lib, { client, exporter, at }) {
|
|
282
285
|
let doc
|
|
283
286
|
try {
|
|
287
|
+
// The types the foundation names from it, and no other of its files: those may be another
|
|
288
|
+
// package's to register, or a copy of one the foundation defines (`library-types.js`).
|
|
289
|
+
const wanted = new Set(lib.refs.map((ref) => `@/${ref.slice(lib.scope.length + 1)}`))
|
|
290
|
+
const all = await collectStandaloneSchemas(lib.dir)
|
|
284
291
|
doc = buildSchemaOnlyPackage({
|
|
285
|
-
schemas:
|
|
292
|
+
schemas: Object.fromEntries(Object.entries(all).filter(([key]) => wanted.has(key))),
|
|
286
293
|
scope: lib.scope,
|
|
287
294
|
exporter
|
|
288
295
|
})
|
|
@@ -316,7 +323,10 @@ async function registerLibraryTypes(lib, { client, exporter, at }) {
|
|
|
316
323
|
return { names, body }
|
|
317
324
|
}
|
|
318
325
|
const member = await memberOfScope(res, lib.scope, client)
|
|
319
|
-
|
|
326
|
+
// ⚖️ Released against what the registry holds only when the refusal is the scope's alone: no
|
|
327
|
+
// typed reason, which a change records can't take carries (`destructive_republish`), and an orgs
|
|
328
|
+
// read that says so. ⛔ Until 2026-11-10 any refusal to a non-member went on this way.
|
|
329
|
+
if (member === false && !(body?.code || body?.reason)) {
|
|
320
330
|
const held = await Promise.all(
|
|
321
331
|
lib.refs.map((ref) => client.readDataSchema(ref).catch(() => undefined))
|
|
322
332
|
)
|
|
@@ -342,6 +352,29 @@ async function registerLibraryTypes(lib, { client, exporter, at }) {
|
|
|
342
352
|
return null
|
|
343
353
|
}
|
|
344
354
|
|
|
355
|
+
/**
|
|
356
|
+
* After a refusal, each type the foundation names that another local package defines and the
|
|
357
|
+
* registry doesn't hold, with the command that registers it there (`unregistered-types.js`).
|
|
358
|
+
*/
|
|
359
|
+
async function sayWhatToRegisterFirst({ schema, defined, targetDir, client }) {
|
|
360
|
+
const missing = await unregisteredLocalTypes({
|
|
361
|
+
named: Object.keys(schema?.dataSchemas || {}),
|
|
362
|
+
defined,
|
|
363
|
+
foundationDir: targetDir,
|
|
364
|
+
client
|
|
365
|
+
}).catch(() => [])
|
|
366
|
+
if (!missing.length) return
|
|
367
|
+
// ⚖️ From the workspace root: `push` and `publish` run this in the foundation's folder, which is
|
|
368
|
+
// not where their person is.
|
|
369
|
+
const root = findWorkspaceRoot(targetDir) || targetDir
|
|
370
|
+
log('')
|
|
371
|
+
for (const { ref, dir } of missing) {
|
|
372
|
+
const at = relative(root, dir) || '.'
|
|
373
|
+
log(` ${ref} is defined in ${at}/, which has not registered it. Register it there first, from the workspace root:`)
|
|
374
|
+
log(` ${colors.blue}cd ${at} && npx uniweb register${colors.reset}`)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
345
378
|
/**
|
|
346
379
|
* Resolve which foundation to register: the cwd if it's a foundation, else the
|
|
347
380
|
* single foundation in the workspace, else prompt (or error in non-interactive).
|
|
@@ -714,8 +747,8 @@ export function foundationNeedsBuild(targetDir) {
|
|
|
714
747
|
return {
|
|
715
748
|
needs: true,
|
|
716
749
|
reason: newer.library
|
|
717
|
-
?
|
|
718
|
-
: 'a source
|
|
750
|
+
? `${newer.library}, a library it bundles, changed since dist/entry.js was built`
|
|
751
|
+
: 'a source changed since dist/entry.js was built'
|
|
719
752
|
}
|
|
720
753
|
} catch {
|
|
721
754
|
// Can't compare — leave the other signals to decide rather than forcing a
|
|
@@ -887,12 +920,20 @@ async function runRegister(args = []) {
|
|
|
887
920
|
|
|
888
921
|
// ⭐ The types it names that a library defines: registered from the library before the
|
|
889
922
|
// foundation, which the registry refuses while a type it names is missing (`library-types.js`).
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
923
|
+
let fromLibraries = []
|
|
924
|
+
if (!standalone) {
|
|
925
|
+
try {
|
|
926
|
+
fromLibraries = await typesFromLibraries({ schemas: schema?.dataSchemas || {}, foundationDir: targetDir })
|
|
927
|
+
} catch (err) {
|
|
928
|
+
// ⛔ Said, never silent: a build too old to tell which library defines a type registers none,
|
|
929
|
+
// and the registry then refuses the foundation for it.
|
|
930
|
+
if (err?.code === 'BUILD_TOO_OLD') {
|
|
931
|
+
log(
|
|
932
|
+
` ${colors.yellow}⚠${colors.reset} This uniweb registers the types a library defines before the foundation, and the installed @uniweb/build is too old to tell which: ${colors.blue}npx uniweb@latest update --yes${colors.reset}`
|
|
933
|
+
)
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
896
937
|
// Where each is, said from the workspace root, which is where its person is.
|
|
897
938
|
const workspaceRoot = standalone ? null : findWorkspaceRoot(targetDir) || targetDir
|
|
898
939
|
const shownAt = (dir) => `${relative(workspaceRoot, dir) || '.'}/`
|
|
@@ -1023,7 +1064,10 @@ async function runRegister(args = []) {
|
|
|
1023
1064
|
const fromLibrariesSent = []
|
|
1024
1065
|
for (const lib of fromLibraries) {
|
|
1025
1066
|
const sent = await registerLibraryTypes(lib, { client, exporter, at: shownAt(lib.dir) })
|
|
1026
|
-
if (!sent)
|
|
1067
|
+
if (!sent) {
|
|
1068
|
+
await sayWhatToRegisterFirst({ schema, defined, targetDir, client })
|
|
1069
|
+
return { exitCode: 1 }
|
|
1070
|
+
}
|
|
1027
1071
|
fromLibrariesSent.push(sent)
|
|
1028
1072
|
}
|
|
1029
1073
|
|
|
@@ -1084,25 +1128,7 @@ async function runRegister(args = []) {
|
|
|
1084
1128
|
})
|
|
1085
1129
|
// ⭐ A type it names that another foundation here defines, and the registry doesn't hold:
|
|
1086
1130
|
// 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
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1131
|
+
if (!standalone && member !== false) await sayWhatToRegisterFirst({ schema, defined, targetDir, client })
|
|
1106
1132
|
return { exitCode: 1 }
|
|
1107
1133
|
}
|
|
1108
1134
|
}
|
package/src/commands/status.js
CHANGED
|
@@ -1876,7 +1876,14 @@ export async function status(args = []) {
|
|
|
1876
1876
|
// files, and the way to one site's checks.
|
|
1877
1877
|
if (found.several?.length) return workspaceOverview(found.root, { json })
|
|
1878
1878
|
if (json) console.log(JSON.stringify({ schema: STATUS_SCHEMA, scope: null, error: 'no-site' }))
|
|
1879
|
-
else
|
|
1879
|
+
else if (!findWorkspaceRoot(process.cwd()) && existsSync(join(process.cwd(), 'package.json'))) {
|
|
1880
|
+
// A package in no workspace's folder: a library beside the workspace, say, whose workspace
|
|
1881
|
+
// can't be found from here, since it is listed there and points nowhere back.
|
|
1882
|
+
console.error(`${c.red}✗${c.reset} No Uniweb site here, and no workspace above this folder.`)
|
|
1883
|
+
console.error(
|
|
1884
|
+
` For a library beside a workspace, run status in that workspace: a site's status names the libraries its foundation bundles.`
|
|
1885
|
+
)
|
|
1886
|
+
} else console.error(`${c.red}✗${c.reset} No Uniweb site here. Run status from a site, or a project with one site.`)
|
|
1880
1887
|
return { exitCode: 2 }
|
|
1881
1888
|
}
|
|
1882
1889
|
const siteDir = found.siteDir
|
package/src/framework-index.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-10T19:03:10.178Z",
|
|
4
4
|
"packages": {
|
|
5
5
|
"@uniweb/api": {
|
|
6
6
|
"version": "1.7.0"
|
|
7
7
|
},
|
|
8
8
|
"@uniweb/build": {
|
|
9
|
-
"version": "1.20.
|
|
9
|
+
"version": "1.20.8"
|
|
10
10
|
},
|
|
11
11
|
"@uniweb/content-reader": {
|
|
12
12
|
"version": "1.5.9"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"version": "1.2.16"
|
|
37
37
|
},
|
|
38
38
|
"@uniweb/runtime": {
|
|
39
|
-
"version": "1.5.
|
|
39
|
+
"version": "1.5.7"
|
|
40
40
|
},
|
|
41
41
|
"@uniweb/scene": {
|
|
42
42
|
"version": "1.0.1"
|
package/src/index.js
CHANGED
|
@@ -74,6 +74,7 @@ import {
|
|
|
74
74
|
import { findWorkspaceRoot } from './utils/workspace.js'
|
|
75
75
|
import { exitWhenDrained } from './utils/exit.js'
|
|
76
76
|
import { staleFrameworkExport, installedVersion } from './utils/stale-export.js'
|
|
77
|
+
import { getVersion } from './versions.js'
|
|
77
78
|
import { outliveTheReader } from './utils/closed-reader.js'
|
|
78
79
|
import { isGitRepo } from './utils/git.js'
|
|
79
80
|
|
|
@@ -261,9 +262,16 @@ async function importProjectCommand(modulePath) {
|
|
|
261
262
|
const stale = staleFrameworkExport(err)
|
|
262
263
|
if (stale) {
|
|
263
264
|
const have = installedVersion(stale.pkg)
|
|
265
|
+
// ⚖️ Older or newer than the one this CLI goes with: said as it is. ⛔ Until 2026-11-10 it
|
|
266
|
+
// always said "needs a newer", and a project ahead of the CLI was told its package was old.
|
|
267
|
+
const wanted = getVersion(stale.pkg)
|
|
268
|
+
const floor = /(\d+)\.(\d+)\.(\d+)/.exec(wanted || '')?.slice(1).map(Number)
|
|
269
|
+
const at = /(\d+)\.(\d+)\.(\d+)/.exec(have || '')?.slice(1).map(Number)
|
|
270
|
+
const older = floor && at ? at[0] - floor[0] || at[1] - floor[1] || at[2] - floor[2] : -1
|
|
264
271
|
error(
|
|
265
|
-
|
|
266
|
-
`which has no \`${stale.name}\`.`
|
|
272
|
+
older < 0
|
|
273
|
+
? `This uniweb (${getCliVersion()}) needs a newer ${stale.pkg} than the one installed${have ? ` (${have})` : ''}, which has no \`${stale.name}\`.`
|
|
274
|
+
: `This uniweb (${getCliVersion()}) goes with ${stale.pkg} ${wanted}, and the one installed (${have}) has no \`${stale.name}\`.`
|
|
267
275
|
)
|
|
268
276
|
log(`Bring the project's framework packages to the versions this CLI goes with:`)
|
|
269
277
|
log(` ${colors.cyan}npx uniweb@latest update --yes${colors.reset}`)
|
|
@@ -1828,6 +1836,7 @@ ${colors.bright}Examples:${colors.reset}
|
|
|
1828
1836
|
uniweb add library libraries/ui --foundation a,b # Create ./libraries/ui/, shared by a and b
|
|
1829
1837
|
uniweb add library libraries/ui --foundation c # Wire one more foundation to it
|
|
1830
1838
|
uniweb add library shared --schemas --scope @acme # With data types named @acme/<file>
|
|
1839
|
+
uniweb add library ../acme-shared --foundation a # A library beside the workspace, another repo's
|
|
1831
1840
|
uniweb add section Hero # Create Hero section type
|
|
1832
1841
|
uniweb add section Hero --foundation ui # Target specific foundation
|
|
1833
1842
|
uniweb add section Hero --starter # Starter content for an existing Hero
|
|
@@ -4,14 +4,19 @@
|
|
|
4
4
|
* they use it (`ensureFoundationFresh`), and `register` before it uploads it
|
|
5
5
|
* (`foundationNeedsBuild`). A build reads:
|
|
6
6
|
* - the foundation's source root, the folder `package.json::main` names (`resolveFoundationSrcPath`:
|
|
7
|
-
* the package itself when flat, `src/` when nested), and
|
|
8
|
-
*
|
|
7
|
+
* the package itself when flat, `src/` when nested), and what at its root shapes the build
|
|
8
|
+
* (`package.json`, a `vite.config.*`, a legacy `foundation.js` or `meta.js`, and `public/`,
|
|
9
|
+
* which Vite copies into `dist/`);
|
|
9
10
|
* - every library it bundles: any local package it depends on (`librariesOf`, `@uniweb/build`),
|
|
10
11
|
* wherever it is linked from.
|
|
11
12
|
* Dot-folders, `node_modules`, and what a foundation's build writes into one (`dist/`, the
|
|
12
13
|
* generated entry) are never sources. A library that is not a foundation keeps its `dist/`, which
|
|
13
14
|
* may be what the foundation imports.
|
|
14
15
|
*
|
|
16
|
+
* A folder counts as well as its files: adding, removing or renaming a file changes its folder's
|
|
17
|
+
* time and no file's, so a deleted section type or a renamed component makes the build stale too.
|
|
18
|
+
* ⛔ Until 2026-11-10 only files counted, and a build kept a section type whose file was gone.
|
|
19
|
+
*
|
|
15
20
|
* Ties count as fresh: a build writes its output after it reads its input, so equal times mean a
|
|
16
21
|
* build in the same millisecond, and on a fresh clone, where whole trees share a time, a tie
|
|
17
22
|
* counted stale would rebuild every foundation once for nothing.
|
|
@@ -27,17 +32,23 @@ import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
|
27
32
|
import { join } from 'node:path'
|
|
28
33
|
import { classifyPackage, librariesOf, resolveFoundationSrcPath } from '@uniweb/build'
|
|
29
34
|
|
|
30
|
-
//
|
|
31
|
-
const ROOT_FILES = ['package.json', 'vite.config.js', 'foundation.js', 'meta.js']
|
|
35
|
+
// What at a foundation's root shapes its build, when its sources are in `src/`.
|
|
36
|
+
const ROOT_FILES = ['package.json', 'vite.config.js', 'vite.config.mjs', 'vite.config.cjs', 'vite.config.ts', 'vite.config.mts', 'foundation.js', 'meta.js']
|
|
37
|
+
const ROOT_FOLDERS = ['public']
|
|
32
38
|
|
|
33
39
|
// What a foundation's build writes into the foundation.
|
|
34
40
|
const BUILD_OUTPUT = new Set(['dist', '_entry.generated.js'])
|
|
35
41
|
|
|
36
|
-
/** The first file under `dir` newer than `builtAt`, or null. */
|
|
42
|
+
/** The first file or folder under `dir`, `dir` itself included, newer than `builtAt`, or null. */
|
|
37
43
|
function newerUnder(dir, builtAt, { skipOutput }) {
|
|
38
44
|
const stack = [dir]
|
|
39
45
|
while (stack.length) {
|
|
40
46
|
const at = stack.pop()
|
|
47
|
+
try {
|
|
48
|
+
if (statSync(at).mtimeMs > builtAt) return at
|
|
49
|
+
} catch {
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
41
52
|
let entries
|
|
42
53
|
try {
|
|
43
54
|
entries = readdirSync(at, { withFileTypes: true })
|
|
@@ -79,8 +90,16 @@ export function newerInput(foundationDir, builtAt) {
|
|
|
79
90
|
// unreadable: not newer
|
|
80
91
|
}
|
|
81
92
|
}
|
|
82
|
-
const
|
|
93
|
+
const srcDir = resolveFoundationSrcPath(foundationDir)
|
|
94
|
+
const own = newerUnder(srcDir, builtAt, { skipOutput: true })
|
|
83
95
|
if (own) return { file: own, library: null }
|
|
96
|
+
if (srcDir !== foundationDir) {
|
|
97
|
+
for (const f of ROOT_FOLDERS) {
|
|
98
|
+
const p = join(foundationDir, f)
|
|
99
|
+
const file = existsSync(p) ? newerUnder(p, builtAt, { skipOutput: false }) : null
|
|
100
|
+
if (file) return { file, library: null }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
84
103
|
for (const { name, dir } of librariesOf(foundationDir)) {
|
|
85
104
|
const file = newerUnder(dir, builtAt, { skipOutput: classifyPackage(dir) === 'foundation' })
|
|
86
105
|
if (file) return { file, library: name }
|
package/src/utils/placement.js
CHANGED
|
@@ -42,7 +42,8 @@ function normalizeParent(given, rootDir) {
|
|
|
42
42
|
*/
|
|
43
43
|
function insideRoot(rootDir, path) {
|
|
44
44
|
if (!rootDir) return { relativePath: path }
|
|
45
|
-
|
|
45
|
+
// Trailing slashes off, but never the whole of `/`, which would be read as no path at all.
|
|
46
|
+
const trimmed = String(path).replace(/(.)\/+$/, '$1')
|
|
46
47
|
const rel = relative(rootDir, resolve(rootDir, trimmed))
|
|
47
48
|
if (!rel || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) return { outsideRoot: trimmed, relativePath: null, packageName: null }
|
|
48
49
|
return { relativePath: rel.split(sep).join('/') }
|
|
@@ -131,7 +132,9 @@ export function resolvePlacement(rootDir, name, opts, kind) {
|
|
|
131
132
|
// is then taken as the package name).
|
|
132
133
|
if (opts.path) {
|
|
133
134
|
const parent = normalizeParent(opts.path, rootDir)
|
|
134
|
-
|
|
135
|
+
// ⛔ With the name: `--path /abs/libs ui` is `/abs/libs/ui`, as it is inside the root. Until
|
|
136
|
+
// 2026-11-10 the name was dropped here, and `add library` wired `/abs/libs` itself.
|
|
137
|
+
if (parent.outsideRoot) return { outsideRoot: name ? `${parent.given}/${name}`.replace(/\/+/g, '/') : parent.given, relativePath: null, packageName: null }
|
|
135
138
|
const dir = parent.relative
|
|
136
139
|
if (name) {
|
|
137
140
|
const last = name.split('/').filter(Boolean).pop()
|
|
@@ -143,6 +143,9 @@ export async function fetchOrgs({ apiBase, token, fetchImpl = globalThis.fetch }
|
|
|
143
143
|
`Could not list your orgs: HTTP ${res.status} ${res.statusText}`
|
|
144
144
|
)
|
|
145
145
|
const data = await res.json().catch(() => null)
|
|
146
|
+
// ⛔ An answer that isn't the orgs read is unknown, never "a member of nothing": until 2026-11-10 a
|
|
147
|
+
// body that didn't parse read as no orgs, and a member's refusal as a non-member's.
|
|
148
|
+
if (!data || typeof data !== 'object') throw new Error('Could not list your orgs: the answer was not readable')
|
|
146
149
|
return {
|
|
147
150
|
account_handle: data?.account_handle ?? null,
|
|
148
151
|
orgs: Array.isArray(data?.orgs) ? data.orgs : [],
|