contentful-import 9.4.55 → 9.4.57
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/README.md +8 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +30 -11
- package/dist/index.mjs +30 -11
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -130,6 +130,10 @@ Skip importing of content types and locales
|
|
|
130
130
|
|
|
131
131
|
Skip importing of locales
|
|
132
132
|
|
|
133
|
+
#### `skipContentUpdates` [boolean] [default: false]
|
|
134
|
+
|
|
135
|
+
Skip updating existing content
|
|
136
|
+
|
|
133
137
|
#### `skipContentPublishing` [boolean] [default: false]
|
|
134
138
|
|
|
135
139
|
Skips content publishing. Creates content but does not publish it
|
|
@@ -140,6 +144,10 @@ Skips content publishing. Creates content but does not publish it
|
|
|
140
144
|
|
|
141
145
|
Upload local asset files downloaded via the [downloadAssets](https://github.com/contentful/contentful-export#downloadassets-boolean) option of the export. Requires `assetsDirectory`
|
|
142
146
|
|
|
147
|
+
#### `skipAssetUpdates` [boolean] [default: false]
|
|
148
|
+
|
|
149
|
+
Skip updating existing assets
|
|
150
|
+
|
|
143
151
|
#### `assetsDirectory` [string]
|
|
144
152
|
|
|
145
153
|
Path to a directory with an asset export made using the [downloadAssets](https://github.com/contentful/contentful-export#downloadassets-boolean) option of the export. Requires `uploadAssets`
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -284,16 +284,21 @@ var import_collection = require("lodash/collection");
|
|
|
284
284
|
var import_object = require("lodash/object");
|
|
285
285
|
var import_get_entity_name2 = __toESM(require("contentful-batch-libs/dist/get-entity-name"));
|
|
286
286
|
var import_logging4 = require("contentful-batch-libs/dist/logging");
|
|
287
|
-
function createEntities({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
288
|
-
return createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, requestQueue });
|
|
287
|
+
function createEntities({ context, entities, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
288
|
+
return createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, skipUpdates, requestQueue });
|
|
289
289
|
}
|
|
290
290
|
function createLocales({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
291
291
|
return createEntitiesInSequence({ context, entities, destinationEntitiesById, requestQueue });
|
|
292
292
|
}
|
|
293
|
-
async function createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
293
|
+
async function createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
294
294
|
const pendingCreatedEntities = entities.map((entity) => {
|
|
295
295
|
const destinationEntity = getDestinationEntityForSourceEntity(destinationEntitiesById, entity.transformed);
|
|
296
|
-
const
|
|
296
|
+
const updateOperation = skipUpdates ? "skip" : "update";
|
|
297
|
+
const operation = destinationEntity ? updateOperation : "create";
|
|
298
|
+
if (destinationEntity && skipUpdates) {
|
|
299
|
+
creationSuccessNotifier(operation, entity.transformed);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
297
302
|
return requestQueue.add(async () => {
|
|
298
303
|
try {
|
|
299
304
|
const createdEntity = await (destinationEntity ? updateDestinationWithSourceData(destinationEntity, entity.transformed) : createInDestination(context, entity.transformed));
|
|
@@ -328,19 +333,24 @@ async function createEntitiesInSequence({ context, entities, destinationEntities
|
|
|
328
333
|
}
|
|
329
334
|
return createdEntities;
|
|
330
335
|
}
|
|
331
|
-
async function createEntries({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
336
|
+
async function createEntries({ context, entities, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
332
337
|
const createdEntries = await Promise.all(entities.map((entry) => {
|
|
333
|
-
return createEntry({ entry, target: context.target, skipContentModel: context.skipContentModel, destinationEntitiesById, requestQueue });
|
|
338
|
+
return createEntry({ entry, target: context.target, skipContentModel: context.skipContentModel, destinationEntitiesById, skipUpdates, requestQueue });
|
|
334
339
|
}));
|
|
335
340
|
return createdEntries.filter((entry) => entry);
|
|
336
341
|
}
|
|
337
|
-
async function createEntry({ entry, target, skipContentModel, destinationEntitiesById, requestQueue }) {
|
|
342
|
+
async function createEntry({ entry, target, skipContentModel, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
338
343
|
const contentTypeId = entry.original.sys.contentType.sys.id;
|
|
339
344
|
const destinationEntry = getDestinationEntityForSourceEntity(
|
|
340
345
|
destinationEntitiesById,
|
|
341
346
|
entry.transformed
|
|
342
347
|
);
|
|
343
|
-
const
|
|
348
|
+
const updateOperation = skipUpdates ? "skip" : "update";
|
|
349
|
+
const operation = destinationEntry ? updateOperation : "create";
|
|
350
|
+
if (destinationEntry && skipUpdates) {
|
|
351
|
+
creationSuccessNotifier(operation, entry.transformed);
|
|
352
|
+
return entry.transformed;
|
|
353
|
+
}
|
|
344
354
|
try {
|
|
345
355
|
const createdOrUpdatedEntry = await requestQueue.add(() => {
|
|
346
356
|
return destinationEntry ? updateDestinationWithSourceData(destinationEntry, entry.transformed) : createEntryInDestination(target, contentTypeId, entry.transformed);
|
|
@@ -352,7 +362,7 @@ async function createEntry({ entry, target, skipContentModel, destinationEntitie
|
|
|
352
362
|
if (skipContentModel && err.name === "UnknownField") {
|
|
353
363
|
const errors = (0, import_object.get)(JSON.parse(err.message), "details.errors");
|
|
354
364
|
entry.transformed.fields = cleanupUnknownFields(entry.transformed.fields, errors);
|
|
355
|
-
return createEntry({ entry, target, skipContentModel, destinationEntitiesById, requestQueue });
|
|
365
|
+
return createEntry({ entry, target, skipContentModel, destinationEntitiesById, skipUpdates, requestQueue });
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
368
|
if (err instanceof ContentfulEntityError) {
|
|
@@ -410,8 +420,7 @@ function getDestinationEntityForSourceEntity(destinationEntitiesById, sourceEnti
|
|
|
410
420
|
return destinationEntitiesById.get((0, import_object.get)(sourceEntity, "sys.id")) || null;
|
|
411
421
|
}
|
|
412
422
|
function creationSuccessNotifier(method, createdEntity) {
|
|
413
|
-
|
|
414
|
-
import_logging4.logEmitter.emit("info", `${verb} ${createdEntity.sys.type} ${(0, import_get_entity_name2.default)(createdEntity)}`);
|
|
423
|
+
import_logging4.logEmitter.emit("info", `${method.toUpperCase()} ${createdEntity.sys.type} ${(0, import_get_entity_name2.default)(createdEntity)}`);
|
|
415
424
|
return createdEntity;
|
|
416
425
|
}
|
|
417
426
|
function getPlainData(entity) {
|
|
@@ -524,12 +533,14 @@ function pushToSpace({
|
|
|
524
533
|
environmentId,
|
|
525
534
|
contentModelOnly,
|
|
526
535
|
skipContentModel,
|
|
536
|
+
skipContentUpdates,
|
|
527
537
|
skipLocales,
|
|
528
538
|
skipContentPublishing,
|
|
529
539
|
timeout,
|
|
530
540
|
retryLimit,
|
|
531
541
|
listrOptions,
|
|
532
542
|
uploadAssets,
|
|
543
|
+
skipAssetUpdates,
|
|
533
544
|
assetsDirectory,
|
|
534
545
|
requestQueue
|
|
535
546
|
}) {
|
|
@@ -588,6 +599,7 @@ function pushToSpace({
|
|
|
588
599
|
context: { target: ctx.environment, type: "ContentType" },
|
|
589
600
|
entities: sourceData.contentTypes,
|
|
590
601
|
destinationEntitiesById: destinationDataById.contentTypes,
|
|
602
|
+
skipUpdates: false,
|
|
591
603
|
requestQueue
|
|
592
604
|
});
|
|
593
605
|
ctx.data.contentTypes = contentTypes2;
|
|
@@ -614,6 +626,7 @@ function pushToSpace({
|
|
|
614
626
|
context: { target: ctx.environment, type: "Tag" },
|
|
615
627
|
entities: sourceData.tags,
|
|
616
628
|
destinationEntitiesById: destinationDataById.tags,
|
|
629
|
+
skipUpdates: false,
|
|
617
630
|
requestQueue
|
|
618
631
|
});
|
|
619
632
|
ctx.data.tags = tags2;
|
|
@@ -703,6 +716,7 @@ function pushToSpace({
|
|
|
703
716
|
context: { target: ctx.environment, type: "Asset" },
|
|
704
717
|
entities: sourceData.assets,
|
|
705
718
|
destinationEntitiesById: destinationDataById.assets,
|
|
719
|
+
skipUpdates: skipAssetUpdates,
|
|
706
720
|
requestQueue
|
|
707
721
|
});
|
|
708
722
|
const processedAssets = await processAssets({
|
|
@@ -746,6 +760,7 @@ function pushToSpace({
|
|
|
746
760
|
context: { target: ctx.environment, skipContentModel },
|
|
747
761
|
entities: sourceData.entries,
|
|
748
762
|
destinationEntitiesById: destinationDataById.entries,
|
|
763
|
+
skipUpdates: skipContentUpdates,
|
|
749
764
|
requestQueue
|
|
750
765
|
});
|
|
751
766
|
ctx.data.entries = entries2;
|
|
@@ -1173,6 +1188,8 @@ async function parseOptions(params) {
|
|
|
1173
1188
|
skipContentModel: false,
|
|
1174
1189
|
skipLocales: false,
|
|
1175
1190
|
skipContentPublishing: false,
|
|
1191
|
+
skipAssetUpdates: false,
|
|
1192
|
+
skipContentUpdates: false,
|
|
1176
1193
|
useVerboseRenderer: false,
|
|
1177
1194
|
environmentId: "master",
|
|
1178
1195
|
rawProxy: false,
|
|
@@ -1329,6 +1346,8 @@ async function runContentfulImport(params) {
|
|
|
1329
1346
|
skipLocales: options.skipLocales,
|
|
1330
1347
|
skipContentModel: options.skipContentModel,
|
|
1331
1348
|
skipContentPublishing: options.skipContentPublishing,
|
|
1349
|
+
skipAssetUpdates: options.skipAssetUpdates,
|
|
1350
|
+
skipContentUpdates: options.skipContentUpdates,
|
|
1332
1351
|
timeout: options.timeout,
|
|
1333
1352
|
retryLimit: options.retryLimit,
|
|
1334
1353
|
uploadAssets: options.uploadAssets,
|
package/dist/index.mjs
CHANGED
|
@@ -257,16 +257,21 @@ import { find } from "lodash/collection";
|
|
|
257
257
|
import { assign, get, omitBy, omit } from "lodash/object";
|
|
258
258
|
import getEntityName2 from "contentful-batch-libs/dist/get-entity-name";
|
|
259
259
|
import { logEmitter as logEmitter4 } from "contentful-batch-libs/dist/logging";
|
|
260
|
-
function createEntities({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
261
|
-
return createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, requestQueue });
|
|
260
|
+
function createEntities({ context, entities, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
261
|
+
return createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, skipUpdates, requestQueue });
|
|
262
262
|
}
|
|
263
263
|
function createLocales({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
264
264
|
return createEntitiesInSequence({ context, entities, destinationEntitiesById, requestQueue });
|
|
265
265
|
}
|
|
266
|
-
async function createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
266
|
+
async function createEntitiesWithConcurrency({ context, entities, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
267
267
|
const pendingCreatedEntities = entities.map((entity) => {
|
|
268
268
|
const destinationEntity = getDestinationEntityForSourceEntity(destinationEntitiesById, entity.transformed);
|
|
269
|
-
const
|
|
269
|
+
const updateOperation = skipUpdates ? "skip" : "update";
|
|
270
|
+
const operation = destinationEntity ? updateOperation : "create";
|
|
271
|
+
if (destinationEntity && skipUpdates) {
|
|
272
|
+
creationSuccessNotifier(operation, entity.transformed);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
270
275
|
return requestQueue.add(async () => {
|
|
271
276
|
try {
|
|
272
277
|
const createdEntity = await (destinationEntity ? updateDestinationWithSourceData(destinationEntity, entity.transformed) : createInDestination(context, entity.transformed));
|
|
@@ -301,19 +306,24 @@ async function createEntitiesInSequence({ context, entities, destinationEntities
|
|
|
301
306
|
}
|
|
302
307
|
return createdEntities;
|
|
303
308
|
}
|
|
304
|
-
async function createEntries({ context, entities, destinationEntitiesById, requestQueue }) {
|
|
309
|
+
async function createEntries({ context, entities, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
305
310
|
const createdEntries = await Promise.all(entities.map((entry) => {
|
|
306
|
-
return createEntry({ entry, target: context.target, skipContentModel: context.skipContentModel, destinationEntitiesById, requestQueue });
|
|
311
|
+
return createEntry({ entry, target: context.target, skipContentModel: context.skipContentModel, destinationEntitiesById, skipUpdates, requestQueue });
|
|
307
312
|
}));
|
|
308
313
|
return createdEntries.filter((entry) => entry);
|
|
309
314
|
}
|
|
310
|
-
async function createEntry({ entry, target, skipContentModel, destinationEntitiesById, requestQueue }) {
|
|
315
|
+
async function createEntry({ entry, target, skipContentModel, destinationEntitiesById, skipUpdates, requestQueue }) {
|
|
311
316
|
const contentTypeId = entry.original.sys.contentType.sys.id;
|
|
312
317
|
const destinationEntry = getDestinationEntityForSourceEntity(
|
|
313
318
|
destinationEntitiesById,
|
|
314
319
|
entry.transformed
|
|
315
320
|
);
|
|
316
|
-
const
|
|
321
|
+
const updateOperation = skipUpdates ? "skip" : "update";
|
|
322
|
+
const operation = destinationEntry ? updateOperation : "create";
|
|
323
|
+
if (destinationEntry && skipUpdates) {
|
|
324
|
+
creationSuccessNotifier(operation, entry.transformed);
|
|
325
|
+
return entry.transformed;
|
|
326
|
+
}
|
|
317
327
|
try {
|
|
318
328
|
const createdOrUpdatedEntry = await requestQueue.add(() => {
|
|
319
329
|
return destinationEntry ? updateDestinationWithSourceData(destinationEntry, entry.transformed) : createEntryInDestination(target, contentTypeId, entry.transformed);
|
|
@@ -325,7 +335,7 @@ async function createEntry({ entry, target, skipContentModel, destinationEntitie
|
|
|
325
335
|
if (skipContentModel && err.name === "UnknownField") {
|
|
326
336
|
const errors = get(JSON.parse(err.message), "details.errors");
|
|
327
337
|
entry.transformed.fields = cleanupUnknownFields(entry.transformed.fields, errors);
|
|
328
|
-
return createEntry({ entry, target, skipContentModel, destinationEntitiesById, requestQueue });
|
|
338
|
+
return createEntry({ entry, target, skipContentModel, destinationEntitiesById, skipUpdates, requestQueue });
|
|
329
339
|
}
|
|
330
340
|
}
|
|
331
341
|
if (err instanceof ContentfulEntityError) {
|
|
@@ -383,8 +393,7 @@ function getDestinationEntityForSourceEntity(destinationEntitiesById, sourceEnti
|
|
|
383
393
|
return destinationEntitiesById.get(get(sourceEntity, "sys.id")) || null;
|
|
384
394
|
}
|
|
385
395
|
function creationSuccessNotifier(method, createdEntity) {
|
|
386
|
-
|
|
387
|
-
logEmitter4.emit("info", `${verb} ${createdEntity.sys.type} ${getEntityName2(createdEntity)}`);
|
|
396
|
+
logEmitter4.emit("info", `${method.toUpperCase()} ${createdEntity.sys.type} ${getEntityName2(createdEntity)}`);
|
|
388
397
|
return createdEntity;
|
|
389
398
|
}
|
|
390
399
|
function getPlainData(entity) {
|
|
@@ -497,12 +506,14 @@ function pushToSpace({
|
|
|
497
506
|
environmentId,
|
|
498
507
|
contentModelOnly,
|
|
499
508
|
skipContentModel,
|
|
509
|
+
skipContentUpdates,
|
|
500
510
|
skipLocales,
|
|
501
511
|
skipContentPublishing,
|
|
502
512
|
timeout,
|
|
503
513
|
retryLimit,
|
|
504
514
|
listrOptions,
|
|
505
515
|
uploadAssets,
|
|
516
|
+
skipAssetUpdates,
|
|
506
517
|
assetsDirectory,
|
|
507
518
|
requestQueue
|
|
508
519
|
}) {
|
|
@@ -561,6 +572,7 @@ function pushToSpace({
|
|
|
561
572
|
context: { target: ctx.environment, type: "ContentType" },
|
|
562
573
|
entities: sourceData.contentTypes,
|
|
563
574
|
destinationEntitiesById: destinationDataById.contentTypes,
|
|
575
|
+
skipUpdates: false,
|
|
564
576
|
requestQueue
|
|
565
577
|
});
|
|
566
578
|
ctx.data.contentTypes = contentTypes2;
|
|
@@ -587,6 +599,7 @@ function pushToSpace({
|
|
|
587
599
|
context: { target: ctx.environment, type: "Tag" },
|
|
588
600
|
entities: sourceData.tags,
|
|
589
601
|
destinationEntitiesById: destinationDataById.tags,
|
|
602
|
+
skipUpdates: false,
|
|
590
603
|
requestQueue
|
|
591
604
|
});
|
|
592
605
|
ctx.data.tags = tags2;
|
|
@@ -676,6 +689,7 @@ function pushToSpace({
|
|
|
676
689
|
context: { target: ctx.environment, type: "Asset" },
|
|
677
690
|
entities: sourceData.assets,
|
|
678
691
|
destinationEntitiesById: destinationDataById.assets,
|
|
692
|
+
skipUpdates: skipAssetUpdates,
|
|
679
693
|
requestQueue
|
|
680
694
|
});
|
|
681
695
|
const processedAssets = await processAssets({
|
|
@@ -719,6 +733,7 @@ function pushToSpace({
|
|
|
719
733
|
context: { target: ctx.environment, skipContentModel },
|
|
720
734
|
entities: sourceData.entries,
|
|
721
735
|
destinationEntitiesById: destinationDataById.entries,
|
|
736
|
+
skipUpdates: skipContentUpdates,
|
|
722
737
|
requestQueue
|
|
723
738
|
});
|
|
724
739
|
ctx.data.entries = entries2;
|
|
@@ -1143,6 +1158,8 @@ async function parseOptions(params) {
|
|
|
1143
1158
|
skipContentModel: false,
|
|
1144
1159
|
skipLocales: false,
|
|
1145
1160
|
skipContentPublishing: false,
|
|
1161
|
+
skipAssetUpdates: false,
|
|
1162
|
+
skipContentUpdates: false,
|
|
1146
1163
|
useVerboseRenderer: false,
|
|
1147
1164
|
environmentId: "master",
|
|
1148
1165
|
rawProxy: false,
|
|
@@ -1299,6 +1316,8 @@ async function runContentfulImport(params) {
|
|
|
1299
1316
|
skipLocales: options.skipLocales,
|
|
1300
1317
|
skipContentModel: options.skipContentModel,
|
|
1301
1318
|
skipContentPublishing: options.skipContentPublishing,
|
|
1319
|
+
skipAssetUpdates: options.skipAssetUpdates,
|
|
1320
|
+
skipContentUpdates: options.skipContentUpdates,
|
|
1302
1321
|
timeout: options.timeout,
|
|
1303
1322
|
retryLimit: options.retryLimit,
|
|
1304
1323
|
uploadAssets: options.uploadAssets,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentful-import",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.57",
|
|
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",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@discoveryjs/json-ext": "^0.5.7",
|
|
64
64
|
"bluebird": "^3.7.2",
|
|
65
|
-
"cli-table3": "^0.6.
|
|
65
|
+
"cli-table3": "^0.6.5",
|
|
66
66
|
"contentful-batch-libs": "^9.6.0",
|
|
67
|
-
"contentful-management": "^11.
|
|
67
|
+
"contentful-management": "^11.26.1",
|
|
68
68
|
"date-fns": "^2.30.0",
|
|
69
69
|
"eslint": "^8.57.0",
|
|
70
70
|
"eslint-config-standard": "^17.1.0",
|
|
71
|
-
"joi": "^17.
|
|
71
|
+
"joi": "^17.13.1",
|
|
72
72
|
"listr": "^0.14.1",
|
|
73
73
|
"listr-update-renderer": "^0.5.0",
|
|
74
74
|
"listr-verbose-renderer": "^0.6.0",
|
|
@@ -87,16 +87,16 @@
|
|
|
87
87
|
"babel-preset-env": "^1.7.0",
|
|
88
88
|
"cz-conventional-changelog": "^3.1.0",
|
|
89
89
|
"eslint-plugin-import": "^2.29.1",
|
|
90
|
-
"eslint-plugin-jest": "^
|
|
90
|
+
"eslint-plugin-jest": "^28.5.0",
|
|
91
91
|
"eslint-plugin-node": "^11.1.0",
|
|
92
92
|
"eslint-plugin-promise": "^6.1.1",
|
|
93
93
|
"eslint-plugin-standard": "^5.0.0",
|
|
94
94
|
"jest": "^29.7.0",
|
|
95
|
-
"rimraf": "^5.0.
|
|
96
|
-
"semantic-release": "^
|
|
97
|
-
"ts-jest": "^29.1.
|
|
95
|
+
"rimraf": "^5.0.7",
|
|
96
|
+
"semantic-release": "^23.1.1",
|
|
97
|
+
"ts-jest": "^29.1.3",
|
|
98
98
|
"tsup": "^8.0.2",
|
|
99
|
-
"typescript": "^5.4.
|
|
99
|
+
"typescript": "^5.4.5"
|
|
100
100
|
},
|
|
101
101
|
"files": [
|
|
102
102
|
"bin",
|