@uniformdev/transformer 1.1.18 → 1.1.20
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 +42 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +41 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -189,7 +189,27 @@ var ComponentService = class {
|
|
|
189
189
|
throw new ComponentNotFoundError(componentType, componentsDir);
|
|
190
190
|
}
|
|
191
191
|
async saveComponent(filePath, component) {
|
|
192
|
-
|
|
192
|
+
const sorted = this.sortComponentArrays(component);
|
|
193
|
+
await this.fileSystem.writeFile(filePath, sorted);
|
|
194
|
+
}
|
|
195
|
+
sortComponentArrays(component) {
|
|
196
|
+
const result = { ...component };
|
|
197
|
+
if (result.parameters) {
|
|
198
|
+
result.parameters = [...result.parameters].sort((a, b) => a.id.localeCompare(b.id));
|
|
199
|
+
}
|
|
200
|
+
if (result.slots) {
|
|
201
|
+
result.slots = [...result.slots].sort((a, b) => a.id.localeCompare(b.id)).map((slot) => {
|
|
202
|
+
if (slot.allowedComponents) {
|
|
203
|
+
return { ...slot, allowedComponents: [...slot.allowedComponents].sort((a, b) => a.localeCompare(b)) };
|
|
204
|
+
}
|
|
205
|
+
return slot;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
const variants = result.variants;
|
|
209
|
+
if (Array.isArray(variants)) {
|
|
210
|
+
result.variants = [...variants].sort((a, b) => a.id.localeCompare(b.id));
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
193
213
|
}
|
|
194
214
|
findParameter(component, parameterName, options = {}) {
|
|
195
215
|
const { strict = false } = options;
|
|
@@ -674,9 +694,26 @@ var CompositionConverterService = class {
|
|
|
674
694
|
for (const inst of instances) {
|
|
675
695
|
const existingId = this.findExistingEntryBySourceItem(inst, sourceItemMap);
|
|
676
696
|
if (existingId) {
|
|
677
|
-
this.
|
|
678
|
-
|
|
697
|
+
const existingEntryPath = this.fileSystem.joinPath(
|
|
698
|
+
entriesDirFull,
|
|
699
|
+
`${existingId}.json`
|
|
700
|
+
);
|
|
701
|
+
this.logger.action(
|
|
702
|
+
whatIf,
|
|
703
|
+
"UPDATE",
|
|
704
|
+
`${entriesDir}/${existingId}.json (${flattenType}, merged fields from "${this.truncate(compositionName, 50)}")`
|
|
679
705
|
);
|
|
706
|
+
if (!whatIf) {
|
|
707
|
+
const existingEntry = await this.fileSystem.readFile(existingEntryPath);
|
|
708
|
+
if (existingEntry?.entry) {
|
|
709
|
+
const instanceFields = inst.instance.parameters ?? {};
|
|
710
|
+
existingEntry.entry.fields = {
|
|
711
|
+
...existingEntry.entry.fields,
|
|
712
|
+
...instanceFields
|
|
713
|
+
};
|
|
714
|
+
await this.fileSystem.writeFile(existingEntryPath, existingEntry);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
680
717
|
entriesReused++;
|
|
681
718
|
continue;
|
|
682
719
|
}
|
|
@@ -1004,7 +1041,7 @@ function walkAndRegenerate(value, currentPath) {
|
|
|
1004
1041
|
for (const [key, val] of Object.entries(obj)) {
|
|
1005
1042
|
const childPath = `${currentPath}.${key}`;
|
|
1006
1043
|
if (key === "_id" && typeof val === "string" && UUID_PATTERN.test(val)) {
|
|
1007
|
-
result[key] = computeGuidHash(
|
|
1044
|
+
result[key] = computeGuidHash(childPath);
|
|
1008
1045
|
} else {
|
|
1009
1046
|
result[key] = walkAndRegenerate(val, childPath);
|
|
1010
1047
|
}
|
|
@@ -4704,7 +4741,7 @@ function createRemoveFieldCommand() {
|
|
|
4704
4741
|
// package.json
|
|
4705
4742
|
var package_default = {
|
|
4706
4743
|
name: "@uniformdev/transformer",
|
|
4707
|
-
version: "1.1.
|
|
4744
|
+
version: "1.1.20",
|
|
4708
4745
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
4709
4746
|
type: "module",
|
|
4710
4747
|
bin: {
|