uniweb 1.31.9 → 1.31.11
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 +6 -6
- package/partials/agents.md +1 -0
- package/partials/guides/data.md +1 -1
- package/src/backend/foundation-bring-along.js +19 -4
- package/src/commands/push.js +3 -0
- package/src/commands/update.js +7 -5
- package/src/framework-index.json +4 -4
- package/src/utils/pm.js +18 -0
- package/src/utils/retired-records.js +79 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniweb",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.11",
|
|
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/semantic-parser": "~1.13.2",
|
|
44
|
+
"@uniweb/content-writer": "~1.3.1",
|
|
46
45
|
"@uniweb/schemas": "~1.7.1",
|
|
47
|
-
"@uniweb/
|
|
46
|
+
"@uniweb/core": "~1.6.12",
|
|
47
|
+
"@uniweb/semantic-parser": "~1.13.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
+
"@uniweb/build": "~1.20.9",
|
|
50
51
|
"@uniweb/content-reader": "~1.5.9",
|
|
51
|
-
"@uniweb/semantic-parser": "~1.13.2"
|
|
52
|
-
"@uniweb/build": "~1.20.8"
|
|
52
|
+
"@uniweb/semantic-parser": "~1.13.2"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@uniweb/build": {
|
package/partials/agents.md
CHANGED
|
@@ -103,6 +103,7 @@ When a rule in §2 feels like friction, that is the moment you are about to take
|
|
|
103
103
|
| `<a href="/about">` | `<Link to="page:about">` (an `id:` survives moves) or `<Link href="/about">`. A bare `<a>` still routes but resolves no `page:` and adds no base path or locale. | silent |
|
|
104
104
|
| `window.location.href = '/fr'` to switch language | `<Link reload href={website.getLocaleUrl('fr')}>` or `website.switchLocale('fr')`. | base-path bug |
|
|
105
105
|
| `useEffect(() => fetch(…))` for records | Declare the key in `meta.js data:`; it arrives in `content.data`, prerendered. | prerenders as loading |
|
|
106
|
+
| `new Date()`, `Date.now()` or `Math.random()` while rendering: a calendar file's `DTSTAMP`, an id | A section renders in the build and again in the browser, so take it from content: the record's date, its `$name`. Only what follows the visitor's clock (open now, upcoming) reads the clock. | silent: each build writes its own time into the pages |
|
|
106
107
|
| `<Icon icon="lu-send" />` for an icon your section always shows | Import it (`uniweb guide foundation` § Icon). A name is for an icon content supplies at runtime: markdown, a param, a record's field. | silent; blank until the browser fetches it |
|
|
107
108
|
| A `Button` or `Card` in `sections/` | `components/`. Everything at the root of `sections/` becomes author vocabulary. | appears in the section picker |
|
|
108
109
|
| Helpers that take `{ content, params }` | Ordinary props. That signature is for section types only. | — |
|
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. 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/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/commands/update.js
CHANGED
|
@@ -56,6 +56,7 @@ import { isNonInteractive } from '../utils/interactive.js'
|
|
|
56
56
|
import {
|
|
57
57
|
detectWorkspacePm,
|
|
58
58
|
installCmd,
|
|
59
|
+
installAfterEditCmd,
|
|
59
60
|
detectGlobalCliPm,
|
|
60
61
|
globalCliUpdateCmd
|
|
61
62
|
} from '../utils/pm.js'
|
|
@@ -501,7 +502,7 @@ export async function update(args = []) {
|
|
|
501
502
|
)
|
|
502
503
|
if (installPm) {
|
|
503
504
|
log(
|
|
504
|
-
`${colors.dim}Then would run:${colors.reset} ${colors.cyan}${
|
|
505
|
+
`${colors.dim}Then would run:${colors.reset} ${colors.cyan}${installAfterEditCmd(installPm)}${colors.reset}`
|
|
505
506
|
)
|
|
506
507
|
} else {
|
|
507
508
|
log(
|
|
@@ -549,7 +550,8 @@ export async function update(args = []) {
|
|
|
549
550
|
}
|
|
550
551
|
|
|
551
552
|
if (installPm) {
|
|
552
|
-
|
|
553
|
+
// Never frozen: the package.json files were just edited (`installAfterEditCmd`).
|
|
554
|
+
const cmd = installAfterEditCmd(installPm)
|
|
553
555
|
let runInstall
|
|
554
556
|
if (hasYes) {
|
|
555
557
|
runInstall = true
|
|
@@ -727,7 +729,7 @@ async function refreshAgents(ctx) {
|
|
|
727
729
|
// package.json. Refreshing the doc here would document features the
|
|
728
730
|
// installed code doesn't have. No override — run the install first.
|
|
729
731
|
if (depsEdited && !installRan) {
|
|
730
|
-
const cmd =
|
|
732
|
+
const cmd = installAfterEditCmd(installPm || 'pnpm')
|
|
731
733
|
warn(
|
|
732
734
|
'AGENTS.md refresh skipped: package.json was updated but not installed.'
|
|
733
735
|
)
|
|
@@ -841,11 +843,11 @@ export function printSummary({
|
|
|
841
843
|
)
|
|
842
844
|
if (installRan) {
|
|
843
845
|
log(
|
|
844
|
-
` ${colors.green}✓${colors.reset} ${
|
|
846
|
+
` ${colors.green}✓${colors.reset} ${installAfterEditCmd(installPm || 'pnpm')} completed`
|
|
845
847
|
)
|
|
846
848
|
} else {
|
|
847
849
|
log(
|
|
848
|
-
` ${colors.yellow}⚠${colors.reset} install NOT run — run ${colors.cyan}${
|
|
850
|
+
` ${colors.yellow}⚠${colors.reset} install NOT run — run ${colors.cyan}${installAfterEditCmd(installPm || 'pnpm')}${colors.reset} to apply`
|
|
849
851
|
)
|
|
850
852
|
}
|
|
851
853
|
}
|
package/src/framework-index.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-10T20:35:09.553Z",
|
|
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.8"
|
|
40
40
|
},
|
|
41
41
|
"@uniweb/scene": {
|
|
42
42
|
"version": "1.0.1"
|
package/src/utils/pm.js
CHANGED
|
@@ -160,6 +160,24 @@ export function installCmd(pm) {
|
|
|
160
160
|
return 'npm install'
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* The install to run right after a command edited the workspace's package.json files, and the one
|
|
165
|
+
* to tell someone to run then.
|
|
166
|
+
*
|
|
167
|
+
* ⭐ NEVER FROZEN. Wherever `CI` is set (a CI job, and the shell some agents run in) pnpm makes
|
|
168
|
+
* `install` frozen, and a frozen install refuses the package.json files the command just wrote.
|
|
169
|
+
* Measured 2026-11-10: `uniweb update --yes` with `CI=1` failed at its install every time, and the
|
|
170
|
+
* retry it printed failed the same way. npm's `install` is never frozen (`npm ci` is the frozen one).
|
|
171
|
+
* yarn is left as it is: berry's flag for this (`--no-immutable`) is not one classic yarn has.
|
|
172
|
+
*
|
|
173
|
+
* @param {'pnpm' | 'yarn' | 'npm'} pm
|
|
174
|
+
* @returns {string}
|
|
175
|
+
*/
|
|
176
|
+
export function installAfterEditCmd(pm) {
|
|
177
|
+
if (pm === 'pnpm') return 'pnpm install --no-frozen-lockfile'
|
|
178
|
+
return installCmd(pm)
|
|
179
|
+
}
|
|
180
|
+
|
|
163
181
|
/**
|
|
164
182
|
* Generate a run-script command.
|
|
165
183
|
* @param {'pnpm' | 'npm'} pm
|
|
@@ -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
|
}
|