@tokenoftrust/cli 3.12.2 → 4.0.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/package.json +1 -1
- package/src/validate.mjs +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
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
|
@@ -669,6 +669,20 @@ function validateFaq(block, file, at, out) {
|
|
|
669
669
|
});
|
|
670
670
|
}
|
|
671
671
|
|
|
672
|
+
function validateEditorial(block, file, at, out) {
|
|
673
|
+
for (const prop of ["excerpt", "date", "id"]) {
|
|
674
|
+
if (block[prop] !== undefined && (typeof block[prop] !== "string" || !block[prop].trim())) {
|
|
675
|
+
out.push(mk(ERROR, "block-prop", file, `${at}.${prop} must be a non-empty string`));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
if (block.ctaVariant !== undefined && block.ctaVariant !== "button" && block.ctaVariant !== "link") {
|
|
679
|
+
out.push(mk(ERROR, "block-prop", file, `${at}.ctaVariant must be button or link`));
|
|
680
|
+
}
|
|
681
|
+
if (typeof block.ctaHref === "string" && !isSafeStorefrontHref(block.ctaHref)) {
|
|
682
|
+
out.push(mk(ERROR, "navigation-href", file, `${at}.ctaHref must be a same-storefront root-relative path`));
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
672
686
|
function validateHomeDoc(doc, file, tenantId) {
|
|
673
687
|
const out = [];
|
|
674
688
|
if (doc == null || typeof doc !== "object" || Array.isArray(doc)) {
|
|
@@ -720,12 +734,16 @@ function validateHomeDoc(doc, file, tenantId) {
|
|
|
720
734
|
if (component === "hero" && block.notice !== undefined && (typeof block.notice !== "string" || !block.notice.trim())) {
|
|
721
735
|
out.push(mk(ERROR, "block-prop", file, `${at}.notice must be a non-empty plain-text string`));
|
|
722
736
|
}
|
|
737
|
+
if (block.id !== undefined && (typeof block.id !== "string" || !block.id.trim())) {
|
|
738
|
+
out.push(mk(ERROR, "block-prop", file, `${at}.id must be a non-empty string`));
|
|
739
|
+
}
|
|
723
740
|
if (component === "editorial" && block.image !== undefined) {
|
|
724
741
|
validateVisualAsset(block.image, file, `${at}.image`, out, tenantId);
|
|
725
742
|
if (typeof block.imageAlt !== "string") {
|
|
726
743
|
out.push(mk(ERROR, "block-required", file, `${at}.imageAlt is required when ${at}.image is supplied`));
|
|
727
744
|
}
|
|
728
745
|
}
|
|
746
|
+
if (component === "editorial") validateEditorial(block, file, at, out);
|
|
729
747
|
if (component === "promo_tiles") validatePromoTiles(block, file, at, out, tenantId);
|
|
730
748
|
if (component === "trust_strip") validateTrustStrip(block, file, at, out, tenantId);
|
|
731
749
|
if (component === "faq") validateFaq(block, file, at, out);
|