@uniformdev/transformer 1.1.20 → 1.1.22
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/cli/index.js +225 -63
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.js +208 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -195,19 +195,51 @@ var ComponentService = class {
|
|
|
195
195
|
sortComponentArrays(component) {
|
|
196
196
|
const result = { ...component };
|
|
197
197
|
if (result.parameters) {
|
|
198
|
-
result.parameters =
|
|
198
|
+
result.parameters = this.sortParametersByGroup(result.parameters);
|
|
199
199
|
}
|
|
200
200
|
if (result.slots) {
|
|
201
|
-
result.slots = [...result.slots].sort((a, b) => a.id.localeCompare(b.id)).map((slot) => {
|
|
201
|
+
result.slots = [...result.slots].sort((a, b) => a.id.localeCompare(b.id, void 0, { sensitivity: "base" })).map((slot) => {
|
|
202
202
|
if (slot.allowedComponents) {
|
|
203
|
-
return { ...slot, allowedComponents: [...slot.allowedComponents].sort((a, b) => a.localeCompare(b)) };
|
|
203
|
+
return { ...slot, allowedComponents: [...slot.allowedComponents].sort((a, b) => a.localeCompare(b, void 0, { sensitivity: "base" })) };
|
|
204
204
|
}
|
|
205
205
|
return slot;
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
const variants = result.variants;
|
|
209
209
|
if (Array.isArray(variants)) {
|
|
210
|
-
result.variants = [...variants].sort((a, b) => a.id.localeCompare(b.id));
|
|
210
|
+
result.variants = [...variants].sort((a, b) => a.id.localeCompare(b.id, void 0, { sensitivity: "base" }));
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
sortParametersByGroup(parameters) {
|
|
215
|
+
const compare = (a, b) => a.localeCompare(b, void 0, { sensitivity: "base" });
|
|
216
|
+
const groups = [];
|
|
217
|
+
const childToGroup = /* @__PURE__ */ new Set();
|
|
218
|
+
for (const param of parameters) {
|
|
219
|
+
if (param.type === "group") {
|
|
220
|
+
groups.push(param);
|
|
221
|
+
if (param.typeConfig?.childrenParams) {
|
|
222
|
+
param.typeConfig.childrenParams = [...param.typeConfig.childrenParams].sort(compare);
|
|
223
|
+
}
|
|
224
|
+
for (const childId of param.typeConfig?.childrenParams ?? []) {
|
|
225
|
+
childToGroup.add(childId.toLowerCase());
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const ungrouped = parameters.filter(
|
|
230
|
+
(p) => p.type !== "group" && !childToGroup.has(p.id.toLowerCase())
|
|
231
|
+
);
|
|
232
|
+
const sortedGroups = [...groups].sort((a, b) => compare(a.id, b.id));
|
|
233
|
+
const result = [];
|
|
234
|
+
result.push(...[...ungrouped].sort((a, b) => compare(a.id, b.id)));
|
|
235
|
+
for (const group of sortedGroups) {
|
|
236
|
+
result.push(group);
|
|
237
|
+
for (const childId of group.typeConfig?.childrenParams ?? []) {
|
|
238
|
+
const child = parameters.find((p) => p.id.toLowerCase() === childId.toLowerCase());
|
|
239
|
+
if (child) {
|
|
240
|
+
result.push(child);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
211
243
|
}
|
|
212
244
|
return result;
|
|
213
245
|
}
|
|
@@ -560,7 +592,8 @@ var CompositionConverterService = class {
|
|
|
560
592
|
contentTypesDir,
|
|
561
593
|
entriesDir,
|
|
562
594
|
compositionTypes,
|
|
563
|
-
|
|
595
|
+
componentsToReferences,
|
|
596
|
+
componentsToBlocks,
|
|
564
597
|
whatIf,
|
|
565
598
|
strict
|
|
566
599
|
} = options;
|
|
@@ -570,13 +603,17 @@ var CompositionConverterService = class {
|
|
|
570
603
|
const entriesDirFull = this.fileSystem.resolvePath(rootDir, entriesDir);
|
|
571
604
|
let contentTypesWritten = 0;
|
|
572
605
|
let entriesFromCompositions = 0;
|
|
573
|
-
let
|
|
606
|
+
let entriesFromReferences = 0;
|
|
574
607
|
let entriesReused = 0;
|
|
608
|
+
let blocksEmbedded = 0;
|
|
575
609
|
this.logger.info(`Composition types: ${compositionTypes.join(", ")}`);
|
|
576
|
-
if (
|
|
577
|
-
this.logger.info(`
|
|
610
|
+
if (componentsToReferences.length > 0) {
|
|
611
|
+
this.logger.info(`Components to references: ${componentsToReferences.join(", ")}`);
|
|
612
|
+
}
|
|
613
|
+
if (componentsToBlocks.length > 0) {
|
|
614
|
+
this.logger.info(`Components to blocks: ${componentsToBlocks.join(", ")}`);
|
|
578
615
|
}
|
|
579
|
-
const sourceItemMap =
|
|
616
|
+
const sourceItemMap = componentsToReferences.length > 0 ? await this.buildSourceItemMap(entriesDirFull) : /* @__PURE__ */ new Map();
|
|
580
617
|
if (sourceItemMap.size > 0) {
|
|
581
618
|
this.logger.info(`Found ${sourceItemMap.size} existing entry(ies) with sourceItem values`);
|
|
582
619
|
}
|
|
@@ -587,7 +624,7 @@ var CompositionConverterService = class {
|
|
|
587
624
|
);
|
|
588
625
|
if (compositionResults.length === 0) {
|
|
589
626
|
this.logger.warn("No compositions found matching the specified types");
|
|
590
|
-
return { contentTypesWritten: 0, entriesFromCompositions: 0,
|
|
627
|
+
return { contentTypesWritten: 0, entriesFromCompositions: 0, entriesFromReferences: 0, entriesReused: 0, blocksEmbedded: 0 };
|
|
591
628
|
}
|
|
592
629
|
this.logger.info(`Found ${compositionResults.length} composition(s)`);
|
|
593
630
|
const rootComponentTypes = /* @__PURE__ */ new Set();
|
|
@@ -604,28 +641,76 @@ var CompositionConverterService = class {
|
|
|
604
641
|
const contentType = this.generateContentType(component);
|
|
605
642
|
contentTypeMap.set(rootType, contentType);
|
|
606
643
|
}
|
|
607
|
-
const
|
|
608
|
-
const
|
|
609
|
-
const
|
|
610
|
-
|
|
644
|
+
const allTargetTypes = [.../* @__PURE__ */ new Set([...componentsToReferences, ...componentsToBlocks])];
|
|
645
|
+
const targetContentTypeMap = /* @__PURE__ */ new Map();
|
|
646
|
+
const missingTargetTypes = [];
|
|
647
|
+
const foundMissingTargetTypes = /* @__PURE__ */ new Set();
|
|
648
|
+
const blockTypeIdMap = /* @__PURE__ */ new Map();
|
|
649
|
+
for (const targetType of allTargetTypes) {
|
|
611
650
|
const isRootType = [...rootComponentTypes].some(
|
|
612
|
-
(rt) => this.compareTypes(rt,
|
|
651
|
+
(rt) => this.compareTypes(rt, targetType, strict)
|
|
613
652
|
);
|
|
614
653
|
if (isRootType) {
|
|
615
654
|
continue;
|
|
616
655
|
}
|
|
656
|
+
const isBlockType = componentsToBlocks.some(
|
|
657
|
+
(bt) => this.compareTypes(bt, targetType, strict)
|
|
658
|
+
);
|
|
659
|
+
const isRefType = componentsToReferences.some(
|
|
660
|
+
(rt) => this.compareTypes(rt, targetType, strict)
|
|
661
|
+
);
|
|
617
662
|
try {
|
|
618
663
|
const { component } = await this.componentService.loadComponent(
|
|
619
664
|
componentsDirFull,
|
|
620
|
-
|
|
665
|
+
targetType,
|
|
621
666
|
{ strict }
|
|
622
667
|
);
|
|
623
|
-
|
|
624
|
-
|
|
668
|
+
if (isRefType) {
|
|
669
|
+
const contentType = this.generateContentType(component);
|
|
670
|
+
targetContentTypeMap.set(targetType, contentType);
|
|
671
|
+
}
|
|
672
|
+
if (isBlockType) {
|
|
673
|
+
let blockId = targetType;
|
|
674
|
+
let needsRename = false;
|
|
675
|
+
if (isRefType) {
|
|
676
|
+
needsRename = true;
|
|
677
|
+
}
|
|
678
|
+
if (!needsRename) {
|
|
679
|
+
const existingPath = this.fileSystem.joinPath(contentTypesDirFull, `${targetType}.json`);
|
|
680
|
+
if (await this.fileSystem.fileExists(existingPath)) {
|
|
681
|
+
try {
|
|
682
|
+
const existing = await this.fileSystem.readFile(existingPath);
|
|
683
|
+
if (existing?.type !== "block") {
|
|
684
|
+
needsRename = true;
|
|
685
|
+
}
|
|
686
|
+
} catch {
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (needsRename) {
|
|
691
|
+
blockId = `${targetType}Block`;
|
|
692
|
+
this.logger.info(`Content type "${targetType}" already exists as non-block, using "${blockId}" for block`);
|
|
693
|
+
}
|
|
694
|
+
blockTypeIdMap.set(targetType, blockId);
|
|
695
|
+
const blockContentType = this.generateContentType(component);
|
|
696
|
+
blockContentType.type = "block";
|
|
697
|
+
blockContentType.id = blockId;
|
|
698
|
+
blockContentType.name = needsRename ? `${blockContentType.name} Block` : blockContentType.name;
|
|
699
|
+
targetContentTypeMap.set(blockId, blockContentType);
|
|
700
|
+
}
|
|
701
|
+
if (!isBlockType) {
|
|
702
|
+
if (!isRefType) {
|
|
703
|
+
const contentType = this.generateContentType(component);
|
|
704
|
+
targetContentTypeMap.set(targetType, contentType);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
625
707
|
} catch (error) {
|
|
626
708
|
if (error instanceof ComponentNotFoundError) {
|
|
627
|
-
this.logger.info(`
|
|
628
|
-
|
|
709
|
+
this.logger.info(`Component type not found: ${targetType}`);
|
|
710
|
+
missingTargetTypes.push(targetType);
|
|
711
|
+
if (isBlockType) {
|
|
712
|
+
blockTypeIdMap.set(targetType, targetType);
|
|
713
|
+
}
|
|
629
714
|
continue;
|
|
630
715
|
}
|
|
631
716
|
throw error;
|
|
@@ -637,48 +722,84 @@ var CompositionConverterService = class {
|
|
|
637
722
|
const compositionName = comp._name ?? compositionId;
|
|
638
723
|
const compositionType = comp.type;
|
|
639
724
|
const entry = this.generateEntryFromComposition(composition);
|
|
640
|
-
const
|
|
641
|
-
if (
|
|
642
|
-
for (const
|
|
643
|
-
if (this.compareTypes(
|
|
725
|
+
const refsByType = /* @__PURE__ */ new Map();
|
|
726
|
+
if (componentsToReferences.length > 0 && comp.slots) {
|
|
727
|
+
for (const refType of componentsToReferences) {
|
|
728
|
+
if (this.compareTypes(refType, compositionType, strict)) {
|
|
644
729
|
this.logger.warn(
|
|
645
|
-
`Skipping
|
|
730
|
+
`Skipping reference of "${refType}" \u2014 same as root component type`
|
|
646
731
|
);
|
|
647
732
|
continue;
|
|
648
733
|
}
|
|
649
734
|
const instances = this.findFlattenTargets(
|
|
650
735
|
comp.slots,
|
|
651
|
-
|
|
736
|
+
refType,
|
|
652
737
|
compositionId,
|
|
653
738
|
compositionName,
|
|
654
739
|
strict
|
|
655
740
|
);
|
|
656
741
|
if (instances.length > 0) {
|
|
657
|
-
|
|
658
|
-
if (
|
|
659
|
-
|
|
742
|
+
refsByType.set(refType, instances);
|
|
743
|
+
if (missingTargetTypes.includes(refType)) {
|
|
744
|
+
foundMissingTargetTypes.add(refType);
|
|
660
745
|
}
|
|
661
746
|
}
|
|
662
747
|
}
|
|
663
748
|
}
|
|
664
749
|
const resolvedRefIds = /* @__PURE__ */ new Map();
|
|
665
|
-
for (const [
|
|
750
|
+
for (const [refType, instances] of refsByType) {
|
|
666
751
|
const refIds = [];
|
|
667
752
|
for (const inst of instances) {
|
|
668
753
|
const existingId = this.findExistingEntryBySourceItem(inst, sourceItemMap);
|
|
669
754
|
refIds.push(existingId ?? inst.determinisiticId);
|
|
670
755
|
}
|
|
671
|
-
resolvedRefIds.set(
|
|
756
|
+
resolvedRefIds.set(refType, refIds);
|
|
672
757
|
}
|
|
673
|
-
for (const [
|
|
674
|
-
entry.entry.fields[
|
|
758
|
+
for (const [refType] of refsByType) {
|
|
759
|
+
entry.entry.fields[refType] = {
|
|
675
760
|
type: "contentReference",
|
|
676
|
-
value: resolvedRefIds.get(
|
|
761
|
+
value: resolvedRefIds.get(refType)
|
|
677
762
|
};
|
|
678
763
|
}
|
|
679
|
-
if (
|
|
764
|
+
if (componentsToReferences.length > 0) {
|
|
680
765
|
this.transformContentReferences(entry);
|
|
681
766
|
}
|
|
767
|
+
const blocksByType = /* @__PURE__ */ new Map();
|
|
768
|
+
if (componentsToBlocks.length > 0 && comp.slots) {
|
|
769
|
+
for (const blockType of componentsToBlocks) {
|
|
770
|
+
if (this.compareTypes(blockType, compositionType, strict)) {
|
|
771
|
+
this.logger.warn(
|
|
772
|
+
`Skipping block of "${blockType}" \u2014 same as root component type`
|
|
773
|
+
);
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
const instances = this.findFlattenTargets(
|
|
777
|
+
comp.slots,
|
|
778
|
+
blockType,
|
|
779
|
+
compositionId,
|
|
780
|
+
compositionName,
|
|
781
|
+
strict
|
|
782
|
+
);
|
|
783
|
+
if (instances.length > 0) {
|
|
784
|
+
blocksByType.set(blockType, instances);
|
|
785
|
+
if (missingTargetTypes.includes(blockType)) {
|
|
786
|
+
foundMissingTargetTypes.add(blockType);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
for (const [blockType, instances] of blocksByType) {
|
|
792
|
+
const resolvedBlockId = blockTypeIdMap.get(blockType) ?? blockType;
|
|
793
|
+
const blockValues = instances.map((inst) => ({
|
|
794
|
+
type: resolvedBlockId,
|
|
795
|
+
fields: { ...inst.instance.parameters ?? {} }
|
|
796
|
+
}));
|
|
797
|
+
entry.entry.fields[resolvedBlockId] = {
|
|
798
|
+
type: "$block",
|
|
799
|
+
value: blockValues
|
|
800
|
+
};
|
|
801
|
+
blocksEmbedded += instances.length;
|
|
802
|
+
}
|
|
682
803
|
const entryId = entry.entry._id;
|
|
683
804
|
const entryFilePath = this.fileSystem.joinPath(entriesDirFull, `${entryId}.json`);
|
|
684
805
|
this.logger.action(
|
|
@@ -690,7 +811,7 @@ var CompositionConverterService = class {
|
|
|
690
811
|
await this.fileSystem.writeFile(entryFilePath, entry);
|
|
691
812
|
}
|
|
692
813
|
entriesFromCompositions++;
|
|
693
|
-
for (const [
|
|
814
|
+
for (const [refType, instances] of refsByType) {
|
|
694
815
|
for (const inst of instances) {
|
|
695
816
|
const existingId = this.findExistingEntryBySourceItem(inst, sourceItemMap);
|
|
696
817
|
if (existingId) {
|
|
@@ -701,7 +822,7 @@ var CompositionConverterService = class {
|
|
|
701
822
|
this.logger.action(
|
|
702
823
|
whatIf,
|
|
703
824
|
"UPDATE",
|
|
704
|
-
`${entriesDir}/${existingId}.json (${
|
|
825
|
+
`${entriesDir}/${existingId}.json (${refType}, merged fields from "${this.truncate(compositionName, 50)}")`
|
|
705
826
|
);
|
|
706
827
|
if (!whatIf) {
|
|
707
828
|
const existingEntry = await this.fileSystem.readFile(existingEntryPath);
|
|
@@ -725,53 +846,86 @@ var CompositionConverterService = class {
|
|
|
725
846
|
this.logger.action(
|
|
726
847
|
whatIf,
|
|
727
848
|
"WRITE",
|
|
728
|
-
`${entriesDir}/${inst.determinisiticId}.json (${
|
|
849
|
+
`${entriesDir}/${inst.determinisiticId}.json (${refType} from "${this.truncate(compositionName, 50)}")`
|
|
729
850
|
);
|
|
730
851
|
if (!whatIf) {
|
|
731
852
|
await this.fileSystem.writeFile(flatEntryPath, flatEntry);
|
|
732
853
|
}
|
|
733
|
-
|
|
854
|
+
entriesFromReferences++;
|
|
734
855
|
}
|
|
735
856
|
}
|
|
736
857
|
}
|
|
737
|
-
if (
|
|
858
|
+
if (componentsToReferences.length > 0) {
|
|
738
859
|
for (const contentType of contentTypeMap.values()) {
|
|
739
|
-
for (const
|
|
740
|
-
if (this.compareTypes(
|
|
860
|
+
for (const refType of componentsToReferences) {
|
|
861
|
+
if (this.compareTypes(refType, contentType.id, strict)) {
|
|
741
862
|
continue;
|
|
742
863
|
}
|
|
743
|
-
if (
|
|
864
|
+
if (missingTargetTypes.includes(refType) && !foundMissingTargetTypes.has(refType)) {
|
|
744
865
|
continue;
|
|
745
866
|
}
|
|
746
867
|
contentType.fields.push({
|
|
747
|
-
id:
|
|
748
|
-
name:
|
|
868
|
+
id: refType,
|
|
869
|
+
name: refType,
|
|
749
870
|
type: "contentReference",
|
|
750
871
|
typeConfig: {
|
|
751
872
|
isMulti: true,
|
|
752
|
-
allowedContentTypes: [
|
|
873
|
+
allowedContentTypes: [refType]
|
|
753
874
|
},
|
|
754
875
|
localizable: false
|
|
755
876
|
});
|
|
756
877
|
}
|
|
757
878
|
}
|
|
758
879
|
}
|
|
880
|
+
if (componentsToBlocks.length > 0) {
|
|
881
|
+
for (const contentType of contentTypeMap.values()) {
|
|
882
|
+
for (const blockType of componentsToBlocks) {
|
|
883
|
+
if (this.compareTypes(blockType, contentType.id, strict)) {
|
|
884
|
+
continue;
|
|
885
|
+
}
|
|
886
|
+
if (missingTargetTypes.includes(blockType) && !foundMissingTargetTypes.has(blockType)) {
|
|
887
|
+
continue;
|
|
888
|
+
}
|
|
889
|
+
const resolvedBlockId = blockTypeIdMap.get(blockType) ?? blockType;
|
|
890
|
+
contentType.fields.push({
|
|
891
|
+
id: resolvedBlockId,
|
|
892
|
+
name: resolvedBlockId,
|
|
893
|
+
type: "$block",
|
|
894
|
+
typeConfig: {
|
|
895
|
+
allowedContentTypes: [resolvedBlockId]
|
|
896
|
+
},
|
|
897
|
+
localizable: false
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
for (const contentType of contentTypeMap.values()) {
|
|
903
|
+
contentType.fields = this.componentService.sortParametersByGroup(contentType.fields);
|
|
904
|
+
}
|
|
905
|
+
for (const contentType of targetContentTypeMap.values()) {
|
|
906
|
+
contentType.fields = this.componentService.sortParametersByGroup(contentType.fields);
|
|
907
|
+
}
|
|
759
908
|
for (const [typeName, contentType] of contentTypeMap) {
|
|
760
909
|
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
761
|
-
const
|
|
910
|
+
const baseFieldCount = contentType.fields.filter((f) => f.type !== "contentReference" && f.type !== "$block").length;
|
|
762
911
|
const refCount = contentType.fields.filter((f) => f.type === "contentReference").length;
|
|
763
|
-
const
|
|
912
|
+
const blockCount = contentType.fields.filter((f) => f.type === "$block").length;
|
|
913
|
+
const extras = [
|
|
914
|
+
refCount > 0 ? `${refCount} reference(s)` : "",
|
|
915
|
+
blockCount > 0 ? `${blockCount} block(s)` : ""
|
|
916
|
+
].filter(Boolean).join(", ");
|
|
917
|
+
const extrasInfo = extras ? ` + ${extras}` : "";
|
|
764
918
|
this.logger.action(
|
|
765
919
|
whatIf,
|
|
766
920
|
"WRITE",
|
|
767
|
-
`${contentTypesDir}/${typeName}.json (${
|
|
921
|
+
`${contentTypesDir}/${typeName}.json (${baseFieldCount} fields${extrasInfo})`
|
|
768
922
|
);
|
|
769
923
|
if (!whatIf) {
|
|
770
924
|
await this.fileSystem.writeFile(filePath, contentType);
|
|
771
925
|
}
|
|
772
926
|
contentTypesWritten++;
|
|
773
927
|
}
|
|
774
|
-
for (const [typeName, contentType] of
|
|
928
|
+
for (const [typeName, contentType] of targetContentTypeMap) {
|
|
775
929
|
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
776
930
|
this.logger.action(
|
|
777
931
|
whatIf,
|
|
@@ -783,15 +937,15 @@ var CompositionConverterService = class {
|
|
|
783
937
|
}
|
|
784
938
|
contentTypesWritten++;
|
|
785
939
|
}
|
|
786
|
-
const neverFoundMissingTypes =
|
|
787
|
-
(type) => !
|
|
940
|
+
const neverFoundMissingTypes = missingTargetTypes.filter(
|
|
941
|
+
(type) => !foundMissingTargetTypes.has(type)
|
|
788
942
|
);
|
|
789
943
|
if (neverFoundMissingTypes.length > 0) {
|
|
790
944
|
this.logger.warn(
|
|
791
|
-
`
|
|
945
|
+
`Component type(s) not found in any composition: ${neverFoundMissingTypes.join(", ")}`
|
|
792
946
|
);
|
|
793
947
|
}
|
|
794
|
-
return { contentTypesWritten, entriesFromCompositions,
|
|
948
|
+
return { contentTypesWritten, entriesFromCompositions, entriesFromReferences, entriesReused, blocksEmbedded };
|
|
795
949
|
}
|
|
796
950
|
// --- Content Type Generation ---
|
|
797
951
|
generateContentType(component) {
|
|
@@ -4136,13 +4290,16 @@ import { Command as Command10 } from "commander";
|
|
|
4136
4290
|
function createConvertCompositionsToEntriesCommand() {
|
|
4137
4291
|
const command = new Command10("convert-compositions-to-entries");
|
|
4138
4292
|
command.description(
|
|
4139
|
-
"Converts compositions into content entries, optionally
|
|
4293
|
+
"Converts compositions into content entries, optionally converting nested components into references or blocks."
|
|
4140
4294
|
).option(
|
|
4141
4295
|
"--compositionTypes <types>",
|
|
4142
4296
|
"Pipe-separated list of composition types to convert (e.g., ProductDetailPage|ArticlePage)"
|
|
4143
4297
|
).option(
|
|
4144
|
-
"--
|
|
4145
|
-
"Pipe-separated list of component types to
|
|
4298
|
+
"--componentsToReferences <types>",
|
|
4299
|
+
"Pipe-separated list of component types to convert into separate referenced entries (e.g., DetailHero|ArticleDetail)"
|
|
4300
|
+
).option(
|
|
4301
|
+
"--componentsToBlocks <types>",
|
|
4302
|
+
"Pipe-separated list of component types to convert into inline blocks (e.g., DetailHero|ArticleDetail)"
|
|
4146
4303
|
).hook("preAction", (thisCommand) => {
|
|
4147
4304
|
const opts = thisCommand.opts();
|
|
4148
4305
|
const requiredOptions = [
|
|
@@ -4158,7 +4315,8 @@ function createConvertCompositionsToEntriesCommand() {
|
|
|
4158
4315
|
const options = {
|
|
4159
4316
|
...globalOpts,
|
|
4160
4317
|
compositionTypes: opts.compositionTypes,
|
|
4161
|
-
|
|
4318
|
+
componentsToReferences: opts.componentsToReferences,
|
|
4319
|
+
componentsToBlocks: opts.componentsToBlocks
|
|
4162
4320
|
};
|
|
4163
4321
|
const logger = new Logger();
|
|
4164
4322
|
const fileSystem = new FileSystemService();
|
|
@@ -4172,7 +4330,9 @@ function createConvertCompositionsToEntriesCommand() {
|
|
|
4172
4330
|
);
|
|
4173
4331
|
try {
|
|
4174
4332
|
const compositionTypes = options.compositionTypes.split("|").map((t) => t.trim()).filter((t) => t.length > 0);
|
|
4175
|
-
const
|
|
4333
|
+
const parsePipeSeparated = (value) => value ? value.split("|").map((t) => t.trim()).filter((t) => t.length > 0) : [];
|
|
4334
|
+
const componentsToReferences = parsePipeSeparated(options.componentsToReferences);
|
|
4335
|
+
const componentsToBlocks = parsePipeSeparated(options.componentsToBlocks);
|
|
4176
4336
|
const result = await converter.convert({
|
|
4177
4337
|
rootDir: options.rootDir,
|
|
4178
4338
|
compositionsDir: options.compositionsDir,
|
|
@@ -4180,14 +4340,16 @@ function createConvertCompositionsToEntriesCommand() {
|
|
|
4180
4340
|
contentTypesDir: options.contentTypesDir,
|
|
4181
4341
|
entriesDir: options.entriesDir,
|
|
4182
4342
|
compositionTypes,
|
|
4183
|
-
|
|
4343
|
+
componentsToReferences,
|
|
4344
|
+
componentsToBlocks,
|
|
4184
4345
|
whatIf: options.whatIf ?? false,
|
|
4185
4346
|
strict: options.strict ?? false
|
|
4186
4347
|
});
|
|
4187
|
-
const
|
|
4348
|
+
const refInfo = result.entriesFromReferences > 0 ? `, ${result.entriesFromReferences} from references` : "";
|
|
4188
4349
|
const reusedInfo = result.entriesReused > 0 ? `, ${result.entriesReused} reused existing` : "";
|
|
4350
|
+
const blocksInfo = result.blocksEmbedded > 0 ? `, ${result.blocksEmbedded} block(s) embedded` : "";
|
|
4189
4351
|
logger.success(
|
|
4190
|
-
`${result.contentTypesWritten} content type(s), ${result.entriesFromCompositions} entry(ies) from compositions${
|
|
4352
|
+
`${result.contentTypesWritten} content type(s), ${result.entriesFromCompositions} entry(ies) from compositions${refInfo}${reusedInfo}${blocksInfo}`
|
|
4191
4353
|
);
|
|
4192
4354
|
} catch (error) {
|
|
4193
4355
|
if (error instanceof TransformError) {
|
|
@@ -4741,7 +4903,7 @@ function createRemoveFieldCommand() {
|
|
|
4741
4903
|
// package.json
|
|
4742
4904
|
var package_default = {
|
|
4743
4905
|
name: "@uniformdev/transformer",
|
|
4744
|
-
version: "1.1.
|
|
4906
|
+
version: "1.1.22",
|
|
4745
4907
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
4746
4908
|
type: "module",
|
|
4747
4909
|
bin: {
|