@taprootio/site-authoring 0.42.0 → 0.56.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/README.md +110 -12
- package/examples/riverbend-wellness/settings/site-publishing-preferences.json +3 -0
- package/examples/riverbend-wellness/settings/taproot-styles.json +11 -0
- package/package.json +4 -3
- package/src/api.js +242 -23
- package/src/appearance-contract.js +264 -3
- package/src/authored-tag-names.js +88 -0
- package/src/authors-contract.js +71 -3
- package/src/block-flow.js +103 -1
- package/src/brand-color.js +22 -0
- package/src/breadcrumb-artwork.js +234 -0
- package/src/breadcrumb-separators.js +11 -0
- package/src/changelog.json +160 -0
- package/src/chrome-features.js +6 -2
- package/src/chrome-input.js +1 -0
- package/src/chrome-paint-catalog-taproot.json +3 -3
- package/src/chrome-report.js +91 -12
- package/src/cli.js +136 -38
- package/src/constants.js +1 -0
- package/src/content/components.js +27 -4
- package/src/content/external-link.js +2 -1
- package/src/content/markdown.js +271 -101
- package/src/content/tiptap-prosemirror.ts +125 -43
- package/src/content/validate-document.js +4 -1
- package/src/content-inset.js +48 -0
- package/src/errors.js +1 -0
- package/src/espalier-shared.js +26 -0
- package/src/field-suggestions.js +40 -0
- package/src/fixture-init.js +22 -5
- package/src/font-catalog.js +11 -1
- package/src/footer-brand-inputs.js +22 -3
- package/src/footer-content.js +1 -0
- package/src/footer-contract.js +11 -0
- package/src/footer-cta-styles.js +6 -0
- package/src/footer-draft-hash.js +4 -2
- package/src/footer-fit.js +62 -15
- package/src/footer-workspace.js +44 -7
- package/src/latest-posts-tags.js +57 -0
- package/src/page-metadata.js +15 -13
- package/src/page-structure-checks.js +5 -0
- package/src/page-tag-badge-modes.js +6 -0
- package/src/page-tag-writes.js +158 -0
- package/src/page-type-tags.js +16 -0
- package/src/presentation-reference.js +297 -86
- package/src/recipe-page-options.js +22 -0
- package/src/recipe-step-contract.js +164 -0
- package/src/recipe-step-contract.json +65 -0
- package/src/reference-help.js +182 -79
- package/src/session.js +39 -24
- package/src/setting-reference.js +239 -48
- package/src/settings-catalog.js +63 -0
- package/src/site-check-findings.js +23 -5
- package/src/site-check-rules.json +1 -0
- package/src/site-health-findings.js +13 -13
- package/src/styling-fixed-values.js +71 -0
- package/src/tag-destination-warnings.js +35 -0
- package/src/template-token-reach.json +242 -0
- package/src/theme-proposals.js +18 -27
- package/src/theme-resolve.js +265 -23
- package/src/theme-validation.js +118 -7
- package/src/token-reach.js +222 -0
- package/src/typed-page-reference.js +94 -16
- package/src/typed-pages.js +233 -74
- package/src/verbs/authors.js +198 -33
- package/src/verbs/deploy.js +6 -0
- package/src/verbs/footer-push.js +30 -5
- package/src/verbs/forms-push.js +11 -3
- package/src/verbs/index.js +4 -2
- package/src/verbs/pages-delete.js +19 -10
- package/src/verbs/pages-push.js +225 -71
- package/src/verbs/plan.js +10 -4
- package/src/verbs/pull.js +324 -69
- package/src/verbs/staging-review.js +27 -1
- package/src/verbs/status.js +22 -0
- package/src/verbs/theme-push.js +93 -25
- package/src/verbs/theme-resolve.js +189 -55
- package/src/verbs/validate.js +6 -5
- package/src/workspace-check.js +35 -3
- package/src/workspace.js +73 -2
- package/test/fixtures/default-site-theme.json +516 -0
package/src/verbs/pull.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
1
5
|
import {
|
|
2
6
|
getNavigation,
|
|
3
7
|
getPage,
|
|
4
8
|
getSettingsGroup,
|
|
9
|
+
getSiteAuthoringCapabilities,
|
|
5
10
|
getSitePresentation,
|
|
6
11
|
getSiteRedirectMap,
|
|
7
12
|
listSiteAuthors,
|
|
@@ -9,6 +14,7 @@ import {
|
|
|
9
14
|
listSitePages,
|
|
10
15
|
PAGE_STATUS_DRAFT,
|
|
11
16
|
PAGE_STATUS_UNKNOWN,
|
|
17
|
+
requireAuthoredTagSnapshot,
|
|
12
18
|
withRefusalGuidance,
|
|
13
19
|
} from "../api.js";
|
|
14
20
|
import {
|
|
@@ -17,7 +23,14 @@ import {
|
|
|
17
23
|
SURFACE_DOCS_PRESENTATION,
|
|
18
24
|
VERB_PULL,
|
|
19
25
|
} from "../constants.js";
|
|
20
|
-
import {
|
|
26
|
+
import { tagDestinationCatalogSlugs } from "../appearance-contract.js";
|
|
27
|
+
import { validateAuthoredTagNames } from "../authored-tag-names.js";
|
|
28
|
+
import {
|
|
29
|
+
AUTHORS_FILE_NAME,
|
|
30
|
+
normalizeAuthorHandle,
|
|
31
|
+
parseAuthorReference,
|
|
32
|
+
projectAuthorsForWorkspace,
|
|
33
|
+
} from "../authors-contract.js";
|
|
21
34
|
import { isCanonicalUuid, sanitizeDiagnostic, SiteAuthoringError } from "../errors.js";
|
|
22
35
|
import { appearanceManifestEntry, footerManifestEntry, presentationManifestEntry } from "../footer-workspace.js";
|
|
23
36
|
import { describeJsonDifferences, reportableDifferencePaths } from "../json-path-diff.js";
|
|
@@ -25,6 +38,7 @@ import { projectRedirectMapForWorkspace, REDIRECTS_FILE_NAME } from "../redirect
|
|
|
25
38
|
import { navigationManifestEntry } from "../navigation-workspace.js";
|
|
26
39
|
import { redirectsManifestEntry } from "../redirects-workspace.js";
|
|
27
40
|
import { projectNavigationForWorkspace } from "./nav-push.js";
|
|
41
|
+
import { parseFrontMatter } from "./pages-push.js";
|
|
28
42
|
import { boundedList, openSession, successResult } from "../session.js";
|
|
29
43
|
import {
|
|
30
44
|
projectSettingsGroup,
|
|
@@ -43,7 +57,11 @@ import {
|
|
|
43
57
|
isLegalTemplateType,
|
|
44
58
|
isAuthorableTemplateType,
|
|
45
59
|
isGeneratedTemplateType,
|
|
60
|
+
projectAuthoredTagSnapshot,
|
|
61
|
+
sentDisplayAuthor,
|
|
46
62
|
sentDisplayDate,
|
|
63
|
+
sentShowOnProfile,
|
|
64
|
+
supportsAuthoredTagWireType,
|
|
47
65
|
TEMPLATE_LEGAL,
|
|
48
66
|
workspaceDocumentFromPage,
|
|
49
67
|
} from "../typed-pages.js";
|
|
@@ -80,6 +98,7 @@ import {
|
|
|
80
98
|
workspaceContentHash,
|
|
81
99
|
workspaceFileExists,
|
|
82
100
|
workspaceFileNameForPage,
|
|
101
|
+
workspacePageSourceBodyHash,
|
|
83
102
|
readManifest,
|
|
84
103
|
writeManifest,
|
|
85
104
|
writeWorkspaceFile,
|
|
@@ -149,11 +168,13 @@ function retiredSourceRecords(value) {
|
|
|
149
168
|
* recorded content key covers exactly those and the source bytes.
|
|
150
169
|
*/
|
|
151
170
|
function metadataEditedLocally(source, templateType) {
|
|
171
|
+
const { contentKey, sourceHash, sourceBodyHash } = source.baseline ?? {};
|
|
152
172
|
return source.sourceFormat !== PAGE_SOURCE_FORMAT_MARKDOWN
|
|
153
173
|
&& !isGeneratedTemplateType(templateType)
|
|
154
|
-
&&
|
|
155
|
-
&&
|
|
156
|
-
&& pageContentKey(
|
|
174
|
+
&& contentKey !== undefined
|
|
175
|
+
&& sourceHash !== undefined
|
|
176
|
+
&& pageContentKey(sourceHash, source.metadata) !== contentKey
|
|
177
|
+
&& (sourceBodyHash === undefined || pageContentKey(sourceBodyHash, source.metadata) !== contentKey);
|
|
157
178
|
}
|
|
158
179
|
|
|
159
180
|
/**
|
|
@@ -259,9 +280,9 @@ function describeDifferenceSummary(differences) {
|
|
|
259
280
|
* A file that cannot be parsed is certainly not what pull wrote, so it counts
|
|
260
281
|
* as authored and is kept rather than refreshed over.
|
|
261
282
|
*/
|
|
262
|
-
function holdsRemoteDocument(sourceBytes, remoteHash) {
|
|
283
|
+
function holdsRemoteDocument(sourceBytes, remoteHash, sourceBodyHash) {
|
|
263
284
|
try {
|
|
264
|
-
return canonicalDocumentHash(JSON.parse(sourceBytes.toString("utf8"))) === remoteHash;
|
|
285
|
+
return (sourceBodyHash ?? canonicalDocumentHash(JSON.parse(sourceBytes.toString("utf8")))) === remoteHash;
|
|
265
286
|
} catch {
|
|
266
287
|
return undefined;
|
|
267
288
|
}
|
|
@@ -277,6 +298,100 @@ function parsePageDocument(bytes) {
|
|
|
277
298
|
}
|
|
278
299
|
}
|
|
279
300
|
|
|
301
|
+
function sourceWithTags(document, tags) {
|
|
302
|
+
return tags === undefined ? document : { ...document, tags };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function sourceWithoutTags(document) {
|
|
306
|
+
const { tags: _tags, ...body } = document;
|
|
307
|
+
return body;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function serializePage(document) {
|
|
311
|
+
return Buffer.from(`${JSON.stringify(document, undefined, 2)}\n`, "utf8");
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function savedTagBaseline(baseline) {
|
|
315
|
+
return baseline?.authoredTagRevision === undefined ? {} : {
|
|
316
|
+
authoredTagRevision: baseline.authoredTagRevision,
|
|
317
|
+
authoredTagSlugs: baseline.authoredTagSlugs,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
function projectedPageTags(page, summary, onProgress) {
|
|
322
|
+
const snapshot = requireAuthoredTagSnapshot(page);
|
|
323
|
+
const projection = projectAuthoredTagSnapshot(snapshot);
|
|
324
|
+
if ("reason" in projection) {
|
|
325
|
+
onProgress(sanitizeDiagnostic(
|
|
326
|
+
`Page '${displayPagePath(summary.path)}' has authored tags this workspace cannot represent. ${projection.reason} `
|
|
327
|
+
+ "Omit tags from the source for a body-only push that preserves the site's tag assignments.",
|
|
328
|
+
));
|
|
329
|
+
return projection;
|
|
330
|
+
}
|
|
331
|
+
return { ...projection, revision: snapshot.revision };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function markdownSourceTags(sourceBytes, file) {
|
|
335
|
+
const { fields, candidates, fault } = parseFrontMatter(sourceBytes.toString("utf8"), file);
|
|
336
|
+
if (fault?.field === "tags") throw fault;
|
|
337
|
+
if (candidates.has("tags")) {
|
|
338
|
+
throw new SiteAuthoringError("pages.front_matter_duplicate", `'${file}' declares tags twice.`, { field: "tags" });
|
|
339
|
+
}
|
|
340
|
+
if (!fields.has("tags")) return undefined;
|
|
341
|
+
try {
|
|
342
|
+
return JSON.parse(fields.get("tags"));
|
|
343
|
+
} catch {
|
|
344
|
+
throw new SiteAuthoringError("pages.tags_invalid", `Use a one-line JSON array of tag names in '${file}'.`, {
|
|
345
|
+
field: "tags",
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function sameTagSlugs(left, right) {
|
|
351
|
+
return Array.isArray(right) && left.length === right.length && left.every((slug, index) => slug === right[index]);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function tagPullConflict(source, projection) {
|
|
355
|
+
const live = boundedList(projection.names, 4);
|
|
356
|
+
const names = live.items.map((name) => JSON.stringify([...name].slice(0, 40).join("")));
|
|
357
|
+
const suffix = live.truncated ? " and more" : "";
|
|
358
|
+
const shown = names.length === 0 ? "no authored tags" : `${names.join(", ")}${suffix}`;
|
|
359
|
+
return new SiteAuthoringError(
|
|
360
|
+
"pages.tag_pull_conflict",
|
|
361
|
+
`Authored tags changed for '${source.file}'. Back up your changes, align its tags with the site's list, then `
|
|
362
|
+
+ `run 'taproot-site pull' again at the same path before reapplying changes. The site has ${shown}.`,
|
|
363
|
+
{ field: source.file, alternatives: live.items },
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** The local source and the saved tag baseline after a retained page reconciles. */
|
|
368
|
+
function reconcileTrackedTags({ source, projection, sourceBytes, localDocument, markdown, localChanged, conflicted }) {
|
|
369
|
+
const tags = localDocument?.tags;
|
|
370
|
+
const saved = savedTagBaseline(source.baseline);
|
|
371
|
+
if (projection === undefined || conflicted) return { tags, baseline: saved };
|
|
372
|
+
if ("reason" in projection) return { tags, baseline: {} };
|
|
373
|
+
if (!markdown && localDocument === undefined) return { tags, baseline: saved };
|
|
374
|
+
|
|
375
|
+
const localTags = markdown ? markdownSourceTags(sourceBytes, source.file) : tags;
|
|
376
|
+
const baseline = (slugs) => ({ authoredTagRevision: projection.revision, authoredTagSlugs: slugs });
|
|
377
|
+
if (localTags === undefined) return { tags, baseline: baseline(null) };
|
|
378
|
+
|
|
379
|
+
const local = validateAuthoredTagNames(localTags);
|
|
380
|
+
if ("reason" in local) {
|
|
381
|
+
throw new SiteAuthoringError("pages.tags_invalid", `'${source.file}', ${local.field}. ${local.reason}`, {
|
|
382
|
+
field: local.field,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (projection.revision === saved.authoredTagRevision) return { tags, baseline: saved };
|
|
386
|
+
if (sameTagSlugs(local.slugs, projection.slugs)) return { tags, baseline: baseline(local.slugs) };
|
|
387
|
+
if (sameTagSlugs(local.slugs, saved.authoredTagSlugs)) {
|
|
388
|
+
return markdown || localChanged
|
|
389
|
+
? { tags, baseline: saved }
|
|
390
|
+
: { tags: projection.names, baseline: baseline(projection.slugs) };
|
|
391
|
+
}
|
|
392
|
+
throw tagPullConflict(source, projection);
|
|
393
|
+
}
|
|
394
|
+
|
|
280
395
|
/**
|
|
281
396
|
* The document this workspace last reconciled with, if it still holds one.
|
|
282
397
|
*
|
|
@@ -313,7 +428,7 @@ async function readPreviousRemoteDocument({ workspaceDir, baselineFile, sourceBy
|
|
|
313
428
|
}
|
|
314
429
|
|
|
315
430
|
/** The JSON paths at which the site's document moved, when that is knowable. */
|
|
316
|
-
async function describeRemoteMovement({ workspaceDir, baselineFile, sourceBytes, markdown, localChanged, body }) {
|
|
431
|
+
async function describeRemoteMovement({ workspaceDir, baselineFile, sourceBytes, markdown, localChanged, body, taggedTemplate }) {
|
|
317
432
|
const previous = await readPreviousRemoteDocument({
|
|
318
433
|
workspaceDir,
|
|
319
434
|
baselineFile,
|
|
@@ -321,7 +436,9 @@ async function describeRemoteMovement({ workspaceDir, baselineFile, sourceBytes,
|
|
|
321
436
|
markdown,
|
|
322
437
|
localChanged,
|
|
323
438
|
});
|
|
324
|
-
return previous === undefined
|
|
439
|
+
return previous === undefined
|
|
440
|
+
? undefined
|
|
441
|
+
: describeJsonDifferences(taggedTemplate ? sourceWithoutTags(previous) : previous, body);
|
|
325
442
|
}
|
|
326
443
|
|
|
327
444
|
function bodyStatusFor(summary) {
|
|
@@ -579,6 +696,17 @@ function trackedDisplayDate(page, templateType) {
|
|
|
579
696
|
return sentDisplayDate(templateType) ? (typeof page.displayDate === "string" ? page.displayDate : "") : undefined;
|
|
580
697
|
}
|
|
581
698
|
|
|
699
|
+
/** The display author a read reports for a page whose push sends one ("" for none), or `undefined` for other pages. */
|
|
700
|
+
function trackedDisplayAuthor(page, templateType) {
|
|
701
|
+
if (!sentDisplayAuthor(templateType)) return undefined;
|
|
702
|
+
return typeof page.displayAuthor === "string" ? normalizeAuthorHandle(page.displayAuthor) ?? "" : "";
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/** Whether a read says the page may be on its author's profile, or `undefined` for pages that carry no such setting. */
|
|
706
|
+
function trackedShowOnProfile(page, templateType) {
|
|
707
|
+
return sentShowOnProfile(templateType) ? page.showOnProfile !== false : undefined;
|
|
708
|
+
}
|
|
709
|
+
|
|
582
710
|
function notThisSite(message, field) {
|
|
583
711
|
// One code for one situation: "this workspace is not provably this site's."
|
|
584
712
|
// The remedy is the same for every branch below — a fresh directory — and an
|
|
@@ -686,6 +814,7 @@ export async function pull(invocation) {
|
|
|
686
814
|
// are the whole of what this workspace holds for it.
|
|
687
815
|
const presentationOnly = surface === SURFACE_DOCS_PRESENTATION;
|
|
688
816
|
|
|
817
|
+
let stageDirectory;
|
|
689
818
|
return await withRefusalGuidance(onProgress, "pull", async () => {
|
|
690
819
|
let pages = [];
|
|
691
820
|
let truncated = false;
|
|
@@ -700,6 +829,67 @@ export async function pull(invocation) {
|
|
|
700
829
|
}
|
|
701
830
|
const live = pages.filter((summary) => !isGonePage(summary));
|
|
702
831
|
const authorable = live.filter((summary) => isAuthorableTemplateType(summary.templateType));
|
|
832
|
+
const capabilities = authorable.some((summary) => supportsAuthoredTagWireType(summary.templateType))
|
|
833
|
+
? await getSiteAuthoringCapabilities(client, siteId)
|
|
834
|
+
: undefined;
|
|
835
|
+
const readsAuthoredTags = (summary) =>
|
|
836
|
+
capabilities !== undefined && supportsAuthoredTagWireType(summary.templateType);
|
|
837
|
+
|
|
838
|
+
const readFreshProjection = async (summary, file) => {
|
|
839
|
+
onProgress(`Reading page '${summary.path}'.`);
|
|
840
|
+
const page = await getPage(client, summary.pageId, bodyStatusFor(summary));
|
|
841
|
+
const tagProjection = readsAuthoredTags(summary) ? projectedPageTags(page, summary, onProgress) : undefined;
|
|
842
|
+
const body = await workspaceBodyFromPage(page, summary.templateType);
|
|
843
|
+
const entry = {
|
|
844
|
+
description: typeof page.shortDescription === "string" ? page.shortDescription : "",
|
|
845
|
+
title: titleFromRead(page, summary),
|
|
846
|
+
path: pathFromRead(page, summary),
|
|
847
|
+
};
|
|
848
|
+
if (body === undefined) {
|
|
849
|
+
onProgress(`Page '${summary.path}' has no readable body; snapshotting metadata only.`);
|
|
850
|
+
return { entry };
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
const confirmedTags = tagProjection === undefined || "reason" in tagProjection ? undefined : tagProjection;
|
|
854
|
+
const tags = confirmedTags?.names.length > 0 ? confirmedTags.names : undefined;
|
|
855
|
+
const source = serializePage(sourceWithTags(body, tags));
|
|
856
|
+
const sourceHash = workspaceContentHash(source);
|
|
857
|
+
const remoteHash = canonicalDocumentHash(body);
|
|
858
|
+
const sourceBodyHash = supportsAuthoredTagWireType(summary.templateType) ? remoteHash : undefined;
|
|
859
|
+
const revision = normalizePageBodyRevision(page.bodyRevision);
|
|
860
|
+
const displayDate = trackedDisplayDate(page, summary.templateType);
|
|
861
|
+
const displayAuthor = trackedDisplayAuthor(page, summary.templateType);
|
|
862
|
+
const showOnProfile = trackedShowOnProfile(page, summary.templateType);
|
|
863
|
+
return {
|
|
864
|
+
source,
|
|
865
|
+
entry: {
|
|
866
|
+
...entry,
|
|
867
|
+
file,
|
|
868
|
+
workspaceMode: PAGE_WORKSPACE_MODE_EDITABLE,
|
|
869
|
+
sourceFormat: pageSourceFormat(file),
|
|
870
|
+
...(isGeneratedTemplateType(summary.templateType) ? { generated: generatedIdentity(body.data) } : {}),
|
|
871
|
+
...(isLegalTemplateType(summary.templateType) ? { legal: legalIdentity(body.data) } : {}),
|
|
872
|
+
baseline: {
|
|
873
|
+
remoteHash,
|
|
874
|
+
sourceHash,
|
|
875
|
+
contentKey: pageContentKey(tags === undefined ? sourceHash : sourceBodyHash, {
|
|
876
|
+
...entry,
|
|
877
|
+
author: summary.authorRef,
|
|
878
|
+
}),
|
|
879
|
+
...(sourceBodyHash === undefined ? {} : { sourceBodyHash }),
|
|
880
|
+
...(revision === undefined ? {} : { revision }),
|
|
881
|
+
...(displayDate === undefined ? {} : { displayDate }),
|
|
882
|
+
...(displayAuthor === undefined ? {} : { displayAuthor }),
|
|
883
|
+
...(showOnProfile === undefined ? {} : { showOnProfile }),
|
|
884
|
+
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
885
|
+
...(confirmedTags === undefined ? {} : {
|
|
886
|
+
authoredTagRevision: confirmedTags.revision,
|
|
887
|
+
authoredTagSlugs: tags === undefined ? null : confirmedTags.slugs,
|
|
888
|
+
}),
|
|
889
|
+
},
|
|
890
|
+
},
|
|
891
|
+
};
|
|
892
|
+
};
|
|
703
893
|
// Generated-page sources recorded apart as retired. One whose page the site
|
|
704
894
|
// lists again (a bounded listing left it out last time) takes its file back
|
|
705
895
|
// as that page's source; with no baseline, pull compares the bytes with the
|
|
@@ -949,6 +1139,8 @@ export async function pull(invocation) {
|
|
|
949
1139
|
if (source === undefined) continue;
|
|
950
1140
|
onProgress(`Reading page '${summary.path}'.`);
|
|
951
1141
|
const page = await getPage(client, summary.pageId, bodyStatusFor(summary));
|
|
1142
|
+
const taggedTemplate = supportsAuthoredTagWireType(summary.templateType);
|
|
1143
|
+
const tagProjection = readsAuthoredTags(summary) ? projectedPageTags(page, summary, onProgress) : undefined;
|
|
952
1144
|
const body = await workspaceBodyFromPage(page, summary.templateType);
|
|
953
1145
|
const description = typeof page.shortDescription === "string" ? page.shortDescription : "";
|
|
954
1146
|
if (body === undefined) {
|
|
@@ -960,7 +1152,16 @@ export async function pull(invocation) {
|
|
|
960
1152
|
// one; without the baseline the next pull could not tell it from the
|
|
961
1153
|
// site's values and would overwrite it.
|
|
962
1154
|
const metadataKept = metadataEditedLocally(source, summary.templateType);
|
|
963
|
-
const
|
|
1155
|
+
const {
|
|
1156
|
+
authoredTagRevision: _tagRevision, authoredTagSlugs: _tagSlugs, ...bodyBaseline
|
|
1157
|
+
} = source.baseline ?? {};
|
|
1158
|
+
const tagBaseline = tagProjection !== undefined && "reason" in tagProjection
|
|
1159
|
+
? {}
|
|
1160
|
+
: savedTagBaseline(source.baseline);
|
|
1161
|
+
const keptBaseline = {
|
|
1162
|
+
...(metadataKept ? withHeldAuthor(bodyBaseline, summary.authorRef) : {}),
|
|
1163
|
+
...tagBaseline,
|
|
1164
|
+
};
|
|
964
1165
|
if (metadataKept) reportPendingAuthorDisagreement(source, summary, onProgress);
|
|
965
1166
|
trackedPlans.set(summary.pageId, {
|
|
966
1167
|
// The page is still the generated page it was; losing the record would
|
|
@@ -973,7 +1174,7 @@ export async function pull(invocation) {
|
|
|
973
1174
|
author: metadataKept ? source.metadata.author : summary.authorRef,
|
|
974
1175
|
file: source.file,
|
|
975
1176
|
sourceFormat: source.sourceFormat,
|
|
976
|
-
...(keptBaseline ===
|
|
1177
|
+
...(Object.keys(keptBaseline).length === 0 ? {} : { baseline: keptBaseline }),
|
|
977
1178
|
});
|
|
978
1179
|
continue;
|
|
979
1180
|
}
|
|
@@ -989,16 +1190,7 @@ export async function pull(invocation) {
|
|
|
989
1190
|
{ field: source.file },
|
|
990
1191
|
);
|
|
991
1192
|
}
|
|
992
|
-
const serialized =
|
|
993
|
-
bufferedBytes += serialized.byteLength;
|
|
994
|
-
if (bufferedBytes > WORKSPACE_LIMITS.pulledBodyBytes) {
|
|
995
|
-
throw new SiteAuthoringError(
|
|
996
|
-
"pages.pulled_bodies_too_large",
|
|
997
|
-
`The tracked pages of this site exceed ${WORKSPACE_LIMITS.pulledBodyBytes} bytes, which is more than one `
|
|
998
|
-
+ "pull can hold before deciding whether any of them conflict.",
|
|
999
|
-
{ field: PAGES_DIRECTORY },
|
|
1000
|
-
);
|
|
1001
|
-
}
|
|
1193
|
+
const serialized = serializePage(body);
|
|
1002
1194
|
const remoteHash = canonicalDocumentHash(body);
|
|
1003
1195
|
const sourceBytes = await readWorkspaceFile(config.workspaceDir, source.file, WORKSPACE_LIMITS.documentBytes);
|
|
1004
1196
|
const sourceHash = workspaceContentHash(sourceBytes);
|
|
@@ -1032,7 +1224,18 @@ export async function pull(invocation) {
|
|
|
1032
1224
|
const dateChanged = remoteDisplayDate !== undefined
|
|
1033
1225
|
&& source.baseline?.displayDate !== undefined
|
|
1034
1226
|
&& source.baseline.displayDate !== remoteDisplayDate;
|
|
1035
|
-
|
|
1227
|
+
// The display author is page content like the date and is compared the
|
|
1228
|
+
// same way (TR01402). A baseline written before it counts as not having
|
|
1229
|
+
// seen the value, so such a workspace pulls without a conflict.
|
|
1230
|
+
const remoteDisplayAuthor = trackedDisplayAuthor(page, summary.templateType);
|
|
1231
|
+
const displayAuthorChanged = remoteDisplayAuthor !== undefined
|
|
1232
|
+
&& source.baseline?.displayAuthor !== undefined
|
|
1233
|
+
&& source.baseline.displayAuthor !== remoteDisplayAuthor;
|
|
1234
|
+
const remoteShowOnProfile = trackedShowOnProfile(page, summary.templateType);
|
|
1235
|
+
const showOnProfileChanged = remoteShowOnProfile !== undefined
|
|
1236
|
+
&& source.baseline?.showOnProfile !== undefined
|
|
1237
|
+
&& source.baseline.showOnProfile !== remoteShowOnProfile;
|
|
1238
|
+
const remoteChanged = revisionChanged || dateChanged || displayAuthorChanged || showOnProfileChanged;
|
|
1036
1239
|
// Markdown is one-way, so a Markdown source can never be rewritten from
|
|
1037
1240
|
// the site's document and is always kept. A ProseMirror source can be
|
|
1038
1241
|
// refreshed — but only over content the author has not edited since the
|
|
@@ -1053,10 +1256,24 @@ export async function pull(invocation) {
|
|
|
1053
1256
|
// the formats differ, so the bytes never match — and pull never writes
|
|
1054
1257
|
// one at all. There is nothing to protect and nothing to compare, so an
|
|
1055
1258
|
// unrecorded hash simply establishes itself.
|
|
1056
|
-
const
|
|
1057
|
-
const
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1259
|
+
const localDocument = taggedTemplate && !markdown ? parsePageDocument(sourceBytes) : undefined;
|
|
1260
|
+
const sourceBodyHash = localDocument === undefined ? undefined : workspacePageSourceBodyHash(localDocument);
|
|
1261
|
+
const tagAwareComparison = sourceBodyHash !== undefined
|
|
1262
|
+
&& (Object.hasOwn(localDocument, "tags") || Array.isArray(source.baseline?.authoredTagSlugs));
|
|
1263
|
+
const savedBodyHash = tagAwareComparison ? source.baseline?.sourceBodyHash : undefined;
|
|
1264
|
+
const localKnown = source.baseline?.sourceHash !== undefined || savedBodyHash !== undefined;
|
|
1265
|
+
const sourceMatchesRemote = !localKnown && !markdown
|
|
1266
|
+
? holdsRemoteDocument(sourceBytes, remoteHash, tagAwareComparison ? sourceBodyHash : undefined)
|
|
1267
|
+
: undefined;
|
|
1268
|
+
// Before the independent body hash existed, pull recorded the same
|
|
1269
|
+
// projection as canonical remote JSON and pretty-printed source bytes.
|
|
1270
|
+
const matchesLegacyBody = tagAwareComparison && savedBodyHash === undefined
|
|
1271
|
+
&& (sourceBodyHash === source.baseline?.remoteHash
|
|
1272
|
+
|| workspaceContentHash(serializePage(sourceWithoutTags(localDocument))) === source.baseline?.sourceHash);
|
|
1273
|
+
const localChanged = savedBodyHash !== undefined
|
|
1274
|
+
? savedBodyHash !== sourceBodyHash
|
|
1275
|
+
: localKnown
|
|
1276
|
+
? source.baseline.sourceHash !== sourceHash && !matchesLegacyBody
|
|
1060
1277
|
: !markdown && sourceMatchesRemote !== true;
|
|
1061
1278
|
// A first revision bypasses the old remote hash. Only the unbaselined
|
|
1062
1279
|
// ProseMirror path above can compare this source with the site's body;
|
|
@@ -1077,6 +1294,26 @@ export async function pull(invocation) {
|
|
|
1077
1294
|
const metadataEdited = metadataEditedLocally(source, summary.templateType);
|
|
1078
1295
|
const keepLocal = markdown || localChanged;
|
|
1079
1296
|
const conflicted = markdown ? remoteChanged : (localChanged || metadataEdited) && remoteChanged;
|
|
1297
|
+
const reconciled = reconcileTrackedTags({
|
|
1298
|
+
source, projection: tagProjection, sourceBytes, localDocument, markdown,
|
|
1299
|
+
localChanged: localChanged || !localKnown, conflicted,
|
|
1300
|
+
});
|
|
1301
|
+
const refresh = keepLocal || conflicted
|
|
1302
|
+
? undefined
|
|
1303
|
+
: reconciled.tags === undefined
|
|
1304
|
+
? serialized
|
|
1305
|
+
: serializePage(sourceWithTags(body, reconciled.tags));
|
|
1306
|
+
const refreshHash = refresh === undefined ? undefined : workspaceContentHash(refresh);
|
|
1307
|
+
const refreshBodyHash = taggedTemplate && refresh !== undefined ? remoteHash : undefined;
|
|
1308
|
+
bufferedBytes += (refresh ?? serialized).byteLength;
|
|
1309
|
+
if (bufferedBytes > WORKSPACE_LIMITS.pulledBodyBytes) {
|
|
1310
|
+
throw new SiteAuthoringError(
|
|
1311
|
+
"pages.pulled_bodies_too_large",
|
|
1312
|
+
`The tracked pages of this site exceed ${WORKSPACE_LIMITS.pulledBodyBytes} bytes, which is more than one `
|
|
1313
|
+
+ "pull can hold before deciding whether any of them conflict.",
|
|
1314
|
+
{ field: PAGES_DIRECTORY },
|
|
1315
|
+
);
|
|
1316
|
+
}
|
|
1080
1317
|
if (metadataEdited && !remoteChanged) {
|
|
1081
1318
|
onProgress(`Kept the local title, path and description of '${source.file}'; push them to send them.`);
|
|
1082
1319
|
}
|
|
@@ -1110,6 +1347,7 @@ export async function pull(invocation) {
|
|
|
1110
1347
|
? {
|
|
1111
1348
|
remoteHash,
|
|
1112
1349
|
sourceHash: localChanged ? source.baseline?.sourceHash : sourceHash,
|
|
1350
|
+
...(source.baseline?.sourceBodyHash === undefined ? {} : { sourceBodyHash: source.baseline.sourceBodyHash }),
|
|
1113
1351
|
// Carried, never minted here: a kept source is only known to match
|
|
1114
1352
|
// the site if a push or an earlier pull already said so. When this
|
|
1115
1353
|
// pull adopts the site's title, path and description (they were not
|
|
@@ -1120,35 +1358,45 @@ export async function pull(invocation) {
|
|
|
1120
1358
|
: {
|
|
1121
1359
|
contentKey: markdown || metadataEdited || source.baseline.sourceHash === undefined
|
|
1122
1360
|
? source.baseline.contentKey
|
|
1123
|
-
: pageContentKey(
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1361
|
+
: pageContentKey(
|
|
1362
|
+
tagAwareComparison ? source.baseline.sourceBodyHash ?? source.baseline.sourceHash : source.baseline.sourceHash,
|
|
1363
|
+
{
|
|
1364
|
+
title: titleFromRead(page, summary),
|
|
1365
|
+
path: pathFromRead(page, summary),
|
|
1366
|
+
description,
|
|
1367
|
+
author: summary.authorRef,
|
|
1368
|
+
},
|
|
1369
|
+
),
|
|
1129
1370
|
}),
|
|
1371
|
+
...reconciled.baseline,
|
|
1130
1372
|
...(revision === undefined ? {} : { revision }),
|
|
1131
1373
|
...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
|
|
1374
|
+
...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
|
|
1375
|
+
...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
|
|
1132
1376
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1133
1377
|
}
|
|
1134
1378
|
: {
|
|
1135
1379
|
remoteHash,
|
|
1136
|
-
sourceHash:
|
|
1137
|
-
|
|
1380
|
+
sourceHash: refreshHash,
|
|
1381
|
+
...(refreshBodyHash === undefined ? {} : { sourceBodyHash: refreshBodyHash }),
|
|
1382
|
+
contentKey: pageContentKey(reconciled.tags === undefined ? refreshHash : refreshBodyHash, {
|
|
1138
1383
|
title: titleFromRead(page, summary),
|
|
1139
1384
|
path: pathFromRead(page, summary),
|
|
1140
1385
|
description,
|
|
1141
1386
|
author: summary.authorRef,
|
|
1142
1387
|
}),
|
|
1388
|
+
...reconciled.baseline,
|
|
1143
1389
|
...(revision === undefined ? {} : { revision }),
|
|
1144
1390
|
...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
|
|
1391
|
+
...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
|
|
1392
|
+
...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
|
|
1145
1393
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1146
1394
|
},
|
|
1147
1395
|
// A conflict preserves the site's version whatever kept the source: the
|
|
1148
1396
|
// refusal names that copy as where the site's document now is.
|
|
1149
1397
|
...(keepLocal || conflicted
|
|
1150
1398
|
? { baselineBody: serialized, baselineFile }
|
|
1151
|
-
: { refresh
|
|
1399
|
+
: { refresh, baselineFile }),
|
|
1152
1400
|
});
|
|
1153
1401
|
if (remoteChanged) {
|
|
1154
1402
|
// A refusal for this same version already worked this out, against a
|
|
@@ -1172,6 +1420,10 @@ export async function pull(invocation) {
|
|
|
1172
1420
|
// the record showed must match too or its differences are stale.
|
|
1173
1421
|
const alreadyShown = observed !== undefined
|
|
1174
1422
|
&& observed.displayDate === remoteDisplayDate
|
|
1423
|
+
&& (remoteDisplayAuthor === undefined || observed.displayAuthor === undefined
|
|
1424
|
+
|| observed.displayAuthor === remoteDisplayAuthor)
|
|
1425
|
+
&& (remoteShowOnProfile === undefined || observed.showOnProfile === undefined
|
|
1426
|
+
|| observed.showOnProfile === remoteShowOnProfile)
|
|
1175
1427
|
&& (revision === undefined
|
|
1176
1428
|
? observed.revision === undefined && observed.remoteHash === remoteHash
|
|
1177
1429
|
: observed.revision === revision);
|
|
@@ -1188,6 +1440,7 @@ export async function pull(invocation) {
|
|
|
1188
1440
|
markdown,
|
|
1189
1441
|
localChanged,
|
|
1190
1442
|
body,
|
|
1443
|
+
taggedTemplate,
|
|
1191
1444
|
});
|
|
1192
1445
|
// Sanitized as one message: the page path is server data and the paths
|
|
1193
1446
|
// are drawn from an untrusted document, and the same strings reach
|
|
@@ -1209,6 +1462,8 @@ export async function pull(invocation) {
|
|
|
1209
1462
|
observedRevision: revision,
|
|
1210
1463
|
observedRemoteHash: remoteHash,
|
|
1211
1464
|
observedDisplayDate: remoteDisplayDate,
|
|
1465
|
+
observedDisplayAuthor: remoteDisplayAuthor,
|
|
1466
|
+
observedShowOnProfile: remoteShowOnProfile,
|
|
1212
1467
|
observedRevisionFile: internalPageObservedRevisionFile(summary.pageId),
|
|
1213
1468
|
});
|
|
1214
1469
|
}
|
|
@@ -1228,6 +1483,22 @@ export async function pull(invocation) {
|
|
|
1228
1483
|
}
|
|
1229
1484
|
}
|
|
1230
1485
|
|
|
1486
|
+
// A malformed snapshot on an untracked typed page must also fail before
|
|
1487
|
+
// touching the workspace. Spool each validated projection as it arrives
|
|
1488
|
+
// so a fresh pull need only hold one of those bodies in memory at a time.
|
|
1489
|
+
const stagedFresh = new Map();
|
|
1490
|
+
for (const summary of authorable) {
|
|
1491
|
+
if (tracked.has(summary.pageId) || !readsAuthoredTags(summary)) continue;
|
|
1492
|
+
const { entry, source } = await readFreshProjection(summary, pageFiles.get(summary.pageId));
|
|
1493
|
+
let stageFile;
|
|
1494
|
+
if (source !== undefined) {
|
|
1495
|
+
stageDirectory ??= await mkdtemp(path.join(tmpdir(), "taproot-pull-pages-"));
|
|
1496
|
+
stageFile = path.join(stageDirectory, String(stagedFresh.size));
|
|
1497
|
+
await writeFile(stageFile, source, { mode: 0o600 });
|
|
1498
|
+
}
|
|
1499
|
+
stagedFresh.set(summary.pageId, { entry, stageFile });
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1231
1502
|
// Internal state, written before the refusal below on purpose: it is what
|
|
1232
1503
|
// makes "the site's version is preserved at ..." true. Nothing here is a
|
|
1233
1504
|
// page source, and rewriting it is idempotent.
|
|
@@ -1260,6 +1531,8 @@ export async function pull(invocation) {
|
|
|
1260
1531
|
? { remoteHash: conflict.observedRemoteHash }
|
|
1261
1532
|
: { revision: conflict.observedRevision }),
|
|
1262
1533
|
...(conflict.observedDisplayDate === undefined ? {} : { displayDate: conflict.observedDisplayDate }),
|
|
1534
|
+
...(conflict.observedDisplayAuthor === undefined ? {} : { displayAuthor: conflict.observedDisplayAuthor }),
|
|
1535
|
+
...(conflict.observedShowOnProfile === undefined ? {} : { showOnProfile: conflict.observedShowOnProfile }),
|
|
1263
1536
|
...(conflict.differences === undefined ? {} : { differences: conflict.differences }),
|
|
1264
1537
|
});
|
|
1265
1538
|
}
|
|
@@ -1281,6 +1554,7 @@ export async function pull(invocation) {
|
|
|
1281
1554
|
isGenerated: summary.isGenerated,
|
|
1282
1555
|
workspaceMode: PAGE_WORKSPACE_MODE_METADATA_ONLY,
|
|
1283
1556
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1557
|
+
...(summary.reviewAuthorMissing === undefined ? {} : { reviewAuthorMissing: summary.reviewAuthorMissing }),
|
|
1284
1558
|
};
|
|
1285
1559
|
if (isAuthorableTemplateType(summary.templateType)) {
|
|
1286
1560
|
// This pull is reconciling the page, so the manifest below carries the
|
|
@@ -1320,40 +1594,13 @@ export async function pull(invocation) {
|
|
|
1320
1594
|
manifestPages.push(entry);
|
|
1321
1595
|
continue;
|
|
1322
1596
|
}
|
|
1323
|
-
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
// The server accepts and stores a body it never validates, so an
|
|
1331
|
-
// unreadable one is a real state. It is reported rather than written
|
|
1332
|
-
// as an empty document that a later push would send back.
|
|
1333
|
-
onProgress(`Page '${summary.path}' has no readable body; snapshotting metadata only.`);
|
|
1334
|
-
} else {
|
|
1335
|
-
entry.file = pageFiles.get(summary.pageId);
|
|
1336
|
-
if (isGeneratedTemplateType(summary.templateType)) entry.generated = generatedIdentity(body.data);
|
|
1337
|
-
if (isLegalTemplateType(summary.templateType)) entry.legal = legalIdentity(body.data);
|
|
1338
|
-
const source = Buffer.from(`${JSON.stringify(body, undefined, 2)}\n`, "utf8");
|
|
1339
|
-
entry.workspaceMode = PAGE_WORKSPACE_MODE_EDITABLE;
|
|
1340
|
-
entry.sourceFormat = pageSourceFormat(entry.file);
|
|
1341
|
-
const revision = normalizePageBodyRevision(page.bodyRevision);
|
|
1342
|
-
const displayDate = trackedDisplayDate(page, summary.templateType);
|
|
1343
|
-
entry.baseline = {
|
|
1344
|
-
remoteHash: canonicalDocumentHash(body),
|
|
1345
|
-
sourceHash: workspaceContentHash(source),
|
|
1346
|
-
contentKey: pageContentKey(workspaceContentHash(source), {
|
|
1347
|
-
title: entry.title,
|
|
1348
|
-
path: entry.path,
|
|
1349
|
-
description: entry.description,
|
|
1350
|
-
author: entry.author,
|
|
1351
|
-
}),
|
|
1352
|
-
...(revision === undefined ? {} : { revision }),
|
|
1353
|
-
...(displayDate === undefined ? {} : { displayDate }),
|
|
1354
|
-
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1355
|
-
};
|
|
1356
|
-
await writeWorkspaceFile(config.workspaceDir, entry.file, source);
|
|
1597
|
+
const staged = stagedFresh.get(summary.pageId);
|
|
1598
|
+
const fresh = staged === undefined
|
|
1599
|
+
? await readFreshProjection(summary, pageFiles.get(summary.pageId))
|
|
1600
|
+
: { entry: staged.entry, source: staged.stageFile === undefined ? undefined : await readFile(staged.stageFile) };
|
|
1601
|
+
Object.assign(entry, fresh.entry);
|
|
1602
|
+
if (fresh.source !== undefined) {
|
|
1603
|
+
await writeWorkspaceFile(config.workspaceDir, entry.file, fresh.source);
|
|
1357
1604
|
bodies += 1;
|
|
1358
1605
|
const baselineFile = internalPageBaselineFile(summary.pageId);
|
|
1359
1606
|
if (baselineFile !== undefined) await deleteWorkspaceFile(config.workspaceDir, baselineFile);
|
|
@@ -1422,7 +1669,13 @@ export async function pull(invocation) {
|
|
|
1422
1669
|
? { appearance: appearanceManifestEntry(pulledAppearance) }
|
|
1423
1670
|
: {}
|
|
1424
1671
|
),
|
|
1425
|
-
...(presentationRevision === undefined ? {} : {
|
|
1672
|
+
...(presentationRevision === undefined ? {} : {
|
|
1673
|
+
presentation: presentationManifestEntry(
|
|
1674
|
+
presentationRevision, presentation.sitePublishingPreferences?.tagDestinations,
|
|
1675
|
+
tagDestinationCatalogSlugs(presentation.tagDestinationCatalog),
|
|
1676
|
+
presentation.sitePublishingPreferences?.recipeMetadataDestinations,
|
|
1677
|
+
),
|
|
1678
|
+
}),
|
|
1426
1679
|
...(formsBaseline === undefined ? {} : { forms: formsBaseline }),
|
|
1427
1680
|
...(marketingBaseline === undefined ? {} : { [MARKETING_MANIFEST_KEY]: marketingBaseline }),
|
|
1428
1681
|
pages: manifestPages,
|
|
@@ -1493,5 +1746,7 @@ export async function pull(invocation) {
|
|
|
1493
1746
|
files: pulledSettings.map((entry) => entry.file),
|
|
1494
1747
|
},
|
|
1495
1748
|
});
|
|
1749
|
+
}).finally(async () => {
|
|
1750
|
+
if (stageDirectory !== undefined) await rm(stageDirectory, { recursive: true, force: true });
|
|
1496
1751
|
});
|
|
1497
1752
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getStagingPreviewStatus,
|
|
3
|
+
mintStagingPreviewHandoff,
|
|
4
|
+
STAGING_HOSTING_SETUP_GUIDANCE,
|
|
5
|
+
withRefusalGuidance,
|
|
6
|
+
} from "../api.js";
|
|
2
7
|
import { STAGING_REVIEW_SESSION_NOTE, VERB_STAGING_REVIEW } from "../constants.js";
|
|
8
|
+
import { SiteAuthoringError } from "../errors.js";
|
|
3
9
|
import { openSession, successResult } from "../session.js";
|
|
4
10
|
|
|
5
11
|
export const STAGING_REVIEW_GUIDANCE = "Open the URL once in a browser, then switch the site's theme toggle between "
|
|
@@ -20,6 +26,26 @@ export const STAGING_REVIEW_GUIDANCE = "Open the URL once in a browser, then swi
|
|
|
20
26
|
export async function stagingReview(invocation) {
|
|
21
27
|
const { client, siteId, now, onProgress } = await openSession(invocation);
|
|
22
28
|
return await withRefusalGuidance(onProgress, "staging review", async () => {
|
|
29
|
+
const staging = await getStagingPreviewStatus(client, siteId);
|
|
30
|
+
if (!staging.ready) {
|
|
31
|
+
throw new SiteAuthoringError("staging.host_unavailable", STAGING_HOSTING_SETUP_GUIDANCE, { field: "Hosting" });
|
|
32
|
+
}
|
|
33
|
+
if (staging.hasStagedRelease === false) {
|
|
34
|
+
throw new SiteAuthoringError(
|
|
35
|
+
"staging.deployment_required",
|
|
36
|
+
"There is no acknowledged staging release to review. Run 'taproot-site deploy --staging' first "
|
|
37
|
+
+ "or wait for the first staging deployment to finish.",
|
|
38
|
+
{ field: "staging" },
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (staging.hasStagedRelease !== true) {
|
|
42
|
+
throw new SiteAuthoringError(
|
|
43
|
+
"staging.release_status_unavailable",
|
|
44
|
+
"Taproot could not confirm a staging release. Retry on an updated server, or run "
|
|
45
|
+
+ "'taproot-site deploy --staging --handoff' when ready to stage a release.",
|
|
46
|
+
{ field: "staging" },
|
|
47
|
+
);
|
|
48
|
+
}
|
|
23
49
|
onProgress("Minting a fresh single-use staging review handoff.");
|
|
24
50
|
const handoff = await mintStagingPreviewHandoff(client, siteId, { now, returnPath: invocation.reviewPath });
|
|
25
51
|
onProgress(`Staging review handoff minted for ${handoff.stagingUrl}. ${STAGING_REVIEW_GUIDANCE}`);
|