@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.
Files changed (65) hide show
  1. package/README.md +91 -22
  2. package/package.json +2 -2
  3. package/src/api.js +90 -17
  4. package/src/authors-contract.js +71 -3
  5. package/src/block-flow.js +4 -2
  6. package/src/changelog.json +104 -0
  7. package/src/chrome-additions.js +106 -0
  8. package/src/chrome-features.js +43 -10
  9. package/src/chrome-input.js +137 -30
  10. package/src/chrome-report.js +4 -2
  11. package/src/cli.js +144 -38
  12. package/src/constants.js +1 -0
  13. package/src/content/button-styles.js +27 -0
  14. package/src/content/components.js +76 -10
  15. package/src/content/free-form-section-registry.json +9 -0
  16. package/src/content/free-form-sections.js +55 -16
  17. package/src/content/markdown.js +133 -56
  18. package/src/content/media-presentation.js +37 -0
  19. package/src/content/tiptap-prosemirror.ts +26 -10
  20. package/src/credentials.js +2 -1
  21. package/src/delivery-check.js +10 -2
  22. package/src/font-catalog.js +9 -6
  23. package/src/footer-content.js +1 -1
  24. package/src/footer-contract.js +3 -0
  25. package/src/footer-draft-hash.js +1 -0
  26. package/src/heading-outline.js +94 -6
  27. package/src/image-description-contract.js +5 -3
  28. package/src/image-description-write.js +26 -0
  29. package/src/index.js +1 -0
  30. package/src/output.js +2 -1
  31. package/src/page-metadata.js +15 -13
  32. package/src/page-structure-checks.js +14 -25
  33. package/src/placed-image-ids.js +42 -17
  34. package/src/presentation-reference.js +63 -18
  35. package/src/problems.js +147 -4
  36. package/src/reference-help.js +122 -60
  37. package/src/site-check-findings.js +2 -3
  38. package/src/site-check-rules.json +0 -1
  39. package/src/site-health-findings.js +7 -9
  40. package/src/site-health-image-checks.js +4 -1
  41. package/src/site-health-precheck.js +23 -6
  42. package/src/site-navigation-groups.js +16 -0
  43. package/src/status-warning-paints.js +175 -0
  44. package/src/template-token-reach.json +13 -18
  45. package/src/theme-proposals.js +143 -55
  46. package/src/theme-resolve.js +14 -1
  47. package/src/theme-validation.js +70 -38
  48. package/src/token-reach.js +20 -0
  49. package/src/typed-page-reference.js +25 -3
  50. package/src/typed-pages.js +73 -14
  51. package/src/verbs/authors.js +198 -33
  52. package/src/verbs/changelog.js +23 -2
  53. package/src/verbs/delivery-check.js +43 -9
  54. package/src/verbs/index.js +4 -2
  55. package/src/verbs/media-images.js +4 -4
  56. package/src/verbs/pages-push.js +138 -67
  57. package/src/verbs/plan.js +28 -20
  58. package/src/verbs/pull.js +226 -26
  59. package/src/verbs/theme-push.js +59 -15
  60. package/src/verbs/theme-resolve.js +109 -11
  61. package/src/verbs/validate.js +97 -16
  62. package/src/workspace-check.js +4 -4
  63. package/src/workspace-context-usage.js +180 -0
  64. package/src/workspace.js +48 -1
  65. package/test/fixtures/default-site-theme.json +1 -1
package/src/cli.js CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  VERB_APPROVE,
24
24
  VERB_AUTHORS_ADD,
25
25
  VERB_AUTHORS_LIST,
26
+ VERB_AUTHORS_SET,
26
27
  VERB_DELIVERY_CHECK,
27
28
  VERB_DEPLOY,
28
29
  VERB_STAGING_REVIEW,
@@ -83,6 +84,7 @@ import {
83
84
  getDesignBlueprint,
84
85
  getFooterReference,
85
86
  getPageTypeReference,
87
+ getSectionsReference,
86
88
  getSettingsReference,
87
89
  getThemeReference,
88
90
  getTokenReference,
@@ -90,6 +92,7 @@ import {
90
92
  listComponentTypeReferences,
91
93
  listDesignBlueprints,
92
94
  listPageTypeReferences,
95
+ PAGE_SOURCE_CONFLICT_RULE,
93
96
  DESIGN_TYPES,
94
97
  PAGE_TYPES,
95
98
  REFERENCE_TOPICS,
@@ -148,18 +151,31 @@ const VERBS = Object.freeze([
148
151
  "With no directory, checks the pulled workspace taproot-site.json names; with one, checks that directory, which "
149
152
  + "is either an offline fixture (manifest.fixture.json) or a pulled workspace. Every page source, the theme, "
150
153
  + "appearance, header, brand, footer, navigation, redirects, and forms are checked with the validators the "
151
- + "pushes use, and every problem is reported at once in error.problems (each with its file, code, and field) "
152
- + "rather than one per run. A pulled workspace is checked offline against the pages (generated ones included, "
154
+ + "pushes use, and the refusing validators' findings are reported at once in error.problems (each with its code and "
155
+ + "optional field, a file for most findings, and a line for a Markdown page when the problem has a source line) rather than one per run: "
156
+ + "every problem in a .pm.json page, and every section decoration, background and section-owned image problem "
157
+ + "in a free-form Markdown page. An ordinary .pm.json document finding carries a "
158
+ + "file-qualified field (pages/post.pm.json:data.body), so read the source path from field; a refusal that merges "
159
+ + "several files' problems also adds file, and drops field when it only repeats file. A .pm.json recipe step finding "
160
+ + "is the other shape: it carries file plus a document-relative field. Any other Markdown problem "
161
+ + "stops that file at its first, and so does a decoration or background problem in a typed page such as an "
162
+ + "article; recipe steps report all of theirs. The JSON keeps the problems that fit its size budget and reports "
163
+ + "problemCount and problemsTruncated, error.problems holds at most 5,000, and stderr lists the problems kept. "
164
+ + "A pulled workspace is checked offline against the pages (generated ones included, "
153
165
  + "so navigation to a folder index resolves), images, and baselines its manifests recorded at the pull. "
154
166
  + "A link whose address is only http(s):// plus its own text (left by older editor autolinking) is reported in "
155
167
  + "linkWarnings without refusing; pages push reports the same for the pages it sends. "
156
168
  + "The site checks that can run offline are reported in findings (a rule id, severity, file, and the value "
157
169
  + "found, such as link.page_missing for a link to a page the workspace does not have) and never refuse a "
158
170
  + "warning. For a free-form page they include the page-structure rules: seo.h1_missing when no heading, banner "
159
- + "title or hero title is the page's h1, seo.h1_demoted when a # heading is published as an h2 because the "
171
+ + "title or hero title is the page's h1, seo.h1_demoted when a # heading or a hero title is published as an h2 because the "
160
172
  + "banner's overlay text, a hero title or an earlier # heading already is the h1 (detail names which), "
161
173
  + "seo.heading_renumbered and seo.heading_before_title for headings published at another level, "
162
- + "a11y.link_text_empty. Image-default completeness (a11y.image_default_missing) needs the site's own image "
174
+ + "a11y.link_text_empty. validate cannot see an integration placement's rendered h1, because a placement carries no "
175
+ + "HTML in the document: an earlier placement can make a level-1 heading (a Markdown page has no placement syntax) "
176
+ + "or a hero title render as an h2 without an seo.h1_demoted finding, and a page whose only h1 comes from a "
177
+ + "placement can still receive seo.h1_missing, so check the published page for those. Adopted fragments are "
178
+ + "different: their stored HTML is visible to validate and can trigger seo.h1_demoted. Image-default completeness (a11y.image_default_missing) needs the site's own image "
163
179
  + "records, so plain validate lists it in siteChecks.skipped with imageCheckReason; validate --site reads those "
164
180
  + "records and reports each undescribed image the workspace places in imageFindings, with the exact 'media images "
165
181
  + "describe' command for its fix (notInSiteLibrary lists placed ids that are not in the site's library: deleted, another site's, or owned media such as a copied video poster, on which no description can be set). Placement alt strings "
@@ -197,7 +213,8 @@ const VERBS = Object.freeze([
197
213
  + "The issued sign-in is written to credentials.json under $XDG_CONFIG_HOME/taproot-site/ (falling back to "
198
214
  + "~/.config/taproot-site/), directory 0700 and file 0600, one per API origin, replacing any sign-in already "
199
215
  + "stored for that origin. The secret itself is never displayed, logged, or placed in the JSON result: the "
200
- + "result names the credential by id and display prefix only. "
216
+ + "result names the credential by id and display prefix only. The display prefix is tr_live_ for production Taproot "
217
+ + "and tr_test_ for any other Taproot, so a tr_test_ credential can never act on production. "
201
218
  + "The sign-in authorizes nothing on any site — it lists the account's sites and exchanges itself for "
202
219
  + "short-lived site credentials. It expires after 24 hours without a successful exchange, and any "
203
220
  + "expiry the approver chose bounds that: using the CLI keeps it alive, but never past their date. "
@@ -237,9 +254,14 @@ const VERBS = Object.freeze([
237
254
  configFree: true,
238
255
  positionals: "siteSelector",
239
256
  note: "Accepts a site id, an exact name, or an unambiguous case-insensitive name, and records the choice as "
240
- + "siteId in taproot-site.json — creating that file in the current directory when there is not one yet — "
241
- + "together with the site's authoringSurface, which is what lets a later verb refuse offline when the site "
242
- + "cannot take it. Two sites sharing a name is refused rather than guessed: pass the site id instead.",
257
+ + "siteId in the taproot-site.json found in this or a parent directory, keeping its workspaceDir; it creates "
258
+ + "one in the current directory only when none is found. It also records "
259
+ + "the site's authoringSurface, which is what lets a later verb refuse offline when the site "
260
+ + "cannot take it. Two sites sharing a name is refused rather than guessed: pass the site id instead. "
261
+ + "A leading --config <path> chooses the file to rewrite instead: use rewrites that file, keeping its workspaceDir, "
262
+ + "and the file must already exist (config.not_found otherwise); it never creates one there. When the parent "
263
+ + "chain holds more than one taproot-site.json, discovery refuses with config.ambiguous, and a leading "
264
+ + "--config <path> chooses the intended one.",
243
265
  },
244
266
  {
245
267
  name: VERB_WHOAMI,
@@ -254,7 +276,8 @@ const VERBS = Object.freeze([
254
276
  note: "Answers entirely from local state — the stored sign-in and the configuration — so it still works when the "
255
277
  + `network or the credential does not. Reports whether ${PUBLISH_KEY_ENVIRONMENT_VARIABLE} is set, but never `
256
278
  + "its value. The sign-in secret is never printed; the credential is named by id and display prefix, which are "
257
- + "what an owner needs to revoke it.",
279
+ + "what an owner needs to revoke it. The display prefix is tr_live_ for production Taproot and tr_test_ for any "
280
+ + "other Taproot.",
258
281
  },
259
282
  {
260
283
  name: VERB_CHANGELOG,
@@ -299,7 +322,10 @@ const VERBS = Object.freeze([
299
322
  note: "Every page path keeps exactly one authoritative source. A page whose manifest entry names a source that is "
300
323
  + "still on disk keeps that file, so pull never writes a '.pm.json' beside a tracked '.md'. "
301
324
  + "For a page tracked as Markdown the site's own document is kept as internal state under "
302
- + "'.taproot-site-state/' instead; it is never a page source and is never pushed. "
325
+ + "'.taproot-site-state/' instead; it is never a page source and is never pushed, and you can ignore that "
326
+ + "folder in version control. "
327
+ + "A manifest entry that was never saved (no pageId) and whose source is still on disk is kept, not dropped; "
328
+ + "the result lists these as keptPendingPages, and 'pages push' creates them. "
303
329
  + "To change a page's source format, remove the tracked source and author the other format beside it — two "
304
330
  + "editable sources for one path is a refusal, not a guess. "
305
331
  + "Markdown is deliberately one-way, so a page edited on the site since the last pull cannot be rewritten as "
@@ -397,10 +423,47 @@ const VERBS = Object.freeze([
397
423
  summary: "Create a site author, someone a page can be credited to who has no Taproot account.",
398
424
  note: "Give the handle (lowercase letters, digits and single hyphens, at most 64 characters; it never changes) "
399
425
  + "and --name, the name readers see on the byline. --email is optional: it is kept private, never published, "
400
- + "and lets the person be linked to a Taproot account later. Then credit pages to the author with "
426
+ + "and lets the person be linked to a Taproot account later. --link-page <site path or resourceId> or "
427
+ + "--link-url <address> gives the byline a link, one or the other (authors.link_conflict): a page is named by "
428
+ + "the path .taproot-site-manifest.json records for it ('/' for the home page) and a web address is an "
429
+ + "absolute http or https address. --image <media path or image id> shows an image from the site's media "
430
+ + "library beside the byline; a path is resolved through .taproot-site-media.json. A page path or media path "
431
+ + "the workspace does not record is refused before any request (authors.link_page_unknown, "
432
+ + "authors.image_unknown); the site refuses an address it cannot link (authors.link_url_invalid) and an id "
433
+ + "that is not this site's page or image (the same codes). Then credit pages to the author with "
401
434
  + "'author: <handle>' in a page's front matter or 'pages meta set <path> --author <handle>'. A handle the site "
402
435
  + "already has under another name is refused (authors.handle_taken); under the same name it succeeds with "
403
- + "existing: true. authors.json is updated with the new author.",
436
+ + "existing: true. A link or image is compared only when its option was passed, so repeating a command after "
437
+ + "someone added a link still succeeds; a passed value that differs is refused with authors.handle_taken and "
438
+ + "points at 'authors set'. Site authors have no Taproot account or follow button. "
439
+ + "authors.json is updated with the new author.",
440
+ },
441
+ {
442
+ name: VERB_AUTHORS_SET,
443
+ surface: SURFACE_STANDARD,
444
+ // A change to the name, link or image of an author on published pages
445
+ // queues a deployment, so a content-only credential would always be
446
+ // refused there. One static declaration per verb: an email-only change
447
+ // asks for both too (TR01401).
448
+ capabilities: [CAPABILITY_CONTENT, CAPABILITY_DEPLOYMENTS],
449
+ tokens: ["authors", "set"],
450
+ positionals: "authorHandle",
451
+ authorOptions: true,
452
+ authorSet: true,
453
+ summary: "Change a site author's name, private email, byline link or image.",
454
+ note: "Names one site author by handle and sends only the options given; everything else keeps its stored value. "
455
+ + "--name changes the name readers see and --email the private address (--no-email removes it). --link-page "
456
+ + "<site path or resourceId> or --link-url <address> sets the byline link, replacing the other kind; --no-link "
457
+ + "removes it. --image <media path or image id> sets the image from the site's media library and --no-image "
458
+ + "removes it. With no option the command is refused (authors.set_empty), as are options that contradict each "
459
+ + "other (authors.link_conflict for --link-page with --link-url or --no-link with either, "
460
+ + "authors.image_conflict for --image with --no-image, authors.email_conflict for --email with --no-email), "
461
+ + "before any request. A page or media path the workspace does not record is authors.link_page_unknown or "
462
+ + "authors.image_unknown, and the site refuses an unusable address (authors.link_url_invalid) or id the same "
463
+ + "way. A handle the site does not have is authors.handle_unknown. Changing the name, link or image of an "
464
+ + "author who appears on published pages queues one production deployment, so the credential needs the "
465
+ + "deployments capability and the account must be allowed to deploy; otherwise the change is refused with "
466
+ + "authors.deployment_refused, or while a deployment is running. authors.json is refreshed.",
404
467
  },
405
468
  {
406
469
  name: VERB_PAGES_PUSH,
@@ -433,8 +496,10 @@ const VERBS = Object.freeze([
433
496
  + "saved, with completedWrites naming what was written; throttling or a denied write stops further writes and "
434
497
  + "exits 0. Once images are set, nextStep is approve while any selected page holds a draft and deploy --staging "
435
498
  + "otherwise. "
499
+ + "Repeating the author a page already has sends no author update. "
436
500
  + "A page is created without an author unless its source names one ('author:' in the front matter, or 'pages "
437
- + "meta set --author'); the pages created that way are listed in pages.authorless with how to credit them. "
501
+ + "meta set --author'); the pages created that way are listed in pages.authorless with how to credit them, except one whose "
502
+ + "typed source names a displayAuthor (a site author's handle the byline shows instead of the member). "
438
503
  + "The homepage is recorded with an empty path, so address it as '/'. "
439
504
  + "A selected path resolves to its one authoritative source from metadata alone, and that page is then validated "
440
505
  + "exactly as a whole push would validate it — site binding, manifest integrity, live create-or-update "
@@ -805,11 +870,11 @@ const VERBS = Object.freeze([
805
870
  capabilities: [CAPABILITY_CONTENT],
806
871
  surfaceCapabilities: { [SURFACE_DOCS_PRESENTATION]: [CAPABILITY_DESIGN] },
807
872
  tokens: ["media", "images", "describe"],
808
- summary: "Save or clear an image-owned default with its expected revision.",
873
+ summary: "Save or clear an image-owned default, fenced by its revision.",
809
874
  positionals: "imageId",
810
875
  imageDescriptionOptions: true,
811
876
  json: true,
812
- note: "Supply exactly one of --description and --clear, plus --expected-revision from list/get. "
877
+ note: "Supply exactly one of --description and --clear, plus --expected-revision from list/get, or --if-missing alone to write at the revision the CLI reads. "
813
878
  + "Text is outer-trimmed and limited by the server to 1000 Unicode scalar values; blank text clears to null. "
814
879
  + "--if-missing is checked atomically on the server and cannot clear. A conflict never retries or overwrites another edit. "
815
880
  + "This changes the reusable image default, never a page-body override. Existing published output changes only after deployment.",
@@ -863,6 +928,13 @@ const VERBS = Object.freeze([
863
928
  + "the staged release stored and returns it as siteHealth, the object 'health --staging' returns: each warning, the ones "
864
929
  + "new since production marked newSinceProduction, with a fix. A warning never fails the deploy, and a report that cannot be "
865
930
  + "read is siteHealth with available false; fix every new warning and stage again before handing the release to the owner. "
931
+ + "The four page counts differ. deployment.pageCount is the authored pages the release publishes, the number "
932
+ + "counted against the published-pages allowance; on a Standard site it leaves out the home page, the 404 page "
933
+ + "and generated pages. deployment.pagesGenerated is the pages this deployment "
934
+ + "rendered, and is null when the server reports none (a production promotion of a staged output, a failed "
935
+ + "deployment, or an older record); null is not 0. selection.stagedPageCount is the pages selected for this "
936
+ + "deploy. readiness.pageEstimate.plannedPageCount is the pages staging would generate, the number charged "
937
+ + "against the pages-generated allowance. "
866
938
  + STAGING_REVIEW_SESSION_NOTE,
867
939
  },
868
940
  {
@@ -906,7 +978,7 @@ const VERBS = Object.freeze([
906
978
  deliveryOptions: true,
907
979
  note: "A completed deployment job is not a verified delivery. This read-only check reads the target the way a "
908
980
  + "visitor does and reports each dimension separately: the latest completed deployment for the target, HTTP "
909
- + "delivery of the authored routes (from the workspace manifest, bounded), the favicon, images, module "
981
+ + "delivery of the authored routes (the pages the workspace manifest links, bounded), the favicon, images, module "
910
982
  + "preloads and site bundle they reference, internal link targets, accidental local-only references, and the "
911
983
  + "pinned runtime (its version, entry module and capability modules), plus a browser "
912
984
  + "dimension that runs only when Playwright is installed and is reported as unchecked otherwise. --staging "
@@ -1112,8 +1184,10 @@ function verbHelp(verb) {
1112
1184
  ? " <page-path>"
1113
1185
  : verb.positionals === "metaPagePath"
1114
1186
  ? " <page-path> [--title <text>] [--description <text>] [--author <handle-or-email>]"
1187
+ : verb.positionals === "authorHandle" && verb.authorSet
1188
+ ? " <handle> [--name <display-name>] [--email <address> | --no-email] [--link-page <path> | --link-url <address> | --no-link] [--image <path> | --no-image]"
1115
1189
  : verb.positionals === "authorHandle"
1116
- ? " <handle> --name <display-name> [--email <address>]"
1190
+ ? " <handle> --name <display-name> [--email <address>] [--link-page <path> | --link-url <address>] [--image <path>]"
1117
1191
  : verb.positionals === "imageId"
1118
1192
  ? " <image-id>"
1119
1193
  : verb.positionals
@@ -1156,12 +1230,20 @@ function verbHelp(verb) {
1156
1230
  : verb.imageDescriptionOptions
1157
1231
  ? `\n --description <text> Set the shared image default; --description=<text> accepts leading hyphens.
1158
1232
  --clear Clear the default instead of supplying --description.
1159
- --expected-revision <n> Required decimal revision from list/get, including 0.
1160
- --if-missing Save only while the stored default is still null; cannot clear.`
1233
+ --expected-revision <n> Decimal revision from list/get, including 0. It counts description text changes, so a cleared description is not 0. Optional with --if-missing, which reads it.
1234
+ --if-missing Save only while the stored default has no text; cannot clear. Without --expected-revision it reads the image first.`
1161
1235
  : "";
1162
1236
  const authorOptions = verb.authorOptions
1163
- ? `\n --name <text> The name readers see on the byline (required).
1164
- --email <address> A private address, kept to link the person to an account later (optional).`
1237
+ ? `\n --name <text> The name readers see on the byline${verb.authorSet ? "" : " (required)"}.
1238
+ --email <address> A private address, kept to link the person to an account later (optional).
1239
+ --link-page <ref> Link the byline to a page: its path from the manifest ('/' for home) or its resourceId.
1240
+ --link-url <address> Link the byline to a web address (absolute http or https). Not with --link-page.
1241
+ --image <ref> Show an image from the media library: its media path or image id.${verb.authorSet
1242
+ ? `
1243
+ --no-email Remove the private address.
1244
+ --no-link Remove the byline link.
1245
+ --no-image Remove the image.`
1246
+ : ""}`
1165
1247
  : "";
1166
1248
  const jsonOption = verb.json && !verb.resolveOptions
1167
1249
  ? "\n --json Emit the stable JSON contract (operational output is always JSON)."
@@ -1296,6 +1378,24 @@ function matchVerb(arguments_) {
1296
1378
  return matched;
1297
1379
  }
1298
1380
 
1381
+ /** The `authors add` and `authors set` options and the invocation field each fills (TR01401). */
1382
+ const AUTHOR_VALUE_OPTIONS = Object.freeze({
1383
+ "--name": "authorName",
1384
+ "--email": "authorEmail",
1385
+ "--link-page": "authorLinkPage",
1386
+ "--link-url": "authorLinkUrl",
1387
+ "--image": "authorImage",
1388
+ });
1389
+ const AUTHOR_CLEAR_OPTIONS = Object.freeze({
1390
+ "--no-email": "authorNoEmail",
1391
+ "--no-link": "authorNoLink",
1392
+ "--no-image": "authorNoImage",
1393
+ });
1394
+ const AUTHOR_INVOCATION_FIELDS = Object.freeze([
1395
+ ...Object.values(AUTHOR_VALUE_OPTIONS),
1396
+ ...Object.values(AUTHOR_CLEAR_OPTIONS),
1397
+ ]);
1398
+
1299
1399
  /** The `link build` options and the invocation field each fills. */
1300
1400
  const LINK_OPTION_FIELDS = Object.freeze({
1301
1401
  "--path": "linkPath",
@@ -1375,6 +1475,7 @@ function parseReferenceArguments(arguments_) {
1375
1475
  if (
1376
1476
  (
1377
1477
  topic === "pages"
1478
+ || topic === "sections"
1378
1479
  || topic === "components"
1379
1480
  || topic === "designs"
1380
1481
  || topic === "nav"
@@ -1419,7 +1520,9 @@ function referenceResult(parsed) {
1419
1520
  case "topics":
1420
1521
  return { ...result, topic: "topics", topics: REFERENCE_TOPICS };
1421
1522
  case "pages":
1422
- return { ...result, topic: "page-types", pageTypes: listPageTypeReferences() };
1523
+ return { ...result, topic: "page-types", pageTypes: listPageTypeReferences(), sourceRule: PAGE_SOURCE_CONFLICT_RULE };
1524
+ case "sections":
1525
+ return { ...result, topic: "sections", sections: getSectionsReference() };
1423
1526
  case "components":
1424
1527
  return { ...result, topic: "component-types", components: listComponentTypeReferences() };
1425
1528
  case "designs":
@@ -1589,7 +1692,7 @@ function parseMetaOption(arguments_, index, option) {
1589
1692
  return candidate;
1590
1693
  }
1591
1694
 
1592
- /** The text after --author, --name (authors add) or --email: one printable value, bounded. */
1695
+ /** The text after --author or an `authors add` / `authors set` option: one printable value, bounded. */
1593
1696
  function parseAuthorOption(arguments_, index, option, { allowEmpty = false } = {}) {
1594
1697
  const candidate = arguments_[index + 1];
1595
1698
  if (
@@ -1729,8 +1832,7 @@ function parseArguments(arguments_) {
1729
1832
  let metaTitle;
1730
1833
  let metaDescription;
1731
1834
  let metaAuthor;
1732
- let authorName;
1733
- let authorEmail;
1835
+ const authorValues = {};
1734
1836
  const positionals = [];
1735
1837
  for (let index = 0; index < rest.length; index += 1) {
1736
1838
  const argument = rest[index];
@@ -1902,18 +2004,24 @@ function parseArguments(arguments_) {
1902
2004
  index += 1;
1903
2005
  continue;
1904
2006
  }
1905
- if (verb.authorOptions && (argument === "--name" || argument === "--email")) {
2007
+ if (verb.authorOptions && Object.hasOwn(AUTHOR_VALUE_OPTIONS, argument)) {
1906
2008
  const value = parseAuthorOption(rest, index, argument);
1907
- if (argument === "--name") {
1908
- if (authorName !== undefined) throw usageError("cli.duplicate_option", "--name may be supplied only once.");
1909
- authorName = value;
1910
- } else {
1911
- if (authorEmail !== undefined) throw usageError("cli.duplicate_option", "--email may be supplied only once.");
1912
- authorEmail = value;
2009
+ const field = AUTHOR_VALUE_OPTIONS[argument];
2010
+ if (authorValues[field] !== undefined) {
2011
+ throw usageError("cli.duplicate_option", `${argument} may be supplied only once.`);
1913
2012
  }
2013
+ authorValues[field] = value;
1914
2014
  index += 1;
1915
2015
  continue;
1916
2016
  }
2017
+ if (verb.authorSet && Object.hasOwn(AUTHOR_CLEAR_OPTIONS, argument)) {
2018
+ const field = AUTHOR_CLEAR_OPTIONS[argument];
2019
+ if (authorValues[field] !== undefined) {
2020
+ throw usageError("cli.duplicate_option", `${argument} may be supplied only once.`);
2021
+ }
2022
+ authorValues[field] = true;
2023
+ continue;
2024
+ }
1917
2025
  if (verb.keyName && argument === "--name") {
1918
2026
  if (keyName !== undefined) throw usageError("cli.duplicate_option", "--name may be supplied only once.");
1919
2027
  keyName = parseNameOption(rest, index);
@@ -2049,11 +2157,11 @@ function parseArguments(arguments_) {
2049
2157
  if (verb.imageListOptions) imageListOptions(imageValues);
2050
2158
  if (verb.imageDescriptionOptions) imageDescriptionOptions(imageValues);
2051
2159
  if (verb.positionals === "authorHandle" && positionals.length !== 1) {
2052
- throw usageError("authors.handle_missing", "authors add needs exactly one handle, such as jane-doe.", {
2160
+ throw usageError("authors.handle_missing", `${verb.name} needs exactly one handle, such as jane-doe.`, {
2053
2161
  field: "handle",
2054
2162
  });
2055
2163
  }
2056
- if (verb.authorOptions && authorName === undefined) {
2164
+ if (verb.authorOptions && !verb.authorSet && authorValues.authorName === undefined) {
2057
2165
  throw usageError("authors.name_missing", "authors add needs --name, the name readers see on the byline.", {
2058
2166
  field: "name",
2059
2167
  });
@@ -2123,8 +2231,7 @@ function parseArguments(arguments_) {
2123
2231
  ...(metaTitle === undefined ? {} : { metaTitle }),
2124
2232
  ...(metaDescription === undefined ? {} : { metaDescription }),
2125
2233
  ...(metaAuthor === undefined ? {} : { metaAuthor }),
2126
- ...(authorName === undefined ? {} : { authorName }),
2127
- ...(authorEmail === undefined ? {} : { authorEmail }),
2234
+ ...authorValues,
2128
2235
  positionals: verb.positionals
2129
2236
  ? {
2130
2237
  key: verb.positionals,
@@ -2230,8 +2337,7 @@ export async function runCli({
2230
2337
  ...(parsed.metaTitle === undefined ? {} : { metaTitle: parsed.metaTitle }),
2231
2338
  ...(parsed.metaDescription === undefined ? {} : { metaDescription: parsed.metaDescription }),
2232
2339
  ...(parsed.metaAuthor === undefined ? {} : { metaAuthor: parsed.metaAuthor }),
2233
- ...(parsed.authorName === undefined ? {} : { authorName: parsed.authorName }),
2234
- ...(parsed.authorEmail === undefined ? {} : { authorEmail: parsed.authorEmail }),
2340
+ ...Object.fromEntries(AUTHOR_INVOCATION_FIELDS.filter((field) => parsed[field] !== undefined).map((field) => [field, parsed[field]])),
2235
2341
  ...Object.fromEntries(["pageSize", "pageToken", "missingDescription", "imageDescription", "clearDescription", "expectedRevision", "onlyIfMissing"]
2236
2342
  .filter((field) => parsed[field] !== undefined).map((field) => [field, parsed[field]])),
2237
2343
  capabilities: parsed.capabilities,
package/src/constants.js CHANGED
@@ -87,6 +87,7 @@ export const VERB_PAGES_META_SET = "pages meta set";
87
87
  export const VERB_PAGES_DELETE = "pages delete";
88
88
  export const VERB_AUTHORS_LIST = "authors list";
89
89
  export const VERB_AUTHORS_ADD = "authors add";
90
+ export const VERB_AUTHORS_SET = "authors set";
90
91
  export const VERB_NAV_PUSH = "nav push";
91
92
  export const VERB_REDIRECTS_CHECK = "redirects check";
92
93
  export const VERB_REDIRECTS_PULL = "redirects pull";
@@ -0,0 +1,27 @@
1
+ // Generated from shared/button-styles.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ /**
3
+ * The look an author gives a hero action or a call-to-action button (TR01418). One owner for the values, their
4
+ * defaults and the Espalier button attribute each one maps to, read by the CLI table, the renderer, the client
5
+ * elements and the editors.
6
+ */
7
+ export const BUTTON_STYLES = ["solid", "outline", "text"];
8
+ /** What each style looks like, for the CLI's described value lists and the editors' picker help. */
9
+ export const BUTTON_STYLE_DESCRIPTIONS = {
10
+ solid: "A filled button, the theme's button look.",
11
+ outline: "A transparent button with a link-colored border and label. A theme outline fill fills it and fits the resting label and border to the fill; a theme border color sets the resting border with or without a fill. Hover and focus keep the link-hover colors. It casts the theme shadow only when the theme sets --esp-button-outline-background in componentProperties; the link-hover fill an unfilled outline button shows on hover or focus does not enable it.",
12
+ text: "A borderless, transparent button that reads as a text link.",
13
+ };
14
+ export const HERO_PRIMARY_ACTION_STYLE_DEFAULT = "solid";
15
+ export const HERO_SECONDARY_ACTION_STYLE_DEFAULT = "outline";
16
+ export const CTA_BUTTON_STYLE_DEFAULT = "solid";
17
+ export function isButtonStyle(value) {
18
+ return BUTTON_STYLES.some(style => style === value);
19
+ }
20
+ /** The stored style, or the fallback for an absent or unknown one. */
21
+ export function resolveButtonStyle(value, fallback) {
22
+ return isButtonStyle(value) ? value : fallback;
23
+ }
24
+ /** The Espalier `esp-button` attributes a style sets: `outline` for outline, `incognito` for text. */
25
+ export function buttonStyleAttributes(style) {
26
+ return { outline: style === "outline", incognito: style === "text" };
27
+ }