@taprootio/site-authoring 0.62.0 → 0.64.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 +63 -23
- package/package.json +2 -2
- package/src/api.js +149 -21
- package/src/appearance-contract.js +9 -0
- package/src/article-end-settings.js +295 -0
- package/src/changelog.json +39 -0
- package/src/chrome-input.js +1 -1
- package/src/cli.js +110 -26
- package/src/constants.js +7 -0
- package/src/content/components.js +130 -14
- package/src/content/cta-decoration-paint.js +321 -0
- package/src/content/form-placement-presentation.js +91 -0
- package/src/content/form-placement-presentation.json +6 -0
- package/src/content/free-form-section-registry.json +19 -1
- package/src/content/free-form-sections.js +64 -55
- package/src/content/markdown.js +13 -0
- package/src/content/tiptap-prosemirror.ts +72 -59
- package/src/content/validate-document.js +2 -0
- package/src/cta-artwork-warnings.js +164 -0
- package/src/errors.js +6 -0
- package/src/field-schema.json +6 -2
- package/src/field-validation.js +14 -5
- package/src/footer-workspace.js +7 -3
- package/src/form-references.js +71 -9
- package/src/forms-contract.js +3 -5
- package/src/heading-outline.js +7 -0
- package/src/output.js +2 -0
- package/src/page-article-end.js +66 -0
- package/src/page-block-catalog.js +54 -0
- package/src/page-form-presentation.js +104 -0
- package/src/page-structure-checks.js +7 -1
- package/src/placed-image-ids.js +15 -18
- package/src/presentation-reference.js +30 -52
- package/src/reference-help.js +97 -27
- package/src/reusable-blocks.js +429 -0
- package/src/reusable-placements.js +271 -0
- package/src/setting-reference.js +25 -1
- package/src/settings-catalog.js +1 -0
- package/src/site-check-findings.js +30 -2
- package/src/site-check-rules.json +1 -0
- package/src/site-checks.js +26 -2
- package/src/site-health-findings.js +25 -3
- package/src/site-health-image-checks.js +1 -1
- package/src/staging-check.js +108 -21
- package/src/staging-served.js +5 -49
- package/src/status-warning-paints.js +17 -0
- package/src/template-token-reach.json +14 -2
- package/src/theme-resolve.js +27 -0
- package/src/transport.js +41 -5
- package/src/typed-page-reference.js +55 -5
- package/src/typed-pages.js +27 -4
- package/src/verbs/approve.js +2 -1
- package/src/verbs/deploy.js +93 -15
- package/src/verbs/footer-push.js +4 -2
- package/src/verbs/forms-push.js +9 -0
- package/src/verbs/health.js +11 -6
- package/src/verbs/index.js +3 -0
- package/src/verbs/pages-blocks-pull.js +22 -0
- package/src/verbs/pages-push.js +89 -34
- package/src/verbs/plan.js +34 -5
- package/src/verbs/pull.js +213 -124
- package/src/verbs/status.js +20 -2
- package/src/verbs/theme-push.js +164 -14
- package/src/verbs/theme-resolve.js +114 -40
- package/src/verbs/validate.js +49 -18
- package/src/workspace-check.js +42 -5
- package/src/workspace-context-usage.js +54 -1
- package/src/workspace.js +37 -7
- package/test/fixtures/default-site-theme.json +1 -1
package/src/verbs/pull.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
VERB_PULL,
|
|
26
26
|
} from "../constants.js";
|
|
27
27
|
import { tagDestinationCatalogSlugs } from "../appearance-contract.js";
|
|
28
|
+
import { ARTICLE_END_FILE, articleEndImageIds, readArticleEndPresentation } from "../article-end-settings.js";
|
|
28
29
|
import { validateAuthoredTagNames } from "../authored-tag-names.js";
|
|
29
30
|
import {
|
|
30
31
|
AUTHORS_FILE_NAME,
|
|
@@ -50,7 +51,15 @@ import {
|
|
|
50
51
|
SETTINGS_TYPE_TAPROOT_STYLES,
|
|
51
52
|
} from "../settings-catalog.js";
|
|
52
53
|
import { ApiError } from "../transport.js";
|
|
53
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
projectReusableBlocks,
|
|
56
|
+
readReusablePresentation,
|
|
57
|
+
REUSABLE_BLOCKS_FILE,
|
|
58
|
+
reusableWorkspaceEvidence,
|
|
59
|
+
} from "../reusable-blocks.js";
|
|
60
|
+
import { normalizeReusablePlacements } from "../reusable-placements.js";
|
|
61
|
+
import { getSitePageBlockCatalog } from "../page-block-catalog.js";
|
|
62
|
+
import { formPresentationHash, placesFormIds, readFormIndex, withFormKeys } from "../form-references.js";
|
|
54
63
|
import { MARKETING_MANIFEST_KEY } from "../marketing-workspace.js";
|
|
55
64
|
import {
|
|
56
65
|
generatedIdentity,
|
|
@@ -102,6 +111,7 @@ import {
|
|
|
102
111
|
workspacePageSourceBodyHash,
|
|
103
112
|
readManifest,
|
|
104
113
|
writeManifest,
|
|
114
|
+
serializeManifest,
|
|
105
115
|
writeWorkspaceFile,
|
|
106
116
|
writeWorkspaceJson,
|
|
107
117
|
} from "../workspace.js";
|
|
@@ -334,6 +344,13 @@ function projectedPageTags(page, summary, onProgress) {
|
|
|
334
344
|
return { ...projection, revision: snapshot.revision };
|
|
335
345
|
}
|
|
336
346
|
|
|
347
|
+
function markdownSourceArticleEnd(sourceBytes, file) {
|
|
348
|
+
const { fields, candidates, fault } = parseFrontMatter(sourceBytes.toString("utf8"), file);
|
|
349
|
+
if (fault?.code === "pages.article_end_invalid" || candidates.has("articleEnd")) return undefined;
|
|
350
|
+
const stated = fields.get("articleEnd");
|
|
351
|
+
return stated === undefined || stated === "true" ? true : stated === "false" ? false : undefined;
|
|
352
|
+
}
|
|
353
|
+
|
|
337
354
|
function markdownSourceTags(sourceBytes, file) {
|
|
338
355
|
const { fields, candidates, fault } = parseFrontMatter(sourceBytes.toString("utf8"), file);
|
|
339
356
|
if (fault?.field === "tags") throw fault;
|
|
@@ -617,15 +634,16 @@ async function readSourceRegistry(workspaceDir, siteId) {
|
|
|
617
634
|
}
|
|
618
635
|
|
|
619
636
|
/** The manifest is read back under a byte bound, so a pull that would write a larger one is refused first. */
|
|
620
|
-
export function requireManifestRoom(pending, live) {
|
|
637
|
+
export function requireManifestRoom(pending, live, pageBlockCatalog) {
|
|
621
638
|
const bytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
|
|
622
639
|
// A pulled page entry also carries a baseline hash and authored fields; 512 bytes covers them.
|
|
623
640
|
const estimate = pending.reduce((total, entry) => total + bytes(entry), 0)
|
|
624
|
-
+ live.reduce((total, summary) => total + bytes(summary) + 512, 0)
|
|
641
|
+
+ live.reduce((total, summary) => total + bytes(summary) + 512, 0)
|
|
642
|
+
+ (pageBlockCatalog === undefined ? 0 : Buffer.byteLength(JSON.stringify({ pageBlockCatalog }, null, 2), "utf8"));
|
|
625
643
|
if (estimate > WORKSPACE_LIMITS.manifestBytes) {
|
|
626
644
|
throw new SiteAuthoringError(
|
|
627
645
|
"pull.manifest_too_large",
|
|
628
|
-
`The pull manifest would exceed ${WORKSPACE_LIMITS.manifestBytes} bytes
|
|
646
|
+
`The pull manifest would exceed ${WORKSPACE_LIMITS.manifestBytes} bytes. `
|
|
629
647
|
+ "Save or remove pending entries, then run 'taproot-site pull' again. Nothing was changed.",
|
|
630
648
|
);
|
|
631
649
|
}
|
|
@@ -929,20 +947,171 @@ async function requireWorkspaceBelongsToSite(workspaceDir, siteId) {
|
|
|
929
947
|
}
|
|
930
948
|
}
|
|
931
949
|
|
|
950
|
+
async function readPullSettings(client, siteId, onProgress) {
|
|
951
|
+
// Project every settings response before the first workspace write. Theme
|
|
952
|
+
// decoding is a wire-contract check and can fail on malformed stored data;
|
|
953
|
+
// discovering that after page bodies were written would strand an
|
|
954
|
+
// unbound workspace that the next pull must refuse for safety.
|
|
955
|
+
//
|
|
956
|
+
// The four groups and the presentation revision `theme push` is fenced by
|
|
957
|
+
// (TR00807) come from one read: the presentation snapshot carries the
|
|
958
|
+
// groups' documents exactly as the revision covers them, so the baseline
|
|
959
|
+
// the manifest records is the revision of the documents the workspace
|
|
960
|
+
// holds. Four per-group reads followed by a revision read would pair
|
|
961
|
+
// whatever the groups held with whatever the revision had become by then,
|
|
962
|
+
// and a push fenced by that baseline could overwrite an edit the workspace
|
|
963
|
+
// never saw. The per-group reads remain for a Taproot that predates the
|
|
964
|
+
// snapshot (404) and for a credential that cannot read it (403): both
|
|
965
|
+
// record no baseline, and `theme push` refuses toward a pull that does.
|
|
966
|
+
let presentation;
|
|
967
|
+
onProgress("Reading the presentation snapshot.");
|
|
968
|
+
try {
|
|
969
|
+
presentation = await getSitePresentation(client, siteId);
|
|
970
|
+
} catch (error) {
|
|
971
|
+
if (
|
|
972
|
+
error instanceof ApiError
|
|
973
|
+
&& error.refusalKind() === REFUSAL_UNCLASSIFIED
|
|
974
|
+
&& error.httpStatus === 404
|
|
975
|
+
) {
|
|
976
|
+
onProgress(
|
|
977
|
+
"This Taproot does not serve the atomic presentation save yet; the settings groups are read one at a "
|
|
978
|
+
+ "time, the manifest records no presentation baseline, and 'theme push' will refuse until it is "
|
|
979
|
+
+ "pulled from a Taproot that does.",
|
|
980
|
+
);
|
|
981
|
+
} else if (
|
|
982
|
+
error instanceof ApiError
|
|
983
|
+
&& (error.refusalKind() === REFUSAL_UNCLASSIFIED
|
|
984
|
+
|| error.refusalKind() === REFUSAL_CAPABILITY_MISSING)
|
|
985
|
+
&& error.httpStatus === 403
|
|
986
|
+
) {
|
|
987
|
+
onProgress(
|
|
988
|
+
"The presentation snapshot is not readable by this credential; the settings groups are read one at a "
|
|
989
|
+
+ "time and the manifest records no presentation baseline.",
|
|
990
|
+
);
|
|
991
|
+
} else {
|
|
992
|
+
throw error;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
const pulledSettings = [];
|
|
996
|
+
const skippedSettings = [];
|
|
997
|
+
const settingsDocuments = [];
|
|
998
|
+
let pulledFooter;
|
|
999
|
+
const pulledAppearance = {};
|
|
1000
|
+
for (const group of SETTINGS_GROUPS) {
|
|
1001
|
+
let response;
|
|
1002
|
+
if (presentation !== undefined) {
|
|
1003
|
+
response = presentation;
|
|
1004
|
+
} else {
|
|
1005
|
+
onProgress(`Reading settings group ${group.settingsType}.`);
|
|
1006
|
+
try {
|
|
1007
|
+
response = await getSettingsGroup(client, siteId, group.settingsType);
|
|
1008
|
+
} catch (error) {
|
|
1009
|
+
if (
|
|
1010
|
+
error instanceof ApiError
|
|
1011
|
+
&& (error.refusalKind() === REFUSAL_UNCLASSIFIED
|
|
1012
|
+
|| error.refusalKind() === REFUSAL_CAPABILITY_MISSING)
|
|
1013
|
+
&& UNAVAILABLE_SETTINGS_STATUSES.has(error.httpStatus)
|
|
1014
|
+
) {
|
|
1015
|
+
onProgress(`Settings group ${group.settingsType} is not readable by this credential; skipping it.`);
|
|
1016
|
+
skippedSettings.push(group.settingsType);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
throw error;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
const file = `${SETTINGS_DIRECTORY}/${group.file}`;
|
|
1023
|
+
const projected = projectSettingsGroup(group, response);
|
|
1024
|
+
settingsDocuments.push({
|
|
1025
|
+
file,
|
|
1026
|
+
value: {
|
|
1027
|
+
settingsType: group.settingsType,
|
|
1028
|
+
entityId: siteId,
|
|
1029
|
+
settings: projected,
|
|
1030
|
+
},
|
|
1031
|
+
});
|
|
1032
|
+
if (group.settingsType === SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES) {
|
|
1033
|
+
pulledFooter = projected.footerSettings;
|
|
1034
|
+
}
|
|
1035
|
+
if (APPEARANCE_SETTINGS_TYPES.includes(group.settingsType)) {
|
|
1036
|
+
pulledAppearance[group.settingsType] = projected;
|
|
1037
|
+
}
|
|
1038
|
+
pulledSettings.push({ settingsType: group.settingsType, file });
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
const reusable = readReusablePresentation(presentation);
|
|
1042
|
+
const reusableDocument = projectReusableBlocks(reusable.blocks, reusable.forms);
|
|
1043
|
+
if (reusableDocument !== undefined) settingsDocuments.push({ file: REUSABLE_BLOCKS_FILE, value: reusableDocument });
|
|
1044
|
+
const articleEnd = readArticleEndPresentation(presentation);
|
|
1045
|
+
if (articleEnd !== undefined) settingsDocuments.push({ file: ARTICLE_END_FILE, value: articleEnd.document });
|
|
1046
|
+
return { presentation, pulledSettings, skippedSettings, settingsDocuments, pulledFooter, pulledAppearance, reusable, articleEnd };
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
const pullSettingsResult = ({ pulledSettings, skippedSettings, settingsDocuments }) => ({
|
|
1050
|
+
pulled: pulledSettings.map(({ settingsType }) => settingsType),
|
|
1051
|
+
skipped: skippedSettings,
|
|
1052
|
+
files: settingsDocuments.map(({ file }) => file),
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
function pulledSettingsBaselines({ presentation, pulledSettings, skippedSettings, pulledFooter, pulledAppearance, reusable, articleEnd }) {
|
|
1056
|
+
const reusableBlocks = reusableWorkspaceEvidence(reusable);
|
|
1057
|
+
const articleEndOwnedImages = articleEnd === undefined ? [] : articleEndImageIds(articleEnd.document);
|
|
1058
|
+
return {
|
|
1059
|
+
settings: pulledSettings,
|
|
1060
|
+
settingsSkipped: skippedSettings,
|
|
1061
|
+
...(pulledFooter === undefined ? {} : { footer: footerManifestEntry(pulledFooter) }),
|
|
1062
|
+
...(APPEARANCE_SETTINGS_TYPES.every((type) => pulledAppearance[type] !== undefined)
|
|
1063
|
+
? { appearance: appearanceManifestEntry(pulledAppearance) } : {}),
|
|
1064
|
+
...(presentation === undefined ? {} : {
|
|
1065
|
+
presentation: presentationManifestEntry(
|
|
1066
|
+
presentation.revision, presentation.sitePublishingPreferences?.tagDestinations,
|
|
1067
|
+
tagDestinationCatalogSlugs(presentation.tagDestinationCatalog),
|
|
1068
|
+
presentation.sitePublishingPreferences?.recipeMetadataDestinations,
|
|
1069
|
+
),
|
|
1070
|
+
}),
|
|
1071
|
+
...(reusableBlocks === undefined ? {} : { reusableBlocks }),
|
|
1072
|
+
...(articleEnd === undefined ? {} : { articleEndTags: articleEnd.tags }),
|
|
1073
|
+
...(articleEndOwnedImages.length === 0 ? {} : { articleEndOwnedImages }),
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
async function pullSettingsOnly({ client, config, siteId, surface, now, onProgress }) {
|
|
1078
|
+
const previous = await readManifest(config.workspaceDir, siteId, { required: false });
|
|
1079
|
+
const snapshot = await withRefusalGuidance(onProgress, "pull", () => readPullSettings(client, siteId, onProgress));
|
|
1080
|
+
const baselines = pulledSettingsBaselines(snapshot);
|
|
1081
|
+
const manifest = previous ?? {
|
|
1082
|
+
manifestVersion: MANIFEST_VERSION,
|
|
1083
|
+
siteId,
|
|
1084
|
+
pages: [],
|
|
1085
|
+
...(surface === SURFACE_DOCS_PRESENTATION
|
|
1086
|
+
? { authoringSurface: SURFACE_DOCS_PRESENTATION, pagesTruncated: false }
|
|
1087
|
+
: { settingsOnly: true, pagesTruncated: true }),
|
|
1088
|
+
};
|
|
1089
|
+
for (const key of ["footer", "appearance", "presentation", "reusableBlocks", "articleEndTags", "articleEndOwnedImages"]) delete manifest[key];
|
|
1090
|
+
Object.assign(manifest, baselines, { settingsPulledAt: new Date(now()).toISOString() });
|
|
1091
|
+
const manifestContents = serializeManifest(manifest);
|
|
1092
|
+
for (const { file, value } of snapshot.settingsDocuments) await writeWorkspaceJson(config.workspaceDir, file, value);
|
|
1093
|
+
await writeWorkspaceFile(config.workspaceDir, MANIFEST_FILE_NAME, manifestContents);
|
|
1094
|
+
onProgress("Refreshed the workspace presentation and kept its content inventory.");
|
|
1095
|
+
return successResult(VERB_PULL, siteId, { settingsOnly: true, settings: pullSettingsResult(snapshot) });
|
|
1096
|
+
}
|
|
1097
|
+
|
|
932
1098
|
export async function pull(invocation) {
|
|
933
|
-
const
|
|
1099
|
+
const session = await openSession(invocation);
|
|
1100
|
+
const { client, config, siteId, surface, now, onProgress } = session;
|
|
934
1101
|
// A page names its forms by id on the site and by key in the workspace (TR01216). The
|
|
935
|
-
//
|
|
1102
|
+
// catalog covers every page. Older sites only need a forms read if a page places one.
|
|
1103
|
+
let pageBlockCatalog;
|
|
936
1104
|
let formKeys;
|
|
937
1105
|
const workspaceBodyFromPage = async (page, listedTemplateType) => {
|
|
938
|
-
const body = workspaceDocumentFromPage(page, listedTemplateType);
|
|
1106
|
+
const body = normalizeReusablePlacements(workspaceDocumentFromPage(page, listedTemplateType));
|
|
939
1107
|
if (body === undefined || !placesFormIds(body)) return body;
|
|
940
|
-
formKeys ??= readFormIndex(client, siteId).then((index) => index.keyById);
|
|
1108
|
+
formKeys ??= readFormIndex(client, siteId, pageBlockCatalog?.forms).then((index) => index.keyById);
|
|
941
1109
|
return withFormKeys(body, await formKeys);
|
|
942
1110
|
};
|
|
943
1111
|
await ensureWorkspaceRoot(config);
|
|
944
1112
|
|
|
945
1113
|
await requireWorkspaceBelongsToSite(config.workspaceDir, siteId);
|
|
1114
|
+
if (invocation.settingsOnly) return await pullSettingsOnly(session);
|
|
946
1115
|
|
|
947
1116
|
const { registry, pending: pendingEntries } = await readSourceRegistry(config.workspaceDir, siteId);
|
|
948
1117
|
const pendingPaths = await requireCarriablePendingEntries(config.workspaceDir, pendingEntries);
|
|
@@ -965,6 +1134,8 @@ export async function pull(invocation) {
|
|
|
965
1134
|
} else {
|
|
966
1135
|
onProgress("Listing the site's pages.");
|
|
967
1136
|
({ pages, truncated } = await listSitePages(client, siteId, { onProgress }));
|
|
1137
|
+
const catalog = await getSitePageBlockCatalog(client, siteId);
|
|
1138
|
+
if (catalog?.forms !== undefined || catalog?.definitions !== undefined) pageBlockCatalog = catalog;
|
|
968
1139
|
}
|
|
969
1140
|
const live = pages.filter((summary) => !isGonePage(summary));
|
|
970
1141
|
const authorable = live.filter((summary) => isAuthorableTemplateType(summary.templateType));
|
|
@@ -996,6 +1167,7 @@ export async function pull(invocation) {
|
|
|
996
1167
|
const remoteHash = canonicalDocumentHash(body);
|
|
997
1168
|
const sourceBodyHash = supportsAuthoredTagWireType(summary.templateType) ? remoteHash : undefined;
|
|
998
1169
|
const revision = normalizePageBodyRevision(page.bodyRevision);
|
|
1170
|
+
const formHash = revision === undefined ? undefined : formPresentationHash(body);
|
|
999
1171
|
const displayDate = trackedDisplayDate(page, summary.templateType);
|
|
1000
1172
|
const displayAuthor = trackedDisplayAuthor(page, summary.templateType);
|
|
1001
1173
|
const showOnProfile = trackedShowOnProfile(page, summary.templateType);
|
|
@@ -1017,9 +1189,11 @@ export async function pull(invocation) {
|
|
|
1017
1189
|
}),
|
|
1018
1190
|
...(sourceBodyHash === undefined ? {} : { sourceBodyHash }),
|
|
1019
1191
|
...(revision === undefined ? {} : { revision }),
|
|
1192
|
+
...(formHash === undefined ? {} : { formPresentationHash: formHash }),
|
|
1020
1193
|
...(displayDate === undefined ? {} : { displayDate }),
|
|
1021
1194
|
...(displayAuthor === undefined ? {} : { displayAuthor }),
|
|
1022
1195
|
...(showOnProfile === undefined ? {} : { showOnProfile }),
|
|
1196
|
+
...(page.articleEnd === undefined ? {} : { articleEnd: page.articleEnd }),
|
|
1023
1197
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1024
1198
|
...(confirmedTags === undefined ? {} : {
|
|
1025
1199
|
authoredTagRevision: confirmedTags.revision,
|
|
@@ -1094,7 +1268,7 @@ export async function pull(invocation) {
|
|
|
1094
1268
|
}
|
|
1095
1269
|
const retiredFiles = retiredGeneratedSources.map((source) => source.file);
|
|
1096
1270
|
requireNoPendingCollisions(pendingEntries, { live, tracked, truncated, retiredFiles, effectivePaths: pendingPaths });
|
|
1097
|
-
requireManifestRoom(pendingEntries, live);
|
|
1271
|
+
requireManifestRoom(pendingEntries, live, pageBlockCatalog);
|
|
1098
1272
|
const keptPendingEntries = pendingEntries;
|
|
1099
1273
|
const pageFiles = assignPageFiles(
|
|
1100
1274
|
authorable,
|
|
@@ -1177,97 +1351,7 @@ export async function pull(invocation) {
|
|
|
1177
1351
|
}
|
|
1178
1352
|
}
|
|
1179
1353
|
|
|
1180
|
-
|
|
1181
|
-
// decoding is a wire-contract check and can fail on malformed stored data;
|
|
1182
|
-
// discovering that after page bodies were written would strand an
|
|
1183
|
-
// unbound workspace that the next pull must refuse for safety.
|
|
1184
|
-
//
|
|
1185
|
-
// The four groups and the presentation revision `theme push` is fenced by
|
|
1186
|
-
// (TR00807) come from one read: the presentation snapshot carries the
|
|
1187
|
-
// groups' documents exactly as the revision covers them, so the baseline
|
|
1188
|
-
// the manifest records is the revision of the documents the workspace
|
|
1189
|
-
// holds. Four per-group reads followed by a revision read would pair
|
|
1190
|
-
// whatever the groups held with whatever the revision had become by then,
|
|
1191
|
-
// and a push fenced by that baseline could overwrite an edit the workspace
|
|
1192
|
-
// never saw. The per-group reads remain for a Taproot that predates the
|
|
1193
|
-
// snapshot (404) and for a credential that cannot read it (403): both
|
|
1194
|
-
// record no baseline, and `theme push` refuses toward a pull that does.
|
|
1195
|
-
let presentation;
|
|
1196
|
-
onProgress("Reading the presentation snapshot.");
|
|
1197
|
-
try {
|
|
1198
|
-
presentation = await getSitePresentation(client, siteId);
|
|
1199
|
-
} catch (error) {
|
|
1200
|
-
if (
|
|
1201
|
-
error instanceof ApiError
|
|
1202
|
-
&& error.refusalKind() === REFUSAL_UNCLASSIFIED
|
|
1203
|
-
&& error.httpStatus === 404
|
|
1204
|
-
) {
|
|
1205
|
-
onProgress(
|
|
1206
|
-
"This Taproot does not serve the atomic presentation save yet; the settings groups are read one at a "
|
|
1207
|
-
+ "time, the manifest records no presentation baseline, and 'theme push' will refuse until it is "
|
|
1208
|
-
+ "pulled from a Taproot that does.",
|
|
1209
|
-
);
|
|
1210
|
-
} else if (
|
|
1211
|
-
error instanceof ApiError
|
|
1212
|
-
&& (error.refusalKind() === REFUSAL_UNCLASSIFIED
|
|
1213
|
-
|| error.refusalKind() === REFUSAL_CAPABILITY_MISSING)
|
|
1214
|
-
&& error.httpStatus === 403
|
|
1215
|
-
) {
|
|
1216
|
-
onProgress(
|
|
1217
|
-
"The presentation snapshot is not readable by this credential; the settings groups are read one at a "
|
|
1218
|
-
+ "time and the manifest records no presentation baseline.",
|
|
1219
|
-
);
|
|
1220
|
-
} else {
|
|
1221
|
-
throw error;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
const presentationRevision = presentation?.revision;
|
|
1225
|
-
|
|
1226
|
-
const pulledSettings = [];
|
|
1227
|
-
const skippedSettings = [];
|
|
1228
|
-
const settingsDocuments = [];
|
|
1229
|
-
let pulledFooter;
|
|
1230
|
-
const pulledAppearance = {};
|
|
1231
|
-
for (const group of SETTINGS_GROUPS) {
|
|
1232
|
-
let response;
|
|
1233
|
-
if (presentation !== undefined) {
|
|
1234
|
-
response = presentation;
|
|
1235
|
-
} else {
|
|
1236
|
-
onProgress(`Reading settings group ${group.settingsType}.`);
|
|
1237
|
-
try {
|
|
1238
|
-
response = await getSettingsGroup(client, siteId, group.settingsType);
|
|
1239
|
-
} catch (error) {
|
|
1240
|
-
if (
|
|
1241
|
-
error instanceof ApiError
|
|
1242
|
-
&& (error.refusalKind() === REFUSAL_UNCLASSIFIED
|
|
1243
|
-
|| error.refusalKind() === REFUSAL_CAPABILITY_MISSING)
|
|
1244
|
-
&& UNAVAILABLE_SETTINGS_STATUSES.has(error.httpStatus)
|
|
1245
|
-
) {
|
|
1246
|
-
onProgress(`Settings group ${group.settingsType} is not readable by this credential; skipping it.`);
|
|
1247
|
-
skippedSettings.push(group.settingsType);
|
|
1248
|
-
continue;
|
|
1249
|
-
}
|
|
1250
|
-
throw error;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
const file = `${SETTINGS_DIRECTORY}/${group.file}`;
|
|
1254
|
-
const projected = projectSettingsGroup(group, response);
|
|
1255
|
-
settingsDocuments.push({
|
|
1256
|
-
file,
|
|
1257
|
-
value: {
|
|
1258
|
-
settingsType: group.settingsType,
|
|
1259
|
-
entityId: siteId,
|
|
1260
|
-
settings: projected,
|
|
1261
|
-
},
|
|
1262
|
-
});
|
|
1263
|
-
if (group.settingsType === SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES) {
|
|
1264
|
-
pulledFooter = projected.footerSettings;
|
|
1265
|
-
}
|
|
1266
|
-
if (APPEARANCE_SETTINGS_TYPES.includes(group.settingsType)) {
|
|
1267
|
-
pulledAppearance[group.settingsType] = projected;
|
|
1268
|
-
}
|
|
1269
|
-
pulledSettings.push({ settingsType: group.settingsType, file });
|
|
1270
|
-
}
|
|
1354
|
+
const settingsSnapshot = await readPullSettings(client, siteId, onProgress);
|
|
1271
1355
|
|
|
1272
1356
|
// Phase one: the pages whose source this workspace already tracks. They are
|
|
1273
1357
|
// the only ones a remote edit can collide with, and the collision has to be
|
|
@@ -1338,6 +1422,7 @@ export async function pull(invocation) {
|
|
|
1338
1422
|
const sourceBytes = await readWorkspaceFile(config.workspaceDir, source.file, WORKSPACE_LIMITS.documentBytes);
|
|
1339
1423
|
const sourceHash = workspaceContentHash(sourceBytes);
|
|
1340
1424
|
const revision = normalizePageBodyRevision(page.bodyRevision);
|
|
1425
|
+
const formHash = revision === undefined ? undefined : formPresentationHash(body);
|
|
1341
1426
|
// The revision is the site's own statement about its stored state, so it
|
|
1342
1427
|
// moves for a real edit to the body, title, path, or description and for
|
|
1343
1428
|
// nothing else. The body hash cannot make that distinction: every read
|
|
@@ -1378,12 +1463,12 @@ export async function pull(invocation) {
|
|
|
1378
1463
|
const showOnProfileChanged = remoteShowOnProfile !== undefined
|
|
1379
1464
|
&& source.baseline?.showOnProfile !== undefined
|
|
1380
1465
|
&& source.baseline.showOnProfile !== remoteShowOnProfile;
|
|
1381
|
-
const
|
|
1466
|
+
const markdown = source.sourceFormat === PAGE_SOURCE_FORMAT_MARKDOWN;
|
|
1467
|
+
const remoteArticleEnd = page.articleEnd;
|
|
1382
1468
|
// Markdown is one-way, so a Markdown source can never be rewritten from
|
|
1383
1469
|
// the site's document and is always kept. A ProseMirror source can be
|
|
1384
1470
|
// refreshed — but only over content the author has not edited since the
|
|
1385
1471
|
// last pull, because that edit is work no push has sent yet.
|
|
1386
|
-
const markdown = source.sourceFormat === PAGE_SOURCE_FORMAT_MARKDOWN;
|
|
1387
1472
|
// With no recorded hash to compare against, "unchanged" is not a safe
|
|
1388
1473
|
// default for a ProseMirror source: it schedules a refresh straight over
|
|
1389
1474
|
// whatever the file actually holds, and three states reach here — a
|
|
@@ -1436,7 +1521,18 @@ export async function pull(invocation) {
|
|
|
1436
1521
|
const generatedPage = isGeneratedTemplateType(summary.templateType);
|
|
1437
1522
|
const metadataEdited = metadataEditedLocally(source, summary.templateType);
|
|
1438
1523
|
const keepLocal = markdown || localChanged;
|
|
1439
|
-
const
|
|
1524
|
+
const localArticleEnd = () => markdown
|
|
1525
|
+
? markdownSourceArticleEnd(sourceBytes, source.file)
|
|
1526
|
+
: localDocument !== undefined && (localDocument.articleEnd === undefined || typeof localDocument.articleEnd === "boolean")
|
|
1527
|
+
? localDocument.articleEnd !== false
|
|
1528
|
+
: undefined;
|
|
1529
|
+
const articleEndChanged = remoteArticleEnd !== undefined && (
|
|
1530
|
+
source.baseline?.articleEnd === undefined
|
|
1531
|
+
? keepLocal && localArticleEnd() !== remoteArticleEnd
|
|
1532
|
+
: source.baseline.articleEnd !== remoteArticleEnd
|
|
1533
|
+
);
|
|
1534
|
+
const remoteChanged = revisionChanged || dateChanged || displayAuthorChanged || showOnProfileChanged || articleEndChanged;
|
|
1535
|
+
const conflicted = (keepLocal || metadataEdited) && remoteChanged;
|
|
1440
1536
|
const reconciled = reconcileTrackedTags({
|
|
1441
1537
|
source, projection: tagProjection, sourceBytes, localDocument, markdown,
|
|
1442
1538
|
localChanged: localChanged || !localKnown, conflicted,
|
|
@@ -1513,9 +1609,12 @@ export async function pull(invocation) {
|
|
|
1513
1609
|
}),
|
|
1514
1610
|
...reconciled.baseline,
|
|
1515
1611
|
...(revision === undefined ? {} : { revision }),
|
|
1612
|
+
// A kept source saw the remote copy only if its previous baseline recorded it.
|
|
1613
|
+
...(formHash === undefined || formHash !== source.baseline?.formPresentationHash ? {} : { formPresentationHash: formHash }),
|
|
1516
1614
|
...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
|
|
1517
1615
|
...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
|
|
1518
1616
|
...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
|
|
1617
|
+
...(remoteArticleEnd === undefined ? {} : { articleEnd: remoteArticleEnd }),
|
|
1519
1618
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1520
1619
|
}
|
|
1521
1620
|
: {
|
|
@@ -1530,9 +1629,11 @@ export async function pull(invocation) {
|
|
|
1530
1629
|
}),
|
|
1531
1630
|
...reconciled.baseline,
|
|
1532
1631
|
...(revision === undefined ? {} : { revision }),
|
|
1632
|
+
...(formHash === undefined ? {} : { formPresentationHash: formHash }),
|
|
1533
1633
|
...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
|
|
1534
1634
|
...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
|
|
1535
1635
|
...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
|
|
1636
|
+
...(remoteArticleEnd === undefined ? {} : { articleEnd: remoteArticleEnd }),
|
|
1536
1637
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1537
1638
|
},
|
|
1538
1639
|
// A conflict preserves the site's version whatever kept the source: the
|
|
@@ -1567,6 +1668,7 @@ export async function pull(invocation) {
|
|
|
1567
1668
|
|| observed.displayAuthor === remoteDisplayAuthor)
|
|
1568
1669
|
&& (remoteShowOnProfile === undefined || observed.showOnProfile === undefined
|
|
1569
1670
|
|| observed.showOnProfile === remoteShowOnProfile)
|
|
1671
|
+
&& (remoteArticleEnd === undefined || observed.articleEnd === remoteArticleEnd)
|
|
1570
1672
|
&& (revision === undefined
|
|
1571
1673
|
? observed.revision === undefined && observed.remoteHash === remoteHash
|
|
1572
1674
|
: observed.revision === revision);
|
|
@@ -1607,6 +1709,8 @@ export async function pull(invocation) {
|
|
|
1607
1709
|
observedDisplayDate: remoteDisplayDate,
|
|
1608
1710
|
observedDisplayAuthor: remoteDisplayAuthor,
|
|
1609
1711
|
observedShowOnProfile: remoteShowOnProfile,
|
|
1712
|
+
observedArticleEnd: remoteArticleEnd,
|
|
1713
|
+
observedFormPresentationHash: revision === undefined ? undefined : formHash ?? null,
|
|
1610
1714
|
observedRevisionFile: internalPageObservedRevisionFile(summary.pageId),
|
|
1611
1715
|
});
|
|
1612
1716
|
}
|
|
@@ -1676,6 +1780,8 @@ export async function pull(invocation) {
|
|
|
1676
1780
|
...(conflict.observedDisplayDate === undefined ? {} : { displayDate: conflict.observedDisplayDate }),
|
|
1677
1781
|
...(conflict.observedDisplayAuthor === undefined ? {} : { displayAuthor: conflict.observedDisplayAuthor }),
|
|
1678
1782
|
...(conflict.observedShowOnProfile === undefined ? {} : { showOnProfile: conflict.observedShowOnProfile }),
|
|
1783
|
+
...(conflict.observedArticleEnd === undefined ? {} : { articleEnd: conflict.observedArticleEnd }),
|
|
1784
|
+
...(conflict.observedFormPresentationHash === undefined ? {} : { formPresentationHash: conflict.observedFormPresentationHash }),
|
|
1679
1785
|
...(conflict.differences === undefined ? {} : { differences: conflict.differences }),
|
|
1680
1786
|
});
|
|
1681
1787
|
}
|
|
@@ -1783,7 +1889,7 @@ export async function pull(invocation) {
|
|
|
1783
1889
|
);
|
|
1784
1890
|
}
|
|
1785
1891
|
|
|
1786
|
-
for (const document of settingsDocuments) {
|
|
1892
|
+
for (const document of settingsSnapshot.settingsDocuments) {
|
|
1787
1893
|
await writeWorkspaceJson(config.workspaceDir, document.file, document.value);
|
|
1788
1894
|
}
|
|
1789
1895
|
|
|
@@ -1807,22 +1913,9 @@ export async function pull(invocation) {
|
|
|
1807
1913
|
pagesTruncated: truncated,
|
|
1808
1914
|
...(navigation === undefined ? {} : { navigation: navigationManifestEntry(navigation) }),
|
|
1809
1915
|
...(redirectMap === undefined ? {} : { redirects: redirectsManifestEntry(redirectMap) }),
|
|
1810
|
-
|
|
1811
|
-
settingsSkipped: skippedSettings,
|
|
1812
|
-
...(pulledFooter === undefined ? {} : { footer: footerManifestEntry(pulledFooter) }),
|
|
1813
|
-
...(
|
|
1814
|
-
APPEARANCE_SETTINGS_TYPES.every((settingsType) => pulledAppearance[settingsType] !== undefined)
|
|
1815
|
-
? { appearance: appearanceManifestEntry(pulledAppearance) }
|
|
1816
|
-
: {}
|
|
1817
|
-
),
|
|
1818
|
-
...(presentationRevision === undefined ? {} : {
|
|
1819
|
-
presentation: presentationManifestEntry(
|
|
1820
|
-
presentationRevision, presentation.sitePublishingPreferences?.tagDestinations,
|
|
1821
|
-
tagDestinationCatalogSlugs(presentation.tagDestinationCatalog),
|
|
1822
|
-
presentation.sitePublishingPreferences?.recipeMetadataDestinations,
|
|
1823
|
-
),
|
|
1824
|
-
}),
|
|
1916
|
+
...pulledSettingsBaselines(settingsSnapshot),
|
|
1825
1917
|
...(formsBaseline === undefined ? {} : { forms: formsBaseline }),
|
|
1918
|
+
...(pageBlockCatalog === undefined ? {} : { pageBlockCatalog }),
|
|
1826
1919
|
...(marketingBaseline === undefined ? {} : { [MARKETING_MANIFEST_KEY]: marketingBaseline }),
|
|
1827
1920
|
pages: [...manifestPages, ...keptPendingEntries],
|
|
1828
1921
|
...(retiredGeneratedSources.length === 0 ? {} : { retiredGeneratedSources }),
|
|
@@ -1896,11 +1989,7 @@ export async function pull(invocation) {
|
|
|
1896
1989
|
members: authorListing.members.length,
|
|
1897
1990
|
},
|
|
1898
1991
|
}),
|
|
1899
|
-
settings:
|
|
1900
|
-
pulled: pulledSettings.map((entry) => entry.settingsType),
|
|
1901
|
-
skipped: skippedSettings,
|
|
1902
|
-
files: pulledSettings.map((entry) => entry.file),
|
|
1903
|
-
},
|
|
1992
|
+
settings: pullSettingsResult(settingsSnapshot),
|
|
1904
1993
|
});
|
|
1905
1994
|
// Files left behind by generated pages the site no longer has, so an agent reading only JSON can delete them
|
|
1906
1995
|
// (TR01433). Absent when there are none; fitted into the bytes the result has left, since the workspace was
|
package/src/verbs/status.js
CHANGED
|
@@ -17,6 +17,7 @@ import { installedWhatsNew } from "../changelog.js";
|
|
|
17
17
|
import { isBehindLatest } from "../cli-release.js";
|
|
18
18
|
import {
|
|
19
19
|
changelogCommandSince,
|
|
20
|
+
CLI_BINARY_NAME,
|
|
20
21
|
CLI_UPGRADE_COMMAND,
|
|
21
22
|
CLI_VERSION,
|
|
22
23
|
EXTERNAL_WRITES_SETTING_KEY,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
PUBLISH_KEY_ENVIRONMENT_VARIABLE,
|
|
25
26
|
REFUSAL_CLI_OUTDATED,
|
|
26
27
|
REFUSAL_PLATFORM_PAUSED,
|
|
28
|
+
STAGING_DEPLOYMENT_ID_OPTION,
|
|
27
29
|
SURFACE_DOCS_PRESENTATION,
|
|
28
30
|
VERB_STATUS,
|
|
29
31
|
} from "../constants.js";
|
|
@@ -166,7 +168,7 @@ async function summarizeStagedHealth(client, siteId, stagedDeploymentId, onProgr
|
|
|
166
168
|
};
|
|
167
169
|
}
|
|
168
170
|
|
|
169
|
-
async function reportStagingHosting(client, siteId, onProgress) {
|
|
171
|
+
async function reportStagingHosting(client, siteId, stagedReleaseUpdateState, onProgress) {
|
|
170
172
|
let hosting;
|
|
171
173
|
try {
|
|
172
174
|
hosting = await getStagingPreviewStatus(client, siteId);
|
|
@@ -176,6 +178,18 @@ async function reportStagingHosting(client, siteId, onProgress) {
|
|
|
176
178
|
return { readyKnown: false, reason };
|
|
177
179
|
}
|
|
178
180
|
const releaseStatus = hosting.hasStagedRelease === undefined ? {} : { hasStagedRelease: hosting.hasStagedRelease };
|
|
181
|
+
const deploymentId = hosting.currentAcknowledgedStagingDeploymentId;
|
|
182
|
+
if (deploymentId !== undefined) {
|
|
183
|
+
releaseStatus.currentAcknowledgedStagingDeploymentId = deploymentId;
|
|
184
|
+
onProgress(`Current acknowledged stage: ${deploymentId}.`);
|
|
185
|
+
if (hosting.suggestAuthoringPromotionRetry === true
|
|
186
|
+
&& (stagedReleaseUpdateState === "" || stagedReleaseUpdateState === "STAGED_RELEASE_UPDATE_STATE_UNSPECIFIED")) {
|
|
187
|
+
const command = `${CLI_BINARY_NAME} deploy --production ${STAGING_DEPLOYMENT_ID_OPTION} ${deploymentId}`;
|
|
188
|
+
releaseStatus.productionRetryCommand = command;
|
|
189
|
+
onProgress(`After reviewing the current acknowledged stage, you can promote it with '${command}'.`);
|
|
190
|
+
onProgress("Run it from the same workspace and reuse your leading --config if you supplied one.");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
179
193
|
if (!hosting.ready) {
|
|
180
194
|
onProgress(`Staging hosting: no ready address. ${STAGING_HOSTING_SETUP_GUIDANCE}`);
|
|
181
195
|
return { ready: false, guidance: STAGING_HOSTING_SETUP_GUIDANCE, ...releaseStatus };
|
|
@@ -205,7 +219,9 @@ export async function status(invocation) {
|
|
|
205
219
|
? { ...reviewed, stagedPageIds: [], includeNavigation: false }
|
|
206
220
|
: reviewed;
|
|
207
221
|
const readiness = await getPublishingReadiness(client, siteId, selection);
|
|
208
|
-
const
|
|
222
|
+
const { stagedReleaseUpdateState, stagedReleaseUpdateMessage } = readiness;
|
|
223
|
+
if (stagedReleaseUpdateMessage !== "") onProgress(stagedReleaseUpdateMessage);
|
|
224
|
+
const stagingHosting = await reportStagingHosting(client, siteId, stagedReleaseUpdateState, onProgress);
|
|
209
225
|
onProgress("Reading the deployment log.");
|
|
210
226
|
const {
|
|
211
227
|
deployments,
|
|
@@ -289,6 +305,8 @@ export async function status(invocation) {
|
|
|
289
305
|
blockedPageCount: readiness.blockedPageCount,
|
|
290
306
|
hasCandidateChanges: readiness.hasCandidateChanges,
|
|
291
307
|
hasSuccessfulStagingDeployment: readiness.hasSuccessfulStagingDeployment,
|
|
308
|
+
...(stagedReleaseUpdateState === "" ? {} : { stagedReleaseUpdateState }),
|
|
309
|
+
...(stagedReleaseUpdateMessage === "" ? {} : { stagedReleaseUpdateMessage }),
|
|
292
310
|
redirectsChanged: readiness.redirectsChanged,
|
|
293
311
|
formsChanged: readiness.formsChanged,
|
|
294
312
|
videosChanged: readiness.videosChanged,
|