uniweb 1.26.8 → 1.27.0
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 -1
- package/partials/guides/backend.md +5 -1
- package/partials/guides/content.md +4 -2
- package/src/backend/site-sync.js +86 -8
- package/src/commands/publish.js +13 -2
- package/src/commands/pull.js +267 -25
- package/src/commands/push.js +16 -2
- package/src/commands/refresh.js +5 -2
- package/src/commands/status.js +35 -35
- package/src/framework-index.json +6 -6
- package/src/utils/git.js +3 -60
- package/src/utils/mounted-repositories.js +65 -10
- package/src/utils/site-roots.js +175 -0
- package/src/utils/sync-point.js +260 -46
package/src/commands/pull.js
CHANGED
|
@@ -71,7 +71,8 @@ import {
|
|
|
71
71
|
statSync
|
|
72
72
|
} from 'node:fs'
|
|
73
73
|
import { createInterface } from 'node:readline/promises'
|
|
74
|
-
import { join, dirname, relative, resolve } from 'node:path'
|
|
74
|
+
import { join, dirname, relative, resolve, posix } from 'node:path'
|
|
75
|
+
import { execFileSync } from 'node:child_process'
|
|
75
76
|
import yaml from 'js-yaml'
|
|
76
77
|
import { downloadMissingAssets, downloadFileRecords } from '../backend/asset-download.js'
|
|
77
78
|
import {
|
|
@@ -103,6 +104,9 @@ import {
|
|
|
103
104
|
mergeBaseVersions,
|
|
104
105
|
writeItemBaseVersions,
|
|
105
106
|
pulledItemVersions,
|
|
107
|
+
readItemUuids,
|
|
108
|
+
writeHeldUnits,
|
|
109
|
+
heldUnitBaseline,
|
|
106
110
|
writeUnitBases,
|
|
107
111
|
commitWriteBacks,
|
|
108
112
|
reportWriteBacks,
|
|
@@ -112,7 +116,7 @@ import {
|
|
|
112
116
|
readItemBaseVersions
|
|
113
117
|
} from '../backend/site-sync.js'
|
|
114
118
|
import { resolveWorkspace } from '../backend/workspace.js'
|
|
115
|
-
import {
|
|
119
|
+
import { siteRoots, sentRoots, laneRoots, writableMounts, refusedMountLines, heldMountLines } from '../utils/site-roots.js'
|
|
116
120
|
import {
|
|
117
121
|
repoOf,
|
|
118
122
|
mergeInProgress,
|
|
@@ -127,6 +131,9 @@ import {
|
|
|
127
131
|
openStandIn,
|
|
128
132
|
fileAt,
|
|
129
133
|
mergeSyncPoint,
|
|
134
|
+
mergeStopper,
|
|
135
|
+
nestedBase,
|
|
136
|
+
recordNestedPins,
|
|
130
137
|
takeSyncPoint,
|
|
131
138
|
snapshotFiles,
|
|
132
139
|
changedInFiles,
|
|
@@ -134,7 +141,7 @@ import {
|
|
|
134
141
|
readSyncPoint,
|
|
135
142
|
writeSyncPoint
|
|
136
143
|
} from '../utils/sync-point.js'
|
|
137
|
-
import { behindLines } from '../utils/mounted-repositories.js'
|
|
144
|
+
import { behindLines, mountedRepositories } from '../utils/mounted-repositories.js'
|
|
138
145
|
import { isNonInteractive } from '../utils/interactive.js'
|
|
139
146
|
import {
|
|
140
147
|
BackendClient,
|
|
@@ -504,6 +511,37 @@ function filesUnder(siteDir, roots) {
|
|
|
504
511
|
return out
|
|
505
512
|
}
|
|
506
513
|
|
|
514
|
+
// ⭐ A VERSION IS BANKED FOR WHAT THE FILES TOOK, OR CHOSE NOT TO TAKE.
|
|
515
|
+
// - A page held because its files cannot say the app's change (`leftOut`) gets NO version: a push leaves
|
|
516
|
+
// it out while its files still say what they said (`heldUnitBaseline`), and the backend keeps an item a
|
|
517
|
+
// push holds no version for. ⛔ Until 2026-11-04 it kept the version this copy last agreed on, so a copy
|
|
518
|
+
// that never agreed on one — a fresh clone, CI — banked the backend's, and its next push sent the file
|
|
519
|
+
// over the app's edit; and a section the app added there was banked, so that push deleted it.
|
|
520
|
+
// - A page of a mount the pull cannot merge into, or of a route the files give two pages for
|
|
521
|
+
// (`heldPages`), keeps the version this copy last agreed on, so the per-item gate keeps the backend's
|
|
522
|
+
// copy while the file is unchanged and refuses a push that changed it. One this copy never agreed on
|
|
523
|
+
// keeps the backend's: there is no agreement to hold.
|
|
524
|
+
export function agreedVersions(pulled, heldPages, prior, leftOut = []) {
|
|
525
|
+
const out = { ...pulled }
|
|
526
|
+
for (const { uuids } of heldPages || []) for (const u of uuids || []) if (prior?.[u]) out[u] = prior[u]
|
|
527
|
+
for (const { uuids } of leftOut || []) for (const u of uuids || []) delete out[u]
|
|
528
|
+
return out
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// The pages a push leaves out while their files say what they said at the pull: every page the pull held
|
|
532
|
+
// for what its files cannot say. Not a route the files give two pages for, which no push can leave out
|
|
533
|
+
// of the two the files send.
|
|
534
|
+
export function leftOutOfPush(heldPages) {
|
|
535
|
+
return (heldPages || []).filter(({ what }) => !(what || []).includes('two pages on one route'))
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// The mounted pages the backend holds at another version than this copy last agreed on, by route.
|
|
539
|
+
export function mountedPagesMoved(mountedPages, pulled, prior) {
|
|
540
|
+
return (mountedPages || [])
|
|
541
|
+
.filter(({ uuids }) => (uuids || []).some((u) => prior?.[u] && pulled?.[u] && prior[u] !== pulled[u]))
|
|
542
|
+
.map(({ route }) => route)
|
|
543
|
+
}
|
|
544
|
+
|
|
507
545
|
/**
|
|
508
546
|
* Outside git, refuse a pull that would overwrite unsaved work. Returns a result object to
|
|
509
547
|
* return from `pull`, or null to proceed.
|
|
@@ -515,7 +553,7 @@ function filesUnder(siteDir, roots) {
|
|
|
515
553
|
* terminal to ask, refused here, and `uniweb clone` could not finish.
|
|
516
554
|
*/
|
|
517
555
|
async function checkWorkingTree(siteDir, args) {
|
|
518
|
-
const roots =
|
|
556
|
+
const roots = siteRoots(siteDir, { media: false })
|
|
519
557
|
const written = readWritten(siteDir)
|
|
520
558
|
if (filesUnder(siteDir, roots).every((f) => isPullOutput(siteDir, f, written))) return null
|
|
521
559
|
// A folder the repository around it ignores is outside git too — said as such, since a
|
|
@@ -759,6 +797,34 @@ export async function pull(args = [], deps = {}) {
|
|
|
759
797
|
const blocked = await checkWorkingTree(siteDir, args)
|
|
760
798
|
if (blocked) return blocked
|
|
761
799
|
}
|
|
800
|
+
// ⭐ A MOUNT IS WRITTEN WHEREVER THIS COPY CAN MERGE IT, and its app edits held where it cannot
|
|
801
|
+
// (`writableMounts`) — never undone. One written in the retired object form stops the pull before
|
|
802
|
+
// anything is asked or taken, as it stops the build.
|
|
803
|
+
const mounts = writableMounts(siteDir)
|
|
804
|
+
if (mounts.refused.length) {
|
|
805
|
+
if (probe) return { exitCode: 1, probe: null }
|
|
806
|
+
error(`${mounts.refused.length === 1 ? 'A mount is' : `${mounts.refused.length} mounts are`} written in a form a pull no longer reads:`)
|
|
807
|
+
for (const m of mounts.refused) for (const line of refusedMountLines(m)) note(line)
|
|
808
|
+
return { exitCode: 1 }
|
|
809
|
+
}
|
|
810
|
+
// …and a submodule one is in merges too, so it is stopped by what would stop the site's merge.
|
|
811
|
+
if (repo && !dryRun && !probe) {
|
|
812
|
+
for (const m of mounts.submodules) {
|
|
813
|
+
const where = `${m.at}, the submodule pages/${m.segment} is mounted from`
|
|
814
|
+
if (mergeInProgress(m.repo)) {
|
|
815
|
+
error(`A merge is in progress in ${where}.`)
|
|
816
|
+
note('Finish it there (`git commit`) or abandon it (`git merge --abort`), then pull.')
|
|
817
|
+
return { exitCode: 1 }
|
|
818
|
+
}
|
|
819
|
+
const unsettled = unmergedPaths(m.repo)
|
|
820
|
+
if (unsettled.length) {
|
|
821
|
+
error(`${unsettled.length} file(s) in ${where} are in conflict:`)
|
|
822
|
+
for (const p of unsettled.slice(0, 12)) note(` ${p}`)
|
|
823
|
+
note('Settle them there first — `git status` says how — then pull.')
|
|
824
|
+
return { exitCode: 1 }
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
762
828
|
// ⭐ THE BACKEND YOU ARE LOGGED IN TO is where this goes *[Diego, 2026-09-21]*, for every
|
|
763
829
|
// backend verb (resolveBackendOrigin). Only UNIWEB_SERVER — the automation
|
|
764
830
|
// override — outranks it, and nothing talks to a backend the user is not logged in to:
|
|
@@ -916,9 +982,17 @@ export async function pull(args = [], deps = {}) {
|
|
|
916
982
|
let sections = 0
|
|
917
983
|
let records = 0
|
|
918
984
|
let deleted = 0
|
|
919
|
-
//
|
|
920
|
-
// pages (`@uniweb/build`'s `
|
|
985
|
+
// The pages a pull does not write — a mount's, a folder-mode `.md` page given what its file cannot
|
|
986
|
+
// hold, a route the files give two pages for (`@uniweb/build`'s `page-files.js`). Said, since an app
|
|
987
|
+
// edit to one does not come back; each `.md` page with what it could not hold.
|
|
921
988
|
let leftAlone = 0
|
|
989
|
+
// Its pages by outcome (`@uniweb/build`'s report): held at the version this copy last agreed on,
|
|
990
|
+
// and a mount's, which the folder wins.
|
|
991
|
+
let heldPages = []
|
|
992
|
+
let mountedPages = []
|
|
993
|
+
// A mount's own route the app renamed or removed, which `site.yml`'s `paths:` now says.
|
|
994
|
+
let mountRoutes = []
|
|
995
|
+
let mountedMoved = []
|
|
922
996
|
// Set when the folder lane carried records this pull did not place — see the ⛔
|
|
923
997
|
// where it is set.
|
|
924
998
|
let recordsNotPlaced = null
|
|
@@ -932,6 +1006,11 @@ export async function pull(args = [], deps = {}) {
|
|
|
932
1006
|
// only while the sync point it was banked with is.
|
|
933
1007
|
const cache = readPullCache(siteDir)
|
|
934
1008
|
const held = repo ? readSyncPoint(siteDir, client.origin) : null
|
|
1009
|
+
// The versions this copy agreed on before this pull — what a mount's held page keeps (`agreedVersions`).
|
|
1010
|
+
const priorVersions = readItemBaseVersions(siteDir, client.origin)
|
|
1011
|
+
// …and the identity it held, by the paths its files keep each item at: where a held page is found in
|
|
1012
|
+
// them though the app moved it (`heldUnitBaseline`). Read before the pull replaces it.
|
|
1013
|
+
const priorItems = readItemUuids(siteDir, client.origin)
|
|
935
1014
|
const cacheHolds = etagsHold(siteDir, client.origin, repo)
|
|
936
1015
|
let etagContent = cache.content
|
|
937
1016
|
let etagFolder = cache.folder
|
|
@@ -1082,11 +1161,15 @@ export async function pull(args = [], deps = {}) {
|
|
|
1082
1161
|
// the base as its merge base. `--force`, and a history with no sync point, write onto
|
|
1083
1162
|
// HEAD instead: the first to take the backend's whole, the second so a file both sides
|
|
1084
1163
|
// hold alike merges without a word.
|
|
1085
|
-
const roots =
|
|
1164
|
+
const roots = sentRoots(siteDir)
|
|
1086
1165
|
let base = null
|
|
1087
1166
|
let onto = null
|
|
1088
1167
|
let standIn = null
|
|
1089
1168
|
let siteMovedFrom = null
|
|
1169
|
+
// ⭐ Each writable mount in a submodule, merged in the submodule's own history from the commit the
|
|
1170
|
+
// site's base records for it (`nestedBase`). With no base there, it is filled from its checkout and
|
|
1171
|
+
// committed onto nothing, as the site is with none: a file both hold alike merges without a word.
|
|
1172
|
+
let nested = []
|
|
1090
1173
|
if (repo && projected) {
|
|
1091
1174
|
// The bases this copy knows of itself — then what the backend names, per lane.
|
|
1092
1175
|
const known = [
|
|
@@ -1095,14 +1178,14 @@ export async function pull(args = [], deps = {}) {
|
|
|
1095
1178
|
// What a sync point the branch no longer holds — a merge abandoned — was made onto.
|
|
1096
1179
|
...madeOnto(repo, held, { origin: client.origin, siteUuid: siteContentUuid })
|
|
1097
1180
|
]
|
|
1098
|
-
const
|
|
1181
|
+
const rootsOfLanes = laneRoots(siteDir)
|
|
1099
1182
|
const taken = (lane) => lane && !lane.notModified && !lane.refused
|
|
1100
1183
|
base = baseFor(repo, {
|
|
1101
1184
|
known,
|
|
1102
1185
|
// ⛔ What each lane the backend answered names is a base only where every lane holds it (`baseFor`).
|
|
1103
1186
|
lanes: [
|
|
1104
|
-
...(taken(content) ? [{ source: content.source, roots:
|
|
1105
|
-
...(taken(folderLane) ? [{ source: folderLane.source, roots:
|
|
1187
|
+
...(taken(content) ? [{ source: content.source, roots: rootsOfLanes.content }] : []),
|
|
1188
|
+
...(taken(folderLane) ? [{ source: folderLane.source, roots: rootsOfLanes.records }] : [])
|
|
1106
1189
|
],
|
|
1107
1190
|
origin: client.origin,
|
|
1108
1191
|
siteUuid: siteContentUuid
|
|
@@ -1113,8 +1196,12 @@ export async function pull(args = [], deps = {}) {
|
|
|
1113
1196
|
onto = force || !base ? repo.head : base
|
|
1114
1197
|
// Why there is no base, when it is a move. Read now: the sync point this pull makes names the new path.
|
|
1115
1198
|
if (!base) siteMovedFrom = movedFrom(repo, { origin: client.origin, siteUuid: siteContentUuid })
|
|
1199
|
+
nested = mounts.submodules.map((m) => {
|
|
1200
|
+
const own = force || !base ? null : nestedBase(repo, base, { at: m.at, sub: m.repo, roots: [m.root] })
|
|
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
|
+
})
|
|
1116
1203
|
try {
|
|
1117
|
-
standIn = openStandIn(repo, { roots, rev: onto })
|
|
1204
|
+
standIn = openStandIn(repo, { roots, rev: onto, nested })
|
|
1118
1205
|
} catch (err) {
|
|
1119
1206
|
error(`Could not merge the site: ${err.message}.`)
|
|
1120
1207
|
return { exitCode: 1 }
|
|
@@ -1186,7 +1273,9 @@ export async function pull(args = [], deps = {}) {
|
|
|
1186
1273
|
// So a query's `@acme/member` comes back as the author's `@/member`.
|
|
1187
1274
|
scope: pullScope,
|
|
1188
1275
|
dataModel,
|
|
1189
|
-
sectionType
|
|
1276
|
+
sectionType,
|
|
1277
|
+
// The mounts it may write into, each one the site declares writable (above).
|
|
1278
|
+
writableMounts: mounts.writable
|
|
1190
1279
|
})
|
|
1191
1280
|
wrote.push(...report.pages, ...report.sections, ...report.layout)
|
|
1192
1281
|
removed.push(
|
|
@@ -1197,7 +1286,29 @@ export async function pull(args = [], deps = {}) {
|
|
|
1197
1286
|
sections += report.sections.length
|
|
1198
1287
|
deleted += report.deleted.length
|
|
1199
1288
|
leftAlone += report.leftAlone?.length || 0
|
|
1289
|
+
heldPages = report.held || []
|
|
1290
|
+
mountedPages = report.mountedPages || []
|
|
1291
|
+
mountRoutes = report.mountRoutes || []
|
|
1292
|
+
mountedMoved = mountedPagesMoved(mountedPages, pulledVersions, priorVersions)
|
|
1200
1293
|
outsideLanguages = report.outsideLanguages || []
|
|
1294
|
+
// ⭐ WHAT IT HELD, AS THE FILES KEEP IT — where each held page is in the files it wrote into, the
|
|
1295
|
+
// stand-in in a repository, and what they say there — for a push to leave out while they still
|
|
1296
|
+
// say it (`readHeldUnits`). Replaced by each pull that takes the site's content. In the stand-in's
|
|
1297
|
+
// cache, which comes back to the site with the others.
|
|
1298
|
+
try {
|
|
1299
|
+
writeHeldUnits(projDir, client.origin, await heldUnitBaseline(projDir, client.origin, {
|
|
1300
|
+
held: leftOutOfPush(heldPages).flatMap((h) => h.uuids || []),
|
|
1301
|
+
// Where this copy kept each item before the pull, over where the backend keeps it — the same
|
|
1302
|
+
// place for a page the app did not move, and the one a `sync.json` without items still has.
|
|
1303
|
+
itemUuids: { ...collectUnitUuids(siteDoc), ...priorItems },
|
|
1304
|
+
...(declarations.size ? { declarations } : {}),
|
|
1305
|
+
fields
|
|
1306
|
+
}))
|
|
1307
|
+
} catch (err) {
|
|
1308
|
+
// The files did not emit: neither will a push from them, which this pull leaves to say why.
|
|
1309
|
+
writeHeldUnits(projDir, client.origin, {})
|
|
1310
|
+
note(`! could not record the pages this pull held: ${err.message}`)
|
|
1311
|
+
}
|
|
1201
1312
|
}
|
|
1202
1313
|
|
|
1203
1314
|
if (folderTaken) {
|
|
@@ -1293,6 +1404,10 @@ export async function pull(args = [], deps = {}) {
|
|
|
1293
1404
|
probe: {
|
|
1294
1405
|
files: standIn.changes(),
|
|
1295
1406
|
itemsBehind,
|
|
1407
|
+
// By route: the mounted pages the backend moved, which the next push puts back, and the pages
|
|
1408
|
+
// held because their files cannot say what the app made of them.
|
|
1409
|
+
mountedMoved,
|
|
1410
|
+
held: heldPages.map(({ route, what }) => ({ route, what })),
|
|
1296
1411
|
recordsNotPlaced: Boolean(recordsNotPlaced),
|
|
1297
1412
|
...(base ? {} : { noBase: true, movedFrom: siteMovedFrom })
|
|
1298
1413
|
}
|
|
@@ -1339,7 +1454,8 @@ export async function pull(args = [], deps = {}) {
|
|
|
1339
1454
|
recordDocs: pulledRecordDocs,
|
|
1340
1455
|
...(declarations.size ? { declarations } : {}),
|
|
1341
1456
|
fields,
|
|
1342
|
-
contentTaken: Boolean(siteDoc)
|
|
1457
|
+
contentTaken: Boolean(siteDoc),
|
|
1458
|
+
contentAgreed: !heldPages.length && !mountedMoved.length
|
|
1343
1459
|
})
|
|
1344
1460
|
} catch (err) {
|
|
1345
1461
|
note(`! could not re-bank the sync cache: ${err.message}`)
|
|
@@ -1379,9 +1495,43 @@ export async function pull(args = [], deps = {}) {
|
|
|
1379
1495
|
} else {
|
|
1380
1496
|
// The files as they are, to tell what the pull changes in them from what they held.
|
|
1381
1497
|
const files = snapshotFiles(repo)
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1498
|
+
// ⭐ EVERY REPOSITORY'S MERGE IS CHECKED BEFORE ANY IS MADE — each writable mount's submodule,
|
|
1499
|
+
// then the site's: one that cannot take its merge leaves every other as it was. Then each
|
|
1500
|
+
// submodule's is made, then the site's, whose commit records the one made in each.
|
|
1501
|
+
const subs = (made.nested || [])
|
|
1502
|
+
.filter((n) => n.commit)
|
|
1503
|
+
.map((n) => ({ ...n, segment: nested.find((x) => x.at === n.at)?.segment, before: n.repo.head, files: snapshotFiles(n.repo) }))
|
|
1504
|
+
let result = null
|
|
1505
|
+
if (!force) {
|
|
1506
|
+
for (const n of subs) {
|
|
1507
|
+
const stopped = mergeStopper(n.repo, n.commit)
|
|
1508
|
+
if (stopped) {
|
|
1509
|
+
result = { ...stopped, where: n.at }
|
|
1510
|
+
break
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
if (!result) result = mergeStopper(repo, made.commit, { roots })
|
|
1514
|
+
}
|
|
1515
|
+
if (!result) {
|
|
1516
|
+
for (const n of subs) {
|
|
1517
|
+
n.result = force
|
|
1518
|
+
? takeSyncPoint(n.repo, n.commit, { roots: n.roots, message: 'Take the edits made in the app' })
|
|
1519
|
+
: mergeSyncPoint(n.repo, n.commit, { message: 'Merge the edits made in the app' })
|
|
1520
|
+
if (!n.result.ok) {
|
|
1521
|
+
result = { ...n.result, where: n.at }
|
|
1522
|
+
break
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
if (!result) {
|
|
1527
|
+
result = force
|
|
1528
|
+
? takeSyncPoint(repo, made.commit, { roots, message: takenFrom(client.origin) })
|
|
1529
|
+
: mergeSyncPoint(repo, made.commit, { message: mergedFrom(client.origin), roots })
|
|
1530
|
+
}
|
|
1531
|
+
// A path in a submodule, as the person reads it: from the site's folder.
|
|
1532
|
+
const fromSite = (p) => posix.relative(repo.path === '.' ? '.' : repo.path, p) || '.'
|
|
1533
|
+
const there = result.where ? ` in ${fromSite(result.where)}, a submodule a writable mount is in` : ''
|
|
1534
|
+
const named = (p) => (result.where ? fromSite(posix.join(result.where, p)) : p)
|
|
1385
1535
|
if (!result.ok) {
|
|
1386
1536
|
// ⛔ A merge that could not be made took nothing: the files are as they were, and
|
|
1387
1537
|
// nothing of this pull is recorded as taken.
|
|
@@ -1389,24 +1539,46 @@ export async function pull(args = [], deps = {}) {
|
|
|
1389
1539
|
restore(syncFile, before.sync)
|
|
1390
1540
|
restore(cacheFile, before.cache)
|
|
1391
1541
|
if (result.reason === 'untracked') {
|
|
1392
|
-
error(`Not merged — the backend's content would overwrite ${result.paths.length} file(s) that are not committed:`)
|
|
1393
|
-
for (const p of result.paths.slice(0, 12)) note(` ${p}`)
|
|
1542
|
+
error(`Not merged — the backend's content would overwrite ${result.paths.length} file(s)${there} that are not committed:`)
|
|
1543
|
+
for (const p of result.paths.slice(0, 12)) note(` ${named(p)}`)
|
|
1394
1544
|
if (result.paths.length > 12) note(` … and ${result.paths.length - 12} more`)
|
|
1395
1545
|
note('Commit them, or move them aside, then pull again.')
|
|
1396
1546
|
} else if (result.reason === 'merge-in-progress') {
|
|
1397
|
-
error(
|
|
1547
|
+
error(`A merge is in progress${there || ' here'}.`)
|
|
1398
1548
|
note('Finish it (`git commit`) or abandon it (`git merge --abort`), then pull.')
|
|
1399
1549
|
} else if (result.reason === 'unmerged') {
|
|
1400
|
-
error(`${result.paths.length} file(s) here are in conflict:`)
|
|
1401
|
-
for (const p of result.paths.slice(0, 12)) note(` ${p}`)
|
|
1550
|
+
error(`${result.paths.length} file(s)${there || ' here'} are in conflict:`)
|
|
1551
|
+
for (const p of result.paths.slice(0, 12)) note(` ${named(p)}`)
|
|
1402
1552
|
note('Settle them first — `git status` says how — then pull.')
|
|
1403
1553
|
} else {
|
|
1404
|
-
error(
|
|
1554
|
+
error(`Could not merge the backend's content${there}:`)
|
|
1405
1555
|
for (const line of String(result.detail).split('\n').slice(0, 8)) note(` ${line}`)
|
|
1406
1556
|
}
|
|
1407
1557
|
} else {
|
|
1408
1558
|
merge.conflicted = result.conflicted || []
|
|
1409
1559
|
merge.stashKept = Boolean(result.stashKept)
|
|
1560
|
+
// ⭐ Each submodule's merge, recorded as the site's pin (`recordNestedPins`).
|
|
1561
|
+
if (subs.length) {
|
|
1562
|
+
const recorded = recordNestedPins(
|
|
1563
|
+
repo,
|
|
1564
|
+
subs.map((n) => ({ at: n.at, repo: n.repo, conflicted: n.result.conflicted || [] })),
|
|
1565
|
+
{ message: (at, head) => `${repo.path}: ${at} at ${head.slice(0, 7)}, with the edits made in the app` }
|
|
1566
|
+
)
|
|
1567
|
+
if (recorded.error) note(`! The site's pin of a submodule is not recorded: ${recorded.error}`)
|
|
1568
|
+
const siteNow = unmergedPaths(repo)
|
|
1569
|
+
if (recorded.concluded && siteNow.length) merge.stashKept = true
|
|
1570
|
+
merge.conflicted = [...siteNow, ...subs.flatMap((n) => (n.result.conflicted || []).map((p) => posix.join(n.at, p)))]
|
|
1571
|
+
merge.nested = subs.map((n) => ({
|
|
1572
|
+
at: n.at,
|
|
1573
|
+
segment: n.segment,
|
|
1574
|
+
files: n.files,
|
|
1575
|
+
before: n.before,
|
|
1576
|
+
repo: n.repo,
|
|
1577
|
+
conflicted: n.result.conflicted || [],
|
|
1578
|
+
stashKept: Boolean(n.result.stashKept),
|
|
1579
|
+
pin: recorded.pins.find((p) => p.at === n.at)
|
|
1580
|
+
}))
|
|
1581
|
+
}
|
|
1410
1582
|
// Whether anything was set aside for the merge: the files as they were, against HEAD.
|
|
1411
1583
|
merge.setAside = files !== repo.head
|
|
1412
1584
|
merge.noBase = !force && !base
|
|
@@ -1414,9 +1586,15 @@ export async function pull(args = [], deps = {}) {
|
|
|
1414
1586
|
merge.changed = changedInFiles(repo, {
|
|
1415
1587
|
from: repo.head,
|
|
1416
1588
|
files,
|
|
1589
|
+
roots,
|
|
1417
1590
|
staged: merge.conflicted.length > 0 && !merge.stashKept,
|
|
1418
1591
|
skip: merge.conflicted
|
|
1419
1592
|
})
|
|
1593
|
+
// …and what each submodule's merge changed in its folders, from the site's folder.
|
|
1594
|
+
for (const n of merge.nested || []) {
|
|
1595
|
+
const changed = changedInFiles(n.repo, { from: n.before, files: n.files, staged: n.conflicted.length > 0 && !n.stashKept, skip: n.conflicted })
|
|
1596
|
+
merge.changed.push(...changed.map(([st, p]) => [st, fromSite(posix.join(n.at, p))]))
|
|
1597
|
+
}
|
|
1420
1598
|
writeSyncPoint(siteDir, client.origin, made.commit)
|
|
1421
1599
|
}
|
|
1422
1600
|
}
|
|
@@ -1462,7 +1640,12 @@ export async function pull(args = [], deps = {}) {
|
|
|
1462
1640
|
// again, asking the backend to delete it. The folder lane's are not kept — that lane
|
|
1463
1641
|
// is gated by its entity version. (Both were merged into one map until 2026-10-07.)
|
|
1464
1642
|
if (pulledVersions && content && !content.notModified && !content.refused) {
|
|
1465
|
-
|
|
1643
|
+
// ⭐ Held where the files cannot take the app's change: a page they cannot say, and each page of a
|
|
1644
|
+
// mount the pull could not write. ⛔ Until 2026-11-04 a mount's took the backend's version, and the
|
|
1645
|
+
// next push put the folder's back over the app's edit.
|
|
1646
|
+
const leftOut = leftOutOfPush(heldPages)
|
|
1647
|
+
const keptAt = [...heldPages.filter((h) => !leftOut.includes(h)), ...mountedPages]
|
|
1648
|
+
writeItemBaseVersions(siteDir, client.origin, agreedVersions(pulledVersions, keptAt, priorVersions, leftOut))
|
|
1466
1649
|
}
|
|
1467
1650
|
// Persist the ETags so the next pull is conditional (304 when unchanged). The
|
|
1468
1651
|
// folder's is DROPPED when records were not placed, so the next pull fetches
|
|
@@ -1481,11 +1664,33 @@ export async function pull(args = [], deps = {}) {
|
|
|
1481
1664
|
(deleted ? `, ${deleted} deleted` : '')
|
|
1482
1665
|
if (notTaken || recordsNotPlaced) info(summary)
|
|
1483
1666
|
else success(summary)
|
|
1667
|
+
// ⭐ Said, since it edits `site.yml`: the route is the mount's key there, and its local folder.
|
|
1668
|
+
if (!notTaken) {
|
|
1669
|
+
for (const { from, to } of mountRoutes) {
|
|
1670
|
+
note(
|
|
1671
|
+
to
|
|
1672
|
+
? `The app renamed /${from}, a mounted route, to /${to}: \`paths:\` in site.yml says pages/${to} now, and its local folder moved with it. The mounted folder is as it was.`
|
|
1673
|
+
: `The app removed /${from}, a mounted route: it is gone from \`paths:\` in site.yml, with its local folder. The mounted folder is as it was.`
|
|
1674
|
+
)
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1484
1677
|
if (leftAlone) {
|
|
1485
1678
|
note(
|
|
1486
|
-
`Left as written: ${leftAlone} page(s)
|
|
1487
|
-
|
|
1679
|
+
`Left as written: ${leftAlone} page(s) a pull cannot write — in a mounted folder it cannot merge into, what a folder of single-section pages cannot hold, or two pages on one route. ` +
|
|
1680
|
+
"An edit made to one in the app is held: kept on the backend, not undone by a push while the page's file is unchanged, and a push that changed it stops."
|
|
1488
1681
|
)
|
|
1682
|
+
if (mountedMoved.length) {
|
|
1683
|
+
note(`Held: ${mountedMoved.length} mounted page(s) changed in the app, which their folder cannot take:`)
|
|
1684
|
+
for (const route of mountedMoved) note(` /${route}`)
|
|
1685
|
+
for (const m of mounts.held) for (const line of heldMountLines(m)) note(line)
|
|
1686
|
+
}
|
|
1687
|
+
if (heldPages.length) {
|
|
1688
|
+
note(
|
|
1689
|
+
`Held: ${heldPages.length} page(s) whose files cannot say what the app made of them. The site keeps the app's version and the files keep theirs; ` +
|
|
1690
|
+
'a push leaves it, and one that changes such a page is refused. Undo it in the app, and pull again.'
|
|
1691
|
+
)
|
|
1692
|
+
for (const { route, what } of heldPages) note(` /${route}: ${what.join(', ')}`)
|
|
1693
|
+
}
|
|
1489
1694
|
// ⭐ A mounted folder's pages are as current as its repository, which no pull moves.
|
|
1490
1695
|
for (const line of await behindLines(siteDir)) note(line)
|
|
1491
1696
|
}
|
|
@@ -1552,6 +1757,43 @@ export async function pull(args = [], deps = {}) {
|
|
|
1552
1757
|
)
|
|
1553
1758
|
}
|
|
1554
1759
|
}
|
|
1760
|
+
// ⭐ A SUBMODULE'S NEW COMMITS ARE ITS OWN REPOSITORY'S, which no push of the site sends: its remote
|
|
1761
|
+
// must hold them before the site's remote holds the commit that names them, or a clone of the site
|
|
1762
|
+
// cannot check it out. The pull pushes neither; it says what to push, in that order.
|
|
1763
|
+
if (merge.nested?.length) {
|
|
1764
|
+
const surveyed = await mountedRepositories(siteDir)
|
|
1765
|
+
for (const n of merge.nested) {
|
|
1766
|
+
const dir = posix.relative(repo.path === '.' ? '.' : repo.path, n.at) || '.'
|
|
1767
|
+
// Each command as it runs from here.
|
|
1768
|
+
const abs = join(repo.top, n.at)
|
|
1769
|
+
const rel = relative(process.cwd(), abs) || '.'
|
|
1770
|
+
const here = rel.length <= abs.length ? rel : abs
|
|
1771
|
+
if (n.conflicted.length) {
|
|
1772
|
+
note(`${dir} is a submodule: settle its conflicts and commit there, then record it here (\`git add ${here}\`) and commit.`)
|
|
1773
|
+
continue
|
|
1774
|
+
}
|
|
1775
|
+
const follows = surveyed.find((m) => m.segment === n.segment)?.follows
|
|
1776
|
+
// The branch: its remote's own default when `.gitmodules` names none — what this checkout
|
|
1777
|
+
// recorded of it, so nothing is asked of the remote.
|
|
1778
|
+
let branch = follows?.branch ?? null
|
|
1779
|
+
if (follows && !branch) {
|
|
1780
|
+
try {
|
|
1781
|
+
branch = execFileSync('git', ['symbolic-ref', '--short', '-q', `refs/remotes/${follows.remote}/HEAD`], { cwd: join(repo.top, n.at), encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim().replace(`${follows.remote}/`, '') || null
|
|
1782
|
+
} catch {
|
|
1783
|
+
branch = null
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
const push = !follows
|
|
1787
|
+
? null
|
|
1788
|
+
: follows.upstream
|
|
1789
|
+
? `git -C ${here} push`
|
|
1790
|
+
: `git -C ${here} push ${follows.remote} HEAD:${branch ?? '<branch>'}`
|
|
1791
|
+
note(
|
|
1792
|
+
`${dir} is a submodule, and the app's edits are a commit in it, which its remote does not hold yet: push it there before you push this repository` +
|
|
1793
|
+
(push ? ` — \`${push}\`.` : '.')
|
|
1794
|
+
)
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1555
1797
|
}
|
|
1556
1798
|
// Unresolved conflicts are a non-zero exit, the way a conflicted `git merge` is.
|
|
1557
1799
|
// The pull itself worked; there is work left for a human. This is what makes a
|
package/src/commands/push.js
CHANGED
|
@@ -88,6 +88,9 @@ import {
|
|
|
88
88
|
readSyncCache,
|
|
89
89
|
readBaseVersions,
|
|
90
90
|
readItemBaseVersions,
|
|
91
|
+
readHeldUnits,
|
|
92
|
+
refuseChangedHeld,
|
|
93
|
+
noteHeldLeftOut,
|
|
91
94
|
readItemUuids,
|
|
92
95
|
readFolderItemUuids,
|
|
93
96
|
readQueryUuids,
|
|
@@ -470,6 +473,7 @@ export async function push(args = [], deps = {}) {
|
|
|
470
473
|
if (!output && !dryRun) {
|
|
471
474
|
let mediaRefs = []
|
|
472
475
|
let refusals = []
|
|
476
|
+
let held = null
|
|
473
477
|
try {
|
|
474
478
|
const probe = await emitSyncPackages(siteDir, {
|
|
475
479
|
backend: client.origin,
|
|
@@ -477,11 +481,14 @@ export async function push(args = [], deps = {}) {
|
|
|
477
481
|
// Placement identity for the folder — see writeFolderItemUuids.
|
|
478
482
|
folderItemUuids: readFolderItemUuids(siteDir, client.origin),
|
|
479
483
|
...(foundationDir ? { foundationDir } : {}),
|
|
480
|
-
resolveModel: makeModelResolver({ client, offline: false, siteDir })
|
|
484
|
+
resolveModel: makeModelResolver({ client, offline: false, siteDir }),
|
|
485
|
+
// What a pull held, for a page that changed since to stop the push before anything goes up.
|
|
486
|
+
...(force ? {} : { heldUnits: readHeldUnits(siteDir, client.origin) })
|
|
481
487
|
})
|
|
482
488
|
// Site-root media, and each file record's file (`@uniweb/file` — `{ ref, path, contentType }`).
|
|
483
489
|
mediaRefs = [...(probe.localAssets || []), ...(probe.localFiles || [])]
|
|
484
490
|
refusals = probe.refusals || []
|
|
491
|
+
held = probe
|
|
485
492
|
} catch (err) {
|
|
486
493
|
error(`Could not scan the site for local media: ${err.message}`)
|
|
487
494
|
return { exitCode: 2 }
|
|
@@ -489,6 +496,8 @@ export async function push(args = [], deps = {}) {
|
|
|
489
496
|
// A record the backend would refuse stops the push HERE — before the site is
|
|
490
497
|
// created or a byte uploaded, not merely before the send (`refuseUnsendableRecords`).
|
|
491
498
|
if (refuseUnsendableRecords(refusals, { error, note })) return { exitCode: 1 }
|
|
499
|
+
// …and so does a page a pull held whose files changed since (`refuseChangedHeld`).
|
|
500
|
+
if (refuseChangedHeld(held, { error, note })) return { exitCode: 1 }
|
|
492
501
|
if (mediaRefs.length) {
|
|
493
502
|
// The site has to exist before its bytes do — an upload with no owning
|
|
494
503
|
// entity is charged and cannot be freed, because freeing means deleting the
|
|
@@ -620,7 +629,10 @@ export async function push(args = [], deps = {}) {
|
|
|
620
629
|
? {}
|
|
621
630
|
: {
|
|
622
631
|
baseVersions: readBaseVersions(siteDir, client.origin),
|
|
623
|
-
itemBaseVersions: readItemBaseVersions(siteDir, client.origin)
|
|
632
|
+
itemBaseVersions: readItemBaseVersions(siteDir, client.origin),
|
|
633
|
+
// ⭐ What a pull held is left out while its files still say what they said, so the backend
|
|
634
|
+
// keeps the app's version (`readHeldUnits`). `--force` sends it with everything else.
|
|
635
|
+
heldUnits: readHeldUnits(siteDir, client.origin)
|
|
624
636
|
}),
|
|
625
637
|
...(assetRewrite ? { assetRewrite } : {}),
|
|
626
638
|
...(assetIds ? { assetIds } : {})
|
|
@@ -652,6 +664,8 @@ export async function push(args = [], deps = {}) {
|
|
|
652
664
|
// The same stop for the paths the probe above does not run on — `-o` and
|
|
653
665
|
// `--dry-run` say what a push would do, and a push would stop here.
|
|
654
666
|
if (refuseUnsendableRecords(pkg.refusals, { error, note })) return { exitCode: 1 }
|
|
667
|
+
if (refuseChangedHeld(pkg, { error, note })) return { exitCode: 1 }
|
|
668
|
+
noteHeldLeftOut(pkg, { note })
|
|
655
669
|
// Warn level, not dim: this is the author choosing entities vs static files.
|
|
656
670
|
reportSchemalessQueries(pkg.schemaless, { warn, dim: note })
|
|
657
671
|
|
package/src/commands/refresh.js
CHANGED
|
@@ -64,6 +64,7 @@ import {
|
|
|
64
64
|
} from '../utils/git.js'
|
|
65
65
|
import { ignoringRepo } from '../utils/sync-point.js'
|
|
66
66
|
import { mountedRepositories, takeLatest, describeTaken } from '../utils/mounted-repositories.js'
|
|
67
|
+
import { writableMounts } from '../utils/site-roots.js'
|
|
67
68
|
import { probeUnpushed } from '../backend/site-sync.js'
|
|
68
69
|
import { resolveBackendOrigin } from '../backend/client.js'
|
|
69
70
|
import { readBackendState } from '@uniweb/build/uwx'
|
|
@@ -181,10 +182,12 @@ export async function refresh(args = [], deps = {}) {
|
|
|
181
182
|
skipped.push(`mounts (${skipGit ? '--no-git' : '--no-mounts'})`)
|
|
182
183
|
} else if (mounts.length) {
|
|
183
184
|
say.info(`Taking the latest of ${mounts.length === 1 ? 'the page folder' : `${mounts.length} page folders`} mounted from ${mounts.length === 1 ? 'another repository' : 'other repositories'}…`)
|
|
185
|
+
// A mount a pull writes into takes its latest by merging, as the site does (`takeLatest`).
|
|
186
|
+
const writable = new Set(writableMounts(siteDir).writable)
|
|
184
187
|
for (const m of mounts) {
|
|
185
|
-
const r = await takeLatest(siteDir, m)
|
|
188
|
+
const r = await takeLatest(siteDir, m, { merge: writable.has(m.segment) })
|
|
186
189
|
say.dim(describeTaken(m, r))
|
|
187
|
-
if (r.error || ['edits', 'no-answer', 'off-branch'].includes(r.kind)) mountsLeft.push(m)
|
|
190
|
+
if (r.error || ['edits', 'no-answer', 'off-branch', 'conflict'].includes(r.kind)) mountsLeft.push(m)
|
|
188
191
|
}
|
|
189
192
|
consulted.push('mounts')
|
|
190
193
|
}
|