storyblok 3.32.0 → 3.32.2
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.mjs +41 -4
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1108,10 +1108,32 @@ class SyncComponents {
|
|
|
1108
1108
|
);
|
|
1109
1109
|
component.component_group_uuid = targetGroupData.uuid;
|
|
1110
1110
|
}
|
|
1111
|
+
const { internal_tags_list, internal_tag_ids, ...rest } = component;
|
|
1112
|
+
const existingTags = await this.getSpaceInternalTags(this.targetSpaceId);
|
|
1113
|
+
let processedInternalTagsIds = [];
|
|
1114
|
+
if (internal_tags_list.length > 0) {
|
|
1115
|
+
await internal_tags_list.forEach(async (tag) => {
|
|
1116
|
+
const existingTag = existingTags.find(({ name }) => tag.name === name);
|
|
1117
|
+
if (!existingTag) {
|
|
1118
|
+
try {
|
|
1119
|
+
const response = await this.createComponentInternalTag(this.targetSpaceId, tag);
|
|
1120
|
+
processedInternalTagsIds.push(response.id);
|
|
1121
|
+
} catch (e) {
|
|
1122
|
+
console.error(chalk.red("X") + ` Internal tag ${tag} creation failed: ${e.message}`);
|
|
1123
|
+
}
|
|
1124
|
+
} else {
|
|
1125
|
+
processedInternalTagsIds.push(existingTag.id);
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
const componentData = {
|
|
1130
|
+
...rest,
|
|
1131
|
+
internal_tag_ids: processedInternalTagsIds || internal_tag_ids
|
|
1132
|
+
};
|
|
1111
1133
|
try {
|
|
1112
1134
|
const componentCreated = await this.createComponent(
|
|
1113
1135
|
this.targetSpaceId,
|
|
1114
|
-
|
|
1136
|
+
componentData
|
|
1115
1137
|
);
|
|
1116
1138
|
console.log(chalk.green("\u2713") + ` Component ${component.name} created`);
|
|
1117
1139
|
if (componentPresets.length) {
|
|
@@ -1126,7 +1148,7 @@ class SyncComponents {
|
|
|
1126
1148
|
await this.updateComponent(
|
|
1127
1149
|
this.targetSpaceId,
|
|
1128
1150
|
componentTarget.id,
|
|
1129
|
-
|
|
1151
|
+
componentData,
|
|
1130
1152
|
componentTarget
|
|
1131
1153
|
);
|
|
1132
1154
|
console.log(chalk.green("\u2713") + ` Component ${component.name} synced`);
|
|
@@ -1177,7 +1199,11 @@ class SyncComponents {
|
|
|
1177
1199
|
targetComponentData
|
|
1178
1200
|
)
|
|
1179
1201
|
};
|
|
1180
|
-
|
|
1202
|
+
payload.component.internal_tag_ids = sourceComponentData.internal_tag_ids;
|
|
1203
|
+
return this.client.put(`spaces/${spaceId}/components/${componentId}`, payload).then((response) => {
|
|
1204
|
+
const component = response.data.component || {};
|
|
1205
|
+
return component;
|
|
1206
|
+
}).catch((error) => Promise.reject(error));
|
|
1181
1207
|
}
|
|
1182
1208
|
mergeComponents(sourceComponent, targetComponent = {}) {
|
|
1183
1209
|
const data = this.componentsFullSync ? {
|
|
@@ -1229,6 +1255,17 @@ class SyncComponents {
|
|
|
1229
1255
|
return targetGroupData.uuid;
|
|
1230
1256
|
});
|
|
1231
1257
|
}
|
|
1258
|
+
getSpaceInternalTags(spaceId) {
|
|
1259
|
+
return this.client.get(`spaces/${spaceId}/internal_tags`).then((response) => response.data.internal_tags || []);
|
|
1260
|
+
}
|
|
1261
|
+
createComponentInternalTag(spaceId, tag) {
|
|
1262
|
+
return this.client.post(`spaces/${spaceId}/internal_tags`, {
|
|
1263
|
+
internal_tag: {
|
|
1264
|
+
name: tag.name,
|
|
1265
|
+
object_type: "component"
|
|
1266
|
+
}
|
|
1267
|
+
}).then((response) => response.data.internal_tag || {}).catch((error) => Promise.reject(error));
|
|
1268
|
+
}
|
|
1232
1269
|
}
|
|
1233
1270
|
|
|
1234
1271
|
class SyncDatasources {
|
|
@@ -3378,7 +3415,7 @@ getPropertyTypeAnnotation_fn = function(property) {
|
|
|
3378
3415
|
_getComponentType = new WeakSet();
|
|
3379
3416
|
getComponentType_fn = function(componentName) {
|
|
3380
3417
|
const componentType = startCase(
|
|
3381
|
-
camelCase(`${__privateGet(this, _options).typeNamesPrefix ?? ""}${componentName}${__privateGet(this, _options).typeNamesSuffix}`)
|
|
3418
|
+
camelCase(`${__privateGet(this, _options).typeNamesPrefix ?? ""}_${componentName}_${__privateGet(this, _options).typeNamesSuffix}`)
|
|
3382
3419
|
).replace(/ /g, "");
|
|
3383
3420
|
const isFirstCharacterNumber = !isNaN(parseInt(componentType.charAt(0)));
|
|
3384
3421
|
return isFirstCharacterNumber ? `_${componentType}` : componentType;
|