@uniformdev/transformer 1.1.20 → 1.1.21
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 +43 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +42 -4
- 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
|
}
|
|
@@ -756,6 +788,12 @@ var CompositionConverterService = class {
|
|
|
756
788
|
}
|
|
757
789
|
}
|
|
758
790
|
}
|
|
791
|
+
for (const contentType of contentTypeMap.values()) {
|
|
792
|
+
contentType.fields = this.componentService.sortParametersByGroup(contentType.fields);
|
|
793
|
+
}
|
|
794
|
+
for (const contentType of flattenContentTypeMap.values()) {
|
|
795
|
+
contentType.fields = this.componentService.sortParametersByGroup(contentType.fields);
|
|
796
|
+
}
|
|
759
797
|
for (const [typeName, contentType] of contentTypeMap) {
|
|
760
798
|
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
761
799
|
const fieldCount = contentType.fields.filter((f) => f.type !== "contentReference").length;
|
|
@@ -4741,7 +4779,7 @@ function createRemoveFieldCommand() {
|
|
|
4741
4779
|
// package.json
|
|
4742
4780
|
var package_default = {
|
|
4743
4781
|
name: "@uniformdev/transformer",
|
|
4744
|
-
version: "1.1.
|
|
4782
|
+
version: "1.1.21",
|
|
4745
4783
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
4746
4784
|
type: "module",
|
|
4747
4785
|
bin: {
|