contentful-import 8.2.29 → 8.3.2
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 +30 -49
- package/dist/parseOptions.js +7 -13
- package/dist/tasks/get-destination-data.js +4 -6
- package/dist/tasks/push-to-space/assets.js +5 -9
- package/dist/tasks/push-to-space/creation.js +3 -5
- package/dist/tasks/push-to-space/publishing.js +6 -8
- package/dist/tasks/push-to-space/push-to-space.js +22 -32
- package/dist/transform/transform-space.js +21 -26
- package/dist/transform/transformers.js +3 -3
- package/dist/usageParams.js +6 -7
- package/dist/utils/schema.js +63 -64
- package/dist/utils/sort-entries.js +1 -3
- package/dist/utils/validations.js +5 -6
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -5,57 +5,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = runContentfulImport;
|
|
7
7
|
|
|
8
|
-
var _cliTable = require("cli-table3");
|
|
8
|
+
var _cliTable = _interopRequireDefault(require("cli-table3"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _differenceInSeconds = _interopRequireDefault(require("date-fns/differenceInSeconds"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _formatDistance = _interopRequireDefault(require("date-fns/formatDistance"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _listr = _interopRequireDefault(require("listr"));
|
|
15
15
|
|
|
16
|
-
var _listrUpdateRenderer = require("listr-update-renderer");
|
|
16
|
+
var _listrUpdateRenderer = _interopRequireDefault(require("listr-update-renderer"));
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _listrVerboseRenderer = require("listr-verbose-renderer");
|
|
21
|
-
|
|
22
|
-
var _listrVerboseRenderer2 = _interopRequireDefault(_listrVerboseRenderer);
|
|
18
|
+
var _listrVerboseRenderer = _interopRequireDefault(require("listr-verbose-renderer"));
|
|
23
19
|
|
|
24
20
|
var _lodash = require("lodash");
|
|
25
21
|
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var _moment2 = _interopRequireDefault(_moment);
|
|
29
|
-
|
|
30
|
-
var _pQueue = require("p-queue");
|
|
31
|
-
|
|
32
|
-
var _pQueue2 = _interopRequireDefault(_pQueue);
|
|
22
|
+
var _pQueue = _interopRequireDefault(require("p-queue"));
|
|
33
23
|
|
|
34
24
|
var _logging = require("contentful-batch-libs/dist/logging");
|
|
35
25
|
|
|
36
|
-
var
|
|
26
|
+
var _listr2 = require("contentful-batch-libs/dist/listr");
|
|
37
27
|
|
|
38
|
-
var _initClient = require("./tasks/init-client");
|
|
28
|
+
var _initClient = _interopRequireDefault(require("./tasks/init-client"));
|
|
39
29
|
|
|
40
|
-
var
|
|
30
|
+
var _getDestinationData = _interopRequireDefault(require("./tasks/get-destination-data"));
|
|
41
31
|
|
|
42
|
-
var
|
|
32
|
+
var _pushToSpace = _interopRequireDefault(require("./tasks/push-to-space/push-to-space"));
|
|
43
33
|
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
var _pushToSpace = require("./tasks/push-to-space/push-to-space");
|
|
47
|
-
|
|
48
|
-
var _pushToSpace2 = _interopRequireDefault(_pushToSpace);
|
|
49
|
-
|
|
50
|
-
var _transformSpace = require("./transform/transform-space");
|
|
51
|
-
|
|
52
|
-
var _transformSpace2 = _interopRequireDefault(_transformSpace);
|
|
34
|
+
var _transformSpace = _interopRequireDefault(require("./transform/transform-space"));
|
|
53
35
|
|
|
54
36
|
var _validations = require("./utils/validations");
|
|
55
37
|
|
|
56
|
-
var _parseOptions = require("./parseOptions");
|
|
57
|
-
|
|
58
|
-
var _parseOptions2 = _interopRequireDefault(_parseOptions);
|
|
38
|
+
var _parseOptions = _interopRequireDefault(require("./parseOptions"));
|
|
59
39
|
|
|
60
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
61
41
|
|
|
@@ -64,28 +44,28 @@ const ONE_SECOND = 1000;
|
|
|
64
44
|
function createListrOptions(options) {
|
|
65
45
|
if (options.useVerboseRenderer) {
|
|
66
46
|
return {
|
|
67
|
-
renderer:
|
|
47
|
+
renderer: _listrVerboseRenderer.default
|
|
68
48
|
};
|
|
69
49
|
}
|
|
70
50
|
|
|
71
51
|
return {
|
|
72
|
-
renderer:
|
|
52
|
+
renderer: _listrUpdateRenderer.default,
|
|
73
53
|
collapse: false
|
|
74
54
|
};
|
|
75
55
|
}
|
|
76
56
|
|
|
77
57
|
function runContentfulImport(params) {
|
|
78
58
|
const log = [];
|
|
79
|
-
const options = (0,
|
|
59
|
+
const options = (0, _parseOptions.default)(params);
|
|
80
60
|
const listrOptions = createListrOptions(options);
|
|
81
|
-
const requestQueue = new
|
|
61
|
+
const requestQueue = new _pQueue.default({
|
|
82
62
|
interval: ONE_SECOND,
|
|
83
63
|
intervalCap: options.rateLimit,
|
|
84
64
|
carryoverConcurrencyCount: true
|
|
85
65
|
}); // Setup custom log listener to store log messages for later
|
|
86
66
|
|
|
87
67
|
(0, _logging.setupLogging)(log);
|
|
88
|
-
const infoTable = new
|
|
68
|
+
const infoTable = new _cliTable.default();
|
|
89
69
|
infoTable.push([{
|
|
90
70
|
colSpan: 2,
|
|
91
71
|
content: 'The following entities are going to be imported:'
|
|
@@ -106,20 +86,20 @@ function runContentfulImport(params) {
|
|
|
106
86
|
infoTable.push([(0, _lodash.startCase)(type), options.content[type].length]);
|
|
107
87
|
});
|
|
108
88
|
console.log(infoTable.toString());
|
|
109
|
-
const tasks = new
|
|
89
|
+
const tasks = new _listr.default([{
|
|
110
90
|
title: 'Validating content-file',
|
|
111
91
|
task: ctx => {
|
|
112
92
|
(0, _validations.assertPayload)(options.content);
|
|
113
93
|
}
|
|
114
94
|
}, {
|
|
115
95
|
title: 'Initialize client',
|
|
116
|
-
task: (0,
|
|
117
|
-
ctx.client = (0,
|
|
96
|
+
task: (0, _listr2.wrapTask)(async ctx => {
|
|
97
|
+
ctx.client = (0, _initClient.default)(options);
|
|
118
98
|
})
|
|
119
99
|
}, {
|
|
120
100
|
title: 'Checking if destination space already has any content and retrieving it',
|
|
121
|
-
task: (0,
|
|
122
|
-
const destinationData = await (0,
|
|
101
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
102
|
+
const destinationData = await (0, _getDestinationData.default)({
|
|
123
103
|
client: ctx.client,
|
|
124
104
|
spaceId: options.spaceId,
|
|
125
105
|
environmentId: options.environmentId,
|
|
@@ -134,14 +114,14 @@ function runContentfulImport(params) {
|
|
|
134
114
|
})
|
|
135
115
|
}, {
|
|
136
116
|
title: 'Apply transformations to source data',
|
|
137
|
-
task: (0,
|
|
138
|
-
const transformedSourceData = (0,
|
|
117
|
+
task: (0, _listr2.wrapTask)(async ctx => {
|
|
118
|
+
const transformedSourceData = (0, _transformSpace.default)(ctx.sourceDataUntransformed, ctx.destinationData);
|
|
139
119
|
ctx.sourceData = transformedSourceData;
|
|
140
120
|
})
|
|
141
121
|
}, {
|
|
142
122
|
title: 'Push content to destination space',
|
|
143
123
|
task: (ctx, task) => {
|
|
144
|
-
return (0,
|
|
124
|
+
return (0, _pushToSpace.default)({
|
|
145
125
|
sourceData: ctx.sourceData,
|
|
146
126
|
destinationData: ctx.destinationData,
|
|
147
127
|
client: ctx.client,
|
|
@@ -167,7 +147,7 @@ function runContentfulImport(params) {
|
|
|
167
147
|
const resultTypes = Object.keys(ctx.data);
|
|
168
148
|
|
|
169
149
|
if (resultTypes.length) {
|
|
170
|
-
const resultTable = new
|
|
150
|
+
const resultTable = new _cliTable.default();
|
|
171
151
|
resultTable.push([{
|
|
172
152
|
colSpan: 2,
|
|
173
153
|
content: 'Imported entities'
|
|
@@ -180,8 +160,9 @@ function runContentfulImport(params) {
|
|
|
180
160
|
console.log('No data was imported');
|
|
181
161
|
}
|
|
182
162
|
|
|
183
|
-
const
|
|
184
|
-
const
|
|
163
|
+
const endTime = new Date();
|
|
164
|
+
const durationHuman = (0, _formatDistance.default)(endTime, options.startTime);
|
|
165
|
+
const durationSeconds = (0, _differenceInSeconds.default)(endTime, options.startTime);
|
|
185
166
|
console.log(`The import took ${durationHuman} (${durationSeconds}s)`);
|
|
186
167
|
return ctx.data;
|
|
187
168
|
}).catch(err => {
|
package/dist/parseOptions.js
CHANGED
|
@@ -5,15 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = parseOptions;
|
|
7
7
|
|
|
8
|
-
var _fs = require("fs");
|
|
9
|
-
|
|
10
|
-
var _fs2 = _interopRequireDefault(_fs);
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
11
9
|
|
|
12
10
|
var _path = require("path");
|
|
13
11
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _moment2 = _interopRequireDefault(_moment);
|
|
12
|
+
var _format = _interopRequireDefault(require("date-fns/format"));
|
|
17
13
|
|
|
18
14
|
var _package = require("../package");
|
|
19
15
|
|
|
@@ -21,9 +17,7 @@ var _headers = require("./utils/headers");
|
|
|
21
17
|
|
|
22
18
|
var _proxy = require("contentful-batch-libs/dist/proxy");
|
|
23
19
|
|
|
24
|
-
var _addSequenceHeader = require("contentful-batch-libs/dist/add-sequence-header");
|
|
25
|
-
|
|
26
|
-
var _addSequenceHeader2 = _interopRequireDefault(_addSequenceHeader);
|
|
20
|
+
var _addSequenceHeader = _interopRequireDefault(require("contentful-batch-libs/dist/add-sequence-header"));
|
|
27
21
|
|
|
28
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
23
|
|
|
@@ -49,7 +43,7 @@ function parseOptions(params) {
|
|
|
49
43
|
const configFile = params.config ? require((0, _path.resolve)(process.cwd(), params.config)) : {};
|
|
50
44
|
|
|
51
45
|
const options = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultOptions), configFile), params), {}, {
|
|
52
|
-
headers: (0,
|
|
46
|
+
headers: (0, _addSequenceHeader.default)(params.headers || (0, _headers.getHeadersConfig)(params.header))
|
|
53
47
|
}); // Validation
|
|
54
48
|
|
|
55
49
|
|
|
@@ -80,17 +74,17 @@ function parseOptions(params) {
|
|
|
80
74
|
throw new Error('Please provide the proxy config in the following format:\nhost:port or user:password@host:port');
|
|
81
75
|
}
|
|
82
76
|
|
|
83
|
-
options.startTime =
|
|
77
|
+
options.startTime = new Date();
|
|
84
78
|
|
|
85
79
|
if (!options.errorLogFile) {
|
|
86
|
-
options.errorLogFile = (0, _path.resolve)(process.cwd(), `contentful-import-error-log-${options.spaceId}-${options.startTime
|
|
80
|
+
options.errorLogFile = (0, _path.resolve)(process.cwd(), `contentful-import-error-log-${options.spaceId}-${(0, _format.default)(options.startTime, "yyyy-MM-dd'T'HH-mm-ss")}.json`);
|
|
87
81
|
} else {
|
|
88
82
|
options.errorLogFile = (0, _path.resolve)(process.cwd(), options.errorLogFile);
|
|
89
83
|
} // Further processing
|
|
90
84
|
|
|
91
85
|
|
|
92
86
|
options.accessToken = options.managementToken;
|
|
93
|
-
options.content = options.content || JSON.parse(
|
|
87
|
+
options.content = options.content || JSON.parse(_fs.default.readFileSync(options.contentFile)); // Clean up content to only include supported entity types
|
|
94
88
|
|
|
95
89
|
Object.keys(options.content).forEach(type => {
|
|
96
90
|
if (SUPPORTED_ENTITY_TYPES.indexOf(type) === -1) {
|
|
@@ -5,9 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = getDestinationData;
|
|
7
7
|
|
|
8
|
-
var _bluebird = require("bluebird");
|
|
9
|
-
|
|
10
|
-
var _bluebird2 = _interopRequireDefault(_bluebird);
|
|
8
|
+
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
11
9
|
|
|
12
10
|
var _logging = require("contentful-batch-libs/dist/logging");
|
|
13
11
|
|
|
@@ -63,7 +61,7 @@ async function batchedIdQuery({
|
|
|
63
61
|
return response.items;
|
|
64
62
|
});
|
|
65
63
|
});
|
|
66
|
-
const responses = await
|
|
64
|
+
const responses = await _bluebird.default.all(allPendingResponses);
|
|
67
65
|
return responses.flat();
|
|
68
66
|
}
|
|
69
67
|
|
|
@@ -148,7 +146,7 @@ async function getDestinationData({
|
|
|
148
146
|
});
|
|
149
147
|
|
|
150
148
|
if (contentModelOnly) {
|
|
151
|
-
return
|
|
149
|
+
return _bluebird.default.props(result);
|
|
152
150
|
}
|
|
153
151
|
|
|
154
152
|
const entryIds = sourceData.entries.map(e => e.sys.id);
|
|
@@ -166,7 +164,7 @@ async function getDestinationData({
|
|
|
166
164
|
requestQueue
|
|
167
165
|
});
|
|
168
166
|
result.webhooks = [];
|
|
169
|
-
return
|
|
167
|
+
return _bluebird.default.props(result);
|
|
170
168
|
}
|
|
171
169
|
|
|
172
170
|
module.exports = exports.default;
|
|
@@ -6,23 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getAssetStreamForURL = getAssetStreamForURL;
|
|
7
7
|
exports.processAssets = processAssets;
|
|
8
8
|
|
|
9
|
-
var _fs = require("fs");
|
|
10
|
-
|
|
11
|
-
var _fs2 = _interopRequireDefault(_fs);
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
10
|
|
|
13
11
|
var _path = require("path");
|
|
14
12
|
|
|
15
13
|
var _util = require("util");
|
|
16
14
|
|
|
17
|
-
var _getEntityName = require("contentful-batch-libs/dist/get-entity-name");
|
|
18
|
-
|
|
19
|
-
var _getEntityName2 = _interopRequireDefault(_getEntityName);
|
|
15
|
+
var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
|
|
20
16
|
|
|
21
17
|
var _logging = require("contentful-batch-libs/dist/logging");
|
|
22
18
|
|
|
23
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
20
|
|
|
25
|
-
const stat = (0, _util.promisify)(
|
|
21
|
+
const stat = (0, _util.promisify)(_fs.default.stat);
|
|
26
22
|
|
|
27
23
|
async function getAssetStreamForURL(url, assetsDirectory) {
|
|
28
24
|
const [, assetPath] = url.split('//');
|
|
@@ -30,7 +26,7 @@ async function getAssetStreamForURL(url, assetsDirectory) {
|
|
|
30
26
|
|
|
31
27
|
try {
|
|
32
28
|
await stat(filePath);
|
|
33
|
-
return
|
|
29
|
+
return _fs.default.createReadStream(filePath);
|
|
34
30
|
} catch (err) {
|
|
35
31
|
const error = new Error('Cannot open asset from filesystem');
|
|
36
32
|
error.filePath = filePath;
|
|
@@ -46,7 +42,7 @@ async function processAssets({
|
|
|
46
42
|
}) {
|
|
47
43
|
const pendingProcessingAssets = assets.map(asset => {
|
|
48
44
|
return requestQueue.add(async () => {
|
|
49
|
-
_logging.logEmitter.emit('info', `Processing Asset ${(0,
|
|
45
|
+
_logging.logEmitter.emit('info', `Processing Asset ${(0, _getEntityName.default)(asset)}`);
|
|
50
46
|
|
|
51
47
|
const processingOptions = Object.assign({}, timeout && {
|
|
52
48
|
processingCheckWait: timeout
|
|
@@ -4,16 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createEntities = createEntities;
|
|
7
|
-
exports.createLocales = createLocales;
|
|
8
7
|
exports.createEntries = createEntries;
|
|
8
|
+
exports.createLocales = createLocales;
|
|
9
9
|
|
|
10
10
|
var _collection = require("lodash/collection");
|
|
11
11
|
|
|
12
12
|
var _object = require("lodash/object");
|
|
13
13
|
|
|
14
|
-
var _getEntityName = require("contentful-batch-libs/dist/get-entity-name");
|
|
15
|
-
|
|
16
|
-
var _getEntityName2 = _interopRequireDefault(_getEntityName);
|
|
14
|
+
var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
|
|
17
15
|
|
|
18
16
|
var _logging = require("contentful-batch-libs/dist/logging");
|
|
19
17
|
|
|
@@ -250,7 +248,7 @@ function getDestinationEntityForSourceEntity(destinationEntitiesById, sourceEnti
|
|
|
250
248
|
function creationSuccessNotifier(method, createdEntity) {
|
|
251
249
|
const verb = method[0].toUpperCase() + method.substr(1, method.length) + 'd';
|
|
252
250
|
|
|
253
|
-
_logging.logEmitter.emit('info', `${verb} ${createdEntity.sys.type} ${(0,
|
|
251
|
+
_logging.logEmitter.emit('info', `${verb} ${createdEntity.sys.type} ${(0, _getEntityName.default)(createdEntity)}`);
|
|
254
252
|
|
|
255
253
|
return createdEntity;
|
|
256
254
|
}
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.publishEntities = publishEntities;
|
|
7
6
|
exports.archiveEntities = archiveEntities;
|
|
7
|
+
exports.publishEntities = publishEntities;
|
|
8
8
|
|
|
9
|
-
var _getEntityName = require("contentful-batch-libs/dist/get-entity-name");
|
|
10
|
-
|
|
11
|
-
var _getEntityName2 = _interopRequireDefault(_getEntityName);
|
|
9
|
+
var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
|
|
12
10
|
|
|
13
11
|
var _logging = require("contentful-batch-libs/dist/logging");
|
|
14
12
|
|
|
@@ -25,7 +23,7 @@ async function publishEntities({
|
|
|
25
23
|
}) {
|
|
26
24
|
const entitiesToPublish = entities.filter(entity => {
|
|
27
25
|
if (!entity || !entity.publish) {
|
|
28
|
-
_logging.logEmitter.emit('warning', `Unable to publish ${(0,
|
|
26
|
+
_logging.logEmitter.emit('warning', `Unable to publish ${(0, _getEntityName.default)(entity)}`);
|
|
29
27
|
|
|
30
28
|
return false;
|
|
31
29
|
}
|
|
@@ -57,7 +55,7 @@ async function archiveEntities({
|
|
|
57
55
|
}) {
|
|
58
56
|
const entitiesToArchive = entities.filter(entity => {
|
|
59
57
|
if (!entity || !entity.archive) {
|
|
60
|
-
_logging.logEmitter.emit('warning', `Unable to archive ${(0,
|
|
58
|
+
_logging.logEmitter.emit('warning', `Unable to archive ${(0, _getEntityName.default)(entity)}`);
|
|
61
59
|
|
|
62
60
|
return false;
|
|
63
61
|
}
|
|
@@ -102,7 +100,7 @@ async function runQueue(queue, result = [], requestQueue) {
|
|
|
102
100
|
const publishedEntities = [];
|
|
103
101
|
|
|
104
102
|
for (const entity of queue) {
|
|
105
|
-
_logging.logEmitter.emit('info', `Publishing ${entity.sys.type} ${(0,
|
|
103
|
+
_logging.logEmitter.emit('info', `Publishing ${entity.sys.type} ${(0, _getEntityName.default)(entity)}`);
|
|
106
104
|
|
|
107
105
|
try {
|
|
108
106
|
const publishedEntity = await requestQueue.add(() => entity.publish());
|
|
@@ -121,7 +119,7 @@ async function runQueue(queue, result = [], requestQueue) {
|
|
|
121
119
|
if (unpublishedEntities.length > 0) {
|
|
122
120
|
if (queue.length === unpublishedEntities.length) {
|
|
123
121
|
// Fail when queue could not publish at least one item
|
|
124
|
-
const unpublishedEntityNames = unpublishedEntities.map(
|
|
122
|
+
const unpublishedEntityNames = unpublishedEntities.map(_getEntityName.default).join(', ');
|
|
125
123
|
|
|
126
124
|
_logging.logEmitter.emit('error', `Could not publish the following entities: ${unpublishedEntityNames}`);
|
|
127
125
|
} else {
|
|
@@ -5,29 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = pushToSpace;
|
|
7
7
|
|
|
8
|
-
var _listr = require("listr");
|
|
8
|
+
var _listr = _interopRequireDefault(require("listr"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _listrVerboseRenderer = require("listr-verbose-renderer");
|
|
13
|
-
|
|
14
|
-
var _listrVerboseRenderer2 = _interopRequireDefault(_listrVerboseRenderer);
|
|
10
|
+
var _listrVerboseRenderer = _interopRequireDefault(require("listr-verbose-renderer"));
|
|
15
11
|
|
|
16
12
|
var _logging = require("contentful-batch-libs/dist/logging");
|
|
17
13
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _assets = require("./assets");
|
|
21
|
-
|
|
22
|
-
var assets = _interopRequireWildcard(_assets);
|
|
23
|
-
|
|
24
|
-
var _creation = require("./creation");
|
|
14
|
+
var _listr2 = require("contentful-batch-libs/dist/listr");
|
|
25
15
|
|
|
26
|
-
var
|
|
16
|
+
var assets = _interopRequireWildcard(require("./assets"));
|
|
27
17
|
|
|
28
|
-
var
|
|
18
|
+
var creation = _interopRequireWildcard(require("./creation"));
|
|
29
19
|
|
|
30
|
-
var publishing = _interopRequireWildcard(
|
|
20
|
+
var publishing = _interopRequireWildcard(require("./publishing"));
|
|
31
21
|
|
|
32
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
23
|
|
|
@@ -92,7 +82,7 @@ function pushToSpace({
|
|
|
92
82
|
sourceData = _objectSpread(_objectSpread({}, DEFAULT_CONTENT_STRUCTURE), sourceData);
|
|
93
83
|
destinationData = _objectSpread(_objectSpread({}, DEFAULT_CONTENT_STRUCTURE), destinationData);
|
|
94
84
|
listrOptions = listrOptions || {
|
|
95
|
-
renderer:
|
|
85
|
+
renderer: _listrVerboseRenderer.default
|
|
96
86
|
};
|
|
97
87
|
const destinationDataById = {};
|
|
98
88
|
|
|
@@ -106,9 +96,9 @@ function pushToSpace({
|
|
|
106
96
|
destinationDataById[entityType] = entitiesById;
|
|
107
97
|
}
|
|
108
98
|
|
|
109
|
-
return new
|
|
99
|
+
return new _listr.default([{
|
|
110
100
|
title: 'Connecting to space',
|
|
111
|
-
task: (0,
|
|
101
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
112
102
|
const space = await client.getSpace(spaceId);
|
|
113
103
|
const environment = await space.getEnvironment(environmentId);
|
|
114
104
|
ctx.space = space;
|
|
@@ -116,7 +106,7 @@ function pushToSpace({
|
|
|
116
106
|
})
|
|
117
107
|
}, {
|
|
118
108
|
title: 'Importing Locales',
|
|
119
|
-
task: (0,
|
|
109
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
120
110
|
const locales = await creation.createLocales({
|
|
121
111
|
context: {
|
|
122
112
|
target: ctx.environment,
|
|
@@ -131,7 +121,7 @@ function pushToSpace({
|
|
|
131
121
|
skip: () => skipContentModel || skipLocales
|
|
132
122
|
}, {
|
|
133
123
|
title: 'Importing Content Types',
|
|
134
|
-
task: (0,
|
|
124
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
135
125
|
const contentTypes = await creation.createEntities({
|
|
136
126
|
context: {
|
|
137
127
|
target: ctx.environment,
|
|
@@ -146,7 +136,7 @@ function pushToSpace({
|
|
|
146
136
|
skip: () => skipContentModel
|
|
147
137
|
}, {
|
|
148
138
|
title: 'Publishing Content Types',
|
|
149
|
-
task: (0,
|
|
139
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
150
140
|
const publishedContentTypes = await publishEntities({
|
|
151
141
|
entities: ctx.data.contentTypes,
|
|
152
142
|
sourceEntities: sourceData.contentTypes,
|
|
@@ -157,7 +147,7 @@ function pushToSpace({
|
|
|
157
147
|
skip: ctx => skipContentModel
|
|
158
148
|
}, {
|
|
159
149
|
title: 'Importing Tags',
|
|
160
|
-
task: (0,
|
|
150
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
161
151
|
const tags = await creation.createEntities({
|
|
162
152
|
context: {
|
|
163
153
|
target: ctx.environment,
|
|
@@ -174,7 +164,7 @@ function pushToSpace({
|
|
|
174
164
|
skip: () => !destinationDataById.tags
|
|
175
165
|
}, {
|
|
176
166
|
title: 'Importing Editor Interfaces',
|
|
177
|
-
task: (0,
|
|
167
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
178
168
|
const allEditorInterfacesBeingFetched = ctx.data.contentTypes.map(async contentType => {
|
|
179
169
|
const editorInterface = sourceData.editorInterfaces.find(editorInterface => {
|
|
180
170
|
return editorInterface.sys.contentType.sys.id === contentType.sys.id;
|
|
@@ -206,7 +196,7 @@ function pushToSpace({
|
|
|
206
196
|
skip: ctx => skipContentModel || ctx.data.contentTypes.length === 0
|
|
207
197
|
}, {
|
|
208
198
|
title: 'Uploading Assets',
|
|
209
|
-
task: (0,
|
|
199
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
210
200
|
const allPendingUploads = [];
|
|
211
201
|
|
|
212
202
|
for (const asset of sourceData.assets) {
|
|
@@ -244,7 +234,7 @@ function pushToSpace({
|
|
|
244
234
|
skip: ctx => !uploadAssets || !sourceData.assets.length
|
|
245
235
|
}, {
|
|
246
236
|
title: 'Importing Assets',
|
|
247
|
-
task: (0,
|
|
237
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
248
238
|
const assetsToProcess = await creation.createEntities({
|
|
249
239
|
context: {
|
|
250
240
|
target: ctx.environment,
|
|
@@ -265,7 +255,7 @@ function pushToSpace({
|
|
|
265
255
|
skip: ctx => contentModelOnly
|
|
266
256
|
}, {
|
|
267
257
|
title: 'Publishing Assets',
|
|
268
|
-
task: (0,
|
|
258
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
269
259
|
const publishedAssets = await publishEntities({
|
|
270
260
|
entities: ctx.data.assets,
|
|
271
261
|
sourceEntities: sourceData.assets,
|
|
@@ -276,7 +266,7 @@ function pushToSpace({
|
|
|
276
266
|
skip: ctx => contentModelOnly || skipContentPublishing
|
|
277
267
|
}, {
|
|
278
268
|
title: 'Archiving Assets',
|
|
279
|
-
task: (0,
|
|
269
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
280
270
|
const archivedAssets = await archiveEntities({
|
|
281
271
|
entities: ctx.data.assets,
|
|
282
272
|
sourceEntities: sourceData.assets,
|
|
@@ -287,7 +277,7 @@ function pushToSpace({
|
|
|
287
277
|
skip: ctx => contentModelOnly || skipContentPublishing
|
|
288
278
|
}, {
|
|
289
279
|
title: 'Importing Content Entries',
|
|
290
|
-
task: (0,
|
|
280
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
291
281
|
const entries = await creation.createEntries({
|
|
292
282
|
context: {
|
|
293
283
|
target: ctx.environment,
|
|
@@ -302,7 +292,7 @@ function pushToSpace({
|
|
|
302
292
|
skip: ctx => contentModelOnly
|
|
303
293
|
}, {
|
|
304
294
|
title: 'Publishing Content Entries',
|
|
305
|
-
task: (0,
|
|
295
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
306
296
|
const publishedEntries = await publishEntities({
|
|
307
297
|
entities: ctx.data.entries,
|
|
308
298
|
sourceEntities: sourceData.entries,
|
|
@@ -313,7 +303,7 @@ function pushToSpace({
|
|
|
313
303
|
skip: ctx => contentModelOnly || skipContentPublishing
|
|
314
304
|
}, {
|
|
315
305
|
title: 'Archiving Entries',
|
|
316
|
-
task: (0,
|
|
306
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
317
307
|
const archivedEntries = await archiveEntities({
|
|
318
308
|
entities: ctx.data.entries,
|
|
319
309
|
sourceEntities: sourceData.entries,
|
|
@@ -324,7 +314,7 @@ function pushToSpace({
|
|
|
324
314
|
skip: ctx => contentModelOnly || skipContentPublishing
|
|
325
315
|
}, {
|
|
326
316
|
title: 'Creating Web Hooks',
|
|
327
|
-
task: (0,
|
|
317
|
+
task: (0, _listr2.wrapTask)(async (ctx, task) => {
|
|
328
318
|
const webhooks = await creation.createEntities({
|
|
329
319
|
context: {
|
|
330
320
|
target: ctx.space,
|
|
@@ -3,37 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
exports.default = function (sourceData, destinationData, customTransformers, entities = spaceEntities) {
|
|
8
|
-
const transformers = (0, _object.defaults)(customTransformers, defaultTransformers);
|
|
9
|
-
const baseSpaceData = (0, _object.omit)(sourceData, ...entities);
|
|
10
|
-
sourceData.locales = (0, _sortLocales2.default)(sourceData.locales);
|
|
11
|
-
const tagsEnabled = !!destinationData.tags;
|
|
12
|
-
return entities.reduce((transformedSpaceData, type) => {
|
|
13
|
-
// tags don't contain links to other entities, don't need to be sorted
|
|
14
|
-
const sortedEntities = type === 'tags' ? sourceData[type] : (0, _sortEntries2.default)(sourceData[type]);
|
|
15
|
-
const transformedEntities = sortedEntities.map(entity => ({
|
|
16
|
-
original: entity,
|
|
17
|
-
transformed: transformers[type](entity, destinationData[type], tagsEnabled)
|
|
18
|
-
}));
|
|
19
|
-
transformedSpaceData[type] = transformedEntities;
|
|
20
|
-
return transformedSpaceData;
|
|
21
|
-
}, baseSpaceData);
|
|
22
|
-
};
|
|
6
|
+
exports.default = _default;
|
|
23
7
|
|
|
24
8
|
var _object = require("lodash/object");
|
|
25
9
|
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var defaultTransformers = _interopRequireWildcard(_transformers);
|
|
29
|
-
|
|
30
|
-
var _sortEntries = require("../utils/sort-entries");
|
|
10
|
+
var defaultTransformers = _interopRequireWildcard(require("./transformers"));
|
|
31
11
|
|
|
32
|
-
var
|
|
12
|
+
var _sortEntries = _interopRequireDefault(require("../utils/sort-entries"));
|
|
33
13
|
|
|
34
|
-
var _sortLocales = require("../utils/sort-locales");
|
|
35
|
-
|
|
36
|
-
var _sortLocales2 = _interopRequireDefault(_sortLocales);
|
|
14
|
+
var _sortLocales = _interopRequireDefault(require("../utils/sort-locales"));
|
|
37
15
|
|
|
38
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
17
|
|
|
@@ -47,4 +25,21 @@ const spaceEntities = ['contentTypes', 'entries', 'assets', 'locales', 'webhooks
|
|
|
47
25
|
* is a need to transform data when copying it to the destination space
|
|
48
26
|
*/
|
|
49
27
|
|
|
28
|
+
function _default(sourceData, destinationData, customTransformers, entities = spaceEntities) {
|
|
29
|
+
const transformers = (0, _object.defaults)(customTransformers, defaultTransformers);
|
|
30
|
+
const baseSpaceData = (0, _object.omit)(sourceData, ...entities);
|
|
31
|
+
sourceData.locales = (0, _sortLocales.default)(sourceData.locales);
|
|
32
|
+
const tagsEnabled = !!destinationData.tags;
|
|
33
|
+
return entities.reduce((transformedSpaceData, type) => {
|
|
34
|
+
// tags don't contain links to other entities, don't need to be sorted
|
|
35
|
+
const sortedEntities = type === 'tags' ? sourceData[type] : (0, _sortEntries.default)(sourceData[type]);
|
|
36
|
+
const transformedEntities = sortedEntities.map(entity => ({
|
|
37
|
+
original: entity,
|
|
38
|
+
transformed: transformers[type](entity, destinationData[type], tagsEnabled)
|
|
39
|
+
}));
|
|
40
|
+
transformedSpaceData[type] = transformedEntities;
|
|
41
|
+
return transformedSpaceData;
|
|
42
|
+
}, baseSpaceData);
|
|
43
|
+
}
|
|
44
|
+
|
|
50
45
|
module.exports = exports.default;
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.assets = assets;
|
|
6
7
|
exports.contentTypes = contentTypes;
|
|
7
|
-
exports.tags = tags;
|
|
8
8
|
exports.entries = entries;
|
|
9
|
-
exports.webhooks = webhooks;
|
|
10
|
-
exports.assets = assets;
|
|
11
9
|
exports.locales = locales;
|
|
10
|
+
exports.tags = tags;
|
|
11
|
+
exports.webhooks = webhooks;
|
|
12
12
|
|
|
13
13
|
var _object = require("lodash/object");
|
|
14
14
|
|
package/dist/usageParams.js
CHANGED
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.default = void 0;
|
|
6
7
|
|
|
7
|
-
var _yargs = require("yargs");
|
|
8
|
+
var _yargs = _interopRequireDefault(require("yargs"));
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
var _package = require("../package");
|
|
12
|
-
|
|
13
|
-
var packageFile = _interopRequireWildcard(_package);
|
|
10
|
+
var packageFile = _interopRequireWildcard(require("../package"));
|
|
14
11
|
|
|
15
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
13
|
|
|
@@ -18,7 +15,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
18
15
|
|
|
19
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
var _default = _yargs.default.version(packageFile.version || 'Version only available on installed package').usage('Usage: $0 [options]').option('space-id', {
|
|
22
19
|
describe: 'ID of the destination space',
|
|
23
20
|
type: 'string',
|
|
24
21
|
demand: true
|
|
@@ -81,4 +78,6 @@ exports.default = _yargs2.default.version(packageFile.version || 'Version only a
|
|
|
81
78
|
type: 'string',
|
|
82
79
|
describe: 'Pass an additional HTTP Header'
|
|
83
80
|
}).config('config', 'An optional configuration JSON file containing all the options for a single run').argv;
|
|
81
|
+
|
|
82
|
+
exports.default = _default;
|
|
84
83
|
module.exports = exports.default;
|
package/dist/utils/schema.js
CHANGED
|
@@ -3,100 +3,99 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.webhookSchema = exports.tagSchema = exports.payloadSchema = exports.localeSchema = exports.entrySchema = exports.editorInterfaceSchema = exports.contentTypeSchema = exports.assetSchema = void 0;
|
|
7
7
|
|
|
8
|
-
var _joi = require("joi");
|
|
9
|
-
|
|
10
|
-
var _joi2 = _interopRequireDefault(_joi);
|
|
8
|
+
var _joi = _interopRequireDefault(require("joi"));
|
|
11
9
|
|
|
12
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
11
|
|
|
14
12
|
const entrySchema = {
|
|
15
|
-
sys:
|
|
16
|
-
fields:
|
|
13
|
+
sys: _joi.default.object(),
|
|
14
|
+
fields: _joi.default.object()
|
|
17
15
|
};
|
|
16
|
+
exports.entrySchema = entrySchema;
|
|
18
17
|
const tagSchema = {
|
|
19
|
-
name:
|
|
20
|
-
sys:
|
|
18
|
+
name: _joi.default.string().required(),
|
|
19
|
+
sys: _joi.default.object()
|
|
21
20
|
};
|
|
21
|
+
exports.tagSchema = tagSchema;
|
|
22
22
|
const contentTypeSchema = {
|
|
23
|
-
sys:
|
|
24
|
-
fields:
|
|
25
|
-
id:
|
|
26
|
-
name:
|
|
27
|
-
type:
|
|
28
|
-
validations:
|
|
29
|
-
disabled:
|
|
30
|
-
omitted:
|
|
31
|
-
required:
|
|
32
|
-
localized:
|
|
33
|
-
linkType:
|
|
23
|
+
sys: _joi.default.object(),
|
|
24
|
+
fields: _joi.default.array().required().items(_joi.default.object().keys({
|
|
25
|
+
id: _joi.default.string().required(),
|
|
26
|
+
name: _joi.default.string().required(),
|
|
27
|
+
type: _joi.default.string().required().regex(/^Symbol|Text|Integer|Number|Date|Object|Boolean|Array|Link|Location$/),
|
|
28
|
+
validations: _joi.default.array(),
|
|
29
|
+
disabled: _joi.default.boolean(),
|
|
30
|
+
omitted: _joi.default.boolean(),
|
|
31
|
+
required: _joi.default.boolean(),
|
|
32
|
+
localized: _joi.default.boolean(),
|
|
33
|
+
linkType: _joi.default.string().when('type', {
|
|
34
34
|
is: 'Link',
|
|
35
|
-
then:
|
|
36
|
-
otherwise:
|
|
35
|
+
then: _joi.default.string().regex(/^Asset|Entry$/),
|
|
36
|
+
otherwise: _joi.default.forbidden()
|
|
37
37
|
})
|
|
38
38
|
}))
|
|
39
39
|
};
|
|
40
|
+
exports.contentTypeSchema = contentTypeSchema;
|
|
40
41
|
const assetSchema = {
|
|
41
|
-
sys:
|
|
42
|
-
fields:
|
|
43
|
-
file:
|
|
44
|
-
url:
|
|
45
|
-
details:
|
|
46
|
-
size:
|
|
47
|
-
image:
|
|
48
|
-
width:
|
|
49
|
-
height:
|
|
42
|
+
sys: _joi.default.object(),
|
|
43
|
+
fields: _joi.default.object({
|
|
44
|
+
file: _joi.default.object().pattern(/.+/, _joi.default.object({
|
|
45
|
+
url: _joi.default.string().required(),
|
|
46
|
+
details: _joi.default.object({
|
|
47
|
+
size: _joi.default.number(),
|
|
48
|
+
image: _joi.default.object({
|
|
49
|
+
width: _joi.default.number(),
|
|
50
|
+
height: _joi.default.number()
|
|
50
51
|
})
|
|
51
52
|
}),
|
|
52
|
-
fileName:
|
|
53
|
-
contentType:
|
|
53
|
+
fileName: _joi.default.string().required(),
|
|
54
|
+
contentType: _joi.default.string().required()
|
|
54
55
|
}))
|
|
55
56
|
}).required()
|
|
56
57
|
};
|
|
58
|
+
exports.assetSchema = assetSchema;
|
|
57
59
|
const editorInterfaceSchema = {
|
|
58
|
-
sys:
|
|
59
|
-
controls:
|
|
60
|
-
fieldId:
|
|
61
|
-
widgetId:
|
|
60
|
+
sys: _joi.default.object(),
|
|
61
|
+
controls: _joi.default.array().items({
|
|
62
|
+
fieldId: _joi.default.string(),
|
|
63
|
+
widgetId: _joi.default.string()
|
|
62
64
|
})
|
|
63
65
|
};
|
|
66
|
+
exports.editorInterfaceSchema = editorInterfaceSchema;
|
|
64
67
|
const localeSchema = {
|
|
65
|
-
name:
|
|
66
|
-
internal_code:
|
|
67
|
-
code:
|
|
68
|
-
fallbackCode:
|
|
69
|
-
default:
|
|
70
|
-
contentManagementApi:
|
|
71
|
-
contentDeliveryApi:
|
|
72
|
-
optional:
|
|
73
|
-
sys:
|
|
68
|
+
name: _joi.default.string().required(),
|
|
69
|
+
internal_code: _joi.default.string(),
|
|
70
|
+
code: _joi.default.string().required(),
|
|
71
|
+
fallbackCode: _joi.default.string().allow(null),
|
|
72
|
+
default: _joi.default.boolean(),
|
|
73
|
+
contentManagementApi: _joi.default.boolean(),
|
|
74
|
+
contentDeliveryApi: _joi.default.boolean(),
|
|
75
|
+
optional: _joi.default.boolean(),
|
|
76
|
+
sys: _joi.default.object()
|
|
74
77
|
};
|
|
78
|
+
exports.localeSchema = localeSchema;
|
|
75
79
|
const webhookSchema = {
|
|
76
|
-
name:
|
|
77
|
-
url:
|
|
78
|
-
topics:
|
|
79
|
-
httpBasicUsername:
|
|
80
|
+
name: _joi.default.string(),
|
|
81
|
+
url: _joi.default.string().replace(/{[^}{]+?}/g, 'x').regex(/^https?:\/\/[^ /}{][^ }{]*$/i).required(),
|
|
82
|
+
topics: _joi.default.array().required(),
|
|
83
|
+
httpBasicUsername: _joi.default.string().allow('', null)
|
|
80
84
|
};
|
|
81
85
|
/**
|
|
82
86
|
* @returns normalized validation object. Don't use normalized output as payload
|
|
83
87
|
*/
|
|
84
88
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
exports.webhookSchema = webhookSchema;
|
|
90
|
+
|
|
91
|
+
const payloadSchema = _joi.default.object({
|
|
92
|
+
entries: _joi.default.array().items(entrySchema),
|
|
93
|
+
contentTypes: _joi.default.array().items(contentTypeSchema),
|
|
94
|
+
tags: _joi.default.array().items(tagSchema),
|
|
95
|
+
assets: _joi.default.array().items(assetSchema),
|
|
96
|
+
locales: _joi.default.array().items(localeSchema),
|
|
97
|
+
editorInterfaces: _joi.default.array().items(editorInterfaceSchema),
|
|
98
|
+
webhooks: _joi.default.array().items(webhookSchema)
|
|
93
99
|
});
|
|
94
100
|
|
|
95
|
-
exports.entrySchema = entrySchema;
|
|
96
|
-
exports.contentTypeSchema = contentTypeSchema;
|
|
97
|
-
exports.tagSchema = tagSchema;
|
|
98
|
-
exports.localeSchema = localeSchema;
|
|
99
|
-
exports.webhookSchema = webhookSchema;
|
|
100
|
-
exports.editorInterfaceSchema = editorInterfaceSchema;
|
|
101
|
-
exports.assetSchema = assetSchema;
|
|
102
101
|
exports.payloadSchema = payloadSchema;
|
|
@@ -7,9 +7,7 @@ exports.default = sortEntries;
|
|
|
7
7
|
|
|
8
8
|
var _collection = require("lodash/collection");
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _o = _interopRequireWildcard(_object);
|
|
10
|
+
var _o = _interopRequireWildcard(require("lodash/object"));
|
|
13
11
|
|
|
14
12
|
var _array = require("lodash/array");
|
|
15
13
|
|
|
@@ -3,20 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.assertPayload = exports.assertDefaultLocale = void 0;
|
|
7
7
|
|
|
8
8
|
var _schema = require("./schema");
|
|
9
9
|
|
|
10
|
-
var _getEntityName = require("contentful-batch-libs/dist/get-entity-name");
|
|
11
|
-
|
|
12
|
-
var _getEntityName2 = _interopRequireDefault(_getEntityName);
|
|
10
|
+
var _getEntityName = _interopRequireDefault(require("contentful-batch-libs/dist/get-entity-name"));
|
|
13
11
|
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
13
|
|
|
16
14
|
const attachEntityName = (details, payload) => {
|
|
17
15
|
details.map(detail => {
|
|
18
16
|
if (detail.path.length >= 2) {
|
|
19
|
-
detail.entity = (0,
|
|
17
|
+
detail.entity = (0, _getEntityName.default)(payload[detail.path[0]][detail.path[1]]);
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
return detail;
|
|
@@ -51,6 +49,8 @@ const assertPayload = payload => {
|
|
|
51
49
|
}
|
|
52
50
|
};
|
|
53
51
|
|
|
52
|
+
exports.assertPayload = assertPayload;
|
|
53
|
+
|
|
54
54
|
const assertDefaultLocale = (source, destination) => {
|
|
55
55
|
const sourceDefaultLocale = source.locales.find(locale => locale.default === true);
|
|
56
56
|
const destinationDefaultLocale = destination.locales.find(locale => locale.default === true);
|
|
@@ -68,5 +68,4 @@ const assertDefaultLocale = (source, destination) => {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
exports.assertPayload = assertPayload;
|
|
72
71
|
exports.assertDefaultLocale = assertDefaultLocale;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contentful-import",
|
|
3
|
-
"version": "8.2
|
|
3
|
+
"version": "8.3.2",
|
|
4
4
|
"description": "this tool allows you to import JSON dump exported by contentful-export",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "npm run clean && babel lib --out-dir dist",
|
|
14
14
|
"build:watch": "babel lib --out-dir dist --watch",
|
|
15
|
-
"clean": "rimraf dist",
|
|
15
|
+
"clean": "rimraf dist && rimraf coverage",
|
|
16
16
|
"lint": "eslint lib bin/contentful-import test",
|
|
17
17
|
"pretest": "npm run lint && npm run build",
|
|
18
18
|
"test": "npm run test:unit && npm run test:integration",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"bluebird": "^3.5.1",
|
|
54
54
|
"cli-table3": "^0.6.0",
|
|
55
|
-
"contentful-batch-libs": "^9.
|
|
55
|
+
"contentful-batch-libs": "^9.4.1",
|
|
56
56
|
"contentful-management": "^7.45.5",
|
|
57
|
+
"date-fns": "^2.28.0",
|
|
57
58
|
"joi": "^17.5.0",
|
|
58
59
|
"listr": "^0.14.1",
|
|
59
60
|
"listr-update-renderer": "^0.5.0",
|
|
60
61
|
"listr-verbose-renderer": "^0.6.0",
|
|
61
62
|
"lodash": "^4.17.10",
|
|
62
|
-
"moment": "^2.22.2",
|
|
63
63
|
"p-queue": "^6.6.2",
|
|
64
64
|
"yargs": "^17.3.0"
|
|
65
65
|
},
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"@babel/cli": "^7.16.0",
|
|
68
68
|
"@babel/core": "^7.16.0",
|
|
69
69
|
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
70
|
+
"@babel/preset-env": "^7.18.2",
|
|
70
71
|
"babel-eslint": "^10.1.0",
|
|
71
72
|
"babel-jest": "^27.4.2",
|
|
72
73
|
"babel-plugin-add-module-exports": "^1.0.2",
|