@tokenoftrust/cli 2.0.10 → 2.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/cli",
3
- "version": "2.0.10",
3
+ "version": "2.0.11",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -1158,9 +1158,9 @@ function reportCandidate(result, changeId, { quiet = false } = {}) {
1158
1158
  * status?: {status?: string, reconcile?: object|null, compliance?: object|null,
1159
1159
  * previewUrl?: string|null, shipped?: object|null, dispatched?: boolean|null,
1160
1160
  * notDispatched?: boolean, delivery?: object|null}|null,
1161
- * previewPrUrl?: string|null, error?: string|null, note?: string|null }} input
1161
+ * previewPrUrl?: string|null, error?: string|null, note?: string|null, noChanges?: boolean }} input
1162
1162
  */
1163
- export function buildJsonResult({ ok, ref = null, commit = null, changeId = null, candidate = null, status = null, previewPrUrl = null, error = null, note = null }) {
1163
+ export function buildJsonResult({ ok, ref = null, commit = null, changeId = null, candidate = null, status = null, previewPrUrl = null, error = null, note = null, noChanges = false }) {
1164
1164
  return {
1165
1165
  ok,
1166
1166
  ref,
@@ -1183,6 +1183,13 @@ export function buildJsonResult({ ok, ref = null, commit = null, changeId = null
1183
1183
  forwardFailed: /** @type {any} */ (status)?.forwardFailed ?? false,
1184
1184
  delivery: status?.delivery ?? null,
1185
1185
  previewPrUrl,
1186
+ // Honest-diagnosis parity with the human-readable formatNotDispatchedBlock: a
1187
+ // `--json` caller gets the SAME "why" signal a human sees on the console. Without
1188
+ // this, `candidate:null, notDispatched:true, delivery:null` reads identically for
1189
+ // "no file diff → candidate_open never even ran" and "webhook never registered" /
1190
+ // "wrong tenant scope" — an automation caller (or a human piping --json) had no way
1191
+ // to tell an empty-diff no-op from a genuine platform dispatch failure.
1192
+ ...(noChanges ? { noChanges: true } : {}),
1186
1193
  ...(error ? { error } : {}),
1187
1194
  ...(note ? { note } : {}),
1188
1195
  };
@@ -1756,8 +1763,9 @@ export async function run(argv, ctx, { verb = "preview" } = {}) {
1756
1763
  // — automation doesn't want a browser popping up.
1757
1764
  // `commit: statusSha` — the diagnostic blocks name the sha that was actually polled,
1758
1765
  // so a "never dispatched" hint points at a sha `preview_status` knows about.
1759
- reportStatus(status, tenant, { open: !args.noOpen && !args.json, quiet: args.json, commit: statusSha, ref, verb, noChanges: patchEntries.length === 0 });
1760
- emitJson(args, buildJsonResult({ ok: status?.status !== "failed", ref, commit, changeId, candidate, status, previewPrUrl }));
1766
+ const noChanges = patchEntries.length === 0;
1767
+ reportStatus(status, tenant, { open: !args.noOpen && !args.json, quiet: args.json, commit: statusSha, ref, verb, noChanges });
1768
+ emitJson(args, buildJsonResult({ ok: status?.status !== "failed", ref, commit, changeId, candidate, status, previewPrUrl, noChanges }));
1761
1769
  return status?.status === "failed" ? 1 : 0;
1762
1770
  } catch (e) {
1763
1771
  progress?.stop();
package/src/validate.mjs CHANGED
@@ -742,7 +742,12 @@ function walk(dir, pred) {
742
742
 
743
743
  // --- link / asset extraction -------------------------------------------------
744
744
  const HREF_RE = /\bhref\s*=\s*"([^"]*)"/gi;
745
- const SRC_RE = /\b(?:src|srcset)\s*=\s*"([^"]*)"/gi;
745
+ const SRC_RE = /\bsrc\s*=\s*"([^"]*)"/gi;
746
+ // `srcset` carries a comma-separated list of `url descriptor` pairs (e.g.
747
+ // "a.webp 480w, b.webp 800w"), not a single URL — each candidate must be split
748
+ // off its descriptor before being checked as an asset. Mirrors
749
+ // scripts/publish/lib/asset-reachability.mjs's srcset handling.
750
+ const SRCSET_RE = /\bsrcset\s*=\s*"([^"]*)"/gi;
746
751
  const STYLE_OPEN_WITH_ATTRS_RE = /<style\s+[^>]*>/i;
747
752
  /** An in-page skip link: an anchor to a #main-ish target, or one carrying a skip class. */
748
753
  const SKIP_LINK_RE = /<a\b[^>]*(?:class="[^"]*\bskip[-\w]*\b[^"]*"|href="#(?:main|content|main-content)\b")/i;
@@ -974,6 +979,14 @@ export function validateTenant(tenantDir, opts = {}) {
974
979
  const f = checkAsset(m[1].trim(), r, publicDir, opts.tenantId || config?.tenant);
975
980
  if (f) findings.push(f);
976
981
  }
982
+ for (const m of html.matchAll(SRCSET_RE)) {
983
+ for (const candidate of m[1].split(",")) {
984
+ const url = candidate.trim().split(/\s+/)[0];
985
+ if (!url) continue;
986
+ const f = checkAsset(url, r, publicDir, opts.tenantId || config?.tenant);
987
+ if (f) findings.push(f);
988
+ }
989
+ }
977
990
  }
978
991
 
979
992
  // 5. git conflict markers — advisory (never blocks), but LOUD: a half-resolved