@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/authors.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import { createSiteAuthor, listSiteAuthors, withRefusalGuidance } from "../api.js";
|
|
1
|
+
import { createSiteAuthor, listSiteAuthors, updateSiteAuthor, withRefusalGuidance } from "../api.js";
|
|
2
2
|
import {
|
|
3
3
|
AUTHOR_DISPLAY_NAME_MAXIMUM_LENGTH,
|
|
4
4
|
AUTHOR_HANDLE_MAXIMUM_LENGTH,
|
|
5
5
|
AUTHORS_FILE_NAME,
|
|
6
|
+
differingAuthorValues,
|
|
6
7
|
normalizeAuthorEmail,
|
|
7
8
|
normalizeAuthorHandle,
|
|
8
9
|
projectAuthorsForWorkspace,
|
|
10
|
+
requireConsistentAuthorOptions,
|
|
9
11
|
} from "../authors-contract.js";
|
|
10
|
-
import { VERB_AUTHORS_ADD, VERB_AUTHORS_LIST } from "../constants.js";
|
|
11
|
-
import { sanitizeDiagnostic, SiteAuthoringError } from "../errors.js";
|
|
12
|
-
import { boundedList, openSession, successResult } from "../session.js";
|
|
12
|
+
import { VERB_AUTHORS_ADD, VERB_AUTHORS_LIST, VERB_AUTHORS_SET } from "../constants.js";
|
|
13
|
+
import { isCanonicalUuid, sanitizeDiagnostic, SiteAuthoringError } from "../errors.js";
|
|
14
|
+
import { boundedList, openSession, resolveSiteSession, successResult } from "../session.js";
|
|
15
|
+
import { trimSocialLinkInput } from "../social-link-url.js";
|
|
13
16
|
import { ApiError } from "../transport.js";
|
|
14
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
ensureWorkspaceRoot,
|
|
19
|
+
mediaReferenceCandidates,
|
|
20
|
+
normalizePagePath,
|
|
21
|
+
readManifest,
|
|
22
|
+
readMediaManifest,
|
|
23
|
+
writeWorkspaceJson,
|
|
24
|
+
} from "../workspace.js";
|
|
15
25
|
|
|
16
26
|
const MAXIMUM_REPORTED = 200;
|
|
17
27
|
|
|
@@ -57,58 +67,154 @@ export async function authorsList(invocation) {
|
|
|
57
67
|
});
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
/** The name readers see, trimmed, or a usage refusal. */
|
|
71
|
+
function requireDisplayName(value) {
|
|
72
|
+
const displayName = typeof value === "string" ? value.trim() : "";
|
|
73
|
+
if (displayName === "" || [...displayName].length > AUTHOR_DISPLAY_NAME_MAXIMUM_LENGTH) {
|
|
74
|
+
throw new SiteAuthoringError(
|
|
75
|
+
"authors.name_invalid",
|
|
76
|
+
`--name must be the name readers see, 1 to ${AUTHOR_DISPLAY_NAME_MAXIMUM_LENGTH} characters.`,
|
|
77
|
+
{ field: "name", exitCode: 2 },
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return displayName;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function requireHandle(value) {
|
|
84
|
+
const handle = normalizeAuthorHandle(value);
|
|
66
85
|
if (handle === undefined) {
|
|
67
86
|
throw new SiteAuthoringError(
|
|
68
87
|
"authors.handle_invalid",
|
|
69
|
-
`'${String(
|
|
88
|
+
`'${String(value ?? "").slice(0, 80)}' is not a handle. Use lowercase letters and digits `
|
|
70
89
|
+ `with single hyphens between them, at most ${AUTHOR_HANDLE_MAXIMUM_LENGTH} characters, such as jane-doe.`,
|
|
71
90
|
{ field: "handle", exitCode: 2 },
|
|
72
91
|
);
|
|
73
92
|
}
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
return handle;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function requireEmail(value) {
|
|
97
|
+
const email = normalizeAuthorEmail(value);
|
|
98
|
+
if (email === undefined) {
|
|
99
|
+
throw new SiteAuthoringError("authors.email_invalid", "--email must be an email address.", {
|
|
100
|
+
field: "email",
|
|
101
|
+
exitCode: 2,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return email;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The byline link and image the options name, as the ids and address the site
|
|
109
|
+
* takes. A page or image given by path is looked up in the workspace's
|
|
110
|
+
* manifests, so a path the workspace does not know is refused before any
|
|
111
|
+
* request (TR01401). An id is passed on, and the site decides whether it is
|
|
112
|
+
* this site's.
|
|
113
|
+
*/
|
|
114
|
+
async function resolveBylineOptions(invocation, config, siteId) {
|
|
115
|
+
const resolved = {};
|
|
116
|
+
if (invocation.authorLinkUrl !== undefined) {
|
|
117
|
+
// The site stores the address trimmed, so it is sent and compared that way. A blank one names no
|
|
118
|
+
// address, and sending it would read as clearing the link.
|
|
119
|
+
const linkUrl = trimSocialLinkInput(invocation.authorLinkUrl);
|
|
120
|
+
if (linkUrl === "") {
|
|
121
|
+
throw new SiteAuthoringError(
|
|
122
|
+
"authors.link_url_invalid",
|
|
123
|
+
"--link-url needs an absolute http or https address. Use --no-link to remove the link.",
|
|
124
|
+
{ field: "link-url", exitCode: 2 },
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
resolved.linkUrl = linkUrl;
|
|
128
|
+
}
|
|
129
|
+
if (invocation.authorLinkPage !== undefined) {
|
|
130
|
+
resolved.linkPageResourceId = await resolvePageResourceId(config, siteId, invocation.authorLinkPage);
|
|
131
|
+
}
|
|
132
|
+
if (invocation.authorImage !== undefined) {
|
|
133
|
+
resolved.imageId = await resolveImageId(config, siteId, invocation.authorImage);
|
|
134
|
+
}
|
|
135
|
+
return resolved;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function resolvePageResourceId(config, siteId, reference) {
|
|
139
|
+
if (isCanonicalUuid(reference)) return reference;
|
|
140
|
+
const wanted = normalizePagePath(reference);
|
|
141
|
+
const manifest = await readManifest(config.workspaceDir, siteId, { required: false });
|
|
142
|
+
const entry = wanted === undefined
|
|
143
|
+
? undefined
|
|
144
|
+
: manifest?.pages.find((page) => page !== null && normalizePagePath(page.path) === wanted);
|
|
145
|
+
if (typeof entry?.resourceId !== "string" || !isCanonicalUuid(entry.resourceId)) {
|
|
76
146
|
throw new SiteAuthoringError(
|
|
77
|
-
"authors.
|
|
78
|
-
`--
|
|
79
|
-
|
|
147
|
+
"authors.link_page_unknown",
|
|
148
|
+
`--link-page '${reference.slice(0, 80)}' is not a page the workspace's manifest records. Give the page's `
|
|
149
|
+
+ "path as 'pull' recorded it ('/' for the home page), or its resourceId.",
|
|
150
|
+
{ field: "link-page", exitCode: 2 },
|
|
80
151
|
);
|
|
81
152
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
153
|
+
return entry.resourceId;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function resolveImageId(config, siteId, reference) {
|
|
157
|
+
if (isCanonicalUuid(reference)) return reference;
|
|
158
|
+
const { media } = await readMediaManifest(config.workspaceDir, siteId);
|
|
159
|
+
for (const candidate of mediaReferenceCandidates(reference)) {
|
|
160
|
+
const imageId = media[candidate]?.imageId;
|
|
161
|
+
if (isCanonicalUuid(imageId)) return imageId;
|
|
91
162
|
}
|
|
163
|
+
throw new SiteAuthoringError(
|
|
164
|
+
"authors.image_unknown",
|
|
165
|
+
`--image '${reference.slice(0, 80)}' is not an image the workspace's media manifest records. Run 'media upload' `
|
|
166
|
+
+ "for the file first, or give the image's id.",
|
|
167
|
+
{ field: "image", exitCode: 2 },
|
|
168
|
+
);
|
|
169
|
+
}
|
|
92
170
|
|
|
93
|
-
|
|
171
|
+
/** How an author reads in a result and a progress line: only what it has. */
|
|
172
|
+
function authorResult(author) {
|
|
173
|
+
const { handle, displayName, hasEmail, linkPageResourceId, linkUrl, imageId } = author;
|
|
174
|
+
return {
|
|
175
|
+
handle,
|
|
176
|
+
displayName,
|
|
177
|
+
hasEmail,
|
|
178
|
+
...(linkPageResourceId === undefined ? {} : { linkPageResourceId }),
|
|
179
|
+
...(linkUrl === undefined ? {} : { linkUrl }),
|
|
180
|
+
...(imageId === undefined ? {} : { imageId }),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* `authors add` — creates a site author, someone a page can be credited to who
|
|
186
|
+
* has no Taproot account, such as one of an imported blog's authors. The
|
|
187
|
+
* author may carry a byline link and an image (TR01401).
|
|
188
|
+
*/
|
|
189
|
+
export async function authorsAdd(invocation) {
|
|
190
|
+
const handle = requireHandle(invocation.authorHandle);
|
|
191
|
+
const displayName = requireDisplayName(invocation.authorName);
|
|
192
|
+
const email = invocation.authorEmail === undefined ? undefined : requireEmail(invocation.authorEmail);
|
|
193
|
+
requireConsistentAuthorOptions(invocation, { set: false });
|
|
194
|
+
|
|
195
|
+
const session = await resolveSiteSession(invocation);
|
|
196
|
+
const byline = await resolveBylineOptions(invocation, session.config, session.siteId);
|
|
197
|
+
const { client, config, siteId, onProgress } = await session.open();
|
|
94
198
|
// A handle that is already taken by the same person is a repeat of this
|
|
95
199
|
// command, not a mistake: a script that adds its authors again succeeds.
|
|
96
200
|
let existing = false;
|
|
97
201
|
let known;
|
|
98
202
|
const created = await withRefusalGuidance(onProgress, "authors add", async () => {
|
|
99
203
|
try {
|
|
100
|
-
return await createSiteAuthor(client, siteId, { handle, displayName, email });
|
|
204
|
+
return await createSiteAuthor(client, siteId, { handle, displayName, email, ...byline });
|
|
101
205
|
} catch (error) {
|
|
102
206
|
const refusal = translateAuthorsRefusal(error, handle);
|
|
103
207
|
if (refusal?.code !== "authors.handle_taken") throw refusal;
|
|
104
208
|
known = await listSiteAuthors(client, siteId);
|
|
105
209
|
const held = known.authors.find((author) => author.handle === handle);
|
|
106
210
|
if (held === undefined) throw refusal;
|
|
107
|
-
|
|
211
|
+
const differs = differingAuthorValues(held, { displayName, ...byline });
|
|
212
|
+
if (differs.length > 0) {
|
|
108
213
|
throw new SiteAuthoringError(
|
|
109
214
|
"authors.handle_taken",
|
|
110
|
-
`A site author with the handle '${handle}' already exists
|
|
111
|
-
+ `'${displayName}'. Use another handle,
|
|
215
|
+
`A site author with the handle '${handle}' already exists and differs in its ${differs.join(" and ")}: `
|
|
216
|
+
+ `it is named '${held.displayName}'. Use another handle, the existing author, or `
|
|
217
|
+
+ `'authors set ${handle}' to change it.`,
|
|
112
218
|
{ field: "handle" },
|
|
113
219
|
);
|
|
114
220
|
}
|
|
@@ -133,7 +239,7 @@ export async function authorsAdd(invocation) {
|
|
|
133
239
|
onProgress(`The author was created, but ${AUTHORS_FILE_NAME} could not be refreshed: run 'authors list'.`);
|
|
134
240
|
}
|
|
135
241
|
return successResult(VERB_AUTHORS_ADD, siteId, {
|
|
136
|
-
author:
|
|
242
|
+
author: authorResult(created),
|
|
137
243
|
existing,
|
|
138
244
|
...(refreshed ? { authorsFile: AUTHORS_FILE_NAME } : {}),
|
|
139
245
|
nextStep: `Credit pages with 'author: ${created.handle}' in a page's front matter or `
|
|
@@ -141,12 +247,66 @@ export async function authorsAdd(invocation) {
|
|
|
141
247
|
});
|
|
142
248
|
}
|
|
143
249
|
|
|
250
|
+
/**
|
|
251
|
+
* `authors set` — changes a site author's name, private email, byline link or
|
|
252
|
+
* image. Only what was passed is sent, so the rest keeps its stored value.
|
|
253
|
+
* A change to the byline of an author on published pages queues a deployment
|
|
254
|
+
* (TR01401).
|
|
255
|
+
*/
|
|
256
|
+
export async function authorsSet(invocation) {
|
|
257
|
+
const handle = requireHandle(invocation.authorHandle);
|
|
258
|
+
requireConsistentAuthorOptions(invocation, { set: true });
|
|
259
|
+
const displayName = invocation.authorName === undefined ? undefined : requireDisplayName(invocation.authorName);
|
|
260
|
+
const email = invocation.authorEmail === undefined ? undefined : requireEmail(invocation.authorEmail);
|
|
261
|
+
|
|
262
|
+
const session = await resolveSiteSession(invocation);
|
|
263
|
+
const byline = await resolveBylineOptions(invocation, session.config, session.siteId);
|
|
264
|
+
const { client, config, siteId, onProgress } = await session.open();
|
|
265
|
+
const changes = {
|
|
266
|
+
...(displayName === undefined ? {} : { displayName }),
|
|
267
|
+
...(email === undefined ? {} : { email }),
|
|
268
|
+
...(invocation.authorNoEmail ? { email: "" } : {}),
|
|
269
|
+
...byline,
|
|
270
|
+
...(invocation.authorNoLink ? { linkPageResourceId: "", linkUrl: "" } : {}),
|
|
271
|
+
...(invocation.authorNoImage ? { imageId: "" } : {}),
|
|
272
|
+
};
|
|
273
|
+
const author = await withRefusalGuidance(onProgress, "authors set", async () => {
|
|
274
|
+
try {
|
|
275
|
+
return await updateSiteAuthor(client, siteId, handle, changes);
|
|
276
|
+
} catch (error) {
|
|
277
|
+
if (error instanceof ApiError && error.httpStatus === 404) {
|
|
278
|
+
throw new SiteAuthoringError(
|
|
279
|
+
"authors.handle_unknown",
|
|
280
|
+
`This site has no site author with the handle '${handle}'. Run 'authors list' to see the handles, or `
|
|
281
|
+
+ "'authors add' to create one.",
|
|
282
|
+
{ field: "handle" },
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
throw translateAuthorsRefusal(error, handle);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
onProgress(`Changed site author '${author.handle}' (${author.displayName}).`);
|
|
289
|
+
|
|
290
|
+
let refreshed = false;
|
|
291
|
+
try {
|
|
292
|
+
await writeAuthorsFile(config, siteId, await listSiteAuthors(client, siteId));
|
|
293
|
+
refreshed = true;
|
|
294
|
+
} catch (error) {
|
|
295
|
+
if (!(error instanceof SiteAuthoringError)) throw error;
|
|
296
|
+
onProgress(`The author was changed, but ${AUTHORS_FILE_NAME} could not be refreshed: run 'authors list'.`);
|
|
297
|
+
}
|
|
298
|
+
return successResult(VERB_AUTHORS_SET, siteId, {
|
|
299
|
+
author: authorResult(author),
|
|
300
|
+
...(refreshed ? { authorsFile: AUTHORS_FILE_NAME } : {}),
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
144
304
|
async function writeAuthorsFile(config, siteId, listing) {
|
|
145
305
|
await ensureWorkspaceRoot(config);
|
|
146
306
|
await writeWorkspaceJson(config.workspaceDir, AUTHORS_FILE_NAME, projectAuthorsForWorkspace(siteId, listing));
|
|
147
307
|
}
|
|
148
308
|
|
|
149
|
-
/** Gives the site's refusals of a new author the stable codes the CLI documents. */
|
|
309
|
+
/** Gives the site's refusals of a new or changed author the stable codes the CLI documents. */
|
|
150
310
|
function translateAuthorsRefusal(error, handle) {
|
|
151
311
|
if (!(error instanceof ApiError)) return error;
|
|
152
312
|
for (const [field, code, fallback] of [
|
|
@@ -154,6 +314,11 @@ function translateAuthorsRefusal(error, handle) {
|
|
|
154
314
|
["Handle", "authors.handle_invalid", `'${handle}' cannot be used as a handle.`],
|
|
155
315
|
["DisplayName", "authors.name_invalid", "The name was refused."],
|
|
156
316
|
["Email", "authors.email_invalid", "The email address was refused."],
|
|
317
|
+
["Link", "authors.link_conflict", "Give a page or a web address for the byline link, not both."],
|
|
318
|
+
["LinkUrl", "authors.link_url_invalid", "The byline link must be an absolute http or https address."],
|
|
319
|
+
["LinkPageResourceId", "authors.link_page_unknown", "The byline link is not a page on this site."],
|
|
320
|
+
["ImageId", "authors.image_unknown", "The image is not in this site's media library."],
|
|
321
|
+
["Deployment", "authors.deployment_refused", "The change could not queue the deployment it needs."],
|
|
157
322
|
]) {
|
|
158
323
|
if (error.hasField(field)) {
|
|
159
324
|
return new SiteAuthoringError(
|
package/src/verbs/changelog.js
CHANGED
|
@@ -7,6 +7,19 @@ import { compareCliVersions } from "../cli-release.js";
|
|
|
7
7
|
import { CLI_UPGRADE_COMMAND, CLI_VERSION, VERB_CHANGELOG } from "../constants.js";
|
|
8
8
|
import { successResult } from "../session.js";
|
|
9
9
|
|
|
10
|
+
// The whole record outgrew the 64 KiB result bound in 0.57.0, so --since keeps
|
|
11
|
+
// the newest releases that fit this share of it and says which were left out.
|
|
12
|
+
const ENTRIES_BYTE_BUDGET = 56 * 1024;
|
|
13
|
+
|
|
14
|
+
function newestThatFit(entries) {
|
|
15
|
+
let bytes = 0;
|
|
16
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
17
|
+
bytes += Buffer.byteLength(JSON.stringify(entries[index]), "utf8");
|
|
18
|
+
if (bytes > ENTRIES_BYTE_BUDGET) return entries.slice(0, index);
|
|
19
|
+
}
|
|
20
|
+
return entries;
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
/**
|
|
11
24
|
* `changelog [--since <version>]` — what changed in each release, offline.
|
|
12
25
|
*
|
|
@@ -21,9 +34,11 @@ export async function changelog(invocation) {
|
|
|
21
34
|
const onProgress = invocation.onProgress ?? (() => {});
|
|
22
35
|
const since = invocation.since;
|
|
23
36
|
const installed = changelogEntryFor(CLI_VERSION);
|
|
24
|
-
const
|
|
37
|
+
const recorded = since === undefined
|
|
25
38
|
? installed === undefined ? [] : [installed]
|
|
26
39
|
: changelogEntriesSince(since);
|
|
40
|
+
const entries = newestThatFit(recorded);
|
|
41
|
+
const omitted = recorded.slice(entries.length);
|
|
27
42
|
const earliest = earliestRecordedVersion();
|
|
28
43
|
const startsBeforeRecord = since !== undefined && earliest !== undefined && compareCliVersions(since, earliest) < 0;
|
|
29
44
|
|
|
@@ -38,6 +53,12 @@ export async function changelog(invocation) {
|
|
|
38
53
|
if (startsBeforeRecord) {
|
|
39
54
|
notes.push(`The record starts at ${earliest}; changes before it are not listed.`);
|
|
40
55
|
}
|
|
56
|
+
if (omitted.length > 0) {
|
|
57
|
+
notes.push(
|
|
58
|
+
`Releases ${omitted.at(-1).version} to ${omitted[0].version} are left out to keep the result within its size `
|
|
59
|
+
+ "limit. They are in the installed package's src/changelog.json.",
|
|
60
|
+
);
|
|
61
|
+
}
|
|
41
62
|
|
|
42
63
|
for (const entry of entries) {
|
|
43
64
|
onProgress(`${entry.version}${entry.date === undefined ? "" : ` (${entry.date})`}: ${entry.note}`);
|
|
@@ -56,7 +77,7 @@ export async function changelog(invocation) {
|
|
|
56
77
|
behavior: [...entry.behavior],
|
|
57
78
|
help: [...entry.help],
|
|
58
79
|
})),
|
|
59
|
-
complete: !startsBeforeRecord,
|
|
80
|
+
complete: !startsBeforeRecord && omitted.length === 0,
|
|
60
81
|
...(notes.length === 0 ? {} : { notes }),
|
|
61
82
|
});
|
|
62
83
|
}
|
|
@@ -7,9 +7,11 @@ import {
|
|
|
7
7
|
mintStagingPreviewHandoff,
|
|
8
8
|
withRefusalGuidance,
|
|
9
9
|
} from "../api.js";
|
|
10
|
-
import {
|
|
10
|
+
import { boundSkippedLinks } from "../chrome-additions.js";
|
|
11
|
+
import { linkedPageEntries, unlinkedSavedPageEntries } from "../chrome-input.js";
|
|
12
|
+
import { DEPLOY_TARGET_PRODUCTION, DEPLOY_TARGET_STAGING, LIMITS, VERB_DELIVERY_CHECK } from "../constants.js";
|
|
11
13
|
import { probeDeliveryWithBrowser } from "../delivery-browser.js";
|
|
12
|
-
import { checkDelivery,
|
|
14
|
+
import { checkDelivery, selectDeliveryRoutes } from "../delivery-check.js";
|
|
13
15
|
import { SiteAuthoringError } from "../errors.js";
|
|
14
16
|
import { openSession, successResult } from "../session.js";
|
|
15
17
|
import { authorizeStagingHandoff } from "../staging-check.js";
|
|
@@ -44,17 +46,31 @@ function environmentFor(target) {
|
|
|
44
46
|
* is exactly what a delivery check on a typed-content site has to prove (TR00893).
|
|
45
47
|
*/
|
|
46
48
|
function routesToCheck(pages) {
|
|
47
|
-
const usable = pages.filter((page) => page !== null && typeof page === "object" && typeof page.path === "string");
|
|
48
49
|
const seenTemplates = new Set();
|
|
49
50
|
const firstOfTemplate = [];
|
|
50
51
|
const rest = [];
|
|
51
|
-
for (const page of
|
|
52
|
+
for (const page of linkedPageEntries(pages)) {
|
|
52
53
|
(seenTemplates.has(page.templateType) ? rest : firstOfTemplate).push(page);
|
|
53
54
|
seenTemplates.add(page.templateType);
|
|
54
55
|
}
|
|
55
|
-
return [...firstOfTemplate, ...rest].map((page) =>
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
return [...firstOfTemplate, ...rest].map((page) => (page.path === "" ? "/" : `/${page.path}/`));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const UNCHECKED_ROUTE_LIMIT = 20;
|
|
60
|
+
const UNCHECKED_ROUTE_REASON = "omitted from the authored-route sample: the workspace manifest records a status other than published or approved (a stale status may not match the deployed site); the check may still fetch the page as a link from another page";
|
|
61
|
+
// Room kept for the envelope a verb wraps around its fields.
|
|
62
|
+
const RESULT_ENVELOPE_RESERVE_BYTES = 2048;
|
|
63
|
+
|
|
64
|
+
/** Saved manifest pages the check skips, bounded like the other report lists. */
|
|
65
|
+
function uncheckedRoutes(pages) {
|
|
66
|
+
// The home page is always probed, so it is never listed as unchecked.
|
|
67
|
+
const entries = unlinkedSavedPageEntries(pages).filter(({ path }) => path !== "/");
|
|
68
|
+
return {
|
|
69
|
+
items: entries.slice(0, UNCHECKED_ROUTE_LIMIT).map(({ path }) => ({ path, reason: UNCHECKED_ROUTE_REASON })),
|
|
70
|
+
total: entries.length,
|
|
71
|
+
truncated: entries.length > UNCHECKED_ROUTE_LIMIT,
|
|
72
|
+
basis: "workspace manifest status",
|
|
73
|
+
};
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
async function resolveTarget(client, siteId, target, invocation, onProgress, now) {
|
|
@@ -141,7 +157,13 @@ export async function deliveryCheck(invocation) {
|
|
|
141
157
|
|
|
142
158
|
const resolved = await resolveTarget(client, siteId, target, invocation, onProgress, now);
|
|
143
159
|
const routes = routesToCheck(manifest?.pages ?? []);
|
|
144
|
-
|
|
160
|
+
const unchecked = uncheckedRoutes(manifest?.pages ?? []);
|
|
161
|
+
if (unchecked.total > 0) {
|
|
162
|
+
onProgress(
|
|
163
|
+
`${unchecked.total} saved page(s) the workspace manifest records as not published or approved were left out of the authored-route sample because of their manifest status (a stale status may not match the deployed site; the check may still fetch one as a link from another page), so the verdict covers the sampled routes and the checks made from them; run pull after approving pages in the app, then check again.`,
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
onProgress(`Checking ${resolved.baseUrl} (${selectDeliveryRoutes(routes).sampled.length} route(s), assets, runtime).`);
|
|
145
167
|
const report = await checkDelivery({
|
|
146
168
|
fetch: client.fetch,
|
|
147
169
|
timeoutSignal: client.timeoutSignal,
|
|
@@ -171,16 +193,18 @@ export async function deliveryCheck(invocation) {
|
|
|
171
193
|
if (browser.status === "checked" && browser.returningCache?.status !== "checked") onProgress("Browser dimension: cache reuse on the returning load could not be observed; it is unchecked.");
|
|
172
194
|
|
|
173
195
|
const verdict = report.verdict === "delivered" && browser.status === "checked" && !browser.ok ? "degraded" : report.verdict;
|
|
196
|
+
if (unchecked.total > 0) onProgress("The verdict covers the sampled routes and the checks made from them; a page left out of the sample for its manifest status can still be fetched as a link and affect it.");
|
|
174
197
|
onProgress(
|
|
175
198
|
verdict === "delivered"
|
|
176
199
|
? "Delivery verified over HTTP" + (browser.status === "checked" ? " and in a browser." : "; browser behaviour unchecked.")
|
|
177
200
|
: `Delivery ${verdict}: ${report.failures.length} HTTP finding(s)` + (browser.status === "checked" && !browser.ok ? " and a browser mismatch." : "."),
|
|
178
201
|
);
|
|
179
|
-
|
|
202
|
+
const fields = {
|
|
180
203
|
environment,
|
|
181
204
|
target: { ...report.target, resolvedFrom: resolved.source },
|
|
182
205
|
deployment,
|
|
183
206
|
verdict,
|
|
207
|
+
verdictCovers: "sampled routes and the checks made from them",
|
|
184
208
|
routes: report.routes,
|
|
185
209
|
assets: report.assets,
|
|
186
210
|
links: report.links,
|
|
@@ -200,6 +224,16 @@ export async function deliveryCheck(invocation) {
|
|
|
200
224
|
? []
|
|
201
225
|
: ["what a returning browser loads from its own cache"]),
|
|
202
226
|
],
|
|
227
|
+
};
|
|
228
|
+
// The unchecked list takes only the room the rest of the result leaves, so long paths never exceed the output bound.
|
|
229
|
+
// It is present in every report: no items and a total of 0 mean no saved page was left out for its status.
|
|
230
|
+
const room = Math.min(
|
|
231
|
+
8 * 1024,
|
|
232
|
+
LIMITS.githubOutputBytes - Buffer.byteLength(JSON.stringify(fields), "utf8") - RESULT_ENVELOPE_RESERVE_BYTES,
|
|
233
|
+
);
|
|
234
|
+
return successResult(VERB_DELIVERY_CHECK, siteId, {
|
|
235
|
+
...fields,
|
|
236
|
+
uncheckedRoutes: boundSkippedLinks(unchecked, Math.max(room, 0)),
|
|
203
237
|
});
|
|
204
238
|
});
|
|
205
239
|
}
|
package/src/verbs/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
VERB_APPROVE,
|
|
4
4
|
VERB_AUTHORS_ADD,
|
|
5
5
|
VERB_AUTHORS_LIST,
|
|
6
|
+
VERB_AUTHORS_SET,
|
|
6
7
|
VERB_DELIVERY_CHECK,
|
|
7
8
|
VERB_DEPLOY,
|
|
8
9
|
VERB_CHANGELOG,
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
VERB_WHOAMI,
|
|
48
49
|
} from "../constants.js";
|
|
49
50
|
import { approve } from "./approve.js";
|
|
50
|
-
import { authorsAdd, authorsList } from "./authors.js";
|
|
51
|
+
import { authorsAdd, authorsList, authorsSet } from "./authors.js";
|
|
51
52
|
import { changelog } from "./changelog.js";
|
|
52
53
|
import { deliveryCheck } from "./delivery-check.js";
|
|
53
54
|
import { deploy } from "./deploy.js";
|
|
@@ -137,7 +138,7 @@ import { whoami } from "./whoami.js";
|
|
|
137
138
|
* placeId, // places category clear: [placeId]
|
|
138
139
|
* pagePaths, // approve: narrow to these page paths; with none, every
|
|
139
140
|
* // draft the workspace manifest tracks is staged
|
|
140
|
-
* authorHandle, // authors add: the handle of the site author to create
|
|
141
|
+
* authorHandle, // authors add / set: the handle of the site author to create or change
|
|
141
142
|
* deletePagePath, // pages delete: the one tracked page to delete
|
|
142
143
|
* pageId, // preview page: the one persisted draft UUID to render
|
|
143
144
|
* previewIds, // preview revoke: [page UUID, snapshot UUID]
|
|
@@ -175,6 +176,7 @@ export const VERB_HANDLERS = Object.freeze({
|
|
|
175
176
|
[VERB_PAGES_DELETE]: pagesDelete,
|
|
176
177
|
[VERB_AUTHORS_LIST]: authorsList,
|
|
177
178
|
[VERB_AUTHORS_ADD]: authorsAdd,
|
|
179
|
+
[VERB_AUTHORS_SET]: authorsSet,
|
|
178
180
|
[VERB_NAV_PUSH]: navPush,
|
|
179
181
|
[VERB_PLAN]: plan,
|
|
180
182
|
[VERB_PLACES_SEARCH]: placesSearch,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { getSiteImageDescription, listSiteImageDescriptions,
|
|
1
|
+
import { getSiteImageDescription, listSiteImageDescriptions, withRefusalGuidance } from "../api.js";
|
|
2
2
|
import { VERB_MEDIA_IMAGES_DESCRIBE, VERB_MEDIA_IMAGES_GET, VERB_MEDIA_IMAGES_LIST } from "../constants.js";
|
|
3
3
|
import { SiteAuthoringError } from "../errors.js";
|
|
4
|
+
import { imageDescriptionExistsError, writeImageDescription } from "../image-description-write.js";
|
|
4
5
|
import { imageDescriptionOptions, imageListOptions, requireImageId } from "../image-description-contract.js";
|
|
5
6
|
import { serializeResult } from "../output.js";
|
|
6
7
|
import { openSession, successResult, warnIfExternalWritesPaused } from "../session.js";
|
|
@@ -47,8 +48,7 @@ export function translateImageDescriptionRefusal(error) {
|
|
|
47
48
|
{ field: "expectedRevision", status: error.status });
|
|
48
49
|
}
|
|
49
50
|
if (error instanceof ApiError && error.hasField("OnlyIfMissing")) {
|
|
50
|
-
return
|
|
51
|
-
{ field: "onlyIfMissing", status: error.status });
|
|
51
|
+
return imageDescriptionExistsError(error.status);
|
|
52
52
|
}
|
|
53
53
|
if (error instanceof ApiError && error.hasField("DefaultDescription")) {
|
|
54
54
|
return new SiteAuthoringError("media.image_description_invalid",
|
|
@@ -66,7 +66,7 @@ export async function mediaImagesDescribe(invocation) {
|
|
|
66
66
|
const { client, siteId, onProgress } = session;
|
|
67
67
|
const image = await withRefusalGuidance(onProgress, VERB_MEDIA_IMAGES_DESCRIBE, async () => {
|
|
68
68
|
try {
|
|
69
|
-
return await
|
|
69
|
+
return await writeImageDescription(client, siteId, imageId, body);
|
|
70
70
|
} catch (error) {
|
|
71
71
|
throw translateImageDescriptionRefusal(error);
|
|
72
72
|
}
|