@uniformdev/transformer 1.1.25 → 1.1.26
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 +58 -14
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +57 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -619,6 +619,7 @@ var CompositionConverterService = class {
|
|
|
619
619
|
if (sourceItemMap.size > 0) {
|
|
620
620
|
this.logger.info(`Found ${sourceItemMap.size} existing entry(ies) with sourceItem values`);
|
|
621
621
|
}
|
|
622
|
+
const existingEntryMap = await this.buildEntryIdMap(entriesDirFull);
|
|
622
623
|
const compositionResults = await this.compositionService.findCompositionsByTypes(
|
|
623
624
|
compositionsDirFull,
|
|
624
625
|
compositionTypes,
|
|
@@ -723,7 +724,23 @@ var CompositionConverterService = class {
|
|
|
723
724
|
const compositionId = comp._id;
|
|
724
725
|
const compositionName = comp._name ?? compositionId;
|
|
725
726
|
const compositionType = comp.type;
|
|
726
|
-
const
|
|
727
|
+
const existingEntryPath = existingEntryMap.get(compositionId);
|
|
728
|
+
let entry;
|
|
729
|
+
let isExistingEntry = false;
|
|
730
|
+
if (existingEntryPath) {
|
|
731
|
+
const existingEntry = await this.fileSystem.readFile(existingEntryPath);
|
|
732
|
+
if (existingEntry?.entry) {
|
|
733
|
+
entry = existingEntry;
|
|
734
|
+
isExistingEntry = true;
|
|
735
|
+
this.logger.info(
|
|
736
|
+
`Found existing entry "${compositionId}" \u2014 merging references and blocks`
|
|
737
|
+
);
|
|
738
|
+
} else {
|
|
739
|
+
entry = this.generateEntryFromComposition(composition);
|
|
740
|
+
}
|
|
741
|
+
} else {
|
|
742
|
+
entry = this.generateEntryFromComposition(composition);
|
|
743
|
+
}
|
|
727
744
|
const refsByType = /* @__PURE__ */ new Map();
|
|
728
745
|
if (componentsToReferences.length > 0 && comp.slots) {
|
|
729
746
|
for (const refType of componentsToReferences) {
|
|
@@ -803,21 +820,33 @@ var CompositionConverterService = class {
|
|
|
803
820
|
blocksEmbedded += instances.length;
|
|
804
821
|
}
|
|
805
822
|
const entryId = entry.entry._id;
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
823
|
+
if (isExistingEntry) {
|
|
824
|
+
this.logger.action(
|
|
825
|
+
whatIf,
|
|
826
|
+
"UPDATE",
|
|
827
|
+
`${entriesDir}/${entryId}.json (${compositionType}, merged refs/blocks from "${this.truncate(compositionName, 50)}")`
|
|
828
|
+
);
|
|
829
|
+
if (!whatIf) {
|
|
830
|
+
await this.fileSystem.writeFile(existingEntryPath, entry);
|
|
831
|
+
}
|
|
832
|
+
entriesReused++;
|
|
833
|
+
} else {
|
|
834
|
+
const entryFilePath = this.fileSystem.joinPath(entriesDirFull, `${entryId}.json`);
|
|
835
|
+
this.logger.action(
|
|
836
|
+
whatIf,
|
|
837
|
+
"WRITE",
|
|
838
|
+
`${entriesDir}/${entryId}.json (${compositionType}, "${this.truncate(compositionName, 50)}")`
|
|
839
|
+
);
|
|
840
|
+
if (!whatIf) {
|
|
841
|
+
await this.fileSystem.writeFile(entryFilePath, entry);
|
|
842
|
+
}
|
|
843
|
+
entriesFromCompositions++;
|
|
814
844
|
}
|
|
815
|
-
entriesFromCompositions++;
|
|
816
845
|
for (const [refType, instances] of refsByType) {
|
|
817
846
|
for (const inst of instances) {
|
|
818
847
|
const existingId = this.findExistingEntryBySourceItem(inst, sourceItemMap);
|
|
819
848
|
if (existingId) {
|
|
820
|
-
const
|
|
849
|
+
const existingEntryPath2 = this.fileSystem.joinPath(
|
|
821
850
|
entriesDirFull,
|
|
822
851
|
`${existingId}.json`
|
|
823
852
|
);
|
|
@@ -827,14 +856,14 @@ var CompositionConverterService = class {
|
|
|
827
856
|
`${entriesDir}/${existingId}.json (${refType}, merged fields from "${this.truncate(compositionName, 50)}")`
|
|
828
857
|
);
|
|
829
858
|
if (!whatIf) {
|
|
830
|
-
const existingEntry = await this.fileSystem.readFile(
|
|
859
|
+
const existingEntry = await this.fileSystem.readFile(existingEntryPath2);
|
|
831
860
|
if (existingEntry?.entry) {
|
|
832
861
|
const instanceFields = inst.instance.parameters ?? {};
|
|
833
862
|
existingEntry.entry.fields = {
|
|
834
863
|
...existingEntry.entry.fields,
|
|
835
864
|
...instanceFields
|
|
836
865
|
};
|
|
837
|
-
await this.fileSystem.writeFile(
|
|
866
|
+
await this.fileSystem.writeFile(existingEntryPath2, existingEntry);
|
|
838
867
|
}
|
|
839
868
|
}
|
|
840
869
|
entriesReused++;
|
|
@@ -1090,6 +1119,21 @@ var CompositionConverterService = class {
|
|
|
1090
1119
|
}
|
|
1091
1120
|
}
|
|
1092
1121
|
// --- Source Item Matching ---
|
|
1122
|
+
async buildEntryIdMap(entriesDirFull) {
|
|
1123
|
+
const entryIdMap = /* @__PURE__ */ new Map();
|
|
1124
|
+
const entryFiles = await this.fileSystem.findFiles(entriesDirFull, "*.json");
|
|
1125
|
+
for (const filePath of entryFiles) {
|
|
1126
|
+
try {
|
|
1127
|
+
const entryData = await this.fileSystem.readFile(filePath);
|
|
1128
|
+
if (entryData?.entry?._id) {
|
|
1129
|
+
entryIdMap.set(entryData.entry._id, filePath);
|
|
1130
|
+
}
|
|
1131
|
+
} catch {
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
return entryIdMap;
|
|
1136
|
+
}
|
|
1093
1137
|
async buildSourceItemMap(entriesDirFull) {
|
|
1094
1138
|
const sourceItemMap = /* @__PURE__ */ new Map();
|
|
1095
1139
|
const entryFiles = await this.fileSystem.findFiles(entriesDirFull, "*.json");
|
|
@@ -4905,7 +4949,7 @@ function createRemoveFieldCommand() {
|
|
|
4905
4949
|
// package.json
|
|
4906
4950
|
var package_default = {
|
|
4907
4951
|
name: "@uniformdev/transformer",
|
|
4908
|
-
version: "1.1.
|
|
4952
|
+
version: "1.1.26",
|
|
4909
4953
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
4910
4954
|
type: "module",
|
|
4911
4955
|
bin: {
|