@uniformdev/transformer 1.1.54 → 1.1.56
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 +75 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +73 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -70,6 +70,14 @@ var SlotAlreadyExistsError = class extends TransformError {
|
|
|
70
70
|
this.name = "SlotAlreadyExistsError";
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
+
var ContentTypeFieldConflictError = class extends TransformError {
|
|
74
|
+
constructor(contentTypeId, fieldId, existingType, newType) {
|
|
75
|
+
super(
|
|
76
|
+
`Content type "${contentTypeId}" field "${fieldId}" type conflict: existing type "${existingType}" differs from generated type "${newType}"`
|
|
77
|
+
);
|
|
78
|
+
this.name = "ContentTypeFieldConflictError";
|
|
79
|
+
}
|
|
80
|
+
};
|
|
73
81
|
|
|
74
82
|
// src/core/services/file-system.service.ts
|
|
75
83
|
var FileSystemService = class {
|
|
@@ -621,6 +629,7 @@ var CompositionConverterService = class {
|
|
|
621
629
|
const contentTypesDirFull = this.fileSystem.resolvePath(rootDir, contentTypesDir);
|
|
622
630
|
const entriesDirFull = this.fileSystem.resolvePath(rootDir, entriesDir);
|
|
623
631
|
let contentTypesWritten = 0;
|
|
632
|
+
let contentTypesMerged = 0;
|
|
624
633
|
let entriesFromCompositions = 0;
|
|
625
634
|
let entriesFromReferences = 0;
|
|
626
635
|
let entriesReused = 0;
|
|
@@ -650,7 +659,7 @@ var CompositionConverterService = class {
|
|
|
650
659
|
);
|
|
651
660
|
if (compositionResults.length === 0) {
|
|
652
661
|
this.logger.warn("No compositions found matching the specified types");
|
|
653
|
-
return { contentTypesWritten: 0, entriesFromCompositions: 0, entriesFromReferences: 0, entriesReused: 0, blocksEmbedded: 0 };
|
|
662
|
+
return { contentTypesWritten: 0, contentTypesMerged: 0, entriesFromCompositions: 0, entriesFromReferences: 0, entriesReused: 0, blocksEmbedded: 0 };
|
|
654
663
|
}
|
|
655
664
|
this.logger.info(`Found ${compositionResults.length} composition(s)`);
|
|
656
665
|
const componentsToReferences = this.expandWildcardTypes(compositionResults, initialComponentsToReferences, strict);
|
|
@@ -1164,37 +1173,49 @@ var CompositionConverterService = class {
|
|
|
1164
1173
|
}
|
|
1165
1174
|
for (const [typeName, contentType] of contentTypeMap) {
|
|
1166
1175
|
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
1167
|
-
const
|
|
1168
|
-
const
|
|
1169
|
-
const
|
|
1176
|
+
const merged = await this.mergeWithExistingContentType(filePath, contentType);
|
|
1177
|
+
const baseFieldCount = merged.fields.filter((f) => f.type !== "contentReference" && f.type !== "$block").length;
|
|
1178
|
+
const refCount = merged.fields.filter((f) => f.type === "contentReference").length;
|
|
1179
|
+
const blockCount = merged.fields.filter((f) => f.type === "$block").length;
|
|
1170
1180
|
const extras = [
|
|
1171
1181
|
refCount > 0 ? `${refCount} reference(s)` : "",
|
|
1172
1182
|
blockCount > 0 ? `${blockCount} block(s)` : ""
|
|
1173
1183
|
].filter(Boolean).join(", ");
|
|
1174
1184
|
const extrasInfo = extras ? ` + ${extras}` : "";
|
|
1185
|
+
const isMerged = merged !== contentType;
|
|
1175
1186
|
this.logger.action(
|
|
1176
1187
|
whatIf,
|
|
1177
|
-
"WRITE",
|
|
1188
|
+
isMerged ? "MERGE" : "WRITE",
|
|
1178
1189
|
`${contentTypesDir}/${typeName}.json (${baseFieldCount} fields${extrasInfo})`
|
|
1179
1190
|
);
|
|
1180
|
-
this.logger.debug(`Content type "${typeName}" fields: ${
|
|
1191
|
+
this.logger.debug(`Content type "${typeName}" fields: ${merged.fields.map((f) => `${f.id}:${f.type}`).join(", ")}`);
|
|
1181
1192
|
if (!whatIf) {
|
|
1182
|
-
await this.fileSystem.writeFile(filePath,
|
|
1193
|
+
await this.fileSystem.writeFile(filePath, merged);
|
|
1194
|
+
}
|
|
1195
|
+
if (isMerged) {
|
|
1196
|
+
contentTypesMerged++;
|
|
1197
|
+
} else {
|
|
1198
|
+
contentTypesWritten++;
|
|
1183
1199
|
}
|
|
1184
|
-
contentTypesWritten++;
|
|
1185
1200
|
}
|
|
1186
1201
|
for (const [typeName, contentType] of targetContentTypeMap) {
|
|
1187
1202
|
const filePath = this.fileSystem.joinPath(contentTypesDirFull, `${typeName}.json`);
|
|
1203
|
+
const merged = await this.mergeWithExistingContentType(filePath, contentType);
|
|
1204
|
+
const isMerged = merged !== contentType;
|
|
1188
1205
|
this.logger.action(
|
|
1189
1206
|
whatIf,
|
|
1190
|
-
"WRITE",
|
|
1191
|
-
`${contentTypesDir}/${typeName}.json (${
|
|
1207
|
+
isMerged ? "MERGE" : "WRITE",
|
|
1208
|
+
`${contentTypesDir}/${typeName}.json (${merged.fields.length} fields)`
|
|
1192
1209
|
);
|
|
1193
|
-
this.logger.debug(`Content type "${typeName}" fields: ${
|
|
1210
|
+
this.logger.debug(`Content type "${typeName}" fields: ${merged.fields.map((f) => `${f.id}:${f.type}`).join(", ")}`);
|
|
1194
1211
|
if (!whatIf) {
|
|
1195
|
-
await this.fileSystem.writeFile(filePath,
|
|
1212
|
+
await this.fileSystem.writeFile(filePath, merged);
|
|
1213
|
+
}
|
|
1214
|
+
if (isMerged) {
|
|
1215
|
+
contentTypesMerged++;
|
|
1216
|
+
} else {
|
|
1217
|
+
contentTypesWritten++;
|
|
1196
1218
|
}
|
|
1197
|
-
contentTypesWritten++;
|
|
1198
1219
|
}
|
|
1199
1220
|
const neverFoundMissingTypes = missingTargetTypes.filter(
|
|
1200
1221
|
(type) => !foundMissingTargetTypes.has(type)
|
|
@@ -1204,7 +1225,7 @@ var CompositionConverterService = class {
|
|
|
1204
1225
|
`Component type(s) not found in any composition: ${neverFoundMissingTypes.join(", ")}`
|
|
1205
1226
|
);
|
|
1206
1227
|
}
|
|
1207
|
-
return { contentTypesWritten, entriesFromCompositions, entriesFromReferences, entriesReused, blocksEmbedded };
|
|
1228
|
+
return { contentTypesWritten, contentTypesMerged, entriesFromCompositions, entriesFromReferences, entriesReused, blocksEmbedded };
|
|
1208
1229
|
}
|
|
1209
1230
|
// --- Content Type Generation ---
|
|
1210
1231
|
generateContentType(component) {
|
|
@@ -1237,6 +1258,37 @@ var CompositionConverterService = class {
|
|
|
1237
1258
|
}
|
|
1238
1259
|
return field;
|
|
1239
1260
|
}
|
|
1261
|
+
async mergeWithExistingContentType(filePath, generated) {
|
|
1262
|
+
const exists = await this.fileSystem.fileExists(filePath);
|
|
1263
|
+
if (!exists) {
|
|
1264
|
+
return generated;
|
|
1265
|
+
}
|
|
1266
|
+
const existing = await this.fileSystem.readFile(filePath);
|
|
1267
|
+
const existingFieldMap = /* @__PURE__ */ new Map();
|
|
1268
|
+
for (const field of existing.fields) {
|
|
1269
|
+
existingFieldMap.set(field.id, field);
|
|
1270
|
+
}
|
|
1271
|
+
for (const newField of generated.fields) {
|
|
1272
|
+
const existingField = existingFieldMap.get(newField.id);
|
|
1273
|
+
if (existingField && existingField.type !== newField.type) {
|
|
1274
|
+
throw new ContentTypeFieldConflictError(
|
|
1275
|
+
generated.id,
|
|
1276
|
+
newField.id,
|
|
1277
|
+
existingField.type,
|
|
1278
|
+
newField.type
|
|
1279
|
+
);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
const generatedFieldIds = new Set(generated.fields.map((f) => f.id));
|
|
1283
|
+
const extraFields = existing.fields.filter((f) => !generatedFieldIds.has(f.id));
|
|
1284
|
+
if (extraFields.length === 0) {
|
|
1285
|
+
return generated;
|
|
1286
|
+
}
|
|
1287
|
+
return {
|
|
1288
|
+
...generated,
|
|
1289
|
+
fields: [...generated.fields, ...extraFields]
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1240
1292
|
// --- Entry Generation ---
|
|
1241
1293
|
generateEntryFromComposition(composition) {
|
|
1242
1294
|
const comp = composition.composition;
|
|
@@ -3962,7 +4014,7 @@ var ComponentAdderService = class {
|
|
|
3962
4014
|
const newInstance = this.createComponentInstance(newComponentType, parsedParams);
|
|
3963
4015
|
const compositionsResult = await this.addComponentToDirectory(
|
|
3964
4016
|
fullCompositionsDir,
|
|
3965
|
-
|
|
4017
|
+
resolvedParentTypes,
|
|
3966
4018
|
slot,
|
|
3967
4019
|
newInstance,
|
|
3968
4020
|
whatIf,
|
|
@@ -3971,7 +4023,7 @@ var ComponentAdderService = class {
|
|
|
3971
4023
|
);
|
|
3972
4024
|
const compositionPatternsResult = await this.addComponentToDirectory(
|
|
3973
4025
|
fullCompositionPatternsDir,
|
|
3974
|
-
|
|
4026
|
+
resolvedParentTypes,
|
|
3975
4027
|
slot,
|
|
3976
4028
|
newInstance,
|
|
3977
4029
|
whatIf,
|
|
@@ -3980,7 +4032,7 @@ var ComponentAdderService = class {
|
|
|
3980
4032
|
);
|
|
3981
4033
|
const componentPatternsResult = await this.addComponentToDirectory(
|
|
3982
4034
|
fullComponentPatternsDir,
|
|
3983
|
-
|
|
4035
|
+
resolvedParentTypes,
|
|
3984
4036
|
slot,
|
|
3985
4037
|
newInstance,
|
|
3986
4038
|
whatIf,
|
|
@@ -4098,7 +4150,7 @@ var ComponentAdderService = class {
|
|
|
4098
4150
|
};
|
|
4099
4151
|
const compositionsResult = await this.addComponentToDirectory(
|
|
4100
4152
|
fullCompositionsDir,
|
|
4101
|
-
|
|
4153
|
+
resolvedParentTypes,
|
|
4102
4154
|
slot,
|
|
4103
4155
|
newInstance,
|
|
4104
4156
|
whatIf,
|
|
@@ -4108,7 +4160,7 @@ var ComponentAdderService = class {
|
|
|
4108
4160
|
);
|
|
4109
4161
|
const compositionPatternsResult = await this.addComponentToDirectory(
|
|
4110
4162
|
fullCompositionPatternsDir,
|
|
4111
|
-
|
|
4163
|
+
resolvedParentTypes,
|
|
4112
4164
|
slot,
|
|
4113
4165
|
newInstance,
|
|
4114
4166
|
whatIf,
|
|
@@ -4118,7 +4170,7 @@ var ComponentAdderService = class {
|
|
|
4118
4170
|
);
|
|
4119
4171
|
const componentPatternsResult = await this.addComponentToDirectory(
|
|
4120
4172
|
fullComponentPatternsDir,
|
|
4121
|
-
|
|
4173
|
+
resolvedParentTypes,
|
|
4122
4174
|
slot,
|
|
4123
4175
|
newInstance,
|
|
4124
4176
|
whatIf,
|
|
@@ -4843,9 +4895,10 @@ function createConvertCompositionsToEntriesCommand() {
|
|
|
4843
4895
|
});
|
|
4844
4896
|
const refInfo = result.entriesFromReferences > 0 ? `, ${result.entriesFromReferences} from references` : "";
|
|
4845
4897
|
const reusedInfo = result.entriesReused > 0 ? `, ${result.entriesReused} reused existing` : "";
|
|
4898
|
+
const mergedInfo = result.contentTypesMerged > 0 ? `, ${result.contentTypesMerged} merged` : "";
|
|
4846
4899
|
const blocksInfo = result.blocksEmbedded > 0 ? `, ${result.blocksEmbedded} block(s) embedded` : "";
|
|
4847
4900
|
logger.success(
|
|
4848
|
-
`${result.contentTypesWritten} content type(s), ${result.entriesFromCompositions} entry(ies) from compositions${refInfo}${reusedInfo}${blocksInfo}`
|
|
4901
|
+
`${result.contentTypesWritten} content type(s)${mergedInfo}, ${result.entriesFromCompositions} entry(ies) from compositions${refInfo}${reusedInfo}${blocksInfo}`
|
|
4849
4902
|
);
|
|
4850
4903
|
} catch (error) {
|
|
4851
4904
|
if (error instanceof ComponentNotFoundError) {
|
|
@@ -7852,7 +7905,7 @@ function createClearSlotCommand() {
|
|
|
7852
7905
|
// package.json
|
|
7853
7906
|
var package_default = {
|
|
7854
7907
|
name: "@uniformdev/transformer",
|
|
7855
|
-
version: "1.1.
|
|
7908
|
+
version: "1.1.56",
|
|
7856
7909
|
description: "CLI tool for transforming Uniform.dev serialization files offline",
|
|
7857
7910
|
type: "module",
|
|
7858
7911
|
bin: {
|