contentful-import 9.0.16 → 9.0.18
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.
|
@@ -24,30 +24,60 @@ async function getAssetStreamForURL(url, assetsDirectory) {
|
|
|
24
24
|
throw error;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
async function processAssetForLocale(locale, asset, processingOptions) {
|
|
28
|
+
try {
|
|
29
|
+
return await asset.processForLocale(locale, processingOptions);
|
|
30
|
+
} catch (err) {
|
|
31
|
+
err.entity = asset;
|
|
32
|
+
_logging.logEmitter.emit('error', err);
|
|
33
|
+
throw err;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// From
|
|
38
|
+
// https://stackoverflow.com/questions/67339630/how-to-get-last-resolved-promise-from-a-list-of-resolved-promises-in-javascript
|
|
39
|
+
async function lastResult(promises) {
|
|
40
|
+
if (!promises.length) throw new RangeError('No last result from no promises');
|
|
41
|
+
const results = [];
|
|
42
|
+
await Promise.all(promises.map(p => p.then(v => {
|
|
43
|
+
results.push(v);
|
|
44
|
+
})));
|
|
45
|
+
return results[results.length - 1];
|
|
46
|
+
}
|
|
27
47
|
async function processAssets({
|
|
28
48
|
assets,
|
|
29
49
|
timeout,
|
|
30
50
|
retryLimit,
|
|
31
51
|
requestQueue
|
|
32
52
|
}) {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
const processingOptions = Object.assign({}, timeout && {
|
|
54
|
+
processingCheckWait: timeout
|
|
55
|
+
}, retryLimit && {
|
|
56
|
+
processingCheckRetry: retryLimit
|
|
57
|
+
});
|
|
58
|
+
const pendingProcessingAssets = assets.map(async asset => {
|
|
59
|
+
_logging.logEmitter.emit('info', `Processing Asset ${(0, _getEntityName.default)(asset)}`);
|
|
60
|
+
|
|
61
|
+
// We want to do what processForAllLocale does, but as the rate
|
|
62
|
+
// limit is only enforced if we have a dedicated requestQueue item
|
|
63
|
+
// for every processForLocale call, we need to duplicate the logic
|
|
64
|
+
// here
|
|
65
|
+
const locales = Object.keys(asset.fields.file || {});
|
|
66
|
+
let latestAssetVersion = asset;
|
|
67
|
+
try {
|
|
68
|
+
// The last resolved promise will return the most up to date asset
|
|
69
|
+
// version which we need for next import steps (e.g. publishing)
|
|
70
|
+
latestAssetVersion = await lastResult(locales.map(locale => {
|
|
71
|
+
return requestQueue.add(() => processAssetForLocale(locale, asset, processingOptions));
|
|
72
|
+
}));
|
|
73
|
+
} catch (err) {
|
|
74
|
+
// Handle any error that arises during the processing of any locale
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
return latestAssetVersion;
|
|
50
78
|
});
|
|
51
79
|
const potentiallyProcessedAssets = await Promise.all(pendingProcessingAssets);
|
|
80
|
+
|
|
81
|
+
// This filters out all process attempts which failed
|
|
52
82
|
return potentiallyProcessedAssets.filter(asset => asset);
|
|
53
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentful-import",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.18",
|
|
4
4
|
"description": "this tool allows you to import JSON dump exported by contentful-export",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"date-fns": "^2.30.0",
|
|
60
60
|
"eslint": "^8.49.0",
|
|
61
61
|
"eslint-config-standard": "^17.1.0",
|
|
62
|
-
"joi": "^17.10.
|
|
62
|
+
"joi": "^17.10.2",
|
|
63
63
|
"listr": "^0.14.1",
|
|
64
64
|
"listr-update-renderer": "^0.5.0",
|
|
65
65
|
"listr-verbose-renderer": "^0.6.0",
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@babel/cli": "^7.22.15",
|
|
72
|
-
"@babel/core": "^7.22.
|
|
72
|
+
"@babel/core": "^7.22.20",
|
|
73
73
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
74
|
-
"@babel/preset-env": "^7.22.
|
|
74
|
+
"@babel/preset-env": "^7.22.20",
|
|
75
75
|
"babel-jest": "^29.7.0",
|
|
76
76
|
"babel-plugin-add-module-exports": "^1.0.2",
|
|
77
77
|
"babel-preset-env": "^1.7.0",
|
|
78
78
|
"cz-conventional-changelog": "^3.1.0",
|
|
79
79
|
"eslint-plugin-import": "^2.28.1",
|
|
80
|
-
"eslint-plugin-jest": "^27.
|
|
80
|
+
"eslint-plugin-jest": "^27.4.0",
|
|
81
81
|
"eslint-plugin-node": "^11.1.0",
|
|
82
82
|
"eslint-plugin-promise": "^6.1.1",
|
|
83
83
|
"husky": "^8.0.3",
|