@yext/visual-editor 2.0.0-beta.3 → 2.0.0-beta.5
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/dist/{SectionLibraryVisualEditorProvider-JVQLJ96r.js → SectionLibraryVisualEditorProvider-Cx0HVYVV.js} +6877 -6746
- package/dist/cli/yextve.js +109 -29
- package/dist/index.d.ts +5 -2
- package/dist/{locatorEntityTypes-s4dmT9l5.d.ts → locatorEntityTypes-Cx069o6O.d.ts} +8 -0
- package/dist/plugin/plugin.js +152 -148
- package/dist/section-library-support.js +52 -52
- package/dist/sectionLibrarySupport.d.ts +2 -2
- package/dist/visual-editor.js +2516 -2507
- package/package.json +2 -2
package/dist/plugin/plugin.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import l from "node:path";
|
|
2
2
|
import f from "fs-extra";
|
|
3
3
|
import { Project as J, Node as I, SyntaxKind as T } from "ts-morph";
|
|
4
4
|
import { fileURLToPath as Nt, pathToFileURL as Dt } from "node:url";
|
|
@@ -356,8 +356,8 @@ const SectionLibraryLayout: Template<TemplateRenderProps> = (props) => {
|
|
|
356
356
|
};
|
|
357
357
|
|
|
358
358
|
export default SectionLibraryLayout;
|
|
359
|
-
`, vt = /^[
|
|
360
|
-
const e =
|
|
359
|
+
`, vt = /^[a-z][a-z0-9-]{0,61}[a-z0-9](?![\s\S])/, W = 1024, Mt = (t) => {
|
|
360
|
+
const e = l.join(t, "src", "library", "library.json"), n = l.relative(t, e), o = [], r = (p, m) => {
|
|
361
361
|
o.push({ category: "api", filePath: n, message: m, rule: p });
|
|
362
362
|
};
|
|
363
363
|
if (!f.existsSync(e))
|
|
@@ -385,11 +385,15 @@ export default SectionLibraryLayout;
|
|
|
385
385
|
"field/description/length",
|
|
386
386
|
`description must be at most ${W} characters.`
|
|
387
387
|
) : s.set("description", d);
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
"
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
const c = s.get("id");
|
|
389
|
+
if (c) {
|
|
390
|
+
const p = c.startsWith("yext_") ? c.slice(5) : c;
|
|
391
|
+
(c.length > 63 || !vt.test(p)) && r(
|
|
392
|
+
"field/id/safe",
|
|
393
|
+
"id must be 2–63 characters, contain only lowercase letters, numbers, and hyphens, start with a lowercase letter, and end with a letter or number."
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return o.length > 0 ? { issues: o } : {
|
|
393
397
|
issues: o,
|
|
394
398
|
metadata: {
|
|
395
399
|
schemaVersion: 1,
|
|
@@ -417,8 +421,8 @@ export default SectionLibraryLayout;
|
|
|
417
421
|
r[i] = a;
|
|
418
422
|
continue;
|
|
419
423
|
}
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
424
|
+
const c = q(s), p = q(a);
|
|
425
|
+
if (c && p) {
|
|
422
426
|
r[i] = k(
|
|
423
427
|
s,
|
|
424
428
|
a,
|
|
@@ -427,9 +431,9 @@ export default SectionLibraryLayout;
|
|
|
427
431
|
);
|
|
428
432
|
continue;
|
|
429
433
|
}
|
|
430
|
-
|
|
434
|
+
c !== p && n?.({
|
|
431
435
|
path: d,
|
|
432
|
-
builtInType:
|
|
436
|
+
builtInType: c ? "object" : "string",
|
|
433
437
|
repoType: p ? "object" : "string"
|
|
434
438
|
}), r[i] = a;
|
|
435
439
|
}
|
|
@@ -437,11 +441,11 @@ export default SectionLibraryLayout;
|
|
|
437
441
|
}, q = (t) => typeof t == "object", D = "stream.config.ts", yt = "/__yext_visual_editor/local-editor", mt = "local-editor-data-", Ft = "src/templates/local-editor-data.tsx", Bt = "/** THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED */", Y = (t) => {
|
|
438
442
|
const e = t.trim().replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "").toLowerCase();
|
|
439
443
|
return `${mt}${e || "layout"}`;
|
|
440
|
-
}, Gt = (t) =>
|
|
444
|
+
}, Gt = (t) => l.join(
|
|
441
445
|
"src",
|
|
442
446
|
"templates",
|
|
443
447
|
`${Y(t)}.tsx`
|
|
444
|
-
), K = (t, e) =>
|
|
448
|
+
), K = (t, e) => l.isAbsolute(e) ? e : l.join(t, e), Ht = (t) => {
|
|
445
449
|
const e = K(
|
|
446
450
|
t,
|
|
447
451
|
D
|
|
@@ -518,7 +522,7 @@ export default config;
|
|
|
518
522
|
}, d = s("id");
|
|
519
523
|
if (!d || !b.test(d))
|
|
520
524
|
throw new Error(`${t} config must define a valid id`);
|
|
521
|
-
const
|
|
525
|
+
const c = a.getProperty("pageSetTypes"), p = c ? c.asKind(T.PropertyAssignment)?.getInitializer()?.asKind(T.ArrayLiteralExpression)?.getElements().map((u) => {
|
|
522
526
|
const E = u.asKind(T.StringLiteral)?.getLiteralValue(), _ = pt.find(
|
|
523
527
|
(L) => L === E
|
|
524
528
|
);
|
|
@@ -528,7 +532,7 @@ export default config;
|
|
|
528
532
|
);
|
|
529
533
|
return _;
|
|
530
534
|
}) : void 0;
|
|
531
|
-
if (
|
|
535
|
+
if (c && !p)
|
|
532
536
|
throw new Error(
|
|
533
537
|
`${t} config.pageSetTypes must be an array of page set types`
|
|
534
538
|
);
|
|
@@ -583,8 +587,8 @@ export default config;
|
|
|
583
587
|
`${t} sharedComponentMetadata must be an array literal`
|
|
584
588
|
);
|
|
585
589
|
return {
|
|
586
|
-
components: d.map((
|
|
587
|
-
const m =
|
|
590
|
+
components: d.map((c, p) => {
|
|
591
|
+
const m = c.asKind(T.ObjectLiteralExpression);
|
|
588
592
|
if (!m)
|
|
589
593
|
throw new Error(
|
|
590
594
|
`${t} sharedComponentMetadata[${p}] must be an object literal`
|
|
@@ -664,25 +668,25 @@ const Wt = (t) => {
|
|
|
664
668
|
e.forget();
|
|
665
669
|
}
|
|
666
670
|
}, ft = (t, e) => {
|
|
667
|
-
const n =
|
|
671
|
+
const n = l.dirname(Nt(import.meta.url));
|
|
668
672
|
let o;
|
|
669
673
|
if (n.endsWith(
|
|
670
|
-
|
|
674
|
+
l.join("src", "internal", "sectionLibraryValidation")
|
|
671
675
|
))
|
|
672
|
-
o =
|
|
676
|
+
o = l.resolve(
|
|
673
677
|
n,
|
|
674
678
|
"..",
|
|
675
679
|
"..",
|
|
676
680
|
"..",
|
|
677
681
|
"locales"
|
|
678
682
|
);
|
|
679
|
-
else if (
|
|
680
|
-
o =
|
|
683
|
+
else if (l.basename(l.dirname(n)) === "dist")
|
|
684
|
+
o = l.resolve(n, "..", "locales");
|
|
681
685
|
else
|
|
682
686
|
throw new Error(
|
|
683
687
|
`Cannot determine the built-in translation location from ${n}`
|
|
684
688
|
);
|
|
685
|
-
const r =
|
|
689
|
+
const r = l.join(
|
|
686
690
|
o,
|
|
687
691
|
t,
|
|
688
692
|
e,
|
|
@@ -702,15 +706,15 @@ const Wt = (t) => {
|
|
|
702
706
|
"local-editor"
|
|
703
707
|
// generated Local Editor template ID
|
|
704
708
|
]), b = /^[A-Za-z0-9_-]+$/, Zt = (t) => {
|
|
705
|
-
const e =
|
|
709
|
+
const e = l.join(t, "src", "library"), n = [], o = (u, E, _, L) => {
|
|
706
710
|
n.push({
|
|
707
711
|
category: "structure",
|
|
708
712
|
...L ? { severity: L } : {},
|
|
709
|
-
filePath:
|
|
713
|
+
filePath: l.relative(t, u) || ".",
|
|
710
714
|
message: pe(_, t),
|
|
711
715
|
rule: E
|
|
712
716
|
});
|
|
713
|
-
}, r = re(t, e, o), i =
|
|
717
|
+
}, r = re(t, e, o), i = l.join(
|
|
714
718
|
e,
|
|
715
719
|
"migrations",
|
|
716
720
|
"registry.ts"
|
|
@@ -729,21 +733,21 @@ const Wt = (t) => {
|
|
|
729
733
|
t,
|
|
730
734
|
e,
|
|
731
735
|
o
|
|
732
|
-
), d =
|
|
736
|
+
), d = l.join(
|
|
733
737
|
e,
|
|
734
738
|
"shared",
|
|
735
739
|
"componentRegistry.ts"
|
|
736
740
|
);
|
|
737
|
-
let
|
|
741
|
+
let c;
|
|
738
742
|
try {
|
|
739
|
-
|
|
743
|
+
c = Kt(d);
|
|
740
744
|
} catch (u) {
|
|
741
745
|
o(d, "shared/invalid", C(u));
|
|
742
746
|
}
|
|
743
|
-
const p =
|
|
747
|
+
const p = c?.components ?? [], m = c?.rootPageSetTypes ?? [], g = ae(e, o), y = g.map(
|
|
744
748
|
({ defaultLayoutPath: u, ...E }) => E
|
|
745
749
|
);
|
|
746
|
-
!
|
|
750
|
+
!c && !f.existsSync(d) && g.some((u) => u.metadata.pageSetType !== "ENTITY") && o(
|
|
747
751
|
d,
|
|
748
752
|
"shared/missing",
|
|
749
753
|
"A shared component registry is required for DIRECTORY and LOCATOR layouts."
|
|
@@ -782,12 +786,12 @@ const Wt = (t) => {
|
|
|
782
786
|
const o = {
|
|
783
787
|
platform: {},
|
|
784
788
|
page: {}
|
|
785
|
-
}, r =
|
|
789
|
+
}, r = l.join(e, "i18n");
|
|
786
790
|
if (!f.existsSync(r))
|
|
787
791
|
return o;
|
|
788
792
|
const i = f.readdirSync(r, { withFileTypes: !0 }).filter((a) => a.name !== ".gitkeep").sort((a, s) => a.name.localeCompare(s.name));
|
|
789
793
|
for (const a of i) {
|
|
790
|
-
const s = a.name, d =
|
|
794
|
+
const s = a.name, d = l.join(r, s);
|
|
791
795
|
if (!a.isDirectory() || !te.includes(
|
|
792
796
|
s
|
|
793
797
|
)) {
|
|
@@ -809,8 +813,8 @@ const Wt = (t) => {
|
|
|
809
813
|
return o;
|
|
810
814
|
}, oe = (t, e, n, o, r) => {
|
|
811
815
|
for (const i of f.readdirSync(e, { withFileTypes: !0 }).filter((a) => a.name !== ".gitkeep").sort((a, s) => a.name.localeCompare(s.name))) {
|
|
812
|
-
const a =
|
|
813
|
-
if (!i.isFile() ||
|
|
816
|
+
const a = l.join(e, i.name), s = l.basename(i.name, l.extname(i.name));
|
|
817
|
+
if (!i.isFile() || l.extname(i.name) !== ".json" || !ee(s)) {
|
|
814
818
|
r(
|
|
815
819
|
a,
|
|
816
820
|
"i18n/locale",
|
|
@@ -837,9 +841,9 @@ const Wt = (t) => {
|
|
|
837
841
|
);
|
|
838
842
|
continue;
|
|
839
843
|
}
|
|
840
|
-
o[n][s] =
|
|
841
|
-
const
|
|
842
|
-
|
|
844
|
+
o[n][s] = l.relative(t, a).split(l.sep).join("/");
|
|
845
|
+
const c = ft(n, s);
|
|
846
|
+
c && k(c, d, (p) => {
|
|
843
847
|
r(
|
|
844
848
|
a,
|
|
845
849
|
"i18n/shape-collision",
|
|
@@ -851,12 +855,12 @@ const Wt = (t) => {
|
|
|
851
855
|
}, gt = (t) => !t || typeof t != "object" || Array.isArray(t) ? !1 : Object.values(t).every(
|
|
852
856
|
(e) => typeof e == "string" || gt(e)
|
|
853
857
|
), re = (t, e, n) => {
|
|
854
|
-
const o =
|
|
858
|
+
const o = l.join(e, "sections");
|
|
855
859
|
if (!f.existsSync(o))
|
|
856
860
|
return [];
|
|
857
861
|
const r = [];
|
|
858
862
|
for (const i of f.readdirSync(o, { withFileTypes: !0 }).filter((a) => a.name !== ".gitkeep").sort((a, s) => a.name.localeCompare(s.name))) {
|
|
859
|
-
const a =
|
|
863
|
+
const a = l.join(o, i.name);
|
|
860
864
|
if (i.isDirectory()) {
|
|
861
865
|
n(
|
|
862
866
|
a,
|
|
@@ -865,7 +869,7 @@ const Wt = (t) => {
|
|
|
865
869
|
);
|
|
866
870
|
continue;
|
|
867
871
|
}
|
|
868
|
-
const s =
|
|
872
|
+
const s = l.extname(i.name);
|
|
869
873
|
if (!i.isFile() || ![".tsx", ".jsx"].includes(s)) {
|
|
870
874
|
n(
|
|
871
875
|
a,
|
|
@@ -874,7 +878,7 @@ const Wt = (t) => {
|
|
|
874
878
|
);
|
|
875
879
|
continue;
|
|
876
880
|
}
|
|
877
|
-
const d =
|
|
881
|
+
const d = l.basename(i.name, s);
|
|
878
882
|
if (!b.test(d)) {
|
|
879
883
|
n(
|
|
880
884
|
a,
|
|
@@ -884,14 +888,14 @@ const Wt = (t) => {
|
|
|
884
888
|
continue;
|
|
885
889
|
}
|
|
886
890
|
try {
|
|
887
|
-
const
|
|
891
|
+
const c = {
|
|
888
892
|
...Jt(a, d),
|
|
889
893
|
componentName: d,
|
|
890
|
-
sourcePath:
|
|
894
|
+
sourcePath: l.relative(t, a)
|
|
891
895
|
};
|
|
892
|
-
b.test(
|
|
893
|
-
} catch (
|
|
894
|
-
const p = C(
|
|
896
|
+
b.test(c.id) ? r.push(c) : n(a, "sections/id", "config must define a valid id");
|
|
897
|
+
} catch (c) {
|
|
898
|
+
const p = C(c), m = p.includes("config must define a valid id");
|
|
895
899
|
n(
|
|
896
900
|
a,
|
|
897
901
|
m ? "sections/id" : "sections/frontmatter",
|
|
@@ -901,12 +905,12 @@ const Wt = (t) => {
|
|
|
901
905
|
}
|
|
902
906
|
return r;
|
|
903
907
|
}, ae = (t, e) => {
|
|
904
|
-
const n =
|
|
908
|
+
const n = l.join(t, "layouts");
|
|
905
909
|
if (!f.existsSync(n))
|
|
906
910
|
return e(n, "layouts/missing", "Missing layouts directory."), [];
|
|
907
911
|
const o = f.readdirSync(n, { withFileTypes: !0 }).filter((i) => i.isDirectory()).sort((i, a) => i.name.localeCompare(a.name)), r = o.flatMap((i) => {
|
|
908
912
|
const a = se(
|
|
909
|
-
|
|
913
|
+
l.join(n, i.name),
|
|
910
914
|
e
|
|
911
915
|
);
|
|
912
916
|
return a ? [a] : [];
|
|
@@ -914,26 +918,26 @@ const Wt = (t) => {
|
|
|
914
918
|
if (r.length === o.length) {
|
|
915
919
|
const i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
|
|
916
920
|
for (const d of r) {
|
|
917
|
-
const
|
|
918
|
-
if (i.has(
|
|
921
|
+
const c = d.metadata.id;
|
|
922
|
+
if (i.has(c) ? e(
|
|
919
923
|
n,
|
|
920
924
|
"layouts/duplicate-id",
|
|
921
|
-
`Layout ID is not unique: ${
|
|
922
|
-
) : i.add(
|
|
925
|
+
`Layout ID is not unique: ${c}`
|
|
926
|
+
) : i.add(c), d.metadata.pageSetType !== "ENTITY" && d.metadata.pageSetType !== "DIRECTORY")
|
|
923
927
|
continue;
|
|
924
|
-
const p = Y(
|
|
925
|
-
m && m !==
|
|
928
|
+
const p = Y(c), m = a.get(p);
|
|
929
|
+
m && m !== c ? e(
|
|
926
930
|
n,
|
|
927
931
|
"layouts/local-editor-template-collision",
|
|
928
|
-
`Layout IDs ${m} and ${
|
|
929
|
-
) : a.set(p,
|
|
932
|
+
`Layout IDs ${m} and ${c} generate the same Local Editor id: ${p}`
|
|
933
|
+
) : a.set(p, c);
|
|
930
934
|
}
|
|
931
935
|
const s = /* @__PURE__ */ new Map();
|
|
932
936
|
for (const d of r) {
|
|
933
|
-
const
|
|
937
|
+
const c = d.metadata.pageSetType;
|
|
934
938
|
s.set(
|
|
935
|
-
|
|
936
|
-
(s.get(
|
|
939
|
+
c,
|
|
940
|
+
(s.get(c) ?? 0) + 1
|
|
937
941
|
);
|
|
938
942
|
}
|
|
939
943
|
(s.get("ENTITY") ?? 0) === 0 && e(
|
|
@@ -952,7 +956,7 @@ const Wt = (t) => {
|
|
|
952
956
|
DIRECTORY: 1,
|
|
953
957
|
LOCATOR: 2
|
|
954
958
|
}, ie = (t, e) => Q[t.metadata.pageSetType] - Q[e.metadata.pageSetType] || t.metadata.id.localeCompare(e.metadata.id), se = (t, e) => {
|
|
955
|
-
const n =
|
|
959
|
+
const n = l.join(t, "metadata.json"), o = l.join(t, "defaultLayout.json"), r = tt(
|
|
956
960
|
n,
|
|
957
961
|
"layout metadata",
|
|
958
962
|
e
|
|
@@ -971,7 +975,7 @@ const Wt = (t) => {
|
|
|
971
975
|
"vertical",
|
|
972
976
|
jt,
|
|
973
977
|
n
|
|
974
|
-
),
|
|
978
|
+
), c = et(
|
|
975
979
|
r,
|
|
976
980
|
"purpose",
|
|
977
981
|
Yt,
|
|
@@ -985,7 +989,7 @@ const Wt = (t) => {
|
|
|
985
989
|
"displayName"
|
|
986
990
|
),
|
|
987
991
|
...d === void 0 ? {} : { vertical: d },
|
|
988
|
-
...
|
|
992
|
+
...c === void 0 ? {} : { purpose: c },
|
|
989
993
|
pageSetType: a
|
|
990
994
|
};
|
|
991
995
|
} else if (a === "DIRECTORY" || a === "LOCATOR")
|
|
@@ -1017,11 +1021,11 @@ const Wt = (t) => {
|
|
|
1017
1021
|
["Component", e]
|
|
1018
1022
|
])
|
|
1019
1023
|
for (const s of a) {
|
|
1020
|
-
const d = i === "Section" && "sourcePath" in s ?
|
|
1024
|
+
const d = i === "Section" && "sourcePath" in s ? l.join(
|
|
1021
1025
|
n,
|
|
1022
1026
|
"sections",
|
|
1023
|
-
s.sourcePath.split(
|
|
1024
|
-
) :
|
|
1027
|
+
s.sourcePath.split(l.sep).at(-1) ?? ""
|
|
1028
|
+
) : l.join(n, "shared", "componentRegistry.ts");
|
|
1025
1029
|
b.test(s.id) || o(
|
|
1026
1030
|
d,
|
|
1027
1031
|
"components/id",
|
|
@@ -1106,7 +1110,7 @@ const Wt = (t) => {
|
|
|
1106
1110
|
);
|
|
1107
1111
|
return r;
|
|
1108
1112
|
}
|
|
1109
|
-
}, C = (t) => t instanceof Error ? t.message : String(t), pe = (t, e) => t.split(`${e}${
|
|
1113
|
+
}, C = (t) => t instanceof Error ? t.message : String(t), pe = (t, e) => t.split(`${e}${l.sep}`).join(""), nt = ["api", "structure", "code"], ye = (t) => [...t].sort((e, n) => nt.indexOf(e.category) - nt.indexOf(n.category) || ot(e.filePath, n.filePath) || (e.line ?? 0) - (n.line ?? 0) || (e.column ?? 0) - (n.column ?? 0) || ot(e.rule, n.rule)), ot = (t, e) => t === e ? 0 : t < e ? -1 : 1, me = (t) => {
|
|
1110
1114
|
const e = t.line ? `:${t.line}${t.column ? `:${t.column}` : ""}` : "";
|
|
1111
1115
|
return `${t.filePath}${e}: ${t.message}`;
|
|
1112
1116
|
};
|
|
@@ -1151,7 +1155,7 @@ const fe = [
|
|
|
1151
1155
|
throw new Error(
|
|
1152
1156
|
"Section Library builds require SECTION_LIBRARY_REVISION_ID"
|
|
1153
1157
|
);
|
|
1154
|
-
if (!f.existsSync(
|
|
1158
|
+
if (!f.existsSync(l.join(t, "src", "library", "library.json")))
|
|
1155
1159
|
return { generatedFiles: [], layouts: [] };
|
|
1156
1160
|
const n = Mt(t), o = Zt(t), r = ye([
|
|
1157
1161
|
...n.issues,
|
|
@@ -1167,11 +1171,11 @@ const fe = [
|
|
|
1167
1171
|
throw new Error(
|
|
1168
1172
|
"Section Library metadata and structure validation did not run."
|
|
1169
1173
|
);
|
|
1170
|
-
const a = n.metadata, s = o.structure, d = Ce(t),
|
|
1174
|
+
const a = n.metadata, s = o.structure, d = Ce(t), c = l.join(t, "src", "library", ".generated"), p = Te(
|
|
1171
1175
|
t,
|
|
1172
|
-
|
|
1176
|
+
c,
|
|
1173
1177
|
s.translationResources
|
|
1174
|
-
), m =
|
|
1178
|
+
), m = l.join(c, "i18n.ts"), g = [...p.generatedFiles];
|
|
1175
1179
|
return A(
|
|
1176
1180
|
m,
|
|
1177
1181
|
Ee(
|
|
@@ -1180,8 +1184,8 @@ const fe = [
|
|
|
1180
1184
|
)
|
|
1181
1185
|
) && g.push(m), g.push(
|
|
1182
1186
|
...s.layouts.flatMap((y) => {
|
|
1183
|
-
const u =
|
|
1184
|
-
|
|
1187
|
+
const u = l.join(
|
|
1188
|
+
c,
|
|
1185
1189
|
`libraryConfig-${y.metadata.id}.tsx`
|
|
1186
1190
|
);
|
|
1187
1191
|
return A(
|
|
@@ -1197,7 +1201,7 @@ const fe = [
|
|
|
1197
1201
|
})
|
|
1198
1202
|
), g.push(
|
|
1199
1203
|
...s.layouts.flatMap((y) => {
|
|
1200
|
-
const u =
|
|
1204
|
+
const u = l.join(
|
|
1201
1205
|
t,
|
|
1202
1206
|
"src",
|
|
1203
1207
|
"templates",
|
|
@@ -1210,7 +1214,7 @@ const fe = [
|
|
|
1210
1214
|
})
|
|
1211
1215
|
), g.push(
|
|
1212
1216
|
...s.layouts.flatMap((y) => {
|
|
1213
|
-
const u =
|
|
1217
|
+
const u = l.join(
|
|
1214
1218
|
t,
|
|
1215
1219
|
"src",
|
|
1216
1220
|
"templates",
|
|
@@ -1247,7 +1251,7 @@ const fe = [
|
|
|
1247
1251
|
};
|
|
1248
1252
|
}, Ee = (t, e) => {
|
|
1249
1253
|
const n = (o) => Object.entries(o).sort(([r], [i]) => r.localeCompare(i)).map(([r, i]) => {
|
|
1250
|
-
const a =
|
|
1254
|
+
const a = l.relative(l.dirname(t), i).split(l.sep).join("/"), s = a.startsWith(".") ? a : `./${a}`;
|
|
1251
1255
|
return ` ${JSON.stringify(r)}: () => import(${JSON.stringify(s)}).then(({ default: translations }) => translations),`;
|
|
1252
1256
|
}).join(`
|
|
1253
1257
|
`);
|
|
@@ -1281,9 +1285,9 @@ const fe = [
|
|
|
1281
1285
|
throw new Error(
|
|
1282
1286
|
`Could not find built-in ${a} translations for ${i}.`
|
|
1283
1287
|
);
|
|
1284
|
-
const
|
|
1285
|
-
f.readFileSync(
|
|
1286
|
-
) : void 0, m = p ? k(d, p) : d, g =
|
|
1288
|
+
const c = n[a][i], p = c ? JSON.parse(
|
|
1289
|
+
f.readFileSync(l.join(t, c), "utf8")
|
|
1290
|
+
) : void 0, m = p ? k(d, p) : d, g = l.join(
|
|
1287
1291
|
e,
|
|
1288
1292
|
"i18n",
|
|
1289
1293
|
s,
|
|
@@ -1311,9 +1315,9 @@ const fe = [
|
|
|
1311
1315
|
const e = /* @__PURE__ */ new Set();
|
|
1312
1316
|
for (const n of t) {
|
|
1313
1317
|
f.removeSync(n);
|
|
1314
|
-
let o =
|
|
1315
|
-
for (e.add(o); o.includes(`${
|
|
1316
|
-
o =
|
|
1318
|
+
let o = l.dirname(n);
|
|
1319
|
+
for (e.add(o); o.includes(`${l.sep}.generated${l.sep}`) && l.basename(o) !== ".generated"; )
|
|
1320
|
+
o = l.dirname(o), e.add(o);
|
|
1317
1321
|
n.endsWith(".tsx") && f.removeSync(n.replace(/\.tsx$/, ".client.tsx"));
|
|
1318
1322
|
}
|
|
1319
1323
|
for (const n of [...e].sort(
|
|
@@ -1321,7 +1325,7 @@ const fe = [
|
|
|
1321
1325
|
))
|
|
1322
1326
|
f.existsSync(n) && f.readdirSync(n).length === 0 && f.removeSync(n);
|
|
1323
1327
|
}, _e = (t, e) => {
|
|
1324
|
-
const n =
|
|
1328
|
+
const n = l.join(t, ".template-manifest.json"), o = JSON.stringify(
|
|
1325
1329
|
{
|
|
1326
1330
|
templates: e.map((r) => ({
|
|
1327
1331
|
name: r.metadata.id,
|
|
@@ -1336,21 +1340,21 @@ const fe = [
|
|
|
1336
1340
|
);
|
|
1337
1341
|
(!f.existsSync(n) || f.readFileSync(n, "utf8") !== o) && f.writeFileSync(n, o);
|
|
1338
1342
|
}, Ie = (t, e, n, o, r) => {
|
|
1339
|
-
const i = e.metadata.id, a =
|
|
1343
|
+
const i = e.metadata.id, a = l.join(
|
|
1340
1344
|
t,
|
|
1341
1345
|
"src",
|
|
1342
1346
|
"library",
|
|
1343
1347
|
".generated",
|
|
1344
1348
|
`libraryConfig-${i}.tsx`
|
|
1345
1349
|
), s = n.filter((g) => g.pageSetTypes.includes(e.metadata.pageSetType)), d = s.map((g, y) => {
|
|
1346
|
-
const u =
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
).replace(/\.(tsx|jsx)$/, "").split(
|
|
1350
|
+
const u = l.relative(
|
|
1351
|
+
l.dirname(a),
|
|
1352
|
+
l.join(t, g.sourcePath)
|
|
1353
|
+
).replace(/\.(tsx|jsx)$/, "").split(l.sep).join("/"), E = u.startsWith(".") ? u : `./${u}`;
|
|
1350
1354
|
return `import { ${g.componentName} as Section${y}, config as sectionConfig${y} } from ${JSON.stringify(E)};`;
|
|
1351
|
-
}),
|
|
1355
|
+
}), c = s.map((g, y) => ` { id: ${JSON.stringify(g.id)}, component: Section${y}, config: sectionConfig${y} },`), p = Le(s), m = o.some((g) => g.pageSetTypes.includes(e.metadata.pageSetType)) || r.includes(e.metadata.pageSetType);
|
|
1352
1356
|
return xt.replace("/* SECTION_LIBRARY_GENERATED_FILE */", O).replace("/* SECTION_LIBRARY_IMPORTS */", d.join(`
|
|
1353
|
-
`)).replace("/* SECTION_LIBRARY_ENTRIES */",
|
|
1357
|
+
`)).replace("/* SECTION_LIBRARY_ENTRIES */", c.join(`
|
|
1354
1358
|
`)).replace("/* SECTION_LIBRARY_CATEGORIES */", p).replace(
|
|
1355
1359
|
"/* SECTION_LIBRARY_SHARED_COMPONENT_REGISTRY */",
|
|
1356
1360
|
m ? 'import { sharedComponentConfigs, sharedComponentMetadata, sharedRootAllowedComponentIds, sharedRootConfigs } from "../shared/componentRegistry";' : `const sharedComponentMetadata: { id: string; pageSetTypes: string[] }[] = [];
|
|
@@ -1400,7 +1404,7 @@ const sharedRootConfigs: Partial<Record<string, NonNullable<Config["root"]>>> =
|
|
|
1400
1404
|
o
|
|
1401
1405
|
).replace("/* SECTION_LIBRARY_COMPONENT_REGISTRY */", r).replace('"__SECTION_LIBRARY_EDITOR_PATH__"', JSON.stringify(e)).replace('"__SECTION_LIBRARY_EDITOR_NAME__"', JSON.stringify(n));
|
|
1402
1406
|
}, Ce = (t) => {
|
|
1403
|
-
const e =
|
|
1407
|
+
const e = l.join(
|
|
1404
1408
|
t,
|
|
1405
1409
|
"src",
|
|
1406
1410
|
"library",
|
|
@@ -1410,7 +1414,7 @@ const sharedRootConfigs: Partial<Record<string, NonNullable<Config["root"]>>> =
|
|
|
1410
1414
|
return f.existsSync(e) ? `import { migrationRegistry as repoMigrationRegistry } from "../library/migrations/registry";
|
|
1411
1415
|
const sectionLibraryMigrationRegistry: MigrationRegistry = repoMigrationRegistry;` : "const sectionLibraryMigrationRegistry: MigrationRegistry = [];";
|
|
1412
1416
|
}, A = (t, e) => {
|
|
1413
|
-
if (f.ensureDirSync(
|
|
1417
|
+
if (f.ensureDirSync(l.dirname(t)), f.existsSync(t)) {
|
|
1414
1418
|
const n = f.readFileSync(t, "utf8");
|
|
1415
1419
|
if (!n.startsWith(O))
|
|
1416
1420
|
return !1;
|
|
@@ -1595,7 +1599,7 @@ export default LocalEditorData;
|
|
|
1595
1599
|
return JSON.parse(f.readFileSync(t, "utf8"));
|
|
1596
1600
|
} catch (n) {
|
|
1597
1601
|
throw new Error(
|
|
1598
|
-
`Failed to parse ${e} at ${
|
|
1602
|
+
`Failed to parse ${e} at ${l.relative(process.cwd(), t)}: ${j(n)}`
|
|
1599
1603
|
);
|
|
1600
1604
|
}
|
|
1601
1605
|
}, j = (t) => t instanceof Error ? t.message : String(t), be = (t, e) => {
|
|
@@ -1605,7 +1609,7 @@ export default LocalEditorData;
|
|
|
1605
1609
|
localEditorDataTemplateSource: e
|
|
1606
1610
|
}) => ({
|
|
1607
1611
|
cleanupGeneratedLocalEditorArtifacts: (i = process.cwd()) => {
|
|
1608
|
-
const a =
|
|
1612
|
+
const a = l.join(
|
|
1609
1613
|
i,
|
|
1610
1614
|
"src",
|
|
1611
1615
|
"templates",
|
|
@@ -1615,37 +1619,37 @@ export default LocalEditorData;
|
|
|
1615
1619
|
},
|
|
1616
1620
|
syncLocalEditorDataTemplates: (i, a = process.cwd()) => {
|
|
1617
1621
|
const s = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Map();
|
|
1618
|
-
for (const
|
|
1619
|
-
if (
|
|
1622
|
+
for (const c of i) {
|
|
1623
|
+
if (c.metadata.pageSetType !== "ENTITY" && c.metadata.pageSetType !== "DIRECTORY")
|
|
1620
1624
|
continue;
|
|
1621
|
-
const p =
|
|
1625
|
+
const p = l.join(
|
|
1622
1626
|
a,
|
|
1623
|
-
Gt(
|
|
1627
|
+
Gt(c.metadata.id)
|
|
1624
1628
|
), m = d.get(p);
|
|
1625
1629
|
m ? console.warn(
|
|
1626
|
-
`Local Editor layouts "${m}" and "${
|
|
1627
|
-
) : d.set(p,
|
|
1628
|
-
const g =
|
|
1629
|
-
|
|
1630
|
+
`Local Editor layouts "${m}" and "${c.metadata.id}" generate the same data template at ${l.relative(a, p)}. The later layout will overwrite the earlier layout's template.`
|
|
1631
|
+
) : d.set(p, c.metadata.id);
|
|
1632
|
+
const g = l.relative(
|
|
1633
|
+
l.dirname(p),
|
|
1630
1634
|
K(
|
|
1631
1635
|
a,
|
|
1632
1636
|
D
|
|
1633
1637
|
)
|
|
1634
|
-
).split(
|
|
1638
|
+
).split(l.sep).join("/");
|
|
1635
1639
|
rt(
|
|
1636
1640
|
p,
|
|
1637
1641
|
Vt(
|
|
1638
1642
|
e,
|
|
1639
1643
|
g.startsWith(".") ? g : `./${g}`,
|
|
1640
|
-
|
|
1641
|
-
|
|
1644
|
+
c.metadata.id,
|
|
1645
|
+
c.metadata.pageSetType
|
|
1642
1646
|
)
|
|
1643
1647
|
), s.add(p);
|
|
1644
1648
|
}
|
|
1645
1649
|
at(a, s);
|
|
1646
1650
|
},
|
|
1647
1651
|
syncLocalEditorTemplate: (i, a = process.cwd()) => {
|
|
1648
|
-
const s =
|
|
1652
|
+
const s = l.join(
|
|
1649
1653
|
a,
|
|
1650
1654
|
"src",
|
|
1651
1655
|
"templates",
|
|
@@ -1661,42 +1665,42 @@ export default LocalEditorData;
|
|
|
1661
1665
|
Pe(a)
|
|
1662
1666
|
).replace(
|
|
1663
1667
|
"/* LOCAL_EDITOR_CONFIG_IMPORTS */",
|
|
1664
|
-
i.map((d,
|
|
1668
|
+
i.map((d, c) => `import { sectionLibraryConfig as LayoutConfig${c} } from ${JSON.stringify(`../library/.generated/libraryConfig-${d.metadata.id}`)};`).join(`
|
|
1665
1669
|
`)
|
|
1666
1670
|
).replace(
|
|
1667
1671
|
"/* LOCAL_EDITOR_COMPONENT_REGISTRY */",
|
|
1668
|
-
i.map((d,
|
|
1672
|
+
i.map((d, c) => ` ${JSON.stringify(d.metadata.id)}: LayoutConfig${c},`).join(`
|
|
1669
1673
|
`)
|
|
1670
1674
|
)
|
|
1671
1675
|
);
|
|
1672
1676
|
}
|
|
1673
1677
|
}), Pe = (t) => f.existsSync(
|
|
1674
|
-
|
|
1678
|
+
l.join(t, "src", "library", "migrations", "registry.ts")
|
|
1675
1679
|
) ? `import { migrationRegistry as repoMigrationRegistry } from "../library/migrations/registry";
|
|
1676
1680
|
const sectionLibraryMigrationRegistry: MigrationRegistry = repoMigrationRegistry;` : "const sectionLibraryMigrationRegistry: MigrationRegistry = [];", rt = (t, e) => {
|
|
1677
|
-
if (f.ensureDirSync(
|
|
1681
|
+
if (f.ensureDirSync(l.dirname(t)), f.existsSync(t) && !v(t))
|
|
1678
1682
|
throw new Error(
|
|
1679
1683
|
`Refusing to overwrite hand-authored local editor template at ${t}`
|
|
1680
1684
|
);
|
|
1681
1685
|
be(t, e);
|
|
1682
1686
|
}, at = (t, e) => {
|
|
1683
|
-
const n =
|
|
1687
|
+
const n = l.join(t, "src", "templates");
|
|
1684
1688
|
if (!f.existsSync(n))
|
|
1685
1689
|
return;
|
|
1686
1690
|
for (const r of f.readdirSync(n, {
|
|
1687
1691
|
withFileTypes: !0
|
|
1688
1692
|
})) {
|
|
1689
|
-
const i =
|
|
1690
|
-
!r.isFile() || !r.name.startsWith(mt) ||
|
|
1693
|
+
const i = l.join(n, r.name);
|
|
1694
|
+
!r.isFile() || !r.name.startsWith(mt) || l.extname(r.name) !== ".tsx" || e?.has(i) || !v(i) || f.removeSync(i);
|
|
1691
1695
|
}
|
|
1692
|
-
const o =
|
|
1696
|
+
const o = l.join(
|
|
1693
1697
|
t,
|
|
1694
1698
|
Ft
|
|
1695
1699
|
);
|
|
1696
1700
|
!e?.has(o) && v(o) && f.removeSync(o);
|
|
1697
1701
|
}, xe = (t) => {
|
|
1698
|
-
const e =
|
|
1699
|
-
return f.existsSync(e) ? f.readdirSync(e, { withFileTypes: !0 }).filter((n) => n.isFile() &&
|
|
1702
|
+
const e = l.join(t, "public", "y-fonts");
|
|
1703
|
+
return f.existsSync(e) ? f.readdirSync(e, { withFileTypes: !0 }).filter((n) => n.isFile() && l.extname(n.name) === ".css").map((n) => `/y-fonts/${n.name}`).sort((n, o) => n.localeCompare(o)) : [];
|
|
1700
1704
|
};
|
|
1701
1705
|
let B;
|
|
1702
1706
|
const Tt = async (t, e, n) => {
|
|
@@ -1706,7 +1710,7 @@ const Tt = async (t, e, n) => {
|
|
|
1706
1710
|
);
|
|
1707
1711
|
if (!f.existsSync(o))
|
|
1708
1712
|
return n.push(
|
|
1709
|
-
`Missing local editor config at ${
|
|
1713
|
+
`Missing local editor config at ${l.relative(process.cwd(), o)}.`
|
|
1710
1714
|
), G(e, {});
|
|
1711
1715
|
try {
|
|
1712
1716
|
return G(
|
|
@@ -1717,9 +1721,9 @@ const Tt = async (t, e, n) => {
|
|
|
1717
1721
|
return n.push(j(r)), G(e, {});
|
|
1718
1722
|
}
|
|
1719
1723
|
}, we = async (t) => {
|
|
1720
|
-
if (
|
|
1724
|
+
if (l.extname(t) === ".json")
|
|
1721
1725
|
throw new Error(
|
|
1722
|
-
`Unsupported local editor config at ${
|
|
1726
|
+
`Unsupported local editor config at ${l.relative(process.cwd(), t)}: use ${D}.`
|
|
1723
1727
|
);
|
|
1724
1728
|
if (B?.filePath === t)
|
|
1725
1729
|
return B.config;
|
|
@@ -1733,7 +1737,7 @@ const Tt = async (t, e, n) => {
|
|
|
1733
1737
|
n = n.default;
|
|
1734
1738
|
if (!n || typeof n != "object")
|
|
1735
1739
|
throw new Error(
|
|
1736
|
-
`Failed to parse local editor stream config at ${
|
|
1740
|
+
`Failed to parse local editor stream config at ${l.relative(process.cwd(), t)}: expected a default-exported object.`
|
|
1737
1741
|
);
|
|
1738
1742
|
const o = n;
|
|
1739
1743
|
return B = {
|
|
@@ -1742,18 +1746,18 @@ const Tt = async (t, e, n) => {
|
|
|
1742
1746
|
}, o;
|
|
1743
1747
|
}, G = (t, e) => {
|
|
1744
1748
|
const n = t.flatMap((o) => {
|
|
1745
|
-
const r = o.metadata.id, i = o.metadata.pageSetType, a = e.pageSetTypes?.[i], s = e.layouts?.[r], d = s?.stream ?? a?.stream,
|
|
1746
|
-
return
|
|
1749
|
+
const r = o.metadata.id, i = o.metadata.pageSetType, a = e.pageSetTypes?.[i], s = e.layouts?.[r], d = s?.stream ?? a?.stream, c = i === "ENTITY" || i === "DIRECTORY" && d ? "stream" : "fixture";
|
|
1750
|
+
return c === "stream" && !d ? [] : [
|
|
1747
1751
|
{
|
|
1748
1752
|
layoutId: r,
|
|
1749
1753
|
dataTemplateName: Y(r),
|
|
1750
1754
|
pageSetType: i,
|
|
1751
|
-
dataSource:
|
|
1755
|
+
dataSource: c,
|
|
1752
1756
|
defaults: {
|
|
1753
1757
|
entityId: s?.defaults?.entityId ?? a?.defaults?.entityId,
|
|
1754
1758
|
locale: s?.defaults?.locale ?? a?.defaults?.locale ?? e.defaults?.locale
|
|
1755
1759
|
},
|
|
1756
|
-
stream:
|
|
1760
|
+
stream: c === "stream" ? d : void 0,
|
|
1757
1761
|
defaultLayoutData: o.defaultLayout
|
|
1758
1762
|
}
|
|
1759
1763
|
];
|
|
@@ -1991,7 +1995,7 @@ const Tt = async (t, e, n) => {
|
|
|
1991
1995
|
a(o, "dm_addressRegionDisplayName"),
|
|
1992
1996
|
[h("Locations Directory", "index.html")],
|
|
1993
1997
|
{ dm_addressCountryDisplayName: "United States" }
|
|
1994
|
-
),
|
|
1998
|
+
), c = w(
|
|
1995
1999
|
String(o.id),
|
|
1996
2000
|
"VA",
|
|
1997
2001
|
"us/va",
|
|
@@ -2021,7 +2025,7 @@ const Tt = async (t, e, n) => {
|
|
|
2021
2025
|
dm_addressRegionDisplayName: "Virginia"
|
|
2022
2026
|
}
|
|
2023
2027
|
);
|
|
2024
|
-
return [s, d,
|
|
2028
|
+
return [s, d, c, p].map(
|
|
2025
2029
|
(m) => ({ layoutId: t, document: m })
|
|
2026
2030
|
);
|
|
2027
2031
|
}, Ue = (t) => ({
|
|
@@ -2073,7 +2077,7 @@ const Tt = async (t, e, n) => {
|
|
|
2073
2077
|
t,
|
|
2074
2078
|
e,
|
|
2075
2079
|
i
|
|
2076
|
-
), s = n ?? a.defaults.layoutId ?? a.layouts[0], d = s ? a.entitiesByLayout[s] ?? [] : [],
|
|
2080
|
+
), s = n ?? a.defaults.layoutId ?? a.layouts[0], d = s ? a.entitiesByLayout[s] ?? [] : [], c = s ? a.layoutDefaults[s] : void 0, p = o ?? c?.entityId ?? a.defaults.entityId ?? d[0]?.entityId, m = d.find((S) => S.entityId === p), g = r ?? c?.locale ?? a.defaults.locale ?? m?.locales[0], y = a.documents.find((S) => S.layoutId === s && S.entityId === p && S.locale === g);
|
|
2077
2081
|
if (!y)
|
|
2078
2082
|
return {
|
|
2079
2083
|
document: null,
|
|
@@ -2162,7 +2166,7 @@ const Tt = async (t, e, n) => {
|
|
|
2162
2166
|
return t;
|
|
2163
2167
|
}
|
|
2164
2168
|
}, Ct = async (t, e, n = 4) => {
|
|
2165
|
-
const o = [], r =
|
|
2169
|
+
const o = [], r = l.join(t, "localData");
|
|
2166
2170
|
e.length === 0 && o.push("Missing src/library/library.json.");
|
|
2167
2171
|
const i = await Tt(
|
|
2168
2172
|
t,
|
|
@@ -2173,7 +2177,7 @@ const Tt = async (t, e, n) => {
|
|
|
2173
2177
|
a,
|
|
2174
2178
|
o,
|
|
2175
2179
|
n
|
|
2176
|
-
),
|
|
2180
|
+
), c = qe(s, d), p = Object.fromEntries(
|
|
2177
2181
|
a.map((y) => [
|
|
2178
2182
|
y.layoutId,
|
|
2179
2183
|
{
|
|
@@ -2204,7 +2208,7 @@ const Tt = async (t, e, n) => {
|
|
|
2204
2208
|
dataSourceByLayout: Object.fromEntries(
|
|
2205
2209
|
a.map((y) => [y.layoutId, y.dataSource])
|
|
2206
2210
|
),
|
|
2207
|
-
entitiesByLayout:
|
|
2211
|
+
entitiesByLayout: c,
|
|
2208
2212
|
documents: d
|
|
2209
2213
|
};
|
|
2210
2214
|
}, Ot = (t) => {
|
|
@@ -2214,24 +2218,24 @@ const Tt = async (t, e, n) => {
|
|
|
2214
2218
|
const r = He(
|
|
2215
2219
|
e,
|
|
2216
2220
|
o
|
|
2217
|
-
).map(({ layoutId:
|
|
2218
|
-
layoutId:
|
|
2221
|
+
).map(({ layoutId: c, document: p }) => ({
|
|
2222
|
+
layoutId: c,
|
|
2219
2223
|
entityId: H(p, "fixture.json"),
|
|
2220
2224
|
displayName: typeof p.name == "string" && p.name.length > 0 ? p.name : H(p, "fixture.json"),
|
|
2221
2225
|
locale: dt(p, "fixture.json"),
|
|
2222
2226
|
fileName: "built-in fixture",
|
|
2223
2227
|
document: p
|
|
2224
|
-
})), i = e.filter((
|
|
2228
|
+
})), i = e.filter((c) => c.dataSource === "stream");
|
|
2225
2229
|
if (i.length === 0)
|
|
2226
2230
|
return r;
|
|
2227
2231
|
if (!f.existsSync(t))
|
|
2228
2232
|
return n.push(
|
|
2229
|
-
`Missing localData snapshots at ${
|
|
2233
|
+
`Missing localData snapshots at ${l.relative(process.cwd(), t)}. Run your existing Pages local data generation flow first.`
|
|
2230
2234
|
), r;
|
|
2231
|
-
const a =
|
|
2235
|
+
const a = l.join(t, "mapping.json");
|
|
2232
2236
|
if (!f.existsSync(a))
|
|
2233
2237
|
return n.push(
|
|
2234
|
-
`Missing local editor snapshot mapping at ${
|
|
2238
|
+
`Missing local editor snapshot mapping at ${l.relative(process.cwd(), a)}. Run yext pages generate-test-data to populate local editor snapshots.`
|
|
2235
2239
|
), r;
|
|
2236
2240
|
let s;
|
|
2237
2241
|
try {
|
|
@@ -2239,25 +2243,25 @@ const Tt = async (t, e, n) => {
|
|
|
2239
2243
|
a,
|
|
2240
2244
|
"local data mapping"
|
|
2241
2245
|
);
|
|
2242
|
-
} catch (
|
|
2243
|
-
return n.push(j(
|
|
2246
|
+
} catch (c) {
|
|
2247
|
+
return n.push(j(c)), r;
|
|
2244
2248
|
}
|
|
2245
2249
|
const d = [...r];
|
|
2246
|
-
for (const
|
|
2250
|
+
for (const c of i) {
|
|
2247
2251
|
const p = new Set(
|
|
2248
|
-
s[
|
|
2252
|
+
s[c.dataTemplateName] ?? []
|
|
2249
2253
|
);
|
|
2250
2254
|
if (p.size === 0) {
|
|
2251
2255
|
n.push(
|
|
2252
|
-
`Missing local editor snapshot mapping for layout "${
|
|
2256
|
+
`Missing local editor snapshot mapping for layout "${c.layoutId}" in ${l.relative(process.cwd(), a)}. Expected generated mapping key "${c.dataTemplateName}". Run yext pages generate-test-data after enabling localEditor.`
|
|
2253
2257
|
);
|
|
2254
2258
|
continue;
|
|
2255
2259
|
}
|
|
2256
2260
|
Array.from(p).sort((m, g) => m.localeCompare(g)).forEach((m) => {
|
|
2257
|
-
const g =
|
|
2261
|
+
const g = l.join(t, m);
|
|
2258
2262
|
if (!f.existsSync(g)) {
|
|
2259
2263
|
n.push(
|
|
2260
|
-
`Snapshot file ${
|
|
2264
|
+
`Snapshot file ${l.join("localData", m)} is referenced but missing.`
|
|
2261
2265
|
);
|
|
2262
2266
|
return;
|
|
2263
2267
|
}
|
|
@@ -2267,7 +2271,7 @@ const Tt = async (t, e, n) => {
|
|
|
2267
2271
|
`local editor snapshot ${m}`
|
|
2268
2272
|
), u = dt(y, m), E = H(y, m);
|
|
2269
2273
|
d.push({
|
|
2270
|
-
layoutId:
|
|
2274
|
+
layoutId: c.layoutId,
|
|
2271
2275
|
entityId: E,
|
|
2272
2276
|
displayName: typeof y.name == "string" && y.name.length > 0 ? y.name : E,
|
|
2273
2277
|
locale: u,
|
|
@@ -2345,7 +2349,7 @@ const Tt = async (t, e, n) => {
|
|
|
2345
2349
|
process.env.SECTION_LIBRARY_REVISION_ID
|
|
2346
2350
|
);
|
|
2347
2351
|
o = g.generatedFiles, r = g.manifestSource, i = g.layouts, a = g.manifestSource !== void 0;
|
|
2348
|
-
},
|
|
2352
|
+
}, c = async () => {
|
|
2349
2353
|
Ht(process.cwd()), await Tt(process.cwd(), i, []), s.syncLocalEditorDataTemplates(i), s.syncLocalEditorTemplate(i);
|
|
2350
2354
|
}, p = () => {
|
|
2351
2355
|
Se(o), o = [];
|
|
@@ -2359,10 +2363,10 @@ const Tt = async (t, e, n) => {
|
|
|
2359
2363
|
})), {
|
|
2360
2364
|
name: "vite-plugin-yext-visual-editor",
|
|
2361
2365
|
async config(g, { command: y }) {
|
|
2362
|
-
e = y === "build", y === "serve" && t.localEditor?.enabled && (d(), a ? await
|
|
2366
|
+
e = y === "build", y === "serve" && t.localEditor?.enabled && (d(), a ? await c() : s.cleanupGeneratedLocalEditorArtifacts(), n = !0);
|
|
2363
2367
|
},
|
|
2364
2368
|
async buildStart() {
|
|
2365
|
-
n || d(), !e && t.localEditor?.enabled && !n && a ? await
|
|
2369
|
+
n || d(), !e && t.localEditor?.enabled && !n && a ? await c() : n || s.cleanupGeneratedLocalEditorArtifacts();
|
|
2366
2370
|
},
|
|
2367
2371
|
generateBundle() {
|
|
2368
2372
|
r && this.emitFile({
|