contentful-export 7.17.0 → 7.17.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/index.js +6 -8
- package/dist/parseOptions.js +7 -9
- package/dist/tasks/download-assets.js +7 -7
- package/dist/tasks/get-space-data.js +14 -16
- package/dist/tasks/init-client.js +4 -4
- package/package.json +2 -2
- package/types.d.ts +1 -2
package/dist/index.js
CHANGED
@@ -27,9 +27,7 @@ var _differenceInSeconds = _interopRequireDefault(require("date-fns/differenceIn
|
|
27
27
|
|
28
28
|
var _formatDistance = _interopRequireDefault(require("date-fns/formatDistance"));
|
29
29
|
|
30
|
-
var
|
31
|
-
|
32
|
-
var _logging = require("contentful-batch-libs/dist/logging");
|
30
|
+
var _contentfulBatchLibs = require("contentful-batch-libs");
|
33
31
|
|
34
32
|
var _downloadAssets = _interopRequireDefault(require("./tasks/download-assets"));
|
35
33
|
|
@@ -61,10 +59,10 @@ function runContentfulExport(params) {
|
|
61
59
|
const options = (0, _parseOptions.default)(params);
|
62
60
|
const listrOptions = createListrOptions(options); // Setup custom error listener to store errors for later
|
63
61
|
|
64
|
-
(0,
|
62
|
+
(0, _contentfulBatchLibs.setupLogging)(log);
|
65
63
|
const tasks = new _listr.default([{
|
66
64
|
title: 'Initialize client',
|
67
|
-
task: (0,
|
65
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
68
66
|
try {
|
69
67
|
// CMA client
|
70
68
|
ctx.client = (0, _initClient.default)(options);
|
@@ -102,7 +100,7 @@ function runContentfulExport(params) {
|
|
102
100
|
}
|
103
101
|
}, {
|
104
102
|
title: 'Download assets',
|
105
|
-
task: (0,
|
103
|
+
task: (0, _contentfulBatchLibs.wrapTask)((0, _downloadAssets.default)(options)),
|
106
104
|
skip: ctx => !options.downloadAssets || !Object.prototype.hasOwnProperty.call(ctx.data, 'assets')
|
107
105
|
}, {
|
108
106
|
title: 'Write export log file',
|
@@ -185,10 +183,10 @@ function runContentfulExport(params) {
|
|
185
183
|
// @todo this should live in batch libs
|
186
184
|
const errorLog = log.filter(logMessage => logMessage.level !== 'info' && logMessage.level !== 'warning');
|
187
185
|
const displayLog = log.filter(logMessage => logMessage.level !== 'info');
|
188
|
-
(0,
|
186
|
+
(0, _contentfulBatchLibs.displayErrorLog)(displayLog);
|
189
187
|
|
190
188
|
if (errorLog.length) {
|
191
|
-
return (0,
|
189
|
+
return (0, _contentfulBatchLibs.writeErrorLogFile)(options.errorLogFile, errorLog).then(() => {
|
192
190
|
const multiError = new Error('Errors occured');
|
193
191
|
multiError.name = 'ContentfulMultiError';
|
194
192
|
multiError.errors = errorLog;
|
package/dist/parseOptions.js
CHANGED
@@ -5,19 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = parseOptions;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _contentfulBatchLibs = require("contentful-batch-libs");
|
9
9
|
|
10
10
|
var _format = _interopRequireDefault(require("date-fns/format"));
|
11
11
|
|
12
|
-
var
|
13
|
-
|
14
|
-
var _proxy = require("contentful-batch-libs/dist/proxy");
|
12
|
+
var _path = require("path");
|
15
13
|
|
16
|
-
var
|
14
|
+
var _querystring = _interopRequireDefault(require("querystring"));
|
17
15
|
|
18
16
|
var _package = require("../package");
|
19
17
|
|
20
|
-
var
|
18
|
+
var _headers = require("./utils/headers");
|
21
19
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
21
|
|
@@ -46,7 +44,7 @@ function parseOptions(params) {
|
|
46
44
|
const configFile = params.config ? require((0, _path.resolve)(process.cwd(), params.config)) : {};
|
47
45
|
|
48
46
|
const options = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultOptions), configFile), params), {}, {
|
49
|
-
headers: (0,
|
47
|
+
headers: (0, _contentfulBatchLibs.addSequenceHeader)(params.headers || (0, _headers.getHeadersConfig)(params.header))
|
50
48
|
}); // Validation
|
51
49
|
|
52
50
|
|
@@ -79,11 +77,11 @@ function parseOptions(params) {
|
|
79
77
|
options.accessToken = options.managementToken;
|
80
78
|
|
81
79
|
if (typeof options.proxy === 'string') {
|
82
|
-
options.proxy = (0,
|
80
|
+
options.proxy = (0, _contentfulBatchLibs.proxyStringToObject)(options.proxy);
|
83
81
|
}
|
84
82
|
|
85
83
|
if (!options.rawProxy && options.proxy) {
|
86
|
-
options.httpsAgent = (0,
|
84
|
+
options.httpsAgent = (0, _contentfulBatchLibs.agentFromProxy)(options.proxy);
|
87
85
|
delete options.proxy;
|
88
86
|
}
|
89
87
|
|
@@ -5,24 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = downloadAssets;
|
7
7
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
8
|
var _bluebird = _interopRequireDefault(require("bluebird"));
|
11
9
|
|
10
|
+
var _contentfulBatchLibs = require("contentful-batch-libs");
|
11
|
+
|
12
12
|
var _figures = _interopRequireDefault(require("figures"));
|
13
13
|
|
14
14
|
var _fs = require("fs");
|
15
15
|
|
16
16
|
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
17
17
|
|
18
|
+
var _path = _interopRequireDefault(require("path"));
|
19
|
+
|
18
20
|
var _stream = require("stream");
|
19
21
|
|
20
22
|
var _util = require("util");
|
21
23
|
|
22
24
|
var _embargoedAssets = require("../utils/embargoedAssets");
|
23
25
|
|
24
|
-
var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
|
25
|
-
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
27
|
|
28
28
|
const streamPipeline = (0, _util.promisify)(_stream.pipeline);
|
@@ -65,7 +65,7 @@ function downloadAssets(options) {
|
|
65
65
|
let errorCount = 0;
|
66
66
|
return _bluebird.default.map(ctx.data.assets, asset => {
|
67
67
|
if (!asset.fields.file) {
|
68
|
-
task.output = `${_figures.default.warning} asset ${(0,
|
68
|
+
task.output = `${_figures.default.warning} asset ${(0, _contentfulBatchLibs.getEntityName)(asset)} has no file(s)`;
|
69
69
|
warningCount++;
|
70
70
|
return;
|
71
71
|
}
|
@@ -75,7 +75,7 @@ function downloadAssets(options) {
|
|
75
75
|
const url = asset.fields.file[locale].url;
|
76
76
|
|
77
77
|
if (!url) {
|
78
|
-
task.output = `${_figures.default.cross} asset '${(0,
|
78
|
+
task.output = `${_figures.default.cross} asset '${(0, _contentfulBatchLibs.getEntityName)(asset)}' doesn't contain an url in path asset.fields.file[${locale}].url`;
|
79
79
|
errorCount++;
|
80
80
|
return _bluebird.default.resolve();
|
81
81
|
}
|
@@ -100,7 +100,7 @@ function downloadAssets(options) {
|
|
100
100
|
}
|
101
101
|
|
102
102
|
return startingPromise.then(downloadAsset).then(downLoadedFile => {
|
103
|
-
task.output = `${_figures.default.tick} downloaded ${(0,
|
103
|
+
task.output = `${_figures.default.tick} downloaded ${(0, _contentfulBatchLibs.getEntityName)(downLoadedFile)} (${url})`;
|
104
104
|
successCount++;
|
105
105
|
}).catch(error => {
|
106
106
|
task.output = `${_figures.default.cross} error downloading ${url}: ${error.message}`;
|
@@ -7,14 +7,12 @@ exports.default = getFullSourceSpace;
|
|
7
7
|
|
8
8
|
var _bluebird = _interopRequireDefault(require("bluebird"));
|
9
9
|
|
10
|
+
var _contentfulBatchLibs = require("contentful-batch-libs");
|
11
|
+
|
10
12
|
var _listr = _interopRequireDefault(require("listr"));
|
11
13
|
|
12
14
|
var _listrVerboseRenderer = _interopRequireDefault(require("listr-verbose-renderer"));
|
13
15
|
|
14
|
-
var _listr2 = require("contentful-batch-libs/dist/listr");
|
15
|
-
|
16
|
-
var _logging = require("contentful-batch-libs/dist/logging");
|
17
|
-
|
18
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
17
|
|
20
18
|
const MAX_ALLOWED_LIMIT = 1000;
|
@@ -47,7 +45,7 @@ function getFullSourceSpace({
|
|
47
45
|
};
|
48
46
|
return new _listr.default([{
|
49
47
|
title: 'Connecting to space',
|
50
|
-
task: (0,
|
48
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
51
49
|
return client.getSpace(spaceId).then(space => {
|
52
50
|
ctx.space = space;
|
53
51
|
return space.getEnvironment(environmentId);
|
@@ -57,7 +55,7 @@ function getFullSourceSpace({
|
|
57
55
|
})
|
58
56
|
}, {
|
59
57
|
title: 'Fetching content types data',
|
60
|
-
task: (0,
|
58
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
61
59
|
return pagedGet({
|
62
60
|
source: ctx.environment,
|
63
61
|
method: 'getContentTypes'
|
@@ -68,7 +66,7 @@ function getFullSourceSpace({
|
|
68
66
|
skip: () => skipContentModel
|
69
67
|
}, {
|
70
68
|
title: 'Fetching tags data',
|
71
|
-
task: (0,
|
69
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
72
70
|
return pagedGet({
|
73
71
|
source: ctx.environment,
|
74
72
|
method: 'getTags'
|
@@ -81,7 +79,7 @@ function getFullSourceSpace({
|
|
81
79
|
skip: () => cdaClient
|
82
80
|
}, {
|
83
81
|
title: 'Fetching editor interfaces data',
|
84
|
-
task: (0,
|
82
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
85
83
|
return getEditorInterfaces(ctx.data.contentTypes).then(editorInterfaces => {
|
86
84
|
ctx.data.editorInterfaces = editorInterfaces.filter(editorInterface => {
|
87
85
|
return editorInterface !== null;
|
@@ -91,7 +89,7 @@ function getFullSourceSpace({
|
|
91
89
|
skip: ctx => skipContentModel || skipEditorInterfaces || ctx.data.contentTypes.length === 0 && 'Skipped since no content types downloaded'
|
92
90
|
}, {
|
93
91
|
title: 'Fetching content entries data',
|
94
|
-
task: (0,
|
92
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
95
93
|
const source = cdaClient || ctx.environment;
|
96
94
|
|
97
95
|
if (cdaClient) {
|
@@ -112,7 +110,7 @@ function getFullSourceSpace({
|
|
112
110
|
skip: () => skipContent
|
113
111
|
}, {
|
114
112
|
title: 'Fetching assets data',
|
115
|
-
task: (0,
|
113
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
116
114
|
const source = cdaClient || ctx.environment;
|
117
115
|
queryAssets = queryAssets || {};
|
118
116
|
queryAssets.locale = '*';
|
@@ -127,7 +125,7 @@ function getFullSourceSpace({
|
|
127
125
|
skip: () => skipContent
|
128
126
|
}, {
|
129
127
|
title: 'Fetching locales data',
|
130
|
-
task: (0,
|
128
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
131
129
|
return pagedGet({
|
132
130
|
source: ctx.environment,
|
133
131
|
method: 'getLocales'
|
@@ -138,7 +136,7 @@ function getFullSourceSpace({
|
|
138
136
|
skip: () => skipContentModel
|
139
137
|
}, {
|
140
138
|
title: 'Fetching webhooks data',
|
141
|
-
task: (0,
|
139
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
142
140
|
return pagedGet({
|
143
141
|
source: ctx.space,
|
144
142
|
method: 'getWebhooks'
|
@@ -149,7 +147,7 @@ function getFullSourceSpace({
|
|
149
147
|
skip: () => skipWebhooks || environmentId !== 'master' && 'Webhooks can only be exported from master environment'
|
150
148
|
}, {
|
151
149
|
title: 'Fetching roles data',
|
152
|
-
task: (0,
|
150
|
+
task: (0, _contentfulBatchLibs.wrapTask)(ctx => {
|
153
151
|
return pagedGet({
|
154
152
|
source: ctx.space,
|
155
153
|
method: 'getRoles'
|
@@ -164,13 +162,13 @@ function getFullSourceSpace({
|
|
164
162
|
function getEditorInterfaces(contentTypes) {
|
165
163
|
return _bluebird.default.map(contentTypes, contentType => {
|
166
164
|
return contentType.getEditorInterface().then(editorInterface => {
|
167
|
-
|
165
|
+
_contentfulBatchLibs.logEmitter.emit('info', `Fetched editor interface for ${contentType.name}`);
|
168
166
|
|
169
167
|
return editorInterface;
|
170
168
|
}).catch(() => {
|
171
169
|
// old contentTypes may not have an editor interface but we'll handle in a later stage
|
172
170
|
// but it should not stop getting the data process
|
173
|
-
|
171
|
+
_contentfulBatchLibs.logEmitter.emit('warning', `No editor interface found for ${contentType}`);
|
174
172
|
|
175
173
|
return _bluebird.default.resolve(null);
|
176
174
|
});
|
@@ -218,7 +216,7 @@ function pagedGet({
|
|
218
216
|
const page = Math.ceil(skip / pageLimit) + 1;
|
219
217
|
const pages = Math.ceil(total / pageLimit);
|
220
218
|
|
221
|
-
|
219
|
+
_contentfulBatchLibs.logEmitter.emit('info', `Fetched ${aggregatedResponse.items.length} of ${total} items (Page ${page}/${pages})`);
|
222
220
|
|
223
221
|
if (skip + pageLimit < total) {
|
224
222
|
return pagedGet({
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = initClient;
|
7
7
|
|
8
|
-
var _contentfulManagement = require("contentful-management");
|
9
|
-
|
10
8
|
var _contentful = require("contentful");
|
11
9
|
|
12
|
-
var
|
10
|
+
var _contentfulBatchLibs = require("contentful-batch-libs");
|
11
|
+
|
12
|
+
var _contentfulManagement = require("contentful-management");
|
13
13
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
15
15
|
|
@@ -18,7 +18,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
18
18
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
19
|
|
20
20
|
function logHandler(level, data) {
|
21
|
-
|
21
|
+
_contentfulBatchLibs.logEmitter.emit(level, data);
|
22
22
|
}
|
23
23
|
|
24
24
|
function initClient(opts, useCda = false) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "contentful-export",
|
3
|
-
"version": "7.17.
|
3
|
+
"version": "7.17.3",
|
4
4
|
"description": "this tool allows you to export a space to a JSON dump",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "types.d.ts",
|
@@ -47,7 +47,7 @@
|
|
47
47
|
"bluebird": "^3.3.3",
|
48
48
|
"cli-table3": "^0.6.0",
|
49
49
|
"contentful": "^9.0.0",
|
50
|
-
"contentful-batch-libs": "^9.
|
50
|
+
"contentful-batch-libs": "^9.3.0",
|
51
51
|
"contentful-management": "^10.0.0",
|
52
52
|
"date-fns": "^2.28.0",
|
53
53
|
"figures": "^3.2.0",
|
package/types.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
export interface Options {
|
2
2
|
managementToken: string;
|
3
3
|
spaceId: string;
|
4
|
-
|
5
4
|
contentFile?: string;
|
6
5
|
contentOnly?: boolean;
|
7
6
|
deliveryToken?: string;
|
@@ -16,7 +15,7 @@ export interface Options {
|
|
16
15
|
limit?: number;
|
17
16
|
managementApplication?: string;
|
18
17
|
managementFeature?: string;
|
19
|
-
maxAllowedLimit?:
|
18
|
+
maxAllowedLimit?: number;
|
20
19
|
proxy?: string;
|
21
20
|
queryEntries?: string[];
|
22
21
|
queryAssets?: string[];
|