uniweb 1.31.10 → 1.31.12
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 +8 -8
- package/partials/guides/data.md +1 -1
- package/src/backend/foundation-bring-along.js +19 -4
- package/src/commands/pull.js +3 -2
- package/src/commands/push.js +3 -0
- package/src/framework-index.json +7 -7
- package/src/utils/retired-records.js +79 -25
- package/src/utils/site-roots.js +60 -1
- package/src/utils/sync-point.js +54 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniweb",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.12",
|
|
4
4
|
"description": "Create structured Vite + React sites with content/code separation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"js-yaml": "^4.3.2",
|
|
42
42
|
"prompts": "^2.4.2",
|
|
43
43
|
"tar": "^7.5.21",
|
|
44
|
-
"@uniweb/
|
|
45
|
-
"@uniweb/core": "~1.6.
|
|
46
|
-
"@uniweb/
|
|
47
|
-
"@uniweb/
|
|
44
|
+
"@uniweb/semantic-parser": "~1.13.3",
|
|
45
|
+
"@uniweb/core": "~1.6.12",
|
|
46
|
+
"@uniweb/schemas": "~1.7.1",
|
|
47
|
+
"@uniweb/content-writer": "~1.3.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@uniweb/
|
|
51
|
-
"@uniweb/
|
|
52
|
-
"@uniweb/
|
|
50
|
+
"@uniweb/semantic-parser": "~1.13.3",
|
|
51
|
+
"@uniweb/content-reader": "~1.5.9",
|
|
52
|
+
"@uniweb/build": "~1.20.9"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@uniweb/build": {
|
package/partials/guides/data.md
CHANGED
|
@@ -136,7 +136,7 @@ data: {
|
|
|
136
136
|
|
|
137
137
|
`single`/`whole` are refused over a schema whose root is a list (`@std/nav`, `@std/form`). A `whole` key its source cannot answer whole is `null`. An optional `schemas.config.js` routes a scope to a directory: `export default { '@acme': '../shared/acme-schemas' }` — a routed scope wins, has no package fallback, and `@/`/`@uniweb` are never routable. Worked examples: `development/schemas-in-practice.md`.
|
|
138
138
|
|
|
139
|
-
**Any foundation can use a data schema another defines, by its full name** — `data: { members: '@acme/member' }`, `schema: '@acme/member'` in `queries.yml`. No backend is involved, and nothing to configure: a local build, `uniweb dev` included, reads the type from the package of the workspace that defines it (a foundation whose name gives the `@acme` scope, with the type in its own `schemas/`), or from a library the foundation bundles whose package.json gives that scope (`uniweb guide foundation` § Libraries). Two packages defining it stop the build, naming both. A type no such package defines comes from `schemas.config.js` (`'@acme/member': '../elsewhere/member.yml'`, or the scope's directory), which wins over both, or an installed `@acme/schemas` package. A scope is a namespace that keeps names from colliding, not a limit on who uses a type. So a type another foundation defines is named, never copied: a copy of its file is a second definition of the same type, which `doctor` points out where the two foundations' names give one scope (`type-defined-twice`). Registering, which only a site with a backend does, names such a type and sends no definition of it; a type a library defines is registered from the library, first (`uniweb guide foundation` § Libraries). A push also needs one of the site's foundations to declare the type, as a section type's data key or a schema of its own: the backend refuses a query whose type none of them declares, since nothing there would render it. A site can hold another site's records of a type too: `paths: { 'records/acme/member': '../../hub/site/records/acme/member' }` in its `site.yml` reads them as its own, a push adds them by reference rather than as copies once their own site has pushed them, and a pull leaves those files alone. A site's records of it sit in `records/acme/member/`; in `records/member/` they'd be the foundation's own `@/member`.
|
|
139
|
+
**Any foundation can use a data schema another defines, by its full name** — `data: { members: '@acme/member' }`, `schema: '@acme/member'` in `queries.yml`. No backend is involved, and nothing to configure: a local build, `uniweb dev` included, reads the type from the package of the workspace that defines it (a foundation whose name gives the `@acme` scope, with the type in its own `schemas/`), or from a library the foundation bundles whose package.json gives that scope (`uniweb guide foundation` § Libraries). Two packages defining it stop the build, naming both. A type no such package defines comes from `schemas.config.js` (`'@acme/member': '../elsewhere/member.yml'`, or the scope's directory), which wins over both, or an installed `@acme/schemas` package. A scope is a namespace that keeps names from colliding, not a limit on who uses a type. So a type another foundation defines is named, never copied: a copy of its file is a second definition of the same type, which `doctor` points out where the two foundations' names give one scope (`type-defined-twice`). Registering, which only a site with a backend does, names such a type and sends no definition of it; a type a library defines is registered from the library, first (`uniweb guide foundation` § Libraries). A push also needs one of the site's foundations to declare the type, as a section type's data key or a schema of its own: the backend refuses a query whose type none of them declares, since nothing there would render it. A site can hold another site's records of a type too: `paths: { 'records/acme/member': '../../hub/site/records/acme/member' }` in its `site.yml` reads them as its own, a push adds them by reference rather than as copies once their own site has pushed them, and a pull leaves those files alone. That site can be in another repository checked out beside this one: the foundation then reads the type through `schemas.config.js` or a schemas package, and the push reads the records' ids from that site's committed `sync.json`. Two sites whose `paths: { records: … }` name one folder are not that: each push sends the folder's records as its own, two of each on the backend. A site's records of it sit in `records/acme/member/`; in `records/member/` they'd be the foundation's own `@/member`.
|
|
140
140
|
|
|
141
141
|
```jsx
|
|
142
142
|
function Article({ content, block }) { // data: { article: { schema: '@std/article', single: true } }
|
|
@@ -616,16 +616,31 @@ async function bringLocalCodeAlong({
|
|
|
616
616
|
})
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
/**
|
|
620
|
+
* A step this command runs as a process of its own, which prints why it stops. What a failed one
|
|
621
|
+
* throws back names only that, never its command line: ⛔ until 2026-11-10 a refused release ended
|
|
622
|
+
* on "Foundation release failed: Command failed: node /<absolute path>/index.js register
|
|
623
|
+
* --non-interactive --org @acme", which reads as a command to run.
|
|
624
|
+
*/
|
|
625
|
+
function runStep(argv, options, what) {
|
|
626
|
+
try {
|
|
627
|
+
execFileSync('node', argv, options)
|
|
628
|
+
} catch (err) {
|
|
629
|
+
if (typeof err?.status !== 'number') throw err
|
|
630
|
+
throw Object.assign(new Error(`${what} stopped, as it says above`), { status: err.status })
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
|
|
619
634
|
// Build the foundation so its dist/ can be fingerprinted. Idempotent — the
|
|
620
635
|
// foundation build no-ops when already fresh.
|
|
621
636
|
function buildFoundation(local, cliBin) {
|
|
622
|
-
|
|
637
|
+
runStep([cliBin, 'build', '--target', 'foundation'], {
|
|
623
638
|
cwd: local.dir,
|
|
624
639
|
stdio: 'inherit',
|
|
625
640
|
// A step of this command, so the build skips the next-step hints meant for
|
|
626
641
|
// someone who ran `uniweb build` themselves.
|
|
627
642
|
env: { ...process.env, UNIWEB_BUILD_STEP: '1' }
|
|
628
|
-
})
|
|
643
|
+
}, 'its build (`uniweb build`)')
|
|
629
644
|
}
|
|
630
645
|
|
|
631
646
|
// Release = `uniweb register` in the foundation directory (the one foundation
|
|
@@ -636,11 +651,11 @@ function releaseFoundation(local, args, cliBin, say, origin) {
|
|
|
636
651
|
// ⭐ Pinned to the parent's backend through the environment, so the release lands
|
|
637
652
|
// where the publish goes by construction — not because two processes happen to read
|
|
638
653
|
// the same session file the same way.
|
|
639
|
-
|
|
654
|
+
runStep([cliBin, 'register', ...forwardedFlags(args)], {
|
|
640
655
|
cwd: local.dir,
|
|
641
656
|
stdio: 'inherit',
|
|
642
657
|
env: origin ? { ...process.env, UNIWEB_SERVER: origin } : process.env
|
|
643
|
-
})
|
|
658
|
+
}, '`uniweb register`')
|
|
644
659
|
console.log('')
|
|
645
660
|
return true
|
|
646
661
|
}
|
package/src/commands/pull.js
CHANGED
|
@@ -116,7 +116,7 @@ import {
|
|
|
116
116
|
readItemBaseVersions
|
|
117
117
|
} from '../backend/site-sync.js'
|
|
118
118
|
import { resolveWorkspace } from '../backend/workspace.js'
|
|
119
|
-
import { siteRoots, sentRoots, laneRoots, writableMounts, refusedMountLines, heldMountLines } from '../utils/site-roots.js'
|
|
119
|
+
import { siteRoots, sentRoots, laneRoots, writableMounts, refusedMountLines, heldMountLines, levelsAboveRepository } from '../utils/site-roots.js'
|
|
120
120
|
import {
|
|
121
121
|
repoOf,
|
|
122
122
|
mergeInProgress,
|
|
@@ -1201,7 +1201,8 @@ export async function pull(args = [], deps = {}) {
|
|
|
1201
1201
|
return { repo: m.repo, at: m.at, roots: [m.root], segment: m.segment, rev: force ? m.repo.head : own ?? m.repo.head, parent: force ? m.repo.head : own }
|
|
1202
1202
|
})
|
|
1203
1203
|
try {
|
|
1204
|
-
|
|
1204
|
+
// As far above the repository as the site's paths reach, so a mount beside it resolves there too.
|
|
1205
|
+
standIn = openStandIn(repo, { roots, rev: onto, nested, above: levelsAboveRepository(siteDir, repo, onto) })
|
|
1205
1206
|
} catch (err) {
|
|
1206
1207
|
error(`Could not merge the site: ${err.message}.`)
|
|
1207
1208
|
return { exitCode: 1 }
|
package/src/commands/push.js
CHANGED
|
@@ -683,6 +683,9 @@ export async function push(args = [], deps = {}) {
|
|
|
683
683
|
holdUnchangedPush(siteDir, client.origin)
|
|
684
684
|
// What it recorded on the way — a media map, an identity recovered — is committed too.
|
|
685
685
|
reportWriteBacks(commitWriteBacks(siteDir, client.origin, { released }), { note })
|
|
686
|
+
// ⭐ An earlier push's retired records too, which is what "push again with --yes" is for
|
|
687
|
+
// (`settleRetiredRecords`). ⛔ Until 2026-11-10 this returned first, and that line did nothing.
|
|
688
|
+
await settleRetiredRecords({ client, siteDir, args, say: { ok: success, dim: note, warn: note } })
|
|
686
689
|
}
|
|
687
690
|
return { exitCode: 0 }
|
|
688
691
|
}
|
package/src/framework-index.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-11T02:16:44.434Z",
|
|
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.9"
|
|
10
10
|
},
|
|
11
11
|
"@uniweb/content-reader": {
|
|
12
12
|
"version": "1.5.9"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"version": "1.3.1"
|
|
16
16
|
},
|
|
17
17
|
"@uniweb/core": {
|
|
18
|
-
"version": "1.6.
|
|
18
|
+
"version": "1.6.12"
|
|
19
19
|
},
|
|
20
20
|
"@uniweb/frame-bridge": {
|
|
21
21
|
"version": "1.0.3"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"version": "1.2.16"
|
|
37
37
|
},
|
|
38
38
|
"@uniweb/runtime": {
|
|
39
|
-
"version": "1.5.
|
|
39
|
+
"version": "1.5.9"
|
|
40
40
|
},
|
|
41
41
|
"@uniweb/scene": {
|
|
42
42
|
"version": "1.0.1"
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"version": "1.7.1"
|
|
46
46
|
},
|
|
47
47
|
"@uniweb/scholar": {
|
|
48
|
-
"version": "1.1.
|
|
48
|
+
"version": "1.1.1"
|
|
49
49
|
},
|
|
50
50
|
"@uniweb/semantic-parser": {
|
|
51
|
-
"version": "1.13.
|
|
51
|
+
"version": "1.13.3"
|
|
52
52
|
},
|
|
53
53
|
"@uniweb/snapshot": {
|
|
54
54
|
"version": "1.1.2"
|
|
55
55
|
},
|
|
56
56
|
"@uniweb/templates": {
|
|
57
|
-
"version": "1.2.
|
|
57
|
+
"version": "1.2.12"
|
|
58
58
|
},
|
|
59
59
|
"@uniweb/theming": {
|
|
60
60
|
"version": "1.3.2"
|
|
@@ -7,17 +7,27 @@
|
|
|
7
7
|
* the cleanup to the app — agents do most of the work through the CLI. The backend's route keeps a
|
|
8
8
|
* record that a folder outside the call still places (another site's), and names it.
|
|
9
9
|
*
|
|
10
|
-
* ⭐ ASKED AT THE END OF
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* ⭐ ASKED AT THE END OF EVERY PUSH, and of a publish, which pushes. A published site reads its
|
|
11
|
+
* records from its folder as the folder stands, with no snapshot taken at publish, so the push has
|
|
12
|
+
* already taken them off the live site [backend, 2026-11-04 — `backend/docs/delivery-orientation.md`:
|
|
13
|
+
* "Adding a blog post updates the live site with no republish"]. ⛔ Until then this asked only at
|
|
14
|
+
* publish, "because until then the live site still has the folder that placed them", which is not
|
|
15
|
+
* how that wire behaves. ⛔ And until 2026-11-10 only a push that sent something asked, so the line
|
|
16
|
+
* a push without a terminal prints, "push again with --yes", did nothing when nothing else had
|
|
17
|
+
* changed: that push stopped at "Nothing to push" first (measured on the playground).
|
|
17
18
|
*
|
|
18
19
|
* As emptying the folder does, it asks first, and `--yes` is the way past the question. With no
|
|
19
20
|
* terminal and no `--yes`, it keeps them and says how to finish. A person who declines keeps them,
|
|
20
21
|
* and is not asked again.
|
|
22
|
+
*
|
|
23
|
+
* ⭐ A RECORD ANOTHER SITE'S FOLDER STILL PLACES IS KEPT, AND DELETED ONCE NONE DOES. A site that
|
|
24
|
+
* mounts this site's records (`site.yml` `paths:`) places them by reference, so a record whose file
|
|
25
|
+
* this site deleted is still on that site until that site pushes again. The backend keeps it then,
|
|
26
|
+
* and this copy holds the choice to delete it (`sync.json` `deleting`): each later push asks the
|
|
27
|
+
* backend again, with no question, and it goes once nothing places it. ⛔ Until 2026-11-10 a kept
|
|
28
|
+
* record was dropped from the list, and once the other site's push stopped placing it, it stayed on
|
|
29
|
+
* the backend in no folder, where nothing offered to delete it (measured on the playground). The
|
|
30
|
+
* messages said those records stay "where no site serves them", which a mounting site contradicted.
|
|
21
31
|
*/
|
|
22
32
|
|
|
23
33
|
import { readBackendState, setBackendMap } from '@uniweb/build/uwx'
|
|
@@ -32,8 +42,44 @@ function describeRetired(retired) {
|
|
|
32
42
|
return `${n === 1 ? '1 record' : `${n} records`} (${groups.join(', ')})`
|
|
33
43
|
}
|
|
34
44
|
|
|
45
|
+
const records = (n) => (n === 1 ? '1 record' : `${n} records`)
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The records this copy chose to delete that the backend kept, asked about again: no question, since
|
|
49
|
+
* the choice was made. Those the backend deletes, or that name nothing any more, leave the list.
|
|
50
|
+
*/
|
|
51
|
+
async function finishDeleting({ client, siteDir, say }) {
|
|
52
|
+
const pending = readBackendState(siteDir, client.origin).deleting || {}
|
|
53
|
+
const uuids = Object.keys(pending)
|
|
54
|
+
if (!uuids.length) return 0
|
|
55
|
+
let res
|
|
56
|
+
try {
|
|
57
|
+
res = await client.deleteEntities({ uuids, placed: 'keep' })
|
|
58
|
+
} catch {
|
|
59
|
+
return 0 // the next push asks again
|
|
60
|
+
}
|
|
61
|
+
// A backend older than its delete route: they wait for one that has it.
|
|
62
|
+
if (res.status === 404) return 0
|
|
63
|
+
const body = await res.json().catch(() => null)
|
|
64
|
+
if (!res.ok) {
|
|
65
|
+
// Refused whole, which asking again would be too: the app is where they go now.
|
|
66
|
+
say.warn(
|
|
67
|
+
`${client.origin} did not delete ${records(uuids.length)} this copy is deleting: HTTP ${res.status}` +
|
|
68
|
+
`${body?.detail ? ` — ${body.detail}` : ''}. Delete ${uuids.length === 1 ? 'it' : 'them'} in the app if ${uuids.length === 1 ? 'it' : 'they'} should go.`
|
|
69
|
+
)
|
|
70
|
+
setBackendMap(siteDir, client.origin, 'deleting', {})
|
|
71
|
+
return 0
|
|
72
|
+
}
|
|
73
|
+
const deleted = Array.isArray(body?.deleted) ? body.deleted : []
|
|
74
|
+
const kept = new Set(Array.isArray(body?.kept) ? body.kept : [])
|
|
75
|
+
if (deleted.length) say.ok(`Deleted ${records(deleted.length)} that another site's folder no longer places.`)
|
|
76
|
+
setBackendMap(siteDir, client.origin, 'deleting', Object.fromEntries(uuids.filter((u) => kept.has(u)).map((u) => [u, pending[u]])))
|
|
77
|
+
return deleted.length
|
|
78
|
+
}
|
|
79
|
+
|
|
35
80
|
/**
|
|
36
|
-
* After a push, or a publish: offer to delete the retired records, and delete them on a yes
|
|
81
|
+
* After a push, or a publish: offer to delete the retired records, and delete them on a yes; and
|
|
82
|
+
* finish deleting those another site's folder placed when they were asked about.
|
|
37
83
|
*
|
|
38
84
|
* @param {object} params
|
|
39
85
|
* @param {object} params.client - a `BackendClient` on the site's backend, in its workspace
|
|
@@ -44,29 +90,32 @@ function describeRetired(retired) {
|
|
|
44
90
|
* @returns {Promise<{ deleted: number, kept: number, asked: boolean }>}
|
|
45
91
|
*/
|
|
46
92
|
export async function settleRetiredRecords({ client, siteDir, args = [], say, ask = confirm }) {
|
|
93
|
+
const finished = await finishDeleting({ client, siteDir, say })
|
|
47
94
|
const retired = readBackendState(siteDir, client.origin).retired || {}
|
|
48
95
|
const uuids = Object.keys(retired)
|
|
49
|
-
if (!uuids.length) return { deleted:
|
|
96
|
+
if (!uuids.length) return { deleted: finished, kept: 0, asked: false }
|
|
50
97
|
const what = describeRetired(retired)
|
|
98
|
+
const one = uuids.length === 1
|
|
51
99
|
const forget = (done) =>
|
|
52
100
|
setBackendMap(siteDir, client.origin, 'retired', Object.fromEntries(Object.entries(retired).filter(([u]) => !done.includes(u))))
|
|
53
101
|
|
|
54
102
|
if (!args.includes('--yes')) {
|
|
55
103
|
if (isNonInteractive(args)) {
|
|
56
104
|
say.dim(
|
|
57
|
-
`! ${what} that pushes took out of the site's folder stay on the backend
|
|
58
|
-
'To delete them, push again with --yes, or from a terminal and answer.'
|
|
105
|
+
`! ${what} that pushes took out of the site's folder ${one ? 'stays' : 'stay'} on the backend. ` +
|
|
106
|
+
'To delete them, push again with --yes, or from a terminal and answer. ' +
|
|
107
|
+
"A record another site's folder still places is kept until none does."
|
|
59
108
|
)
|
|
60
|
-
return { deleted:
|
|
109
|
+
return { deleted: finished, kept: uuids.length, asked: false }
|
|
61
110
|
}
|
|
62
111
|
const yes = await ask(
|
|
63
|
-
`Delete ${what} that pushes took out of the site's folder from ${client.origin}? A record another site's folder places is kept.`,
|
|
112
|
+
`Delete ${what} that pushes took out of the site's folder from ${client.origin}? A record another site's folder places is kept until none does.`,
|
|
64
113
|
false
|
|
65
114
|
)
|
|
66
115
|
if (!yes) {
|
|
67
116
|
forget(uuids)
|
|
68
|
-
say.dim('Kept them on the backend
|
|
69
|
-
return { deleted:
|
|
117
|
+
say.dim('Kept them on the backend. They are not asked about again.')
|
|
118
|
+
return { deleted: finished, kept: uuids.length, asked: true }
|
|
70
119
|
}
|
|
71
120
|
}
|
|
72
121
|
|
|
@@ -75,12 +124,12 @@ export async function settleRetiredRecords({ client, siteDir, args = [], say, as
|
|
|
75
124
|
res = await client.deleteEntities({ uuids, placed: 'keep' })
|
|
76
125
|
} catch (err) {
|
|
77
126
|
say.warn(`Could not delete them: ${err?.message || err}. They stay on the backend; the next push asks again.`)
|
|
78
|
-
return { deleted:
|
|
127
|
+
return { deleted: finished, kept: uuids.length, asked: true }
|
|
79
128
|
}
|
|
80
129
|
if (res.status === 404) {
|
|
81
130
|
// A backend older than its delete route: they wait for one that has it.
|
|
82
|
-
say.dim(`! ${client.origin} cannot delete records from the CLI yet, so they stay
|
|
83
|
-
return { deleted:
|
|
131
|
+
say.dim(`! ${client.origin} cannot delete records from the CLI yet, so they stay on the backend.`)
|
|
132
|
+
return { deleted: finished, kept: uuids.length, asked: true }
|
|
84
133
|
}
|
|
85
134
|
const body = await res.json().catch(() => null)
|
|
86
135
|
if (!res.ok) {
|
|
@@ -88,18 +137,23 @@ export async function settleRetiredRecords({ client, siteDir, args = [], say, as
|
|
|
88
137
|
// nothing was deleted, and asking again would be refused again.
|
|
89
138
|
say.warn(
|
|
90
139
|
`${client.origin} did not delete them: HTTP ${res.status}${body?.detail ? ` — ${body.detail}` : ''}. ` +
|
|
91
|
-
'They stay on the backend
|
|
140
|
+
'They stay on the backend; delete them in the app if they should go.'
|
|
92
141
|
)
|
|
93
142
|
forget(uuids)
|
|
94
|
-
return { deleted:
|
|
143
|
+
return { deleted: finished, kept: uuids.length, asked: true }
|
|
95
144
|
}
|
|
96
145
|
const deleted = Array.isArray(body?.deleted) ? body.deleted : []
|
|
97
|
-
const kept = Array.isArray(body?.kept) ? body.kept : []
|
|
98
|
-
if (deleted.length) say.ok(`Deleted ${deleted.length
|
|
146
|
+
const kept = (Array.isArray(body?.kept) ? body.kept : []).filter((u) => retired[u])
|
|
147
|
+
if (deleted.length) say.ok(`Deleted ${records(deleted.length)} from the backend.`)
|
|
99
148
|
if (kept.length) {
|
|
100
|
-
|
|
149
|
+
// Chosen for deletion, and kept for another site's folder: deleted at a later push, once none
|
|
150
|
+
// places it (`finishDeleting`).
|
|
151
|
+
const pending = readBackendState(siteDir, client.origin).deleting || {}
|
|
152
|
+
setBackendMap(siteDir, client.origin, 'deleting', { ...pending, ...Object.fromEntries(kept.map((u) => [u, retired[u]])) })
|
|
153
|
+
const it = kept.length === 1 ? 'it' : 'them'
|
|
154
|
+
say.dim(`Kept ${records(kept.length)}: another site's folder still places ${it}. A later push deletes ${it} once none does.`)
|
|
101
155
|
}
|
|
102
|
-
// Every uuid is settled: deleted,
|
|
156
|
+
// Every uuid is settled: deleted, held to delete once no folder places it, or naming nothing any more.
|
|
103
157
|
forget(uuids)
|
|
104
|
-
return { deleted: deleted.length, kept: kept.length, asked: true }
|
|
158
|
+
return { deleted: finished + deleted.length, kept: kept.length, asked: true }
|
|
105
159
|
}
|
package/src/utils/site-roots.js
CHANGED
|
@@ -21,7 +21,7 @@ import yaml from 'js-yaml'
|
|
|
21
21
|
import { siteContentRoots } from '@uniweb/build/uwx'
|
|
22
22
|
import { mountEntriesOf } from '@uniweb/build/site'
|
|
23
23
|
import { mountHolding } from './mounted-repositories.js'
|
|
24
|
-
import { repoOf } from './sync-point.js'
|
|
24
|
+
import { fileAt, repoOf } from './sync-point.js'
|
|
25
25
|
|
|
26
26
|
function readSiteYml(siteDir) {
|
|
27
27
|
try {
|
|
@@ -64,6 +64,65 @@ export function laneRoots(siteDir) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* ⭐ HOW FAR ABOVE ITS REPOSITORY THE SITE REACHES: the most directories above the repository's top
|
|
69
|
+
* that one of the site's relative paths climbs, `site.yml`'s `paths:` and its `file:` and `link:`
|
|
70
|
+
* dependencies, as this copy holds them and as `rev` does. A pull's stand-in mirrors that far up
|
|
71
|
+
* (`openStandIn`), so a records or pages mount in a repository beside the site's resolves there as in
|
|
72
|
+
* the project. ⛔ Until 2026-11-10 none did: a records mount there stopped every pull, and `status`,
|
|
73
|
+
* with "not a directory here", and a pages mount there failed the pull's re-bank, so the next push
|
|
74
|
+
* sent the whole site again.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} siteDir
|
|
77
|
+
* @param {object|null} repo - `repoOf(siteDir)`
|
|
78
|
+
* @param {string|null} [rev] - the commit the stand-in is filled from
|
|
79
|
+
* @returns {number}
|
|
80
|
+
*/
|
|
81
|
+
export function levelsAboveRepository(siteDir, repo, rev = null) {
|
|
82
|
+
if (!repo) return 0
|
|
83
|
+
const depth = repo.prefix.split('/').filter(Boolean).length
|
|
84
|
+
const climbOf = (path) => {
|
|
85
|
+
const p = typeof path === 'string' ? path.trim() : ''
|
|
86
|
+
if (!p || isAbsolute(p)) return 0
|
|
87
|
+
let level = depth
|
|
88
|
+
let low = depth
|
|
89
|
+
for (const segment of p.split(/[\\/]+/)) {
|
|
90
|
+
if (segment === '..') low = Math.min(low, --level)
|
|
91
|
+
else if (segment && segment !== '.') level++
|
|
92
|
+
}
|
|
93
|
+
return Math.max(0, -low)
|
|
94
|
+
}
|
|
95
|
+
const parsed = (text, parse) => {
|
|
96
|
+
try {
|
|
97
|
+
return text == null ? null : parse(String(text))
|
|
98
|
+
} catch {
|
|
99
|
+
return null // unreadable: it names no path
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const here = (name) => {
|
|
103
|
+
try {
|
|
104
|
+
return readFileSync(join(siteDir, name), 'utf8')
|
|
105
|
+
} catch {
|
|
106
|
+
return null
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const copies = [[here('site.yml'), here('package.json')]]
|
|
110
|
+
if (rev) copies.push([fileAt(repo, rev, 'site.yml'), fileAt(repo, rev, 'package.json')])
|
|
111
|
+
const paths = []
|
|
112
|
+
for (const [siteYml, packageJson] of copies) {
|
|
113
|
+
for (const value of Object.values(parsed(siteYml, (t) => yaml.load(t))?.paths || {})) {
|
|
114
|
+
paths.push(typeof value === 'string' ? value : value?.path)
|
|
115
|
+
}
|
|
116
|
+
const pkg = parsed(packageJson, (t) => JSON.parse(t))
|
|
117
|
+
for (const field of ['dependencies', 'devDependencies', 'optionalDependencies']) {
|
|
118
|
+
for (const spec of Object.values(pkg?.[field] || {})) {
|
|
119
|
+
if (typeof spec === 'string' && /^(file|link):/.test(spec)) paths.push(spec.replace(/^(file|link):/, ''))
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return Math.max(0, ...paths.map(climbOf))
|
|
124
|
+
}
|
|
125
|
+
|
|
67
126
|
/**
|
|
68
127
|
* The submodules that hold a mounted folder, each by its path relative to the site: the commit the
|
|
69
128
|
* site's repository records for one is the site's to commit, and `uniweb status` reads a pin that
|
package/src/utils/sync-point.js
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
mkdtempSync,
|
|
43
43
|
readdirSync,
|
|
44
44
|
readFileSync,
|
|
45
|
+
realpathSync,
|
|
45
46
|
rmSync,
|
|
46
47
|
statSync,
|
|
47
48
|
symlinkSync,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
writeFileSync
|
|
50
51
|
} from 'node:fs'
|
|
51
52
|
import { tmpdir } from 'node:os'
|
|
52
|
-
import { join, dirname, posix } from 'node:path'
|
|
53
|
+
import { join, basename, dirname, posix, sep } from 'node:path'
|
|
53
54
|
|
|
54
55
|
export const SYNC_TRAILER = 'Uniweb-Sync'
|
|
55
56
|
export const SITE_TRAILER = 'Uniweb-Site'
|
|
@@ -460,6 +461,13 @@ export function nestedBase(repo, siteBase, { at, sub, roots }) {
|
|
|
460
461
|
* site's `sync.json` and `.uniweb/`, which are copies (written there, and taken back by the
|
|
461
462
|
* caller). The stand-in lives outside the project.
|
|
462
463
|
*
|
|
464
|
+
* ⭐ AND WHAT IS AROUND THE REPOSITORY, `above` directories up: the repository stands that deep,
|
|
465
|
+
* under directories named as its parents, each holding links to what is beside it there. So a path
|
|
466
|
+
* leading out of the repository, a records or pages mount in a repository beside it, resolves as in
|
|
467
|
+
* the project too. With `above` 0 the stand-in is the repository's alone. ⛔ Until 2026-11-10 it
|
|
468
|
+
* always was: such a path resolved under the temporary folder, which stopped every pull of a site
|
|
469
|
+
* mounting another repository's records ("not a directory here").
|
|
470
|
+
*
|
|
463
471
|
* ⛔ CLOSE IT. `close()` unlinks every link it made before removing the rest — a recursive
|
|
464
472
|
* remove that followed one would delete the project's own files.
|
|
465
473
|
*
|
|
@@ -481,9 +489,11 @@ export function nestedBase(repo, siteBase, { at, sub, roots }) {
|
|
|
481
489
|
* each submodule a writable mount is in: its `repoOf`, its path from the site repository's top,
|
|
482
490
|
* the mounted folders in it (relative to its own top), the commit they are filled from, and the
|
|
483
491
|
* one a commit of them is made onto (null: none, an unrelated history)
|
|
492
|
+
* @param {number} [opts.above] - how many directories above the repository's top to mirror: as far
|
|
493
|
+
* as the site's relative paths climb (`levelsAboveRepository`, `utils/site-roots.js`)
|
|
484
494
|
* @returns {{ siteDir: string, commit: Function, changes: Function, placeIgnored: Function, close: Function }}
|
|
485
495
|
*/
|
|
486
|
-
export function openStandIn(repo, { roots, rev, nested = [] }) {
|
|
496
|
+
export function openStandIn(repo, { roots, rev, nested = [], above = 0 }) {
|
|
487
497
|
// ⭐ A root is named relative to the site and held by the repository, so one outside the site's
|
|
488
498
|
// folder — a mounted folder elsewhere in the repository — is filled and committed like the rest.
|
|
489
499
|
// One outside the repository is in no commit of it. ⛔ Until 2026-11-04 every root leading out of
|
|
@@ -494,7 +504,19 @@ export function openStandIn(repo, { roots, rev, nested = [] }) {
|
|
|
494
504
|
throw new Error(`the content root \`${r}\` is outside the site's repository, so a pull cannot merge it`)
|
|
495
505
|
}
|
|
496
506
|
})
|
|
497
|
-
const
|
|
507
|
+
const base = mkdtempSync(join(tmpdir(), 'uniweb-stand-in-'))
|
|
508
|
+
// The directories above the repository the stand-in mirrors, nearest first, each with the name of
|
|
509
|
+
// the one below it on the way down; `base` stands for the farthest, and the repository's own stand-in
|
|
510
|
+
// is named as it is, under them.
|
|
511
|
+
const around = []
|
|
512
|
+
for (let real = repo.top; around.length < above && dirname(real) !== real; real = dirname(real)) {
|
|
513
|
+
around.push({ dir: dirname(real), child: basename(real) })
|
|
514
|
+
}
|
|
515
|
+
let root = base
|
|
516
|
+
for (let k = around.length - 1; k >= 0; k--) {
|
|
517
|
+
around[k].stand = root
|
|
518
|
+
root = join(root, around[k].child)
|
|
519
|
+
}
|
|
498
520
|
const indexDir = mkdtempSync(join(tmpdir(), 'uniweb-stand-in-index-'))
|
|
499
521
|
const env = { GIT_INDEX_FILE: join(indexDir, 'index') }
|
|
500
522
|
const at = (args, opts = {}) =>
|
|
@@ -523,7 +545,7 @@ export function openStandIn(repo, { roots, rev, nested = [] }) {
|
|
|
523
545
|
/* already gone */
|
|
524
546
|
}
|
|
525
547
|
}
|
|
526
|
-
rmSync(
|
|
548
|
+
rmSync(base, { recursive: true, force: true })
|
|
527
549
|
rmSync(indexDir, { recursive: true, force: true })
|
|
528
550
|
}
|
|
529
551
|
|
|
@@ -597,6 +619,34 @@ export function openStandIn(repo, { roots, rev, nested = [] }) {
|
|
|
597
619
|
} else link(real, stand, name)
|
|
598
620
|
}
|
|
599
621
|
}
|
|
622
|
+
// What is beside the repository, and beside each directory above it, as far up as `around` goes.
|
|
623
|
+
const realBase = realpathSync(base)
|
|
624
|
+
for (const { dir, child, stand } of around) {
|
|
625
|
+
mkdirSync(stand, { recursive: true })
|
|
626
|
+
let names = []
|
|
627
|
+
try {
|
|
628
|
+
names = readdirSync(dir)
|
|
629
|
+
} catch {
|
|
630
|
+
continue // unreadable: nothing resolves through it in the project either
|
|
631
|
+
}
|
|
632
|
+
for (const name of names) {
|
|
633
|
+
if (name === child) continue
|
|
634
|
+
let target
|
|
635
|
+
try {
|
|
636
|
+
target = realpathSync(join(dir, name))
|
|
637
|
+
} catch {
|
|
638
|
+
continue
|
|
639
|
+
}
|
|
640
|
+
// ⛔ Never the stand-in itself, nor a folder holding it: a link back into it is a loop.
|
|
641
|
+
if (target === realBase || realBase.startsWith(`${target}${sep}`)) continue
|
|
642
|
+
try {
|
|
643
|
+
link(join(dir, name), join(stand, name), name)
|
|
644
|
+
} catch {
|
|
645
|
+
// One the system will not link (macOS refuses a protected folder, `TemporaryItems`) is left
|
|
646
|
+
// out: only a path through it would miss it, as every such path did before.
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
600
650
|
mirror(repo.top, root, '')
|
|
601
651
|
if (sitePath) mkdirSync(join(root, sitePath), { recursive: true })
|
|
602
652
|
|