storyblok 3.33.1 → 3.33.3
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 +34 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1967,6 +1967,17 @@ const createContentList$1 = (content, key) => {
|
|
|
1967
1967
|
else
|
|
1968
1968
|
return !isEmpty$3(content) ? [content] : [];
|
|
1969
1969
|
};
|
|
1970
|
+
const getSpaceInternalTags = (client, spaceId) => {
|
|
1971
|
+
return client.get(`spaces/${spaceId}/internal_tags`).then((response) => response.data.internal_tags || []);
|
|
1972
|
+
};
|
|
1973
|
+
const createComponentInternalTag = (client, spaceId, tag) => {
|
|
1974
|
+
return client.post(`spaces/${spaceId}/internal_tags`, {
|
|
1975
|
+
internal_tag: {
|
|
1976
|
+
name: tag.name,
|
|
1977
|
+
object_type: "component"
|
|
1978
|
+
}
|
|
1979
|
+
}).then((response) => response.data.internal_tag || {}).catch((error) => Promise.reject(error));
|
|
1980
|
+
};
|
|
1970
1981
|
const pushComponents = async (api, { source, presetsSource }) => {
|
|
1971
1982
|
try {
|
|
1972
1983
|
const rawComponents = await getDataFromPath$1(source);
|
|
@@ -2024,7 +2035,9 @@ const pushComponentsGroups = async (api, group) => {
|
|
|
2024
2035
|
}
|
|
2025
2036
|
};
|
|
2026
2037
|
const push = async (api, components, componentsGroups = [], presets = []) => {
|
|
2027
|
-
const
|
|
2038
|
+
const targetSpaceId = api.spaceId;
|
|
2039
|
+
const presetsLib = new PresetsLib({ oauthToken: api.accessToken, targetSpaceId });
|
|
2040
|
+
const apiClient = api.getClient();
|
|
2028
2041
|
try {
|
|
2029
2042
|
const componentGroupsTree = buildComponentsGroupsTree(componentsGroups);
|
|
2030
2043
|
for (const rootComponent of componentGroupsTree) {
|
|
@@ -2042,6 +2055,25 @@ const push = async (api, components, componentsGroups = [], presets = []) => {
|
|
|
2042
2055
|
components[i].component_group_uuid = groupData.uuid;
|
|
2043
2056
|
delete components[i].component_group_name;
|
|
2044
2057
|
}
|
|
2058
|
+
const { internal_tags_list, internal_tag_ids } = components[i];
|
|
2059
|
+
const existingTags = await getSpaceInternalTags(apiClient, targetSpaceId);
|
|
2060
|
+
let processedInternalTagsIds = [];
|
|
2061
|
+
if (internal_tags_list.length > 0) {
|
|
2062
|
+
await internal_tags_list.forEach(async (tag) => {
|
|
2063
|
+
const existingTag = existingTags.find(({ name }) => tag.name === name);
|
|
2064
|
+
if (!existingTag) {
|
|
2065
|
+
try {
|
|
2066
|
+
const response = await createComponentInternalTag(apiClient, targetSpaceId, tag);
|
|
2067
|
+
processedInternalTagsIds.push(response.id);
|
|
2068
|
+
} catch (e) {
|
|
2069
|
+
console.error(chalk.red("X") + ` Internal tag ${tag} creation failed: ${e.message}`);
|
|
2070
|
+
}
|
|
2071
|
+
} else {
|
|
2072
|
+
processedInternalTagsIds.push(existingTag.id);
|
|
2073
|
+
}
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
components[i].internal_tag_ids = processedInternalTagsIds || internal_tag_ids;
|
|
2045
2077
|
const schema = components[i].schema;
|
|
2046
2078
|
if (schema) {
|
|
2047
2079
|
Object.keys(schema).forEach((field) => {
|
|
@@ -2134,7 +2166,7 @@ const getPathToFile = (fileName, migrationPath = null) => {
|
|
|
2134
2166
|
return `${pathTo}/${fileName}`;
|
|
2135
2167
|
};
|
|
2136
2168
|
const getNameOfMigrationFile = (component, field) => {
|
|
2137
|
-
return `change_${component}_${field}.
|
|
2169
|
+
return `change_${component}_${field}.mjs`;
|
|
2138
2170
|
};
|
|
2139
2171
|
const getStoriesByComponent = async (api, componentName) => {
|
|
2140
2172
|
try {
|