contentful-import 9.3.4 → 9.4.1
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/index.js +24 -23
- package/dist/index.mjs +3 -2
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_formatDistance = __toESM(require("date-fns/formatDistance"));
|
|
|
38
38
|
var import_listr3 = __toESM(require("listr"));
|
|
39
39
|
var import_listr_update_renderer = __toESM(require("listr-update-renderer"));
|
|
40
40
|
var import_listr_verbose_renderer2 = __toESM(require("listr-verbose-renderer"));
|
|
41
|
-
var
|
|
41
|
+
var import_lodash2 = require("lodash");
|
|
42
42
|
var import_p_queue = __toESM(require("p-queue"));
|
|
43
43
|
var import_logging7 = require("contentful-batch-libs/dist/logging");
|
|
44
44
|
var import_listr4 = require("contentful-batch-libs/dist/listr");
|
|
@@ -642,6 +642,8 @@ function pushToSpace({
|
|
|
642
642
|
ctEditorInterface.controls = editorInterface.controls;
|
|
643
643
|
ctEditorInterface.groupControls = editorInterface.groupControls;
|
|
644
644
|
ctEditorInterface.editorLayout = editorInterface.editorLayout;
|
|
645
|
+
ctEditorInterface.sidebar = editorInterface.sidebar;
|
|
646
|
+
ctEditorInterface.editors = editorInterface.editors;
|
|
645
647
|
const updatedEditorInterface = await requestQueue.add(() => ctEditorInterface.update());
|
|
646
648
|
return updatedEditorInterface;
|
|
647
649
|
} catch (err) {
|
|
@@ -804,7 +806,7 @@ function publishEntities2({ entities, sourceEntities, requestQueue }) {
|
|
|
804
806
|
}
|
|
805
807
|
|
|
806
808
|
// lib/transform/transform-space.ts
|
|
807
|
-
var
|
|
809
|
+
var import_object2 = require("lodash/object");
|
|
808
810
|
|
|
809
811
|
// lib/transform/transformers.ts
|
|
810
812
|
var transformers_exports = {};
|
|
@@ -816,8 +818,7 @@ __export(transformers_exports, {
|
|
|
816
818
|
tags: () => tags,
|
|
817
819
|
webhooks: () => webhooks
|
|
818
820
|
});
|
|
819
|
-
var
|
|
820
|
-
var import_collection2 = require("lodash/collection");
|
|
821
|
+
var import_lodash = require("lodash");
|
|
821
822
|
function contentTypes(contentType) {
|
|
822
823
|
return contentType;
|
|
823
824
|
}
|
|
@@ -837,13 +838,13 @@ function webhooks(webhook) {
|
|
|
837
838
|
return webhook;
|
|
838
839
|
}
|
|
839
840
|
function assets(asset, _, tagsEnabled = false) {
|
|
840
|
-
const transformedAsset = (0,
|
|
841
|
-
transformedAsset.sys = (0,
|
|
842
|
-
transformedAsset.fields = (0,
|
|
843
|
-
transformedAsset.fields.file = (0,
|
|
841
|
+
const transformedAsset = (0, import_lodash.omit)(asset, "sys");
|
|
842
|
+
transformedAsset.sys = (0, import_lodash.pick)(asset.sys, "id");
|
|
843
|
+
transformedAsset.fields = (0, import_lodash.pick)(asset.fields, "title", "description");
|
|
844
|
+
transformedAsset.fields.file = (0, import_lodash.reduce)(
|
|
844
845
|
asset.fields.file,
|
|
845
846
|
(newFile, localizedFile, locale) => {
|
|
846
|
-
newFile[locale] = (0,
|
|
847
|
+
newFile[locale] = (0, import_lodash.pick)(localizedFile, "contentType", "fileName");
|
|
847
848
|
if (!localizedFile.uploadFrom) {
|
|
848
849
|
const assetUrl = localizedFile.url || localizedFile.upload;
|
|
849
850
|
newFile[locale].upload = `${/^(http|https):\/\//i.test(assetUrl) ? "" : "https:"}${assetUrl}`;
|
|
@@ -857,10 +858,10 @@ function assets(asset, _, tagsEnabled = false) {
|
|
|
857
858
|
return removeMetadataTags(transformedAsset, tagsEnabled);
|
|
858
859
|
}
|
|
859
860
|
function locales(locale, destinationLocales) {
|
|
860
|
-
const transformedLocale = (0,
|
|
861
|
-
const destinationLocale = (0,
|
|
861
|
+
const transformedLocale = (0, import_lodash.pick)(locale, "code", "name", "contentManagementApi", "contentDeliveryApi", "fallbackCode", "optional");
|
|
862
|
+
const destinationLocale = (0, import_lodash.find)(destinationLocales, { code: locale.code });
|
|
862
863
|
if (destinationLocale) {
|
|
863
|
-
transformedLocale.sys = (0,
|
|
864
|
+
transformedLocale.sys = (0, import_lodash.pick)(destinationLocale.sys, "id");
|
|
864
865
|
}
|
|
865
866
|
return transformedLocale;
|
|
866
867
|
}
|
|
@@ -872,7 +873,7 @@ function removeMetadataTags(entity, tagsEnabled = false) {
|
|
|
872
873
|
}
|
|
873
874
|
|
|
874
875
|
// lib/utils/sort-entries.ts
|
|
875
|
-
var
|
|
876
|
+
var import_collection2 = require("lodash/collection");
|
|
876
877
|
var _o = __toESM(require("lodash/object"));
|
|
877
878
|
var import_array = require("lodash/array");
|
|
878
879
|
function sortEntries(entries2) {
|
|
@@ -880,10 +881,10 @@ function sortEntries(entries2) {
|
|
|
880
881
|
const mergedLinkedEntries = mergeSort(linkedEntries, (a) => {
|
|
881
882
|
return hasLinkedIndexesInFront(a);
|
|
882
883
|
});
|
|
883
|
-
return (0,
|
|
884
|
+
return (0, import_collection2.map)(mergedLinkedEntries, (linkInfo) => entries2[linkInfo.index]);
|
|
884
885
|
function hasLinkedIndexesInFront(item) {
|
|
885
886
|
if (hasLinkedIndexes(item)) {
|
|
886
|
-
return (0,
|
|
887
|
+
return (0, import_collection2.some)(item.linkIndexes, (index) => index > item.index) ? 1 : -1;
|
|
887
888
|
}
|
|
888
889
|
return 0;
|
|
889
890
|
}
|
|
@@ -892,19 +893,19 @@ function sortEntries(entries2) {
|
|
|
892
893
|
}
|
|
893
894
|
}
|
|
894
895
|
function getLinkedEntries(entries2) {
|
|
895
|
-
return (0,
|
|
896
|
+
return (0, import_collection2.map)(entries2, function(entry) {
|
|
896
897
|
const entryIndex = entries2.indexOf(entry);
|
|
897
|
-
const rawLinks = (0,
|
|
898
|
+
const rawLinks = (0, import_collection2.map)(entry.fields, (field) => {
|
|
898
899
|
field = _o.values(field)[0];
|
|
899
900
|
if (isEntryLink(field)) {
|
|
900
901
|
return getFieldEntriesIndex(field, entries2);
|
|
901
902
|
} else if (isEntityArray(field) && isEntryLink(field[0])) {
|
|
902
|
-
return (0,
|
|
903
|
+
return (0, import_collection2.map)(field, (item) => getFieldEntriesIndex(item, entries2));
|
|
903
904
|
}
|
|
904
905
|
});
|
|
905
906
|
return {
|
|
906
907
|
index: entryIndex,
|
|
907
|
-
linkIndexes: (0,
|
|
908
|
+
linkIndexes: (0, import_collection2.filter)((0, import_array.flatten)(rawLinks), (index) => index >= 0)
|
|
908
909
|
};
|
|
909
910
|
});
|
|
910
911
|
}
|
|
@@ -989,8 +990,8 @@ var spaceEntities = [
|
|
|
989
990
|
"tags"
|
|
990
991
|
];
|
|
991
992
|
function transform_space_default(sourceData, destinationData, customTransformers, entities = spaceEntities) {
|
|
992
|
-
const transformers = (0,
|
|
993
|
-
const baseSpaceData = (0,
|
|
993
|
+
const transformers = (0, import_object2.defaults)(customTransformers, transformers_exports);
|
|
994
|
+
const baseSpaceData = (0, import_object2.omit)(sourceData, ...entities);
|
|
994
995
|
sourceData.locales = sortLocales(sourceData.locales);
|
|
995
996
|
const tagsEnabled = !!destinationData.tags;
|
|
996
997
|
return entities.reduce((transformedSpaceData, type) => {
|
|
@@ -1271,7 +1272,7 @@ async function runContentfulImport(params) {
|
|
|
1271
1272
|
if (options.contentModelOnly && !(["contentTypes", "editorInterfaces", "locales"].indexOf(type) >= 0)) {
|
|
1272
1273
|
return;
|
|
1273
1274
|
}
|
|
1274
|
-
infoTable.push([(0,
|
|
1275
|
+
infoTable.push([(0, import_lodash2.startCase)(type), options.content[type].length]);
|
|
1275
1276
|
});
|
|
1276
1277
|
console.log(infoTable.toString());
|
|
1277
1278
|
const tasks = new import_listr3.default([
|
|
@@ -1343,7 +1344,7 @@ async function runContentfulImport(params) {
|
|
|
1343
1344
|
const resultTable = new import_cli_table3.default();
|
|
1344
1345
|
resultTable.push([{ colSpan: 2, content: "Imported entities" }]);
|
|
1345
1346
|
resultTypes.forEach((type) => {
|
|
1346
|
-
resultTable.push([(0,
|
|
1347
|
+
resultTable.push([(0, import_lodash2.startCase)(type), ctx.data[type].length]);
|
|
1347
1348
|
});
|
|
1348
1349
|
console.log(resultTable.toString());
|
|
1349
1350
|
} else {
|
package/dist/index.mjs
CHANGED
|
@@ -615,6 +615,8 @@ function pushToSpace({
|
|
|
615
615
|
ctEditorInterface.controls = editorInterface.controls;
|
|
616
616
|
ctEditorInterface.groupControls = editorInterface.groupControls;
|
|
617
617
|
ctEditorInterface.editorLayout = editorInterface.editorLayout;
|
|
618
|
+
ctEditorInterface.sidebar = editorInterface.sidebar;
|
|
619
|
+
ctEditorInterface.editors = editorInterface.editors;
|
|
618
620
|
const updatedEditorInterface = await requestQueue.add(() => ctEditorInterface.update());
|
|
619
621
|
return updatedEditorInterface;
|
|
620
622
|
} catch (err) {
|
|
@@ -789,8 +791,7 @@ __export(transformers_exports, {
|
|
|
789
791
|
tags: () => tags,
|
|
790
792
|
webhooks: () => webhooks
|
|
791
793
|
});
|
|
792
|
-
import { omit as omit2, pick } from "lodash
|
|
793
|
-
import { find as find2, reduce } from "lodash/collection";
|
|
794
|
+
import { find as find2, omit as omit2, pick, reduce } from "lodash";
|
|
794
795
|
function contentTypes(contentType) {
|
|
795
796
|
return contentType;
|
|
796
797
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentful-import",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.1",
|
|
4
4
|
"description": "this tool allows you to import JSON dump exported by contentful-export",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
9
|
+
"node": ">=18"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
"default": "./dist/index.js",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@discoveryjs/json-ext": "^0.5.7",
|
|
64
|
-
"bluebird": "^3.
|
|
64
|
+
"bluebird": "^3.7.2",
|
|
65
65
|
"cli-table3": "^0.6.0",
|
|
66
|
-
"contentful-batch-libs": "^9.5.
|
|
66
|
+
"contentful-batch-libs": "^9.5.1",
|
|
67
67
|
"contentful-management": "^11.1.1",
|
|
68
68
|
"date-fns": "^2.30.0",
|
|
69
69
|
"eslint": "^8.51.0",
|
|
@@ -72,12 +72,13 @@
|
|
|
72
72
|
"listr": "^0.14.1",
|
|
73
73
|
"listr-update-renderer": "^0.5.0",
|
|
74
74
|
"listr-verbose-renderer": "^0.6.0",
|
|
75
|
-
"lodash": "^4.17.
|
|
75
|
+
"lodash": "^4.17.21",
|
|
76
76
|
"p-queue": "^6.6.2",
|
|
77
77
|
"yargs": "^17.7.2"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/jest": "^29.5.5",
|
|
81
|
+
"@types/lodash": "^4.14.199",
|
|
81
82
|
"@types/node": "^20.6.3",
|
|
82
83
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
|
83
84
|
"@typescript-eslint/parser": "^6.7.5",
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"eslint-plugin-standard": "^5.0.0",
|
|
93
94
|
"jest": "^29.7.0",
|
|
94
95
|
"rimraf": "^5.0.5",
|
|
95
|
-
"semantic-release": "^
|
|
96
|
+
"semantic-release": "^22.0.5",
|
|
96
97
|
"ts-jest": "^29.1.1",
|
|
97
98
|
"tsup": "^7.2.0",
|
|
98
99
|
"typescript": "^5.2.2"
|