@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/pages-push.js
CHANGED
|
@@ -43,7 +43,7 @@ import { outcomeUnknown, SiteAuthoringError } from "../errors.js";
|
|
|
43
43
|
import { DESCRIPTION_MAXIMUM_LENGTH, DESCRIPTION_WARN_LENGTH, descriptionWarnings } from "../page-metadata.js";
|
|
44
44
|
import { stableJson } from "../footer-draft-hash.js";
|
|
45
45
|
import { outgoingTagIntent, preflightPageTagWrites, tagBaselineAfterWrite, translatePageTagRefusal } from "../page-tag-writes.js";
|
|
46
|
-
import { CHECK_AREA, collectProblems, planStale, problemsOf, refuseProblems } from "../problems.js";
|
|
46
|
+
import { CHECK_AREA, appendAll, attachProblemsFile, collectProblems, planStale, problemsOf, refuseProblems, withFullProblems } from "../problems.js";
|
|
47
47
|
import { RUNTIME_MIRROR_PATH_REASON, isRuntimeMirrorPath } from "../reserved-paths.js";
|
|
48
48
|
import { boundedByBytes, openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
49
49
|
import { SETTINGS_TYPE_TAPROOT_STYLES } from "../settings-catalog.js";
|
|
@@ -67,7 +67,9 @@ import {
|
|
|
67
67
|
PAGE_TEMPLATES,
|
|
68
68
|
requireTemplateName,
|
|
69
69
|
RETIRED_GENERATED_PAGE_KINDS,
|
|
70
|
+
sentDisplayAuthor,
|
|
70
71
|
sentDisplayDate,
|
|
72
|
+
sentShowOnProfile,
|
|
71
73
|
TEMPLATE_FREE_FORM,
|
|
72
74
|
TEMPLATE_GENERATED,
|
|
73
75
|
templateFrontMatterFault,
|
|
@@ -118,6 +120,8 @@ import {
|
|
|
118
120
|
workspacePageSourceBodyHash,
|
|
119
121
|
writeManifest,
|
|
120
122
|
writeWorkspaceJson,
|
|
123
|
+
mediaReferenceCandidates,
|
|
124
|
+
retiredSourcesByFile,
|
|
121
125
|
} from "../workspace.js";
|
|
122
126
|
|
|
123
127
|
/**
|
|
@@ -199,6 +203,7 @@ const RESOLUTION_METADATA_CODES = new Set([
|
|
|
199
203
|
"pages.front_matter_invalid",
|
|
200
204
|
"pages.front_matter_unknown",
|
|
201
205
|
"pages.front_matter_duplicate",
|
|
206
|
+
"pages.display_author_invalid",
|
|
202
207
|
"pages.metadata_missing",
|
|
203
208
|
"pages.path_missing",
|
|
204
209
|
"pages.path_unsupported",
|
|
@@ -271,6 +276,17 @@ export function parseFrontMatter(source, file) {
|
|
|
271
276
|
));
|
|
272
277
|
continue;
|
|
273
278
|
}
|
|
279
|
+
// A bare `displayAuthor:` reads as empty, and empty clears the pen name. Only a quoted empty value may
|
|
280
|
+
// do that, so an unfinished line cannot put the member's own byline back on the page (TR01402).
|
|
281
|
+
if (key === "displayAuthor" && rawValue.trim() === "") {
|
|
282
|
+
record(documentError(
|
|
283
|
+
"pages.display_author_invalid",
|
|
284
|
+
`'${file}' declares displayAuthor with no value. Write displayAuthor: "" to clear the display author, `
|
|
285
|
+
+ "or a site author's handle.",
|
|
286
|
+
key,
|
|
287
|
+
));
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
274
290
|
const seen = values.get(key);
|
|
275
291
|
if (seen === undefined) {
|
|
276
292
|
if (key === "tags") tagsLine = index + 1;
|
|
@@ -368,21 +384,6 @@ function unwrapProseMirrorDocument(parsed, file) {
|
|
|
368
384
|
);
|
|
369
385
|
}
|
|
370
386
|
|
|
371
|
-
/**
|
|
372
|
-
* The candidate keys a Markdown image reference could match in the media
|
|
373
|
-
* manifest. Authors write `./media/hero.png`, `media/hero.png`, or
|
|
374
|
-
* `/media/hero.png` for the same file, and a resolver that accepted only one
|
|
375
|
-
* spelling would refuse content that is plainly correct.
|
|
376
|
-
*/
|
|
377
|
-
function mediaReferenceCandidates(reference) {
|
|
378
|
-
if (typeof reference !== "string" || reference === "") return [];
|
|
379
|
-
const withoutQuery = reference.split("#")[0].split("?")[0];
|
|
380
|
-
const stripped = withoutQuery.replace(/^\.\//u, "").replace(/^\/+/u, "");
|
|
381
|
-
const candidates = new Set([reference, withoutQuery, stripped]);
|
|
382
|
-
if (!stripped.includes("/")) candidates.add(`media/${stripped}`);
|
|
383
|
-
return [...candidates];
|
|
384
|
-
}
|
|
385
|
-
|
|
386
387
|
function makeResolveImage(mediaManifest, file) {
|
|
387
388
|
return async (reference) => {
|
|
388
389
|
for (const candidate of mediaReferenceCandidates(reference)) {
|
|
@@ -502,7 +503,7 @@ function peekJsonTemplate(text) {
|
|
|
502
503
|
* site deletes such a page on its next synchronization, but until then it is still listed,
|
|
503
504
|
* so a pulled source of that kind is judged here, before its document is read.
|
|
504
505
|
*/
|
|
505
|
-
function isRetiredGeneratedSource(source) {
|
|
506
|
+
export function isRetiredGeneratedSource(source) {
|
|
506
507
|
if (source.template !== TEMPLATE_GENERATED || typeof source.text !== "string") return false;
|
|
507
508
|
try {
|
|
508
509
|
return RETIRED_GENERATED_PAGE_KINDS.includes(JSON.parse(source.text)?.data?.kind);
|
|
@@ -679,29 +680,33 @@ export function requireReconciledRevision({ file, pagePath, target, entry, obser
|
|
|
679
680
|
}
|
|
680
681
|
|
|
681
682
|
/**
|
|
682
|
-
* The same guard for a typed page's display date,
|
|
683
|
-
* cover. It refuses only when this push would change a
|
|
684
|
-
* site since the workspace last saw it: an unset
|
|
685
|
-
* update, and a pull that showed the operator a conflict has
|
|
686
|
-
* them the site's version.
|
|
683
|
+
* The same guard for a typed page's display date, display author and showOnProfile, which the
|
|
684
|
+
* revision does not cover. It refuses only when this push would change a value
|
|
685
|
+
* that moved on the site since the workspace last saw it: an unset value is
|
|
686
|
+
* left alone by the update, and a pull that showed the operator a conflict has
|
|
687
|
+
* already handed them the site's version. `key` names the value in the
|
|
688
|
+
* document, the target, the baseline and the observed record, and `label` the
|
|
689
|
+
* value in the refusal (TR01402).
|
|
687
690
|
*/
|
|
688
|
-
function
|
|
689
|
-
const sent = documentTemplate(document_) === TEMPLATE_FREE_FORM ? undefined : document_
|
|
690
|
-
const recorded = entry?.baseline?.
|
|
691
|
-
const live = target
|
|
691
|
+
function requireReconciledPageValue(key, label, { file, pagePath, target, entry, document_, observed }) {
|
|
692
|
+
const sent = documentTemplate(document_) === TEMPLATE_FREE_FORM ? undefined : document_[key];
|
|
693
|
+
const recorded = entry?.baseline?.[key];
|
|
694
|
+
const live = target[key];
|
|
692
695
|
if (sent === undefined || recorded === undefined) return;
|
|
693
|
-
// A refused pull records the
|
|
694
|
-
// page whose
|
|
695
|
-
// A record from a pull that named no
|
|
696
|
-
if (observed !== undefined && (observed
|
|
697
|
-
if (
|
|
696
|
+
// A refused pull records the value it showed. Only that value is overridable: a
|
|
697
|
+
// page whose value moved again since is refused again, like a moved revision.
|
|
698
|
+
// A record from a pull that named no value still counts as having shown it.
|
|
699
|
+
if (observed !== undefined && (observed[key] === undefined || observed[key] === live)) return;
|
|
700
|
+
if (live === recorded || live === sent) return;
|
|
701
|
+
// A flag reads as true or false. An empty text value reads as "not set": "none" is a handle a site may use.
|
|
702
|
+
const shown = (value) => typeof value === "boolean" ? String(value) : value ? `'${value}'` : "not set";
|
|
698
703
|
throw new SiteAuthoringError(
|
|
699
704
|
"pages.push_conflict",
|
|
700
|
-
`Page '${pagePath || "/"}' has a different
|
|
701
|
-
+ `workspace last reconciled with (${recorded
|
|
702
|
-
+ `${sent
|
|
705
|
+
`Page '${pagePath || "/"}' has a different ${label} on the site (${shown(live)}) than the one this `
|
|
706
|
+
+ `workspace last reconciled with (${shown(recorded)}), and '${file}' would replace it with `
|
|
707
|
+
+ `${shown(sent)}. No page was pushed. Run 'taproot-site pull' to adopt the site's ${label}, or delete `
|
|
703
708
|
+ `'${file}' and pull again.`,
|
|
704
|
-
{ field: file, alternatives: [recorded, live] },
|
|
709
|
+
{ field: file, alternatives: [String(recorded), String(live)] },
|
|
705
710
|
);
|
|
706
711
|
}
|
|
707
712
|
|
|
@@ -780,26 +785,33 @@ async function convertedWorkspacePageSource({ source, mediaManifest, content: in
|
|
|
780
785
|
const { file } = source;
|
|
781
786
|
if (source.sourceFormat === PAGE_SOURCE_FORMAT_MARKDOWN) {
|
|
782
787
|
const resolveImage = makeResolveImage(mediaManifest, file);
|
|
783
|
-
|
|
784
|
-
|
|
788
|
+
// Only a free-form page collects every section decoration and background problem (TR01427).
|
|
789
|
+
const recoverSectionProblems = source.template === TEMPLATE_FREE_FORM;
|
|
790
|
+
const convert = async (markdown, firstLine = source.markdownFirstLine) => {
|
|
791
|
+
const converted = await content.markdownToProseMirror(markdown, { resolveImage, firstLine, recoverSectionProblems });
|
|
785
792
|
return unwrapProseMirrorDocument(
|
|
786
793
|
converted === null || typeof converted !== "object" ? undefined : converted.doc,
|
|
787
794
|
file,
|
|
788
795
|
);
|
|
789
796
|
};
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
797
|
+
try {
|
|
798
|
+
const document = source.template === TEMPLATE_FREE_FORM
|
|
799
|
+
? await convert(source.markdown)
|
|
800
|
+
: await typedDocumentFromMarkdown({
|
|
801
|
+
template: source.template,
|
|
802
|
+
fields: source.fields,
|
|
803
|
+
markdown: source.markdown,
|
|
804
|
+
file,
|
|
805
|
+
convert,
|
|
806
|
+
convertStep: (markdown, firstLine) => content.markdownToProseMirror(markdown, { resolveImage, recipeStep: true, firstLine }),
|
|
807
|
+
firstLine: source.markdownFirstLine,
|
|
808
|
+
resolveImage,
|
|
809
|
+
});
|
|
810
|
+
return { document };
|
|
811
|
+
} catch (error) {
|
|
812
|
+
// A lone refusal is rethrown as raised, so the file is attached to its problems here.
|
|
813
|
+
throw attachProblemsFile(error, file);
|
|
814
|
+
}
|
|
803
815
|
}
|
|
804
816
|
let parsed;
|
|
805
817
|
try {
|
|
@@ -815,6 +827,12 @@ async function convertedWorkspacePageSource({ source, mediaManifest, content: in
|
|
|
815
827
|
if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, "tags")) {
|
|
816
828
|
throw documentError("pages.tags_unsupported", `'${file}' declares tags, which the free-form template does not accept.`, "tags");
|
|
817
829
|
}
|
|
830
|
+
// Dropping one of these silently would publish the page under the member's own byline (TR01402, TR01403).
|
|
831
|
+
for (const key of ["displayAuthor", "showOnProfile"]) {
|
|
832
|
+
if (parsed !== null && typeof parsed === "object" && Object.hasOwn(parsed, key)) {
|
|
833
|
+
throw documentError("pages.document_shape", `'${file}' declares ${key}, which the free-form template does not accept.`, key);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
818
836
|
return { document: normalizeColumnsBody(unwrapProseMirrorDocument(parsed, file)).body };
|
|
819
837
|
}
|
|
820
838
|
|
|
@@ -926,7 +944,7 @@ export async function placedVideoProblems(client, siteId, planned) {
|
|
|
926
944
|
const problems = [];
|
|
927
945
|
for (const [videoId, file] of placements) {
|
|
928
946
|
if (knownIds.has(videoId)) continue;
|
|
929
|
-
problems
|
|
947
|
+
appendAll(problems, problemsOf(
|
|
930
948
|
library.truncated
|
|
931
949
|
? documentError(
|
|
932
950
|
"pages.video_library_unverifiable",
|
|
@@ -975,7 +993,7 @@ export async function placedFormProblems(client, siteId, planned, readLocalFormK
|
|
|
975
993
|
localFormKeys = await readLocalFormKeys();
|
|
976
994
|
localRead = true;
|
|
977
995
|
}
|
|
978
|
-
problems
|
|
996
|
+
appendAll(problems, problemsOf(
|
|
979
997
|
index.archivedKeys.has(key)
|
|
980
998
|
? documentError(
|
|
981
999
|
"pages.form_archived",
|
|
@@ -1073,6 +1091,11 @@ export function liveAuthorsRefresher({ client, workspaceDir, siteId, write, onPr
|
|
|
1073
1091
|
};
|
|
1074
1092
|
}
|
|
1075
1093
|
|
|
1094
|
+
/** The display author a write left on the page: what the site reports, else what was declared. */
|
|
1095
|
+
function displayAuthorAfterWrite(page, summary) {
|
|
1096
|
+
return summary.displayAuthor || page.document.displayAuthor || "";
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1076
1099
|
/**
|
|
1077
1100
|
* Decides what a page says about its author before anything is sent
|
|
1078
1101
|
* (TR01196). `declared` is what the source (or, for a `.pm.json` page, its
|
|
@@ -1139,6 +1162,30 @@ async function resolvePageAuthor({ file, pagePath, declared, recorded, markdown,
|
|
|
1139
1162
|
return { author: reference.value, sendAuthor: true, unverified };
|
|
1140
1163
|
}
|
|
1141
1164
|
|
|
1165
|
+
/**
|
|
1166
|
+
* Checks a declared display author against the site's authors (TR01402), as
|
|
1167
|
+
* `resolvePageAuthor` checks a new author: `authors.json` first, then, online,
|
|
1168
|
+
* the site's own list once, refusing only a handle the site really lacks. An
|
|
1169
|
+
* offline run cannot ask, so it flags the handle as unverified. The empty value
|
|
1170
|
+
* clears the display author and a value the site already holds needs no check.
|
|
1171
|
+
*/
|
|
1172
|
+
async function checkDisplayAuthor({ file, declared, held, knownAuthors, refreshAuthors }) {
|
|
1173
|
+
if (declared === undefined || declared === "" || declared === held) return {};
|
|
1174
|
+
let known = authorKnown(await knownAuthors(), declared);
|
|
1175
|
+
if (known === true) return {};
|
|
1176
|
+
if (refreshAuthors === undefined) return known === false ? { unverified: true } : {};
|
|
1177
|
+
known = authorKnown(await refreshAuthors(), declared);
|
|
1178
|
+
if (known === false) {
|
|
1179
|
+
throw documentError(
|
|
1180
|
+
"pages.display_author_unknown",
|
|
1181
|
+
`'${file}' names displayAuthor '${declared}', who is not one of the site's authors. Run 'taproot-site authors `
|
|
1182
|
+
+ "list' to see the handles, or 'taproot-site authors add' to create a site author.",
|
|
1183
|
+
file,
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
return {};
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1142
1189
|
/**
|
|
1143
1190
|
* Phase one over the workspace's page sources (TR01002): resolve which file is
|
|
1144
1191
|
* each page's one source, convert and validate it, and decide create, update,
|
|
@@ -1225,11 +1272,7 @@ export async function planPages({
|
|
|
1225
1272
|
// Sources of generated pages the site has since retired, which pull keeps
|
|
1226
1273
|
// apart from the live pages (TR01195). Never sent; reported, not refused,
|
|
1227
1274
|
// unless a push names that path.
|
|
1228
|
-
const retiredByFile =
|
|
1229
|
-
(Array.isArray(manifest.retiredGeneratedSources) ? manifest.retiredGeneratedSources : [])
|
|
1230
|
-
.filter((entry) => typeof entry?.file === "string" && typeof entry?.path === "string")
|
|
1231
|
-
.map((entry) => [entry.file, entry]),
|
|
1232
|
-
);
|
|
1275
|
+
const retiredByFile = retiredSourcesByFile(manifest);
|
|
1233
1276
|
for (const file of files) {
|
|
1234
1277
|
const manifestEntry = manifestByFile.get(file);
|
|
1235
1278
|
const retired = manifestEntry === undefined ? retiredByFile.get(file) : undefined;
|
|
@@ -1258,7 +1301,7 @@ export async function planPages({
|
|
|
1258
1301
|
// reports it; a targeted one refuses only if the selection touches a
|
|
1259
1302
|
// path it might be.
|
|
1260
1303
|
if (targeted) claimants.push(source);
|
|
1261
|
-
else problems
|
|
1304
|
+
else appendAll(problems, problemsOf(source.fault ?? missingPathError(file), { ...area, file }));
|
|
1262
1305
|
continue;
|
|
1263
1306
|
}
|
|
1264
1307
|
sources.push(source);
|
|
@@ -1274,7 +1317,7 @@ export async function planPages({
|
|
|
1274
1317
|
continue;
|
|
1275
1318
|
}
|
|
1276
1319
|
if (targeted) throw error;
|
|
1277
|
-
problems
|
|
1320
|
+
appendAll(problems, problemsOf(error, { ...area, file }));
|
|
1278
1321
|
}
|
|
1279
1322
|
}
|
|
1280
1323
|
|
|
@@ -1293,7 +1336,7 @@ export async function planPages({
|
|
|
1293
1336
|
}
|
|
1294
1337
|
if (!targeted || requestedPaths.has(source.pagePath)) {
|
|
1295
1338
|
conflicted.add(source.pagePath);
|
|
1296
|
-
problems
|
|
1339
|
+
appendAll(problems, problemsOf(
|
|
1297
1340
|
documentError(
|
|
1298
1341
|
"pages.path_conflict",
|
|
1299
1342
|
`'${source.file}' and '${existing.file}' both claim page path '${source.pagePath}'.`,
|
|
@@ -1516,7 +1559,9 @@ export async function planPages({
|
|
|
1516
1559
|
if (sourceTemplate === TEMPLATE_LEGAL) legalRevisionGuard = guard;
|
|
1517
1560
|
else {
|
|
1518
1561
|
if (tagIntent === undefined) requireReconciledRevision(guard);
|
|
1519
|
-
|
|
1562
|
+
requireReconciledPageValue("displayDate", "display date", { ...guard, document_, observed });
|
|
1563
|
+
requireReconciledPageValue("displayAuthor", "display author", { ...guard, document_, observed });
|
|
1564
|
+
requireReconciledPageValue("showOnProfile", "showOnProfile setting", { ...guard, document_, observed });
|
|
1520
1565
|
}
|
|
1521
1566
|
}
|
|
1522
1567
|
}
|
|
@@ -1569,6 +1614,15 @@ export async function planPages({
|
|
|
1569
1614
|
knownAuthors: getRecordedAuthors,
|
|
1570
1615
|
refreshAuthors: getLiveAuthors,
|
|
1571
1616
|
});
|
|
1617
|
+
const displayAuthor = generated
|
|
1618
|
+
? {}
|
|
1619
|
+
: await checkDisplayAuthor({
|
|
1620
|
+
file,
|
|
1621
|
+
declared: document_.displayAuthor,
|
|
1622
|
+
held: online && target !== undefined ? target.displayAuthor : baseline?.displayAuthor,
|
|
1623
|
+
knownAuthors: getRecordedAuthors,
|
|
1624
|
+
refreshAuthors: getLiveAuthors,
|
|
1625
|
+
});
|
|
1572
1626
|
contentKey = contentKeyFor(authorship.author);
|
|
1573
1627
|
// An author the site no longer holds is a change to send, however the
|
|
1574
1628
|
// source compares with the record.
|
|
@@ -1604,8 +1658,15 @@ export async function planPages({
|
|
|
1604
1658
|
file,
|
|
1605
1659
|
);
|
|
1606
1660
|
}
|
|
1661
|
+
// The byline the page will have after this push (TR01402): the declared
|
|
1662
|
+
// display author, none after an explicit clear, else the site's value.
|
|
1663
|
+
const declaredDisplayAuthor = document_.displayAuthor;
|
|
1664
|
+
const siteDisplayAuthor = (online && target !== undefined ? target.displayAuthor : baseline?.displayAuthor) ?? "";
|
|
1607
1665
|
const reviewAuthorMissing = documentTemplate(document_) === TEMPLATE_PLACE_REVIEW
|
|
1608
1666
|
&& authorship.author === ""
|
|
1667
|
+
&& (declaredDisplayAuthor ?? siteDisplayAuthor) === ""
|
|
1668
|
+
// The site's own flag decides for a page it already has, so a display author cleared by this
|
|
1669
|
+
// push shows its warning on the next run, once the site reports the page without a credit.
|
|
1609
1670
|
&& (online && target !== undefined
|
|
1610
1671
|
? target.reviewAuthorMissing === true
|
|
1611
1672
|
: targetEntry?.pageId === undefined || targetEntry.reviewAuthorMissing === true);
|
|
@@ -1623,6 +1684,7 @@ export async function planPages({
|
|
|
1623
1684
|
sendAuthor: authorship.sendAuthor,
|
|
1624
1685
|
reviewAuthorMissing,
|
|
1625
1686
|
...(authorship.unverified === true ? { authorUnverified: true } : {}),
|
|
1687
|
+
...(displayAuthor.unverified === true ? { displayAuthorUnverified: true } : {}),
|
|
1626
1688
|
document: document_,
|
|
1627
1689
|
sourceFormat: source.sourceFormat,
|
|
1628
1690
|
sourceHash: source.sourceHash,
|
|
@@ -1641,7 +1703,9 @@ export async function planPages({
|
|
|
1641
1703
|
});
|
|
1642
1704
|
}
|
|
1643
1705
|
|
|
1644
|
-
|
|
1706
|
+
// Both claimants of a contested path, so a caller can say neither was counted (the problem names only the later one).
|
|
1707
|
+
const conflictedFiles = sources.filter((source) => conflicted.has(source.pagePath)).map((source) => source.file);
|
|
1708
|
+
return { targeted, sources, selected, planned, unresolved, staleGenerated, problems, conflictedFiles };
|
|
1645
1709
|
}
|
|
1646
1710
|
|
|
1647
1711
|
function missingPathError(file) {
|
|
@@ -1817,15 +1881,15 @@ export async function pagesPush(invocation) {
|
|
|
1817
1881
|
});
|
|
1818
1882
|
const { planned, targeted, unresolved, staleGenerated } = plan;
|
|
1819
1883
|
await preflightPageTagWrites(client, siteId, plan, invocation.pageTagCapabilities);
|
|
1820
|
-
plan.problems
|
|
1884
|
+
appendAll(plan.problems, latestPostsTagProblems(planned, manifest, { sendingOnly: true }));
|
|
1821
1885
|
// A page that places a video names it by id, and only the library knows
|
|
1822
1886
|
// whether that id is one of this site's videos. Asked once for the whole
|
|
1823
1887
|
// push, before anything is written, so a page cannot be sent that
|
|
1824
1888
|
// publishing would then refuse.
|
|
1825
|
-
plan.problems
|
|
1889
|
+
appendAll(plan.problems, await placedVideoProblems(client, siteId, planned));
|
|
1826
1890
|
// Likewise a form: pages store its id, which only the site's own forms can supply.
|
|
1827
1891
|
const placedForms = await placedFormProblems(client, siteId, planned, () => workspaceFormKeys(config.workspaceDir));
|
|
1828
|
-
plan.problems
|
|
1892
|
+
appendAll(plan.problems, placedForms.problems);
|
|
1829
1893
|
|
|
1830
1894
|
// Under apply, the workspace read ledger has already held every source and
|
|
1831
1895
|
// manifest to the plan. What it cannot see is the site: every page the plan
|
|
@@ -1838,7 +1902,7 @@ export async function pagesPush(invocation) {
|
|
|
1838
1902
|
for (const [file, expected] of invocation.plannedPages) {
|
|
1839
1903
|
const page = byFile.get(file);
|
|
1840
1904
|
if (page === undefined || stableJson(plannedPageWriteIdentity(page)) !== expected) {
|
|
1841
|
-
throw planStale(`'${file}'`, file)
|
|
1905
|
+
throw withFullProblems(planStale(`'${file}'`, file), plan.problems);
|
|
1842
1906
|
}
|
|
1843
1907
|
}
|
|
1844
1908
|
const unplanned = planned.find((page) => !page.unchanged && !invocation.plannedPages.has(page.file));
|
|
@@ -1940,6 +2004,7 @@ export async function pagesPush(invocation) {
|
|
|
1940
2004
|
action: page.action,
|
|
1941
2005
|
status: summary.status,
|
|
1942
2006
|
...(page.author === "" ? {} : { author: page.author }),
|
|
2007
|
+
...(displayAuthorAfterWrite(page, summary) === "" ? {} : { displayAuthor: displayAuthorAfterWrite(page, summary) }),
|
|
1943
2008
|
});
|
|
1944
2009
|
// `entry?.` because a hand-edited manifest can hold a null in the list,
|
|
1945
2010
|
// and a raw TypeError here would collapse to an opaque `site.failed`
|
|
@@ -1992,6 +2057,11 @@ export async function pagesPush(invocation) {
|
|
|
1992
2057
|
// Recorded for the pages whose push sends a date, so the next push
|
|
1993
2058
|
// can tell a date the site changed from one it already holds.
|
|
1994
2059
|
...(sentDisplayDate(page.templateType) ? { displayDate: summary.displayDate } : {}),
|
|
2060
|
+
// Recorded from the handle the write's answer returns, so a second
|
|
2061
|
+
// push with no pull between compares with what the site holds now.
|
|
2062
|
+
...(sentDisplayAuthor(page.templateType) ? { displayAuthor: summary.displayAuthor } : {}),
|
|
2063
|
+
// The value the write's answer returns, in the workspace's sense (TR01403).
|
|
2064
|
+
...(sentShowOnProfile(page.templateType) ? { showOnProfile: summary.showOnProfile } : {}),
|
|
1995
2065
|
...(heldAuthor === "" ? {} : { author: heldAuthor }),
|
|
1996
2066
|
},
|
|
1997
2067
|
pendingApproval: true,
|
|
@@ -2077,7 +2147,8 @@ export async function pagesPush(invocation) {
|
|
|
2077
2147
|
|
|
2078
2148
|
// Pages are authorless unless a source names an author, and an owner
|
|
2079
2149
|
// otherwise finds the missing byline only after publishing (TR01196).
|
|
2080
|
-
const authorless = applied.filter((entry) =>
|
|
2150
|
+
const authorless = applied.filter((entry) =>
|
|
2151
|
+
entry.action === "created" && entry.author === undefined && entry.displayAuthor === undefined);
|
|
2081
2152
|
if (authorless.length > 0) {
|
|
2082
2153
|
onProgress(
|
|
2083
2154
|
`${authorless.length} page(s) were created without an author, so they publish with no byline. To credit one, `
|
package/src/verbs/plan.js
CHANGED
|
@@ -32,7 +32,7 @@ import { FOOTER_SETTINGS_FILE } from "../footer-workspace.js";
|
|
|
32
32
|
import { workspaceFormKeys } from "../forms-workspace.js";
|
|
33
33
|
import { preflightPageTagWrites } from "../page-tag-writes.js";
|
|
34
34
|
import { latestPostsTagProblems } from "../latest-posts-tags.js";
|
|
35
|
-
import { CHECK_AREA, collectProblems, problemsError, problemsOf, problemsWithinBudget, withinByteBudget } from "../problems.js";
|
|
35
|
+
import { CHECK_AREA, appendAll, collectProblems, omittedAreas, omittedProblemDigest, problemTotal, problemsError, problemsOf, problemsWithinBudget, withFullProblems, withinByteBudget } from "../problems.js";
|
|
36
36
|
import { openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
37
37
|
import { IMAGE_IDENTIFIER, usedImageIds } from "../typed-pages.js";
|
|
38
38
|
import { checkWorkspace } from "../workspace-check.js";
|
|
@@ -167,7 +167,7 @@ function step(name, status, detail = {}) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function stepStatus(problems, name, changed) {
|
|
170
|
-
if (problems.some((problem) => problem.area === STEP_AREAS[name])) return BLOCKED;
|
|
170
|
+
if (problems.some((problem) => problem.area === STEP_AREAS[name]) || omittedAreas(problems).has(STEP_AREAS[name])) return BLOCKED;
|
|
171
171
|
return changed ? READY : NOTHING_TO_DO;
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -228,7 +228,7 @@ async function preflight(session, invocation) {
|
|
|
228
228
|
areas: PLANNED_AREAS,
|
|
229
229
|
onProgress,
|
|
230
230
|
});
|
|
231
|
-
problems
|
|
231
|
+
appendAll(problems, offline.problems);
|
|
232
232
|
|
|
233
233
|
// What the site holds of every image this plan depends on, read by id so a
|
|
234
234
|
// large library cannot hide one: the recorded uploads, and the images the
|
|
@@ -254,7 +254,7 @@ async function preflight(session, invocation) {
|
|
|
254
254
|
: { videos: [], truncated: false };
|
|
255
255
|
const media = await collectProblems(problems, { area: CHECK_AREA.media }, async () =>
|
|
256
256
|
await pendingMediaFiles(workspaceDir, mediaManifest, { imageStates, videos }));
|
|
257
|
-
problems
|
|
257
|
+
appendAll(problems, media?.problems ?? []);
|
|
258
258
|
const pendingMedia = media?.files ?? [];
|
|
259
259
|
const plannedMedia = {
|
|
260
260
|
...mediaManifest,
|
|
@@ -293,9 +293,10 @@ async function preflight(session, invocation) {
|
|
|
293
293
|
onProgress,
|
|
294
294
|
});
|
|
295
295
|
const pageTagCapabilities = await preflightPageTagWrites(client, siteId, pages);
|
|
296
|
-
|
|
297
|
-
problems
|
|
298
|
-
problems
|
|
296
|
+
appendAll(problems, pages.problems);
|
|
297
|
+
appendAll(problems, latestPostsTagProblems(pages.planned, manifest, { sendingOnly: true }));
|
|
298
|
+
appendAll(problems, await placedVideoProblems(client, siteId, pages.planned));
|
|
299
|
+
appendAll(problems, (await placedFormProblems(client, siteId, pages.planned, () => workspaceFormKeys(workspaceDir))).problems);
|
|
299
300
|
const sending = pages.planned.filter((page) => !page.unchanged);
|
|
300
301
|
|
|
301
302
|
// An image a page names must be one the site holds; an image this plan
|
|
@@ -312,7 +313,7 @@ async function preflight(session, invocation) {
|
|
|
312
313
|
: new Map([...imageStates, ...await readImageStates(client, siteId, unread)]);
|
|
313
314
|
for (const { file, imageId } of pageImages) {
|
|
314
315
|
if (pageImageStates.has(imageId)) continue;
|
|
315
|
-
problems
|
|
316
|
+
appendAll(problems, problemsOf(new SiteAuthoringError(
|
|
316
317
|
"plan.page_image_missing",
|
|
317
318
|
`'${file}' names image ${imageId}, which this site does not hold (it was deleted, or belongs to another `
|
|
318
319
|
+ "site). Upload the file with media upload and refer to it by its media path.",
|
|
@@ -326,9 +327,9 @@ async function preflight(session, invocation) {
|
|
|
326
327
|
theme = await comparePresentation(client, siteId, offline.presentation, manifest);
|
|
327
328
|
// Only a theme step that would run can be refused.
|
|
328
329
|
if (theme.changed && theme.baseline === undefined) {
|
|
329
|
-
problems
|
|
330
|
+
appendAll(problems, problemsOf(presentationPullRequired(), { area: CHECK_AREA.presentation }));
|
|
330
331
|
} else if (theme.changed && theme.stale && !theme.replaying) {
|
|
331
|
-
problems
|
|
332
|
+
appendAll(problems, problemsOf(presentationMovedRefusal(theme), { area: CHECK_AREA.presentation }));
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
335
|
|
|
@@ -340,7 +341,7 @@ async function preflight(session, invocation) {
|
|
|
340
341
|
? undefined
|
|
341
342
|
: computeFooterDraftHash(theme.current.sitePublishingPreferences?.footerSettings ?? {});
|
|
342
343
|
if (footerChanged && liveFooterDraftHash !== undefined && liveFooterDraftHash !== manifest.footer?.expectedDraftHash) {
|
|
343
|
-
problems
|
|
344
|
+
appendAll(problems, problemsOf(new SiteAuthoringError(
|
|
344
345
|
"footer.concurrent_modification",
|
|
345
346
|
"The footer changed on the site after this workspace was pulled, so footer push would be refused. Pull, "
|
|
346
347
|
+ "reconcile the footer document, and plan again.",
|
|
@@ -352,12 +353,12 @@ async function preflight(session, invocation) {
|
|
|
352
353
|
const unheld = (imageIds) => imageIds.filter((imageId) => imageStates.get(imageId) !== IMAGE_PROCESSING_STATE_COMPLETE);
|
|
353
354
|
if (theme?.changed === true) {
|
|
354
355
|
for (const imageId of unheld(appearanceImages)) {
|
|
355
|
-
problems
|
|
356
|
+
appendAll(problems, problemsOf(settingsImageMissing(imageId, "the appearance settings"), { area: CHECK_AREA.presentation }));
|
|
356
357
|
}
|
|
357
358
|
}
|
|
358
359
|
if (footerChanged) {
|
|
359
360
|
for (const imageId of unheld(footerImages)) {
|
|
360
|
-
problems
|
|
361
|
+
appendAll(problems, problemsOf(settingsImageMissing(imageId, "the footer"), {
|
|
361
362
|
area: CHECK_AREA.footer,
|
|
362
363
|
file: FOOTER_SETTINGS_FILE,
|
|
363
364
|
}));
|
|
@@ -395,7 +396,7 @@ async function preflight(session, invocation) {
|
|
|
395
396
|
if (requireNavigationBaseline(manifest) !== live.revision) throw navigationMovedRefusal();
|
|
396
397
|
} catch (error) {
|
|
397
398
|
if (!(error instanceof SiteAuthoringError)) throw error;
|
|
398
|
-
problems
|
|
399
|
+
appendAll(problems, problemsOf(error, { area: CHECK_AREA.navigation, file: NAVIGATION_FILE_NAME }));
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
}
|
|
@@ -438,7 +439,11 @@ async function preflight(session, invocation) {
|
|
|
438
439
|
footer: [footerChanged, workspaceFooter === undefined ? "" : computeFooterContentHash(workspaceFooter), liveFooterDraftHash ?? ""],
|
|
439
440
|
theme: theme === undefined ? [] : [theme.changeSetHash, theme.current.revision],
|
|
440
441
|
navigation: [stableJson(offline.navigation?.navItems ?? null), stableJson(liveNavigation ?? null)],
|
|
441
|
-
problems:
|
|
442
|
+
problems: [
|
|
443
|
+
...problems.map((problem) => [problem.area ?? "", problem.file ?? "", problem.code, problem.field ?? ""]),
|
|
444
|
+
omittedProblemDigest(problems),
|
|
445
|
+
problemTotal(problems),
|
|
446
|
+
],
|
|
442
447
|
}), "utf8").digest("hex")}`;
|
|
443
448
|
return {
|
|
444
449
|
steps,
|
|
@@ -487,12 +492,13 @@ function planReport(planned) {
|
|
|
487
492
|
// The problems get whatever the rest of the report leaves of the result's
|
|
488
493
|
// bound, so a long plan still serializes.
|
|
489
494
|
const rest = Buffer.byteLength(JSON.stringify(report), "utf8");
|
|
495
|
+
const total = problemTotal(problems);
|
|
490
496
|
const shown = problemsWithinBudget(problems, LIMITS.githubOutputBytes - RESULT_ENVELOPE_BYTES - rest);
|
|
491
497
|
return {
|
|
492
498
|
...report,
|
|
493
499
|
problems: shown,
|
|
494
|
-
problemCount:
|
|
495
|
-
...(shown.length <
|
|
500
|
+
problemCount: total,
|
|
501
|
+
...(shown.length < total ? { problemsTruncated: true } : {}),
|
|
496
502
|
};
|
|
497
503
|
}
|
|
498
504
|
|
|
@@ -504,7 +510,7 @@ export async function plan(invocation) {
|
|
|
504
510
|
session.onProgress(
|
|
505
511
|
report.ready
|
|
506
512
|
? `Ready: run 'taproot-site apply --plan ${report.planHash}' to send it. Nothing was written.`
|
|
507
|
-
: `${planned.problems
|
|
513
|
+
: `${problemTotal(planned.problems)} problem(s) block the plan; fix them and plan again. Nothing was written.`,
|
|
508
514
|
);
|
|
509
515
|
return successResult(VERB_PLAN, session.siteId, report);
|
|
510
516
|
}
|
|
@@ -549,12 +555,14 @@ export async function apply(invocation) {
|
|
|
549
555
|
onProgress("Re-planning to confirm the workspace and the site still match the plan.");
|
|
550
556
|
const planned = await recordedPlan(session, invocation);
|
|
551
557
|
if (planned.planHash !== invocation.planHash) {
|
|
552
|
-
|
|
558
|
+
const stale = new SiteAuthoringError(
|
|
553
559
|
"apply.plan_stale",
|
|
554
560
|
"The workspace or the site changed since that plan was made, so nothing was applied. Run 'taproot-site plan' "
|
|
555
561
|
+ "again, read it, and apply the new planHash.",
|
|
556
562
|
{ field: "planHash", alternatives: [planned.planHash] },
|
|
557
|
-
)
|
|
563
|
+
);
|
|
564
|
+
withFullProblems(stale, planned.problems);
|
|
565
|
+
throw stale;
|
|
558
566
|
}
|
|
559
567
|
if (planned.problems.length > 0) throw problemsError(planned.problems, "apply sent nothing; the plan has problems");
|
|
560
568
|
|