@taprootio/site-authoring 0.55.0 → 0.59.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 +91 -22
- package/package.json +2 -2
- package/src/api.js +90 -17
- package/src/authors-contract.js +71 -3
- package/src/block-flow.js +4 -2
- package/src/changelog.json +104 -0
- package/src/chrome-additions.js +106 -0
- package/src/chrome-features.js +43 -10
- package/src/chrome-input.js +137 -30
- package/src/chrome-report.js +4 -2
- package/src/cli.js +144 -38
- package/src/constants.js +1 -0
- package/src/content/button-styles.js +27 -0
- package/src/content/components.js +76 -10
- package/src/content/free-form-section-registry.json +9 -0
- package/src/content/free-form-sections.js +55 -16
- package/src/content/markdown.js +133 -56
- package/src/content/media-presentation.js +37 -0
- package/src/content/tiptap-prosemirror.ts +26 -10
- package/src/credentials.js +2 -1
- package/src/delivery-check.js +10 -2
- package/src/font-catalog.js +9 -6
- package/src/footer-content.js +1 -1
- package/src/footer-contract.js +3 -0
- package/src/footer-draft-hash.js +1 -0
- package/src/heading-outline.js +94 -6
- package/src/image-description-contract.js +5 -3
- package/src/image-description-write.js +26 -0
- package/src/index.js +1 -0
- package/src/output.js +2 -1
- package/src/page-metadata.js +15 -13
- package/src/page-structure-checks.js +14 -25
- package/src/placed-image-ids.js +42 -17
- package/src/presentation-reference.js +63 -18
- package/src/problems.js +147 -4
- package/src/reference-help.js +122 -60
- package/src/site-check-findings.js +2 -3
- package/src/site-check-rules.json +0 -1
- package/src/site-health-findings.js +7 -9
- package/src/site-health-image-checks.js +4 -1
- package/src/site-health-precheck.js +23 -6
- package/src/site-navigation-groups.js +16 -0
- package/src/status-warning-paints.js +175 -0
- package/src/template-token-reach.json +13 -18
- package/src/theme-proposals.js +143 -55
- package/src/theme-resolve.js +14 -1
- package/src/theme-validation.js +70 -38
- package/src/token-reach.js +20 -0
- package/src/typed-page-reference.js +25 -3
- package/src/typed-pages.js +73 -14
- package/src/verbs/authors.js +198 -33
- package/src/verbs/changelog.js +23 -2
- package/src/verbs/delivery-check.js +43 -9
- package/src/verbs/index.js +4 -2
- package/src/verbs/media-images.js +4 -4
- package/src/verbs/pages-push.js +138 -67
- package/src/verbs/plan.js +28 -20
- package/src/verbs/pull.js +226 -26
- package/src/verbs/theme-push.js +59 -15
- package/src/verbs/theme-resolve.js +109 -11
- package/src/verbs/validate.js +97 -16
- package/src/workspace-check.js +4 -4
- package/src/workspace-context-usage.js +180 -0
- package/src/workspace.js +48 -1
- package/test/fixtures/default-site-theme.json +1 -1
package/src/verbs/pull.js
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
withRefusalGuidance,
|
|
19
19
|
} from "../api.js";
|
|
20
20
|
import {
|
|
21
|
+
LIMITS,
|
|
21
22
|
REFUSAL_CAPABILITY_MISSING,
|
|
22
23
|
REFUSAL_UNCLASSIFIED,
|
|
23
24
|
SURFACE_DOCS_PRESENTATION,
|
|
@@ -25,7 +26,12 @@ import {
|
|
|
25
26
|
} from "../constants.js";
|
|
26
27
|
import { tagDestinationCatalogSlugs } from "../appearance-contract.js";
|
|
27
28
|
import { validateAuthoredTagNames } from "../authored-tag-names.js";
|
|
28
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
AUTHORS_FILE_NAME,
|
|
31
|
+
normalizeAuthorHandle,
|
|
32
|
+
parseAuthorReference,
|
|
33
|
+
projectAuthorsForWorkspace,
|
|
34
|
+
} from "../authors-contract.js";
|
|
29
35
|
import { isCanonicalUuid, sanitizeDiagnostic, SiteAuthoringError } from "../errors.js";
|
|
30
36
|
import { appearanceManifestEntry, footerManifestEntry, presentationManifestEntry } from "../footer-workspace.js";
|
|
31
37
|
import { describeJsonDifferences, reportableDifferencePaths } from "../json-path-diff.js";
|
|
@@ -33,7 +39,7 @@ import { projectRedirectMapForWorkspace, REDIRECTS_FILE_NAME } from "../redirect
|
|
|
33
39
|
import { navigationManifestEntry } from "../navigation-workspace.js";
|
|
34
40
|
import { redirectsManifestEntry } from "../redirects-workspace.js";
|
|
35
41
|
import { projectNavigationForWorkspace } from "./nav-push.js";
|
|
36
|
-
import { parseFrontMatter } from "./pages-push.js";
|
|
42
|
+
import { parseFrontMatter, readWorkspacePageSource } from "./pages-push.js";
|
|
37
43
|
import { boundedList, openSession, successResult } from "../session.js";
|
|
38
44
|
import {
|
|
39
45
|
projectSettingsGroup,
|
|
@@ -53,7 +59,9 @@ import {
|
|
|
53
59
|
isAuthorableTemplateType,
|
|
54
60
|
isGeneratedTemplateType,
|
|
55
61
|
projectAuthoredTagSnapshot,
|
|
62
|
+
sentDisplayAuthor,
|
|
56
63
|
sentDisplayDate,
|
|
64
|
+
sentShowOnProfile,
|
|
57
65
|
supportsAuthoredTagWireType,
|
|
58
66
|
TEMPLATE_LEGAL,
|
|
59
67
|
workspaceDocumentFromPage,
|
|
@@ -471,13 +479,16 @@ function bodyStatusFor(summary) {
|
|
|
471
479
|
function assignPageFiles(pages, tracked, kept = new Set()) {
|
|
472
480
|
// `kept` holds files this pull must not write over: the sources of retired
|
|
473
481
|
// generated pages, which may hold unpushed edits (TR01195).
|
|
474
|
-
|
|
482
|
+
// Names compare case-insensitively: pages/ABOUT.pm.json and pages/about.pm.json are one file on macOS and Windows.
|
|
483
|
+
const key = (file) => file.toLowerCase();
|
|
484
|
+
const reserved = new Set([...pages.map((summary) => `${PAGES_DIRECTORY}/${summary.pageId}.pm.json`), ...kept].map(key));
|
|
485
|
+
const keptKeys = new Set([...kept].map(key));
|
|
475
486
|
const claimed = new Set();
|
|
476
487
|
const assigned = new Map();
|
|
477
488
|
for (const summary of pages) {
|
|
478
489
|
const source = tracked.get(summary.pageId);
|
|
479
490
|
if (source === undefined) continue;
|
|
480
|
-
claimed.add(source.file);
|
|
491
|
+
claimed.add(key(source.file));
|
|
481
492
|
assigned.set(summary.pageId, source.file);
|
|
482
493
|
}
|
|
483
494
|
const homeFirst = [...pages].sort((left, right) => {
|
|
@@ -491,13 +502,13 @@ function assignPageFiles(pages, tracked, kept = new Set()) {
|
|
|
491
502
|
if (assigned.has(summary.pageId)) continue;
|
|
492
503
|
const fallback = `${PAGES_DIRECTORY}/${summary.pageId}.pm.json`;
|
|
493
504
|
const preferred = `${PAGES_DIRECTORY}/${workspaceFileNameForPage(summary.path, summary.pageId)}.pm.json`;
|
|
494
|
-
const available = preferred === fallback || (!claimed.has(preferred) && !reserved.has(preferred));
|
|
505
|
+
const available = preferred === fallback || (!claimed.has(key(preferred)) && !reserved.has(key(preferred)));
|
|
495
506
|
const file = available ? preferred : fallback;
|
|
496
507
|
// The page-id fallback is unique by construction, so the only way it is
|
|
497
508
|
// already taken is a tracked source that was renamed onto another page's
|
|
498
509
|
// reserved name by hand. Guessing which page owns it is exactly the
|
|
499
510
|
// ambiguity this task exists to remove.
|
|
500
|
-
if (claimed.has(file)) {
|
|
511
|
+
if (claimed.has(key(file)) || keptKeys.has(key(file))) {
|
|
501
512
|
throw new SiteAuthoringError(
|
|
502
513
|
"pages.source_conflict",
|
|
503
514
|
`Page ${summary.pageId} has no free workspace file: '${file}' is already the tracked source of another `
|
|
@@ -505,7 +516,7 @@ function assignPageFiles(pages, tracked, kept = new Set()) {
|
|
|
505
516
|
{ field: file },
|
|
506
517
|
);
|
|
507
518
|
}
|
|
508
|
-
claimed.add(file);
|
|
519
|
+
claimed.add(key(file));
|
|
509
520
|
assigned.set(summary.pageId, file);
|
|
510
521
|
}
|
|
511
522
|
return assigned;
|
|
@@ -578,33 +589,165 @@ async function resolveTrackedSources(workspaceDir, pages, registry, onProgress)
|
|
|
578
589
|
* scheme; see `withoutSupersededRemoteHashes`.
|
|
579
590
|
*/
|
|
580
591
|
async function readSourceRegistry(workspaceDir, siteId) {
|
|
581
|
-
if (!await workspaceFileExists(workspaceDir, MANIFEST_FILE_NAME)) return new Map();
|
|
592
|
+
if (!await workspaceFileExists(workspaceDir, MANIFEST_FILE_NAME)) return { registry: new Map(), pending: [] };
|
|
582
593
|
let parsed;
|
|
583
594
|
try {
|
|
584
595
|
parsed = await readWorkspaceJson(workspaceDir, MANIFEST_FILE_NAME, WORKSPACE_LIMITS.manifestBytes);
|
|
585
596
|
} catch {
|
|
586
|
-
return new Map();
|
|
597
|
+
return { registry: new Map(), pending: [] };
|
|
587
598
|
}
|
|
588
599
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed) || parsed.siteId !== siteId) {
|
|
589
|
-
return new Map();
|
|
600
|
+
return { registry: new Map(), pending: [] };
|
|
590
601
|
}
|
|
591
602
|
const manifest = withoutRetiredReadOnlyProjections(parsed);
|
|
603
|
+
// A new source's metadata lives only in its pending entry until its first save.
|
|
604
|
+
const pending = [];
|
|
592
605
|
for (const entry of Array.isArray(manifest.pages) ? manifest.pages : []) {
|
|
593
606
|
if (entry === null || typeof entry !== "object" || Array.isArray(entry) || isCanonicalUuid(entry.pageId)) continue;
|
|
594
607
|
if (!["file", "title", "path"].some((field) => Object.hasOwn(entry, field))) continue;
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
608
|
+
pending.push(entry);
|
|
609
|
+
}
|
|
610
|
+
const registry = pageSourceRegistry(manifest);
|
|
611
|
+
return {
|
|
612
|
+
registry: parsed.manifestVersion === MANIFEST_VERSION ? registry : withoutSupersededRemoteHashes(registry),
|
|
613
|
+
pending,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** The manifest is read back under a byte bound, so a pull that would write a larger one is refused first. */
|
|
618
|
+
export function requireManifestRoom(pending, live) {
|
|
619
|
+
const bytes = (value) => Buffer.byteLength(JSON.stringify(value), "utf8");
|
|
620
|
+
// A pulled page entry also carries a baseline hash and authored fields; 512 bytes covers them.
|
|
621
|
+
const estimate = pending.reduce((total, entry) => total + bytes(entry), 0)
|
|
622
|
+
+ live.reduce((total, summary) => total + bytes(summary) + 512, 0);
|
|
623
|
+
if (estimate > WORKSPACE_LIMITS.manifestBytes) {
|
|
598
624
|
throw new SiteAuthoringError(
|
|
599
|
-
"
|
|
600
|
-
`The
|
|
601
|
-
+ "Save
|
|
602
|
-
+ "entry before running 'taproot-site pull' again. Nothing was changed.",
|
|
603
|
-
{ field },
|
|
625
|
+
"pull.manifest_too_large",
|
|
626
|
+
`The pull manifest would exceed ${WORKSPACE_LIMITS.manifestBytes} bytes with the pending page entries it keeps. `
|
|
627
|
+
+ "Save or remove pending entries, then run 'taproot-site pull' again. Nothing was changed.",
|
|
604
628
|
);
|
|
605
629
|
}
|
|
606
|
-
|
|
607
|
-
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function pendingRefusal(entry, reason) {
|
|
633
|
+
const field = sanitizeDiagnostic(entry.file, MANIFEST_FILE_NAME);
|
|
634
|
+
const label = sanitizeDiagnostic(entry.path, field);
|
|
635
|
+
return new SiteAuthoringError(
|
|
636
|
+
"pages.source_conflict",
|
|
637
|
+
`The pending page entry '${label}' has no server page id and ${reason}. Pull would discard its saved metadata. `
|
|
638
|
+
+ "Save the draft with 'taproot-site pages push' first (a legal page needs 'taproot-site login --legal-drafts', "
|
|
639
|
+
+ "then 'taproot-site --legal-drafts pages push'), or back up and move its source file and manifest "
|
|
640
|
+
+ "entry before running 'taproot-site pull' again. Nothing was changed.",
|
|
641
|
+
{ field },
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Refuses, before any request, a pending entry pull cannot carry as it is: no file on disk, no usable path,
|
|
647
|
+
* or a path or file another pending entry already uses.
|
|
648
|
+
*/
|
|
649
|
+
async function requireCarriablePendingEntries(workspaceDir, pending) {
|
|
650
|
+
const seenPaths = new Set();
|
|
651
|
+
const seenFiles = new Set();
|
|
652
|
+
const effectivePaths = new Map();
|
|
653
|
+
for (const entry of pending) {
|
|
654
|
+
// Like pages push, only an entry with no pageId at all is a pending draft.
|
|
655
|
+
if (entry.pageId !== undefined) {
|
|
656
|
+
const field = sanitizeDiagnostic(entry.file, MANIFEST_FILE_NAME);
|
|
657
|
+
throw new SiteAuthoringError(
|
|
658
|
+
"pages.source_conflict",
|
|
659
|
+
`The page entry '${sanitizeDiagnostic(entry.path, field)}' has a pageId that is not a canonical page id. Remove the `
|
|
660
|
+
+ "pageId to keep the entry as a draft, or replace it with the page's real id, then run 'taproot-site pull' again. "
|
|
661
|
+
+ "Nothing was changed.",
|
|
662
|
+
{ field },
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
const file = typeof entry.file === "string" ? entry.file : undefined;
|
|
666
|
+
if (file === undefined || !await workspaceFileExists(workspaceDir, file)) {
|
|
667
|
+
throw pendingRefusal(entry, "has no source file on disk");
|
|
668
|
+
}
|
|
669
|
+
if (pageSourceFormat(file) === undefined || !isDiscoverablePageSource(file)) {
|
|
670
|
+
throw pendingRefusal(entry, "names a file that is not a page source");
|
|
671
|
+
}
|
|
672
|
+
const paths = await pendingEffectivePaths(workspaceDir, entry);
|
|
673
|
+
if (paths.length === 0) throw pendingRefusal(entry, "has no usable path");
|
|
674
|
+
if (paths.some((path) => seenPaths.has(path)) || seenFiles.has(file.toLowerCase())) {
|
|
675
|
+
throw pendingRefusal(entry, "shares its path or source file with another pending entry");
|
|
676
|
+
}
|
|
677
|
+
for (const path of paths) seenPaths.add(path);
|
|
678
|
+
seenFiles.add(file.toLowerCase());
|
|
679
|
+
effectivePaths.set(entry, paths);
|
|
680
|
+
}
|
|
681
|
+
return effectivePaths;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/** The page paths a pending source claims: a Markdown source's front matter wins over its entry, as in pages push. */
|
|
685
|
+
async function pendingEffectivePaths(workspaceDir, entry) {
|
|
686
|
+
if (pageSourceFormat(entry.file) !== PAGE_SOURCE_FORMAT_MARKDOWN) {
|
|
687
|
+
const path = normalizePagePath(entry.path);
|
|
688
|
+
return path === undefined ? [] : [path];
|
|
689
|
+
}
|
|
690
|
+
try {
|
|
691
|
+
const source = await readWorkspacePageSource({ workspaceDir, file: entry.file, manifestEntry: entry });
|
|
692
|
+
return source.pagePath === undefined ? source.pathClaims : [source.pagePath];
|
|
693
|
+
} catch {
|
|
694
|
+
return [];
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* The pending entries this pull carries into the new manifest, unchanged, with their files.
|
|
700
|
+
*
|
|
701
|
+
* Once the page list is read, an entry is carried only when nothing can claim its path or file: no live page
|
|
702
|
+
* holds its path, no tracked source is the same file, and the listing was complete. Anything else refuses
|
|
703
|
+
* before a byte is written, so the saved metadata is never discarded.
|
|
704
|
+
*/
|
|
705
|
+
function requireNoPendingCollisions(pending, { live, tracked, truncated, retiredFiles, effectivePaths }) {
|
|
706
|
+
if (pending.length === 0) return;
|
|
707
|
+
if (truncated) throw pendingRefusal(pending[0], "cannot be checked against a page list this pull could not read in full");
|
|
708
|
+
const livePaths = new Set(live.map((summary) => normalizePagePath(summary.path) ?? summary.path));
|
|
709
|
+
const takenFiles = new Set([...[...tracked.values()].map((source) => source.file), ...retiredFiles].map((file) => file.toLowerCase()));
|
|
710
|
+
for (const entry of pending) {
|
|
711
|
+
if (effectivePaths.get(entry).some((path) => livePaths.has(path))) throw pendingRefusal(entry, "has a path a page on the site holds");
|
|
712
|
+
if (takenFiles.has(entry.file.toLowerCase())) throw pendingRefusal(entry, "shares its source file with another page");
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
const PENDING_SAVE_REMINDER = "Save kept pending pages with 'taproot-site pages push'.";
|
|
717
|
+
const PENDING_LEGAL_REMINDER = "A legal page needs 'taproot-site login --legal-drafts', then 'taproot-site --legal-drafts pages push'.";
|
|
718
|
+
|
|
719
|
+
/** What a pull tells the author about the pending entries it kept. */
|
|
720
|
+
async function describeKeptPending(workspaceDir, entries, effectivePaths) {
|
|
721
|
+
const items = [];
|
|
722
|
+
let legal = false;
|
|
723
|
+
// One source at a time: each read can be as large as a document.
|
|
724
|
+
for (const entry of entries) {
|
|
725
|
+
try {
|
|
726
|
+
legal ||= (await readWorkspaceJson(workspaceDir, entry.file, WORKSPACE_LIMITS.documentBytes))?.template === TEMPLATE_LEGAL;
|
|
727
|
+
} catch {
|
|
728
|
+
// A Markdown source or an unreadable one is not a legal document.
|
|
729
|
+
}
|
|
730
|
+
// The path a targeted push will find: a Markdown source's front matter wins over its entry.
|
|
731
|
+
items.push({ file: entry.file, path: displayPagePath(effectivePaths.get(entry)?.[0] ?? entry.path ?? "") });
|
|
732
|
+
}
|
|
733
|
+
return {
|
|
734
|
+
count: items.length,
|
|
735
|
+
items,
|
|
736
|
+
reminder: legal ? `${PENDING_SAVE_REMINDER} ${PENDING_LEGAL_REMINDER}` : PENDING_SAVE_REMINDER,
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/** Keeps the count and shrinks the item list until the block fits the bytes the rest of the result leaves. */
|
|
741
|
+
function fitKeptPending(block, byteBudget) {
|
|
742
|
+
const shown = [];
|
|
743
|
+
let used = Buffer.byteLength(JSON.stringify({ ...block, items: [], itemsTruncated: true }), "utf8");
|
|
744
|
+
for (const item of block.items.slice(0, MAXIMUM_REPORTED)) {
|
|
745
|
+
const size = Buffer.byteLength(JSON.stringify(item), "utf8") + 1;
|
|
746
|
+
if (used + size > byteBudget) break;
|
|
747
|
+
shown.push(item);
|
|
748
|
+
used += size;
|
|
749
|
+
}
|
|
750
|
+
return { ...block, items: shown, ...(shown.length < block.items.length ? { itemsTruncated: true } : {}) };
|
|
608
751
|
}
|
|
609
752
|
|
|
610
753
|
/**
|
|
@@ -689,6 +832,17 @@ function trackedDisplayDate(page, templateType) {
|
|
|
689
832
|
return sentDisplayDate(templateType) ? (typeof page.displayDate === "string" ? page.displayDate : "") : undefined;
|
|
690
833
|
}
|
|
691
834
|
|
|
835
|
+
/** The display author a read reports for a page whose push sends one ("" for none), or `undefined` for other pages. */
|
|
836
|
+
function trackedDisplayAuthor(page, templateType) {
|
|
837
|
+
if (!sentDisplayAuthor(templateType)) return undefined;
|
|
838
|
+
return typeof page.displayAuthor === "string" ? normalizeAuthorHandle(page.displayAuthor) ?? "" : "";
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/** Whether a read says the page may be on its author's profile, or `undefined` for pages that carry no such setting. */
|
|
842
|
+
function trackedShowOnProfile(page, templateType) {
|
|
843
|
+
return sentShowOnProfile(templateType) ? page.showOnProfile !== false : undefined;
|
|
844
|
+
}
|
|
845
|
+
|
|
692
846
|
function notThisSite(message, field) {
|
|
693
847
|
// One code for one situation: "this workspace is not provably this site's."
|
|
694
848
|
// The remedy is the same for every branch below — a fresh directory — and an
|
|
@@ -788,7 +942,8 @@ export async function pull(invocation) {
|
|
|
788
942
|
|
|
789
943
|
await requireWorkspaceBelongsToSite(config.workspaceDir, siteId);
|
|
790
944
|
|
|
791
|
-
const registry = await readSourceRegistry(config.workspaceDir, siteId);
|
|
945
|
+
const { registry, pending: pendingEntries } = await readSourceRegistry(config.workspaceDir, siteId);
|
|
946
|
+
const pendingPaths = await requireCarriablePendingEntries(config.workspaceDir, pendingEntries);
|
|
792
947
|
|
|
793
948
|
// A managed Docs site has no pages, navigation, or redirects of its own to
|
|
794
949
|
// snapshot (TR00790): the Docs shell takes those from the artifact, and the
|
|
@@ -840,6 +995,8 @@ export async function pull(invocation) {
|
|
|
840
995
|
const sourceBodyHash = supportsAuthoredTagWireType(summary.templateType) ? remoteHash : undefined;
|
|
841
996
|
const revision = normalizePageBodyRevision(page.bodyRevision);
|
|
842
997
|
const displayDate = trackedDisplayDate(page, summary.templateType);
|
|
998
|
+
const displayAuthor = trackedDisplayAuthor(page, summary.templateType);
|
|
999
|
+
const showOnProfile = trackedShowOnProfile(page, summary.templateType);
|
|
843
1000
|
return {
|
|
844
1001
|
source,
|
|
845
1002
|
entry: {
|
|
@@ -859,6 +1016,8 @@ export async function pull(invocation) {
|
|
|
859
1016
|
...(sourceBodyHash === undefined ? {} : { sourceBodyHash }),
|
|
860
1017
|
...(revision === undefined ? {} : { revision }),
|
|
861
1018
|
...(displayDate === undefined ? {} : { displayDate }),
|
|
1019
|
+
...(displayAuthor === undefined ? {} : { displayAuthor }),
|
|
1020
|
+
...(showOnProfile === undefined ? {} : { showOnProfile }),
|
|
862
1021
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
863
1022
|
...(confirmedTags === undefined ? {} : {
|
|
864
1023
|
authoredTagRevision: confirmedTags.revision,
|
|
@@ -931,10 +1090,14 @@ export async function pull(invocation) {
|
|
|
931
1090
|
);
|
|
932
1091
|
}
|
|
933
1092
|
}
|
|
1093
|
+
const retiredFiles = retiredGeneratedSources.map((source) => source.file);
|
|
1094
|
+
requireNoPendingCollisions(pendingEntries, { live, tracked, truncated, retiredFiles, effectivePaths: pendingPaths });
|
|
1095
|
+
requireManifestRoom(pendingEntries, live);
|
|
1096
|
+
const keptPendingEntries = pendingEntries;
|
|
934
1097
|
const pageFiles = assignPageFiles(
|
|
935
1098
|
authorable,
|
|
936
1099
|
tracked,
|
|
937
|
-
new Set(
|
|
1100
|
+
new Set([...retiredFiles, ...keptPendingEntries.map((entry) => entry.file)]),
|
|
938
1101
|
);
|
|
939
1102
|
|
|
940
1103
|
// A fresh destination has no ownership baseline. Protect legal drafts even
|
|
@@ -1202,7 +1365,18 @@ export async function pull(invocation) {
|
|
|
1202
1365
|
const dateChanged = remoteDisplayDate !== undefined
|
|
1203
1366
|
&& source.baseline?.displayDate !== undefined
|
|
1204
1367
|
&& source.baseline.displayDate !== remoteDisplayDate;
|
|
1205
|
-
|
|
1368
|
+
// The display author is page content like the date and is compared the
|
|
1369
|
+
// same way (TR01402). A baseline written before it counts as not having
|
|
1370
|
+
// seen the value, so such a workspace pulls without a conflict.
|
|
1371
|
+
const remoteDisplayAuthor = trackedDisplayAuthor(page, summary.templateType);
|
|
1372
|
+
const displayAuthorChanged = remoteDisplayAuthor !== undefined
|
|
1373
|
+
&& source.baseline?.displayAuthor !== undefined
|
|
1374
|
+
&& source.baseline.displayAuthor !== remoteDisplayAuthor;
|
|
1375
|
+
const remoteShowOnProfile = trackedShowOnProfile(page, summary.templateType);
|
|
1376
|
+
const showOnProfileChanged = remoteShowOnProfile !== undefined
|
|
1377
|
+
&& source.baseline?.showOnProfile !== undefined
|
|
1378
|
+
&& source.baseline.showOnProfile !== remoteShowOnProfile;
|
|
1379
|
+
const remoteChanged = revisionChanged || dateChanged || displayAuthorChanged || showOnProfileChanged;
|
|
1206
1380
|
// Markdown is one-way, so a Markdown source can never be rewritten from
|
|
1207
1381
|
// the site's document and is always kept. A ProseMirror source can be
|
|
1208
1382
|
// refreshed — but only over content the author has not edited since the
|
|
@@ -1338,6 +1512,8 @@ export async function pull(invocation) {
|
|
|
1338
1512
|
...reconciled.baseline,
|
|
1339
1513
|
...(revision === undefined ? {} : { revision }),
|
|
1340
1514
|
...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
|
|
1515
|
+
...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
|
|
1516
|
+
...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
|
|
1341
1517
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1342
1518
|
}
|
|
1343
1519
|
: {
|
|
@@ -1353,6 +1529,8 @@ export async function pull(invocation) {
|
|
|
1353
1529
|
...reconciled.baseline,
|
|
1354
1530
|
...(revision === undefined ? {} : { revision }),
|
|
1355
1531
|
...(remoteDisplayDate === undefined ? {} : { displayDate: remoteDisplayDate }),
|
|
1532
|
+
...(remoteDisplayAuthor === undefined ? {} : { displayAuthor: remoteDisplayAuthor }),
|
|
1533
|
+
...(remoteShowOnProfile === undefined ? {} : { showOnProfile: remoteShowOnProfile }),
|
|
1356
1534
|
...(summary.authorRef === "" ? {} : { author: summary.authorRef }),
|
|
1357
1535
|
},
|
|
1358
1536
|
// A conflict preserves the site's version whatever kept the source: the
|
|
@@ -1383,6 +1561,10 @@ export async function pull(invocation) {
|
|
|
1383
1561
|
// the record showed must match too or its differences are stale.
|
|
1384
1562
|
const alreadyShown = observed !== undefined
|
|
1385
1563
|
&& observed.displayDate === remoteDisplayDate
|
|
1564
|
+
&& (remoteDisplayAuthor === undefined || observed.displayAuthor === undefined
|
|
1565
|
+
|| observed.displayAuthor === remoteDisplayAuthor)
|
|
1566
|
+
&& (remoteShowOnProfile === undefined || observed.showOnProfile === undefined
|
|
1567
|
+
|| observed.showOnProfile === remoteShowOnProfile)
|
|
1386
1568
|
&& (revision === undefined
|
|
1387
1569
|
? observed.revision === undefined && observed.remoteHash === remoteHash
|
|
1388
1570
|
: observed.revision === revision);
|
|
@@ -1421,6 +1603,8 @@ export async function pull(invocation) {
|
|
|
1421
1603
|
observedRevision: revision,
|
|
1422
1604
|
observedRemoteHash: remoteHash,
|
|
1423
1605
|
observedDisplayDate: remoteDisplayDate,
|
|
1606
|
+
observedDisplayAuthor: remoteDisplayAuthor,
|
|
1607
|
+
observedShowOnProfile: remoteShowOnProfile,
|
|
1424
1608
|
observedRevisionFile: internalPageObservedRevisionFile(summary.pageId),
|
|
1425
1609
|
});
|
|
1426
1610
|
}
|
|
@@ -1488,6 +1672,8 @@ export async function pull(invocation) {
|
|
|
1488
1672
|
? { remoteHash: conflict.observedRemoteHash }
|
|
1489
1673
|
: { revision: conflict.observedRevision }),
|
|
1490
1674
|
...(conflict.observedDisplayDate === undefined ? {} : { displayDate: conflict.observedDisplayDate }),
|
|
1675
|
+
...(conflict.observedDisplayAuthor === undefined ? {} : { displayAuthor: conflict.observedDisplayAuthor }),
|
|
1676
|
+
...(conflict.observedShowOnProfile === undefined ? {} : { showOnProfile: conflict.observedShowOnProfile }),
|
|
1491
1677
|
...(conflict.differences === undefined ? {} : { differences: conflict.differences }),
|
|
1492
1678
|
});
|
|
1493
1679
|
}
|
|
@@ -1633,11 +1819,21 @@ export async function pull(invocation) {
|
|
|
1633
1819
|
}),
|
|
1634
1820
|
...(formsBaseline === undefined ? {} : { forms: formsBaseline }),
|
|
1635
1821
|
...(marketingBaseline === undefined ? {} : { [MARKETING_MANIFEST_KEY]: marketingBaseline }),
|
|
1636
|
-
pages: manifestPages,
|
|
1822
|
+
pages: [...manifestPages, ...keptPendingEntries],
|
|
1637
1823
|
...(retiredGeneratedSources.length === 0 ? {} : { retiredGeneratedSources }),
|
|
1638
1824
|
};
|
|
1639
1825
|
await writeManifest(config.workspaceDir, manifest);
|
|
1640
|
-
|
|
1826
|
+
// TR01420: count every manifest entry, so the line agrees with the file.
|
|
1827
|
+
onProgress(
|
|
1828
|
+
`Wrote ${MANIFEST_FILE_NAME} describing ${manifest.pages.length} pages`
|
|
1829
|
+
+ `${keptPendingEntries.length === 0 ? "" : ` (${keptPendingEntries.length} kept pending)`}.`,
|
|
1830
|
+
);
|
|
1831
|
+
const keptPendingPages = keptPendingEntries.length === 0
|
|
1832
|
+
? undefined
|
|
1833
|
+
: await describeKeptPending(config.workspaceDir, keptPendingEntries, pendingPaths);
|
|
1834
|
+
if (keptPendingPages !== undefined) {
|
|
1835
|
+
onProgress(`Kept ${keptPendingPages.count} pending page(s) that were never saved. ${keptPendingPages.reminder}`);
|
|
1836
|
+
}
|
|
1641
1837
|
if (revisionsRecordedWithoutBodyComparison > 0) {
|
|
1642
1838
|
onProgress(
|
|
1643
1839
|
`revision recorded for ${revisionsRecordedWithoutBodyComparison} pages that had none; bodies were not compared`,
|
|
@@ -1659,7 +1855,7 @@ export async function pull(invocation) {
|
|
|
1659
1855
|
})),
|
|
1660
1856
|
MAXIMUM_REPORTED,
|
|
1661
1857
|
);
|
|
1662
|
-
|
|
1858
|
+
const result = successResult(VERB_PULL, siteId, {
|
|
1663
1859
|
manifestFile: MANIFEST_FILE_NAME,
|
|
1664
1860
|
...(presentationOnly ? { authoringSurface: SURFACE_DOCS_PRESENTATION } : {}),
|
|
1665
1861
|
pages: {
|
|
@@ -1701,6 +1897,10 @@ export async function pull(invocation) {
|
|
|
1701
1897
|
files: pulledSettings.map((entry) => entry.file),
|
|
1702
1898
|
},
|
|
1703
1899
|
});
|
|
1900
|
+
if (keptPendingPages === undefined) return result;
|
|
1901
|
+
// 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(result), "utf8") - 2048;
|
|
1903
|
+
return { ...result, keptPendingPages: fitKeptPending(keptPendingPages, Math.max(0, room)) };
|
|
1704
1904
|
}).finally(async () => {
|
|
1705
1905
|
if (stageDirectory !== undefined) await rm(stageDirectory, { recursive: true, force: true });
|
|
1706
1906
|
});
|
package/src/verbs/theme-push.js
CHANGED
|
@@ -11,8 +11,20 @@ import {
|
|
|
11
11
|
tagDestinationCatalogSlugs,
|
|
12
12
|
footerPresentationOverlay,
|
|
13
13
|
} from "../appearance-contract.js";
|
|
14
|
-
import { captureChromeResources, selectNameReportEligibility } from "../chrome-input.js";
|
|
14
|
+
import { captureChromeResources, describeSkippedLinks, selectNameReportEligibility } from "../chrome-input.js";
|
|
15
15
|
import { completeChromeReport } from "../chrome-report.js";
|
|
16
|
+
import { fitChromeAdditions } from "../chrome-additions.js";
|
|
17
|
+
import { readWorkspaceContextUsage } from "../workspace-context-usage.js";
|
|
18
|
+
import {
|
|
19
|
+
contextScopedNames,
|
|
20
|
+
hasContextScopedStatusWarning,
|
|
21
|
+
notCountedLine,
|
|
22
|
+
statusPaintFields,
|
|
23
|
+
statusPaintLines,
|
|
24
|
+
statusWarningPaints,
|
|
25
|
+
usageUnavailableLine,
|
|
26
|
+
} from "../status-warning-paints.js";
|
|
27
|
+
import { sharedThemeContextNames } from "../content/free-form-sections.js";
|
|
16
28
|
import { REFUSAL_UNCLASSIFIED, VERB_THEME_PUSH } from "../constants.js";
|
|
17
29
|
import { MISSING_SETTING_MESSAGE, SiteAuthoringError } from "../errors.js";
|
|
18
30
|
import { projectFooterSettingsForWorkspace, validateFooterDocument } from "../footer-contract.js";
|
|
@@ -429,8 +441,11 @@ export async function comparePresentation(client, siteId, validated, manifest) {
|
|
|
429
441
|
};
|
|
430
442
|
}
|
|
431
443
|
|
|
432
|
-
function reportPushWarnings(themes, onProgress) {
|
|
433
|
-
for (const warning of themes.warnings)
|
|
444
|
+
function reportPushWarnings(themes, onProgress, paints = statusWarningPaints(themes.warnings)) {
|
|
445
|
+
for (const warning of themes.warnings) {
|
|
446
|
+
onProgress(`Espalier warning: ${warning}`);
|
|
447
|
+
for (const line of statusPaintLines(paints, warning)) onProgress(line);
|
|
448
|
+
}
|
|
434
449
|
if (themes.warningsTruncated) {
|
|
435
450
|
const hidden = themes.warningCount - themes.warnings.length;
|
|
436
451
|
onProgress(
|
|
@@ -444,15 +459,25 @@ function reportPushWarnings(themes, onProgress) {
|
|
|
444
459
|
};
|
|
445
460
|
}
|
|
446
461
|
|
|
447
|
-
async function completePushWarnings(appearance, resources, evidence, onProgress, chromeDependencies) {
|
|
462
|
+
async function completePushWarnings(appearance, resources, evidence, onProgress, chromeDependencies, usageRead) {
|
|
448
463
|
const { themes } = appearance;
|
|
449
|
-
const { warnings } = await completeChromeReport({
|
|
464
|
+
const { warnings, skippedNavigationLinks } = await completeChromeReport({
|
|
450
465
|
themes,
|
|
451
466
|
appearance,
|
|
452
467
|
resources,
|
|
453
468
|
nameReportEnabled: selectNameReportEligibility(evidence),
|
|
454
469
|
}, chromeDependencies);
|
|
455
|
-
|
|
470
|
+
const bounded = withChromeWarnings(themes, warnings);
|
|
471
|
+
const paints = statusWarningPaints(bounded.warnings, { usage: usageRead?.usage });
|
|
472
|
+
const reported = reportPushWarnings(bounded, onProgress, paints);
|
|
473
|
+
for (const line of [...notCountedLine(usageRead?.skipped), ...usageUnavailableLine(usageRead?.unavailable)]) onProgress(line);
|
|
474
|
+
if (skippedNavigationLinks?.count > 0) onProgress(describeSkippedLinks(skippedNavigationLinks));
|
|
475
|
+
return {
|
|
476
|
+
warnings: reported,
|
|
477
|
+
...statusPaintFields(bounded.warnings, paints),
|
|
478
|
+
...(usageRead?.skipped === undefined ? {} : { contextUsageSkipped: usageRead.skipped }),
|
|
479
|
+
...(skippedNavigationLinks?.count > 0 ? { skippedNavigationLinks } : {}),
|
|
480
|
+
};
|
|
456
481
|
}
|
|
457
482
|
|
|
458
483
|
async function saveComparedPresentation(session, comparison) {
|
|
@@ -570,7 +595,8 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
570
595
|
// saved. Context-only differences are theme push's own to write.
|
|
571
596
|
if (!dryRun) requireFooterContentPushed(appearanceContext.footer, publishing.footerSettings);
|
|
572
597
|
const proposedFooter = dryRun && hasFooterContentEdits(appearanceContext.footer, publishing.footerSettings)
|
|
573
|
-
|
|
598
|
+
// Shape and images only: the chrome inventory classifies page targets, and footer push checks membership.
|
|
599
|
+
? validateFooterDocument(publishing.footerSettings, { knownImageIds: appearanceContext.knownImageIds })
|
|
574
600
|
: undefined;
|
|
575
601
|
const baseline = readPresentationBaseline(appearanceContext.manifest);
|
|
576
602
|
if (!dryRun && baseline === undefined) {
|
|
@@ -582,6 +608,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
582
608
|
onProgress(`Validated the complete light/dark theme pair and ${scalarOperations.length} appearance settings.`);
|
|
583
609
|
let comparison;
|
|
584
610
|
let resources;
|
|
611
|
+
let usageRead;
|
|
585
612
|
let saved;
|
|
586
613
|
try {
|
|
587
614
|
// Both modes check the complete proposed context state against the site.
|
|
@@ -604,6 +631,21 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
604
631
|
// Keep the optional snapshot on this side of the save. Report completion
|
|
605
632
|
// never reads settings or manifests after the response has arrived.
|
|
606
633
|
resources = await captureChromeResources({ ...appearanceContext, siteId, workspaceDir: config.workspaceDir });
|
|
634
|
+
// Read before the save so the evidence is the workspace the author pushed.
|
|
635
|
+
// Optional evidence: a failed read leaves usage unknown and never blocks the save.
|
|
636
|
+
// Reading converts every page, so skip it unless a warning names a context the usage could annotate.
|
|
637
|
+
if (hasContextScopedStatusWarning(validated.themes.warnings)) usageRead = await readWorkspaceContextUsage({
|
|
638
|
+
workspaceDir: config.workspaceDir,
|
|
639
|
+
siteId,
|
|
640
|
+
// The candidate theme's full shared list, so a page naming a context only the candidate defines still counts.
|
|
641
|
+
themeContexts: sharedThemeContextNames(validated.style.lightTheme, validated.style.darkTheme),
|
|
642
|
+
manifest: appearanceContext.manifest,
|
|
643
|
+
mediaManifest: resources.mediaManifest,
|
|
644
|
+
header: validated.header,
|
|
645
|
+
footerSettings: validated.publishing?.footerSettings,
|
|
646
|
+
content: invocation.content,
|
|
647
|
+
contexts: contextScopedNames(validated.themes.warnings),
|
|
648
|
+
}).catch(() => undefined);
|
|
607
649
|
if (!dryRun) saved = await saveComparedPresentation(session, comparison);
|
|
608
650
|
} catch (error) {
|
|
609
651
|
reportPushWarnings(validated.themes, onProgress);
|
|
@@ -618,7 +660,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
618
660
|
const footerContent = proposedFooter === undefined
|
|
619
661
|
? undefined
|
|
620
662
|
: compareFooterContent(appearanceContext.footer, comparison.currentFooter, proposedFooter);
|
|
621
|
-
const
|
|
663
|
+
const pushWarnings = await completePushWarnings(
|
|
622
664
|
validated,
|
|
623
665
|
{
|
|
624
666
|
...resources,
|
|
@@ -629,6 +671,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
629
671
|
{ current, manifest },
|
|
630
672
|
onProgress,
|
|
631
673
|
chromeDependencies,
|
|
674
|
+
usageRead,
|
|
632
675
|
);
|
|
633
676
|
for (const entry of differences) {
|
|
634
677
|
if (entry.paths.length === 0 && entry.truncated !== true) continue;
|
|
@@ -656,7 +699,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
656
699
|
);
|
|
657
700
|
}
|
|
658
701
|
onProgress("Dry run: nothing was written.");
|
|
659
|
-
return successResult(VERB_THEME_PUSH, siteId, {
|
|
702
|
+
return fitChromeAdditions(successResult(VERB_THEME_PUSH, siteId, {
|
|
660
703
|
dryRun: true,
|
|
661
704
|
revision: {
|
|
662
705
|
...(baseline === undefined ? {} : { baseline: baseline.revision }),
|
|
@@ -673,8 +716,8 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
673
716
|
differences,
|
|
674
717
|
...(footerContent === undefined ? {} : { footerContent }),
|
|
675
718
|
...(tagDestinationWarnings === undefined ? {} : { tagDestinationWarnings }),
|
|
676
|
-
|
|
677
|
-
});
|
|
719
|
+
...pushWarnings,
|
|
720
|
+
}));
|
|
678
721
|
}
|
|
679
722
|
|
|
680
723
|
const { presentation, applied } = saved;
|
|
@@ -682,7 +725,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
682
725
|
reportPushWarnings(validated.themes, onProgress);
|
|
683
726
|
throw error;
|
|
684
727
|
});
|
|
685
|
-
const
|
|
728
|
+
const pushWarnings = await completePushWarnings(
|
|
686
729
|
{
|
|
687
730
|
...validated,
|
|
688
731
|
footerPresentation: { context: projectedFooter.context, logoVariant: projectedFooter.logoVariant },
|
|
@@ -691,6 +734,7 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
691
734
|
{ saved, current, manifest },
|
|
692
735
|
onProgress,
|
|
693
736
|
chromeDependencies,
|
|
737
|
+
usageRead,
|
|
694
738
|
);
|
|
695
739
|
onProgress(
|
|
696
740
|
applied
|
|
@@ -704,10 +748,10 @@ export async function themePush(invocation, chromeDependencies) {
|
|
|
704
748
|
...scalarOperations.map((operation) => `${operation.settingsType}.${operation.setting}`),
|
|
705
749
|
...THEME_SETTINGS.map((setting) => `${SETTINGS_TYPE_TAPROOT_STYLES}.${setting}`),
|
|
706
750
|
];
|
|
707
|
-
return successResult(VERB_THEME_PUSH, siteId, {
|
|
751
|
+
return fitChromeAdditions(successResult(VERB_THEME_PUSH, siteId, {
|
|
708
752
|
applied,
|
|
709
753
|
revision: presentation.revision,
|
|
710
754
|
written: boundedList(written, 100),
|
|
711
|
-
|
|
712
|
-
});
|
|
755
|
+
...pushWarnings,
|
|
756
|
+
}));
|
|
713
757
|
}
|