@tokenoftrust/cli 2.2.4 → 2.2.6
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 +1 -1
- package/src/validate.mjs +46 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
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",
|
package/src/validate.mjs
CHANGED
|
@@ -653,6 +653,28 @@ export const TRACKING_ID_STEP_NAME = "assign stable tracking ids";
|
|
|
653
653
|
export const CTA_MISSING_ID_FIX =
|
|
654
654
|
"assign stable tracking ids: GET/POST /api/admin/tracking-writeback proposes a data-tot-el for every element that's missing one, as a reviewable candidate PR (GET first for a dry-run preview) — or run `tot validate` to see the full list before you submit.";
|
|
655
655
|
|
|
656
|
+
// `public/**` is git-tracked and wholesale-ingested into R2 on every publish
|
|
657
|
+
// with no content-hash dedup (ingestAssetVersion re-copies every file under a
|
|
658
|
+
// new version key, changed or not) — see docs/versioned-assets-contract.md.
|
|
659
|
+
// A large binary there works, but it compounds: every future publish re-pays
|
|
660
|
+
// its storage cost, and the tenant's Gitea repo keeps that blob permanently.
|
|
661
|
+
// WARN only — never blocks a submit. Idea tracked for a built-in fix (auto
|
|
662
|
+
// relocation to a deduped, content-addressed store): fb-1790956035713-snpovm.
|
|
663
|
+
export const LARGE_PUBLIC_ASSET_BYTES = 100 * 1024;
|
|
664
|
+
export const LARGE_PUBLIC_ASSET_IDEA_ID = "fb-1790956035713-snpovm";
|
|
665
|
+
export const LARGE_PUBLIC_ASSET_FIX =
|
|
666
|
+
`storing it under public/ will work, but every publish re-copies it into R2 and ` +
|
|
667
|
+
`your Gitea repo keeps it forever — on a tenant with many of these, expect ` +
|
|
668
|
+
`slower publishes and slower clones over time. If this is an image, you don't ` +
|
|
669
|
+
`need to do anything extra: reference its public URL directly in your <img>/ ` +
|
|
670
|
+
`background-image/srcset and our capture step pulls it into CDN storage ` +
|
|
671
|
+
`automatically on publish. For a PDF or other non-image file, that auto-capture ` +
|
|
672
|
+
`doesn't apply yet — linking straight to an external URL avoids the repo-size ` +
|
|
673
|
+
`problem entirely, or send us the URL and we'll pull it in manually. We're ` +
|
|
674
|
+
`tracking a built-in fix to auto-relocate large files of any type the same way ` +
|
|
675
|
+
`images already work (idea ${LARGE_PUBLIC_ASSET_IDEA_ID}) — vote for it if ` +
|
|
676
|
+
`you'd like this handled for you sooner.`;
|
|
677
|
+
|
|
656
678
|
/**
|
|
657
679
|
* The advisory rules LOUD enough to call out by NAME at `tot validate` / `tot
|
|
658
680
|
* submit` / `tot preview` — none of them block, but each ships a page that
|
|
@@ -682,6 +704,11 @@ export const LOUD_ADVISORY_RULES = [
|
|
|
682
704
|
`actionable element with no governed identity (data-tot-el) — needs to ${TRACKING_ID_STEP_NAME}`,
|
|
683
705
|
`It renders and works fine, but it's invisible to interaction tracking — nothing about it is ever recorded. ${CTA_MISSING_ID_FIX}`,
|
|
684
706
|
],
|
|
707
|
+
[
|
|
708
|
+
"large-public-asset",
|
|
709
|
+
`a public/ asset is ${(LARGE_PUBLIC_ASSET_BYTES / 1024).toFixed(0)}KB or larger`,
|
|
710
|
+
LARGE_PUBLIC_ASSET_FIX,
|
|
711
|
+
],
|
|
685
712
|
[
|
|
686
713
|
"cta-id-drift",
|
|
687
714
|
"a previously-declared data-tot-el changed value",
|
|
@@ -1208,6 +1235,9 @@ export function validateTenant(tenantDir, opts = {}) {
|
|
|
1208
1235
|
}
|
|
1209
1236
|
}
|
|
1210
1237
|
|
|
1238
|
+
// large public assets — advisory (never blocks); see LARGE_PUBLIC_ASSET_FIX.
|
|
1239
|
+
findings.push(...findLargePublicAssets(publicDir, rel));
|
|
1240
|
+
|
|
1211
1241
|
const ok = !findings.some((f) => f.level === ERROR);
|
|
1212
1242
|
return { ok, findings };
|
|
1213
1243
|
}
|
|
@@ -1276,4 +1306,20 @@ function checkAsset(src, file, publicDir, tenantId) {
|
|
|
1276
1306
|
return null;
|
|
1277
1307
|
}
|
|
1278
1308
|
|
|
1309
|
+
/**
|
|
1310
|
+
* Every file under `public/**` at or above `LARGE_PUBLIC_ASSET_BYTES`. WARN only —
|
|
1311
|
+
* the file works fine, this is a cost/perf nudge toward the hosted-upload path
|
|
1312
|
+
* (see LARGE_PUBLIC_ASSET_FIX for why: no R2 dedup, permanent Gitea growth).
|
|
1313
|
+
*/
|
|
1314
|
+
function findLargePublicAssets(publicDir, rel) {
|
|
1315
|
+
const out = [];
|
|
1316
|
+
for (const p of walk(publicDir, () => true)) {
|
|
1317
|
+
const size = statSync(p).size;
|
|
1318
|
+
if (size >= LARGE_PUBLIC_ASSET_BYTES) {
|
|
1319
|
+
out.push(mk(WARN, "large-public-asset", rel(p), `${(size / 1024).toFixed(0)}KB`));
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return out;
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1279
1325
|
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|