@taprootio/site-authoring 0.59.0 → 0.61.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 +14 -1
- package/package.json +2 -2
- package/src/api.js +9 -0
- package/src/appearance-contract.js +36 -1
- package/src/changelog.json +33 -0
- package/src/chrome-additions.js +25 -7
- package/src/chrome-input.js +47 -0
- package/src/cli.js +4 -2
- package/src/content/components.js +21 -6
- package/src/content/media-presentation.js +13 -2
- package/src/content/validate-document.js +2 -0
- package/src/latest-posts-settings.js +78 -0
- package/src/legal-roles.js +121 -0
- package/src/output.js +2 -0
- package/src/page-metadata.js +3 -0
- package/src/presentation-reference.js +11 -4
- package/src/reference-help.js +16 -3
- package/src/session.js +19 -1
- package/src/setting-reference.js +21 -2
- package/src/settings-catalog.js +5 -0
- package/src/site-check-findings.js +8 -3
- package/src/status-warning-paints.js +2 -2
- package/src/template-token-reach.json +10 -8
- package/src/theme-resolve.js +10 -0
- package/src/theme-validation.js +11 -1
- package/src/token-reach.js +2 -1
- package/src/transport.js +15 -2
- package/src/typed-page-reference.js +18 -3
- package/src/typed-pages.js +3 -1
- package/src/verbs/delivery-check.js +31 -10
- package/src/verbs/footer-push.js +33 -7
- package/src/verbs/pages-meta-set.js +10 -1
- package/src/verbs/pages-push.js +12 -4
- package/src/verbs/plan.js +1 -0
- package/src/verbs/pull.js +26 -4
- package/src/verbs/status.js +23 -0
- package/src/verbs/theme-push.js +9 -0
- package/src/verbs/theme-resolve.js +1 -0
- package/src/verbs/validate.js +14 -5
- package/src/workspace-check.js +20 -8
- package/src/workspace-context-usage.js +12 -5
- package/test/fixtures/default-site-theme.json +1 -1
package/src/verbs/footer-push.js
CHANGED
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
readPresentationBaseline,
|
|
15
15
|
reportFooterPreview,
|
|
16
16
|
} from "../footer-workspace.js";
|
|
17
|
-
import { openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
17
|
+
import { boundedByBytes, openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
18
|
+
import { unservedFooterLinks } from "../chrome-input.js";
|
|
18
19
|
import { SETTINGS_TYPE_SITE_PUBLISHING_PREFERENCES } from "../settings-catalog.js";
|
|
19
20
|
import { ApiError } from "../transport.js";
|
|
20
21
|
import { readWorkspaceJson, WORKSPACE_LIMITS, writeWorkspaceJson } from "../workspace.js";
|
|
@@ -65,6 +66,28 @@ function translateConcurrency(error) {
|
|
|
65
66
|
return error;
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
const FOOTER_LINK_REASONS = Object.freeze({
|
|
70
|
+
page_not_approved: "the page is not approved, so no release carries it",
|
|
71
|
+
legal_page_not_published: "it is an approved legal page that was never published; deploy leaves legal pages out, so "
|
|
72
|
+
+ "stage and publish it from the app",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/** Footer page links the next release cannot render as links, reported rather than refused (TR01433). */
|
|
76
|
+
const FOOTER_LINK_WARNING_BYTES = 4 * 1024;
|
|
77
|
+
|
|
78
|
+
export function footerLinkWarnings(pages, footerSettings, onProgress, budget = FOOTER_LINK_WARNING_BYTES) {
|
|
79
|
+
const links = unservedFooterLinks(pages, footerSettings);
|
|
80
|
+
for (const link of links) {
|
|
81
|
+
onProgress(`Warning: the footer link '${link.label}'${link.path === null ? "" : ` to ${link.path}`} is unavailable `
|
|
82
|
+
+ "until its page is in the release (a column, utility or aside link is left out; an inline link keeps only its "
|
|
83
|
+
+ `words): ${FOOTER_LINK_REASONS[link.reason]}.`);
|
|
84
|
+
}
|
|
85
|
+
// Left out, as the progress text still names the links, when not even its summary fits.
|
|
86
|
+
if (links.length === 0 || budget < 512) return {};
|
|
87
|
+
const reported = boundedByBytes(links, Math.min(budget - 256, FOOTER_LINK_WARNING_BYTES));
|
|
88
|
+
return { footerLinkWarnings: { count: links.length, ...reported } };
|
|
89
|
+
}
|
|
90
|
+
|
|
68
91
|
export async function footerPush(invocation) {
|
|
69
92
|
const session = await openSession(invocation);
|
|
70
93
|
const { client, config, siteId, onProgress } = session;
|
|
@@ -84,12 +107,15 @@ export async function footerPush(invocation) {
|
|
|
84
107
|
);
|
|
85
108
|
onProgress("Validated the complete footer document, stable page targets, and site-owned image references locally.");
|
|
86
109
|
|
|
87
|
-
const footerChecks =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
110
|
+
const footerChecks = {
|
|
111
|
+
...evaluateOfflineSiteChecks({
|
|
112
|
+
pagePaths: [],
|
|
113
|
+
footerOnly: true,
|
|
114
|
+
footerInput: await readFooterFitInput(config.workspaceDir, footerSettings),
|
|
115
|
+
onProgress,
|
|
116
|
+
}),
|
|
117
|
+
...footerLinkWarnings(context.manifest.pages, footerSettings, onProgress),
|
|
118
|
+
};
|
|
93
119
|
|
|
94
120
|
if (dryRun) {
|
|
95
121
|
const response = await withRefusalGuidance(onProgress, VERB_FOOTER_PUSH, () =>
|
|
@@ -10,7 +10,7 @@ import { VERB_PAGES_META_SET } from "../constants.js";
|
|
|
10
10
|
import { SiteAuthoringError } from "../errors.js";
|
|
11
11
|
import { descriptionWarnings, PAGE_AUTHOR_UNVERIFIED, requireDescriptionLength } from "../page-metadata.js";
|
|
12
12
|
import { openAnonymousSession, successResult } from "../session.js";
|
|
13
|
-
import { isGeneratedTemplateType, TEMPLATE_GENERATED, typedDocumentFromJson } from "../typed-pages.js";
|
|
13
|
+
import { isGeneratedTemplateType, isLegalTemplateType, TEMPLATE_GENERATED, typedDocumentFromJson } from "../typed-pages.js";
|
|
14
14
|
import {
|
|
15
15
|
displayPagePath,
|
|
16
16
|
normalizePagePath,
|
|
@@ -107,6 +107,15 @@ export async function pagesMetaSet(invocation) {
|
|
|
107
107
|
{ field: shown },
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
|
+
// Taproot stores and renders no description for a legal page, so one would be dropped without a word (TR01433).
|
|
111
|
+
if (description !== undefined && description !== "" && isLegalTemplateType(entry.templateType)) {
|
|
112
|
+
throw new SiteAuthoringError(
|
|
113
|
+
"pages.legal_description_unsupported",
|
|
114
|
+
`'${shown}' is a legal page, which carries no description: Taproot drops it on save and renders none, and `
|
|
115
|
+
+ "the description checks skip legal pages.",
|
|
116
|
+
{ field: "description", exitCode: 2 },
|
|
117
|
+
);
|
|
118
|
+
}
|
|
110
119
|
if (description !== undefined) requireDescriptionLength(description);
|
|
111
120
|
// A generated page's custom title and description are in its source, where
|
|
112
121
|
// pull already protects an edit like any other.
|
package/src/verbs/pages-push.js
CHANGED
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
wirePageFields,
|
|
83
83
|
wireTemplate,
|
|
84
84
|
} from "../typed-pages.js";
|
|
85
|
+
import { legalRoleRefusal } from "../legal-roles.js";
|
|
85
86
|
import {
|
|
86
87
|
hasNamedFreeFormSectionContext,
|
|
87
88
|
sharedThemeContextNames,
|
|
@@ -1211,6 +1212,7 @@ export async function planPages({
|
|
|
1211
1212
|
getSharedThemeContexts,
|
|
1212
1213
|
refreshAuthors,
|
|
1213
1214
|
legalDrafts = false,
|
|
1215
|
+
platformLegalSite = false,
|
|
1214
1216
|
readLegalPage,
|
|
1215
1217
|
onProgress = () => {},
|
|
1216
1218
|
}) {
|
|
@@ -1288,10 +1290,9 @@ export async function planPages({
|
|
|
1288
1290
|
file,
|
|
1289
1291
|
);
|
|
1290
1292
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
}
|
|
1293
|
+
// Reported on a targeted run too, since `discovered` counts the file (TR01433).
|
|
1294
|
+
staleGenerated.push({ file, path: displayPagePath(retiredPath) });
|
|
1295
|
+
onProgress(`'${file}' is the source of a generated page the site no longer has; nothing is sent for it.`);
|
|
1295
1296
|
continue;
|
|
1296
1297
|
}
|
|
1297
1298
|
try {
|
|
@@ -1646,6 +1647,12 @@ export async function planPages({
|
|
|
1646
1647
|
}
|
|
1647
1648
|
}
|
|
1648
1649
|
}
|
|
1650
|
+
// Only a changed legal source is checked, as the site checks only what it saves, and after
|
|
1651
|
+
// the identity fence so an edited identity is named as that (TR01433).
|
|
1652
|
+
if (documentTemplate(document_) === TEMPLATE_LEGAL && !unchanged) {
|
|
1653
|
+
const refusal = legalRoleRefusal(legalIdentity(document_.data), pagePath, file, { platformLegalSite });
|
|
1654
|
+
if (refusal !== undefined) throw refusal;
|
|
1655
|
+
}
|
|
1649
1656
|
// Only for a page this push sends: a description stored before the limit
|
|
1650
1657
|
// existed must not block a push that leaves it alone (TR01194). A
|
|
1651
1658
|
// generated page's derived description is not the owner's to shorten;
|
|
@@ -1867,6 +1874,7 @@ export async function pagesPush(invocation) {
|
|
|
1867
1874
|
livePages,
|
|
1868
1875
|
online: true,
|
|
1869
1876
|
legalDrafts: session.legalDrafts === true,
|
|
1877
|
+
platformLegalSite: session.legalDraftPlatformSite === true,
|
|
1870
1878
|
readLegalPage: (target) => getPage(client, target.pageId, target.hasDraft ? PAGE_STATUS_DRAFT : target.status),
|
|
1871
1879
|
requestedPaths,
|
|
1872
1880
|
refreshAuthors: liveAuthorsRefresher({
|
package/src/verbs/plan.js
CHANGED
|
@@ -282,6 +282,7 @@ async function preflight(session, invocation) {
|
|
|
282
282
|
livePages,
|
|
283
283
|
online: true,
|
|
284
284
|
legalDrafts: session.legalDrafts === true,
|
|
285
|
+
platformLegalSite: session.legalDraftPlatformSite === true,
|
|
285
286
|
readLegalPage: (target) => getPage(client, target.pageId, target.hasDraft ? PAGE_STATUS_DRAFT : target.status),
|
|
286
287
|
// Asked of the site but never written down: `plan` leaves the workspace as it found it.
|
|
287
288
|
refreshAuthors: liveAuthorsRefresher({ client, workspaceDir, siteId, write: false, onProgress }),
|
package/src/verbs/pull.js
CHANGED
|
@@ -40,7 +40,7 @@ import { navigationManifestEntry } from "../navigation-workspace.js";
|
|
|
40
40
|
import { redirectsManifestEntry } from "../redirects-workspace.js";
|
|
41
41
|
import { projectNavigationForWorkspace } from "./nav-push.js";
|
|
42
42
|
import { parseFrontMatter, readWorkspacePageSource } from "./pages-push.js";
|
|
43
|
-
import { boundedList, openSession, successResult } from "../session.js";
|
|
43
|
+
import { boundedByBytes, boundedList, openSession, successResult } from "../session.js";
|
|
44
44
|
import {
|
|
45
45
|
projectSettingsGroup,
|
|
46
46
|
SETTINGS_GROUPS,
|
|
@@ -142,6 +142,8 @@ import {
|
|
|
142
142
|
*/
|
|
143
143
|
|
|
144
144
|
const MAXIMUM_REPORTED = 200;
|
|
145
|
+
// Paths and file names run long, so the retired list is bounded by bytes as well as count (TR01433).
|
|
146
|
+
const RETIRED_SOURCES_BYTES = 4 * 1024;
|
|
145
147
|
// A settings group the credential's envelope does not reach is a narrower
|
|
146
148
|
// snapshot, not a failed pull. The server names that shortfall as a
|
|
147
149
|
// capability denial (TR00691), and an older server answers a bare 403; both
|
|
@@ -1696,6 +1698,9 @@ export async function pull(invocation) {
|
|
|
1696
1698
|
workspaceMode: PAGE_WORKSPACE_MODE_METADATA_ONLY,
|
|
1697
1699
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1698
1700
|
...(summary.reviewAuthorMissing === undefined ? {} : { reviewAuthorMissing: summary.reviewAuthorMissing }),
|
|
1701
|
+
// Whether a legal page was ever published: an approved one that never was is in no release the CLI
|
|
1702
|
+
// deploys (TR01433). Absent in older manifests, where the checks treat it as unknown.
|
|
1703
|
+
...(isLegalTemplateType(summary.templateType) ? { neverPublished: summary.datePublished === "" } : {}),
|
|
1699
1704
|
};
|
|
1700
1705
|
if (isAuthorableTemplateType(summary.templateType)) {
|
|
1701
1706
|
// This pull is reconciling the page, so the manifest below carries the
|
|
@@ -1897,10 +1902,27 @@ export async function pull(invocation) {
|
|
|
1897
1902
|
files: pulledSettings.map((entry) => entry.file),
|
|
1898
1903
|
},
|
|
1899
1904
|
});
|
|
1900
|
-
|
|
1905
|
+
// Files left behind by generated pages the site no longer has, so an agent reading only JSON can delete them
|
|
1906
|
+
// (TR01433). Absent when there are none; fitted into the bytes the result has left, since the workspace was
|
|
1907
|
+
// already rewritten and the result must not overflow.
|
|
1908
|
+
// Left out, as the progress text still names the files, when not even its summary fits.
|
|
1909
|
+
const retiredRoom = LIMITS.githubOutputBytes - Buffer.byteLength(JSON.stringify(result), "utf8") - 2048;
|
|
1910
|
+
const withRetired = retiredGeneratedSources.length === 0 || retiredRoom < 512 ? result : {
|
|
1911
|
+
...result,
|
|
1912
|
+
retiredGeneratedSources: {
|
|
1913
|
+
count: retiredGeneratedSources.length,
|
|
1914
|
+
...boundedByBytes(
|
|
1915
|
+
retiredGeneratedSources.slice(0, MAXIMUM_REPORTED).map(({ file, path }) => ({ file, path: displayPagePath(path) })),
|
|
1916
|
+
Math.min(RETIRED_SOURCES_BYTES, retiredRoom - 256),
|
|
1917
|
+
),
|
|
1918
|
+
...(retiredGeneratedSources.length > MAXIMUM_REPORTED ? { truncated: true } : {}),
|
|
1919
|
+
...(truncated ? { listingTruncated: true } : {}),
|
|
1920
|
+
},
|
|
1921
|
+
};
|
|
1922
|
+
if (keptPendingPages === undefined) return withRetired;
|
|
1901
1923
|
// Result bytes after the workspace was rewritten must never overflow, so the list gives way first.
|
|
1902
|
-
const room = LIMITS.githubOutputBytes - Buffer.byteLength(JSON.stringify(
|
|
1903
|
-
return { ...
|
|
1924
|
+
const room = LIMITS.githubOutputBytes - Buffer.byteLength(JSON.stringify(withRetired), "utf8") - 2048;
|
|
1925
|
+
return { ...withRetired, keptPendingPages: fitKeptPending(keptPendingPages, Math.max(0, room)) };
|
|
1904
1926
|
}).finally(async () => {
|
|
1905
1927
|
if (stageDirectory !== undefined) await rm(stageDirectory, { recursive: true, force: true });
|
|
1906
1928
|
});
|
package/src/verbs/status.js
CHANGED
|
@@ -2,6 +2,7 @@ import { describeNavigationReadiness, reportNavigationReadiness } from "../navig
|
|
|
2
2
|
import {
|
|
3
3
|
getDeploySelection,
|
|
4
4
|
getPublishingReadiness,
|
|
5
|
+
getSiteAuthoringCapabilities,
|
|
5
6
|
getSiteHealth,
|
|
6
7
|
getStagingPreviewStatus,
|
|
7
8
|
IMAGE_PROCESSING_STATE_COMPLETE,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
STAGING_HOSTING_SETUP_GUIDANCE,
|
|
12
13
|
withRefusalGuidance,
|
|
13
14
|
} from "../api.js";
|
|
15
|
+
import { SiteAuthoringError } from "../errors.js";
|
|
14
16
|
import { installedWhatsNew } from "../changelog.js";
|
|
15
17
|
import { isBehindLatest } from "../cli-release.js";
|
|
16
18
|
import {
|
|
@@ -222,6 +224,26 @@ export async function status(invocation) {
|
|
|
222
224
|
onProgress("Reading the stored deployment health report.");
|
|
223
225
|
health = await getSiteHealth(client, siteId);
|
|
224
226
|
}
|
|
227
|
+
// Whether 'tags' in a page source can be sent, so a paused platform switch shows here and not first at a push
|
|
228
|
+
// (TR01433). Absent from a server that predates authored tag writes, and on a Docs site.
|
|
229
|
+
// Advisory, so a failed read leaves the field out rather than failing status.
|
|
230
|
+
const tagCapabilities = presentationOnly
|
|
231
|
+
? undefined
|
|
232
|
+
: await getSiteAuthoringCapabilities(client, siteId).catch((error) => {
|
|
233
|
+
if (!(error instanceof SiteAuthoringError)) throw error;
|
|
234
|
+
onProgress("Authored tags: Taproot did not say whether tag writes are accepted; 'plan' checks before a push.");
|
|
235
|
+
return undefined;
|
|
236
|
+
});
|
|
237
|
+
const authoredTagWrites = tagCapabilities === undefined ? undefined : {
|
|
238
|
+
enabled: tagCapabilities.authoredTagWritesEnabled,
|
|
239
|
+
permitted: tagCapabilities.authoredTagWritesPermitted,
|
|
240
|
+
};
|
|
241
|
+
if (authoredTagWrites !== undefined && !(authoredTagWrites.enabled && authoredTagWrites.permitted)) {
|
|
242
|
+
onProgress(authoredTagWrites.enabled
|
|
243
|
+
? "Authored tags: this credential cannot write them; a push that sets 'tags' is refused."
|
|
244
|
+
: "Authored tags: Taproot has paused tag writes; a push that sets 'tags' is refused until an administrator "
|
|
245
|
+
+ "turns them on.");
|
|
246
|
+
}
|
|
225
247
|
const reportedFindings = boundedList(health.findings, MAXIMUM_HEALTH_FINDINGS);
|
|
226
248
|
const reportedImageFindings = boundedByBytes(health.images ?? [], MAXIMUM_HEALTH_IMAGE_BYTES);
|
|
227
249
|
const stagedSiteHealth = presentationOnly
|
|
@@ -259,6 +281,7 @@ export async function status(invocation) {
|
|
|
259
281
|
platform: platformReport,
|
|
260
282
|
cliRelease: cliReleaseReport,
|
|
261
283
|
...(presentationOnly ? { authoringSurface: SURFACE_DOCS_PRESENTATION } : {}),
|
|
284
|
+
...(authoredTagWrites === undefined ? {} : { authoredTagWrites }),
|
|
262
285
|
readiness: {
|
|
263
286
|
state: readiness.state,
|
|
264
287
|
navigationReadiness: reportNavigationReadiness(readiness.navigationReadiness),
|
package/src/verbs/theme-push.js
CHANGED
|
@@ -215,6 +215,7 @@ export async function validateThemeWorkspace(
|
|
|
215
215
|
darkTheme: style.darkTheme,
|
|
216
216
|
headerContext: header.context,
|
|
217
217
|
footerContext: footerPresentation.context,
|
|
218
|
+
listingCardContext: publishing.listingCardContext,
|
|
218
219
|
});
|
|
219
220
|
}
|
|
220
221
|
const themes = await validateAndLintThemePair(style.lightTheme, style.darkTheme);
|
|
@@ -371,6 +372,11 @@ export function presentationMovedRefusal({ baseline, current, differences }) {
|
|
|
371
372
|
).withDifferences(differences.flatMap((entry) => entry.paths.map((path) => `${entry.file}:${path}`)));
|
|
372
373
|
}
|
|
373
374
|
|
|
375
|
+
/** The context the site holds after this push: a workspace without the field keeps the site's, and "" clears it. */
|
|
376
|
+
function effectiveListingCardContext(validated, current) {
|
|
377
|
+
return validated.publishing.listingCardContext ?? current?.sitePublishingPreferences?.listingCardContext ?? "";
|
|
378
|
+
}
|
|
379
|
+
|
|
374
380
|
/**
|
|
375
381
|
* What pushing this validated presentation would do, from one fresh read of
|
|
376
382
|
* the site: the JSON paths that differ, whether the pull's baseline is still
|
|
@@ -390,6 +396,8 @@ export async function comparePresentation(client, siteId, validated, manifest) {
|
|
|
390
396
|
darkTheme: validated.style.darkTheme,
|
|
391
397
|
headerContext: validated.header.context,
|
|
392
398
|
footerContext: validated.footerPresentation.context,
|
|
399
|
+
// A workspace without the field keeps the site's choice, so that choice must still be declared.
|
|
400
|
+
listingCardContext: effectiveListingCardContext(validated, current),
|
|
393
401
|
}, current);
|
|
394
402
|
const stale = baseline !== undefined && baseline.revision !== current.revision;
|
|
395
403
|
// A save this workspace sent and never heard back from (TR00807). When the
|
|
@@ -643,6 +651,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
643
651
|
mediaManifest: resources.mediaManifest,
|
|
644
652
|
header: validated.header,
|
|
645
653
|
footerSettings: validated.publishing?.footerSettings,
|
|
654
|
+
listingCardContext: effectiveListingCardContext(validated, comparison.current),
|
|
646
655
|
content: invocation.content,
|
|
647
656
|
contexts: contextScopedNames(validated.themes.warnings),
|
|
648
657
|
}).catch(() => undefined);
|
package/src/verbs/validate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { footerLinkWarnings } from "./footer-push.js";
|
|
1
2
|
import { lstat, realpath } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
withoutUsedIn,
|
|
24
25
|
} from "../status-warning-paints.js";
|
|
25
26
|
import { loadSiteConfig } from "../config.js";
|
|
26
|
-
import { SURFACE_DOCS_PRESENTATION, VERB_VALIDATE } from "../constants.js";
|
|
27
|
+
import { LIMITS, SURFACE_DOCS_PRESENTATION, VERB_VALIDATE } from "../constants.js";
|
|
27
28
|
import { freeFormRootPresentation } from "../content/free-form-sections.js";
|
|
28
29
|
import { autolinkWarnings } from "../content/link-warnings.js";
|
|
29
30
|
import { isCanonicalUuid, SiteAuthoringError } from "../errors.js";
|
|
@@ -44,7 +45,7 @@ import { FORMS_DIRECTORY } from "../forms-contract.js";
|
|
|
44
45
|
import { authorWarnings, descriptionWarnings } from "../page-metadata.js";
|
|
45
46
|
import { CHECK_AREA, appendAll, collectProblems, omittedFileCodes, refuseProblems } from "../problems.js";
|
|
46
47
|
import { isRedirectMapRevision, REDIRECT_KIND_GONE, REDIRECTS_FILE_NAME } from "../redirects-contract.js";
|
|
47
|
-
import { boundedList, openSession, successResult } from "../session.js";
|
|
48
|
+
import { boundedList, openSession, storedPlatformLegalSite, successResult } from "../session.js";
|
|
48
49
|
import {
|
|
49
50
|
evaluateOfflineSiteChecks,
|
|
50
51
|
mergeOfflineSiteChecks,
|
|
@@ -819,6 +820,7 @@ export function pageContextUsage(checked, problems) {
|
|
|
819
820
|
return buildContextUsage({
|
|
820
821
|
header: checked.presentation.header,
|
|
821
822
|
footerSettings: checked.footer?.footerSettings,
|
|
823
|
+
listingCardContext: checked.presentation.publishing?.listingCardContext,
|
|
822
824
|
contexts: contextScopedNames(checked.presentation.themes.warnings),
|
|
823
825
|
pages: (checked.pages?.planned ?? []).filter((page) => !codes.has(page.file)),
|
|
824
826
|
skipped: [...codes].map(([file, code]) => ({ file, code })),
|
|
@@ -1027,6 +1029,7 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
|
|
|
1027
1029
|
manifest,
|
|
1028
1030
|
mediaManifest,
|
|
1029
1031
|
content: invocation.content,
|
|
1032
|
+
platformLegalSite: await storedPlatformLegalSite(invocation, siteId),
|
|
1030
1033
|
onProgress,
|
|
1031
1034
|
});
|
|
1032
1035
|
const options = { ...reporting, nameReportEnabled: selectNameReportEligibility({ manifest }) };
|
|
@@ -1102,11 +1105,17 @@ async function validatePulledWorkspace(workspaceDir, siteId, invocation, onProgr
|
|
|
1102
1105
|
],
|
|
1103
1106
|
nextStep: "Run 'taproot-site plan' to check the workspace against the live site and see the ordered apply.",
|
|
1104
1107
|
}));
|
|
1105
|
-
|
|
1108
|
+
// Footer links outside the release, fitted into the bytes the result has left (TR01433).
|
|
1109
|
+
const withFooterLinks = checked.footer?.footerSettings === undefined ? base : {
|
|
1110
|
+
...base,
|
|
1111
|
+
...footerLinkWarnings(manifest.pages, checked.footer.footerSettings, onProgress,
|
|
1112
|
+
LIMITS.githubOutputBytes - Buffer.byteLength(JSON.stringify(base), "utf8") - 2048 - 256),
|
|
1113
|
+
};
|
|
1114
|
+
if (site.block === undefined) return withContextUsage(withFooterLinks, checked);
|
|
1106
1115
|
const fitted = fitPrecheckToBudget(
|
|
1107
|
-
|
|
1116
|
+
withFooterLinks,
|
|
1108
1117
|
{ imageFindings: site.block.imageFindings, notInSiteLibrary: site.block.notInSiteLibrary },
|
|
1109
1118
|
["notInSiteLibrary", "imageFindings"],
|
|
1110
1119
|
);
|
|
1111
|
-
return withContextUsage({ ...
|
|
1120
|
+
return withContextUsage({ ...withFooterLinks, ...fitted }, checked);
|
|
1112
1121
|
}
|
package/src/workspace-check.js
CHANGED
|
@@ -15,6 +15,7 @@ import { missingTagDestinations, reportTagDestinationWarnings } from "./tag-dest
|
|
|
15
15
|
import { validateFooterWorkspaceDocument } from "./verbs/footer-push.js";
|
|
16
16
|
import { validateNavigationWorkspaceDocument } from "./verbs/nav-push.js";
|
|
17
17
|
import { planPages } from "./verbs/pages-push.js";
|
|
18
|
+
import { GENERATED_PAGE_KIND_FOLDER_INDEX } from "./typed-pages.js";
|
|
18
19
|
import { validateThemeWorkspace } from "./verbs/theme-push.js";
|
|
19
20
|
import {
|
|
20
21
|
NAVIGATION_FILE_NAME,
|
|
@@ -55,6 +56,7 @@ export async function checkWorkspace({
|
|
|
55
56
|
binding = {},
|
|
56
57
|
content,
|
|
57
58
|
areas = ALL_AREAS,
|
|
59
|
+
platformLegalSite = false,
|
|
58
60
|
onProgress = () => {},
|
|
59
61
|
}) {
|
|
60
62
|
const problems = [];
|
|
@@ -137,6 +139,7 @@ export async function checkWorkspace({
|
|
|
137
139
|
// pulled, which is what an offline check can know.
|
|
138
140
|
livePages: manifest.pages.filter((entry) => typeof entry?.pageId === "string"),
|
|
139
141
|
online: false,
|
|
142
|
+
platformLegalSite,
|
|
140
143
|
// The theme was validated above, so its contexts come from it; reading
|
|
141
144
|
// the styles file again would re-check a binding a fixture spells
|
|
142
145
|
// differently, and repeat a theme problem once per page.
|
|
@@ -219,18 +222,27 @@ async function checkRedirects(workspaceDir, siteId, manifest, sources) {
|
|
|
219
222
|
const redirects = validateRedirectsDocument(document_, siteId);
|
|
220
223
|
// The pages the next push leaves on the site: each workspace source at the
|
|
221
224
|
// path it declares, and every recorded page no source here claims. A page a
|
|
222
|
-
// source renames frees its old path for a redirect
|
|
225
|
+
// source renames frees its old path for a redirect, and so does 'pages
|
|
226
|
+
// delete', which drops the page from the manifest. A folder index occupies
|
|
227
|
+
// its path only while a page stays under it (TR01431), as the site judges it.
|
|
223
228
|
const claimed = new Set((sources ?? []).map((source) => source.file));
|
|
229
|
+
const folderIndexFiles = new Set(manifest.pages
|
|
230
|
+
.filter((entry) => entry?.generated?.kind === GENERATED_PAGE_KIND_FOLDER_INDEX)
|
|
231
|
+
.map((entry) => entry.file));
|
|
232
|
+
const routeKey = (pagePath) => (`/${pagePath}`.replace(/\/+$/u, "") || "/").toLowerCase();
|
|
224
233
|
const occupied = [
|
|
225
|
-
...(sources ?? []).map((source) => source.pagePath),
|
|
234
|
+
...(sources ?? []).map((source) => ({ pagePath: source.pagePath, folder: folderIndexFiles.has(source.file) })),
|
|
226
235
|
...manifest.pages
|
|
227
236
|
.filter((entry) => typeof entry?.path === "string" && !claimed.has(entry.file))
|
|
228
|
-
.map((entry) =>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
);
|
|
237
|
+
.map((entry) => ({
|
|
238
|
+
pagePath: normalizePagePath(entry.path),
|
|
239
|
+
folder: entry.generated?.kind === GENERATED_PAGE_KIND_FOLDER_INDEX,
|
|
240
|
+
})),
|
|
241
|
+
].filter(({ pagePath }) => pagePath !== undefined).map(({ pagePath, folder }) => ({ key: routeKey(pagePath), folder }));
|
|
242
|
+
const listed = occupied.filter(({ folder }) => !folder).map(({ key }) => key);
|
|
243
|
+
const pagePaths = new Set(occupied
|
|
244
|
+
.filter(({ key, folder }) => !folder || key === "/" || listed.some((path) => path.startsWith(`${key}/`)))
|
|
245
|
+
.map(({ key }) => key));
|
|
234
246
|
const authoredIndexByPath = new Map();
|
|
235
247
|
for (const [index, entry] of document_.entries.entries()) {
|
|
236
248
|
const path = normalizeRedirectPath(entry?.path);
|
|
@@ -27,12 +27,12 @@ const KIND_CTA = "cta";
|
|
|
27
27
|
* ordinal among every section (or every call to action) of the page, in document order. Documents arrive in the
|
|
28
28
|
* workspace page walk's order, so the first rows kept are the first in that order.
|
|
29
29
|
*/
|
|
30
|
-
export function createContextUsageCounter({ header, footerSettings, contexts } = {}) {
|
|
30
|
+
export function createContextUsageCounter({ header, footerSettings, listingCardContext, contexts } = {}) {
|
|
31
31
|
const usage = new Map();
|
|
32
32
|
let documents = 0;
|
|
33
33
|
const entry = (name) => {
|
|
34
34
|
if (!contexts?.has(name)) return undefined;
|
|
35
|
-
if (!usage.has(name)) usage.set(name, { header: false, footer: false, sections: 0, ctas: 0, items: [], total: 0 });
|
|
35
|
+
if (!usage.has(name)) usage.set(name, { header: false, footer: false, listingCards: false, sections: 0, ctas: 0, items: [], total: 0 });
|
|
36
36
|
return usage.get(name);
|
|
37
37
|
};
|
|
38
38
|
if (typeof header?.context === "string" && header.context !== "") {
|
|
@@ -43,6 +43,10 @@ export function createContextUsageCounter({ header, footerSettings, contexts } =
|
|
|
43
43
|
const used = entry(footerSettings.context);
|
|
44
44
|
if (used !== undefined) used.footer = true;
|
|
45
45
|
}
|
|
46
|
+
if (typeof listingCardContext === "string" && listingCardContext !== "") {
|
|
47
|
+
const used = entry(listingCardContext);
|
|
48
|
+
if (used !== undefined) used.listingCards = true;
|
|
49
|
+
}
|
|
46
50
|
return {
|
|
47
51
|
add(document, file) {
|
|
48
52
|
// Tallied apart and merged at the end, so a walk that throws adds nothing.
|
|
@@ -104,8 +108,10 @@ function skippedReport(skipped) {
|
|
|
104
108
|
* counted with their first problem code, and, when the page inventory itself could not be read, why (TR01426).
|
|
105
109
|
* `pages` are `{ file, document }` rows already converted and checked; `skipped` are `{ file, code }` rows.
|
|
106
110
|
*/
|
|
107
|
-
export function buildContextUsage(
|
|
108
|
-
|
|
111
|
+
export function buildContextUsage(
|
|
112
|
+
{ header, footerSettings, listingCardContext, contexts, pages = [], skipped = [], unavailable } = {},
|
|
113
|
+
) {
|
|
114
|
+
const counter = createContextUsageCounter({ header, footerSettings, listingCardContext, contexts });
|
|
109
115
|
for (const { file, document } of pages) counter.add(document, file);
|
|
110
116
|
return { usage: counter.result(), skipped: skippedReport(skipped), ...(unavailable === undefined ? {} : { unavailable }) };
|
|
111
117
|
}
|
|
@@ -138,11 +144,12 @@ export async function readWorkspaceContextUsage({
|
|
|
138
144
|
mediaManifest,
|
|
139
145
|
header,
|
|
140
146
|
footerSettings,
|
|
147
|
+
listingCardContext,
|
|
141
148
|
content,
|
|
142
149
|
contexts,
|
|
143
150
|
themeContexts,
|
|
144
151
|
}) {
|
|
145
|
-
const counter = createContextUsageCounter({ header, footerSettings, contexts });
|
|
152
|
+
const counter = createContextUsageCounter({ header, footerSettings, listingCardContext, contexts });
|
|
146
153
|
const manifestByFile = new Map(
|
|
147
154
|
(manifest?.pages ?? []).filter((entry) => typeof entry?.file === "string").map((entry) => [entry.file, entry]),
|
|
148
155
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$generated": "Generated by scripts/build-default-site-theme.mjs from @taprootio/espalier. Do not edit by hand — run `npm run theme:build`.",
|
|
3
|
-
"espalierVersion": "7.
|
|
3
|
+
"espalierVersion": "7.10.0",
|
|
4
4
|
"light": {
|
|
5
5
|
"encoded": "eyJzZWVkQ29sb3IiOiJva2xjaCguMDcgMC4xNSAyMTYpIiwiZm9udEJvZHkiOiJcIk5vdG8gU2Fuc1wiLCBzYW5zLXNlcmlmIiwiZm9udEhlYWRpbmdzIjoiXCJJbmlrYVwiLCBzZXJpZiIsImZvbnRCcmFuZCI6IlwiSW5pa2FcIiwgc2VyaWYiLCJmb250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