@contentstack/cli-cm-bulk-publish 0.1.1-beta.1 → 0.1.1-beta.4
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 +70 -18
- package/oclif.manifest.json +1 -1
- package/package.json +6 -5
- package/src/commands/cm/bulk-publish/add-fields.js +18 -13
- package/src/commands/cm/bulk-publish/assets.js +15 -10
- package/src/commands/cm/bulk-publish/clear.js +8 -6
- package/src/commands/cm/bulk-publish/configure.js +5 -7
- package/src/commands/cm/bulk-publish/cross-publish.js +24 -26
- package/src/commands/cm/bulk-publish/entries.js +26 -20
- package/src/commands/cm/bulk-publish/entry-edits.js +23 -17
- package/src/commands/cm/bulk-publish/nonlocalized-field-changes.js +14 -9
- package/src/commands/cm/bulk-publish/revert.js +5 -5
- package/src/commands/cm/bulk-publish/unpublish.js +24 -15
- package/src/commands/cm/bulk-publish/unpublished-entries.js +17 -12
- package/src/config/index.js +88 -88
- package/src/consumer/publish.js +5 -7
- package/src/producer/add-fields.js +30 -35
- package/src/producer/cross-publish.js +99 -92
- package/src/producer/nonlocalized-field-changes.js +27 -38
- package/src/producer/publish-assets.js +18 -25
- package/src/producer/publish-edits.js +24 -35
- package/src/producer/publish-entries.js +26 -33
- package/src/producer/publish-unpublished-env.js +24 -35
- package/src/producer/revert.js +4 -4
- package/src/producer/unpublish.js +99 -106
- package/src/util/client.js +16 -11
- package/src/util/queue.js +2 -2
- package/src/util/request.js +6 -4
- package/src/util/store.js +8 -12
package/src/config/index.js
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
alias: 'Placeholder Management Token Alias',
|
|
3
|
+
publish_unpublished_env: {
|
|
4
|
+
contentTypes: [
|
|
5
|
+
'placeholder content type',
|
|
6
6
|
],
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
sourceEnv: 'placeholder source env',
|
|
8
|
+
locale: 'placeholder locale',
|
|
9
|
+
environments: [
|
|
10
|
+
'placeholder env',
|
|
11
11
|
],
|
|
12
|
-
|
|
12
|
+
bulkPublish: true,
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
]
|
|
14
|
+
publish_assets: {
|
|
15
|
+
environments: [
|
|
16
|
+
'placeholder env',
|
|
17
|
+
],
|
|
18
|
+
folderUid: 'placeholder folder uid',
|
|
19
|
+
bulkPublish: true,
|
|
20
|
+
locales: [
|
|
21
|
+
'placeholder locale',
|
|
22
|
+
],
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
publish_entries: {
|
|
25
|
+
contentTypes: [
|
|
26
|
+
'placeholder content type',
|
|
27
27
|
],
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
locales: [
|
|
29
|
+
'placeholder locale',
|
|
30
30
|
],
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
bulkPublish: true,
|
|
32
|
+
environments: [
|
|
33
|
+
'placeholder env',
|
|
34
34
|
],
|
|
35
|
-
|
|
35
|
+
publishAllContentTypes: false,
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
Unpublish: {
|
|
38
|
+
filter: {
|
|
39
|
+
environment: 'placeholder env',
|
|
40
|
+
content_type_uid: 'placeholder content type',
|
|
41
|
+
locale: 'placeholder locale',
|
|
42
|
+
type: 'placeholder types',
|
|
43
43
|
},
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
deliveryToken: 'placeholder delivery token',
|
|
45
|
+
bulkUnpublish: true,
|
|
46
46
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
cross_env_publish: {
|
|
48
|
+
filter: {
|
|
49
|
+
environment: 'placeholder env',
|
|
50
|
+
content_type_uid: 'placeholder content type',
|
|
51
|
+
locale: 'placeholder locale',
|
|
52
|
+
type: 'placeholder types',
|
|
53
53
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
deliveryToken: 'placeholder delivery token',
|
|
55
|
+
destEnv: [
|
|
56
|
+
'placeholder env',
|
|
57
57
|
],
|
|
58
|
-
|
|
58
|
+
bulkPublish: true,
|
|
59
59
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
publish_edits_on_env: {
|
|
61
|
+
contentTypes: [
|
|
62
|
+
'placeholder content type',
|
|
63
63
|
],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
sourceEnv: 'placeholder source env',
|
|
65
|
+
environments: [
|
|
66
|
+
'placeholder env',
|
|
67
67
|
],
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
locales: [
|
|
69
|
+
'placeholder locale',
|
|
70
70
|
],
|
|
71
|
-
|
|
71
|
+
bulkPublish: true,
|
|
72
72
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
nonlocalized_field_changes: {
|
|
74
|
+
sourceEnv: 'placeholder env',
|
|
75
|
+
contentTypes: [
|
|
76
|
+
'placeholder content type',
|
|
77
77
|
],
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
environments: [
|
|
79
|
+
'placeholder env',
|
|
80
80
|
],
|
|
81
|
-
|
|
81
|
+
bulkPublish: true,
|
|
82
82
|
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
],
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
],
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
],
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
],
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
83
|
+
addFields: {
|
|
84
|
+
deleteFields: [
|
|
85
|
+
'updated_by',
|
|
86
|
+
'created_by',
|
|
87
|
+
'created_at',
|
|
88
|
+
'updated_at',
|
|
89
|
+
'_version',
|
|
90
|
+
'ACL',
|
|
91
|
+
],
|
|
92
|
+
locales: [
|
|
93
|
+
'placeholder locale',
|
|
94
|
+
],
|
|
95
|
+
contentTypes: [
|
|
96
|
+
'placeholder content type',
|
|
97
|
+
],
|
|
98
|
+
environments: [
|
|
99
|
+
'placeholder env',
|
|
100
|
+
],
|
|
101
|
+
defaults: {
|
|
102
|
+
number: null,
|
|
103
|
+
boolean: false,
|
|
104
|
+
isodate: [],
|
|
105
|
+
file: null,
|
|
106
|
+
reference: [],
|
|
107
107
|
},
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
108
|
+
bulkPublish: true,
|
|
109
|
+
},
|
|
110
|
+
}
|
package/src/consumer/publish.js
CHANGED
|
@@ -91,8 +91,7 @@ async function UnpublishEntry(data, config, queue) {
|
|
|
91
91
|
const entryObj = data.obj
|
|
92
92
|
const stack = entryObj.stack
|
|
93
93
|
lang.push(entryObj.locale)
|
|
94
|
-
|
|
95
|
-
stack.contentType(entryObj.content_type).entry(entryObj.entryUid).unpublish({publishDetails: {environments: entryObj.environments, locales: lang}})
|
|
94
|
+
stack.contentType(entryObj.content_type).entry(entryObj.entryUid).unpublish({publishDetails: {environments: entryObj.environments, locales: lang}, locale: entryObj.locale})
|
|
96
95
|
.then(unpublishEntryResponse => {
|
|
97
96
|
if (!unpublishEntryResponse.error_message) {
|
|
98
97
|
delete entryObj.stack
|
|
@@ -140,7 +139,7 @@ async function UnpublishAsset(data, config, queue) {
|
|
|
140
139
|
})
|
|
141
140
|
}
|
|
142
141
|
|
|
143
|
-
async function
|
|
142
|
+
async function performBulkPublish(data, config, queue) {
|
|
144
143
|
let conf
|
|
145
144
|
const bulkPublishObj = data.obj
|
|
146
145
|
const stack = bulkPublishObj.stack
|
|
@@ -167,7 +166,6 @@ async function bulkPublish(data, config, queue) {
|
|
|
167
166
|
queue.Enqueue(data)
|
|
168
167
|
} else {
|
|
169
168
|
delete bulkPublishObj.stack
|
|
170
|
-
const entries = bulkPublishObj.entries.map(entry => entry.uid)
|
|
171
169
|
console.log(chalk.red(`Bulk entries ${JSON.stringify(removePublishDetails(bulkPublishObj.entries))} failed to publish with error ${formatError(error)}`))
|
|
172
170
|
addLogs(logger, {options: bulkPublishObj, api_key: stack.stackHeaders.api_key, alias: stack.alias, host: stack.host}, 'error')
|
|
173
171
|
}
|
|
@@ -205,7 +203,7 @@ async function bulkPublish(data, config, queue) {
|
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
205
|
|
|
208
|
-
async function
|
|
206
|
+
async function performBulkUnPublish(data, config, queue) {
|
|
209
207
|
let conf
|
|
210
208
|
const bulkUnPublishObj = data.obj
|
|
211
209
|
const stack = bulkUnPublishObj.stack
|
|
@@ -433,8 +431,8 @@ async function publishUsingVersion(data, config, queue) {
|
|
|
433
431
|
}
|
|
434
432
|
|
|
435
433
|
module.exports = {
|
|
436
|
-
|
|
437
|
-
|
|
434
|
+
performBulkPublish,
|
|
435
|
+
performBulkUnPublish,
|
|
438
436
|
initializeLogger,
|
|
439
437
|
publishEntry,
|
|
440
438
|
publishAsset,
|
|
@@ -8,17 +8,16 @@
|
|
|
8
8
|
const {getQueue} = require('../util/queue')
|
|
9
9
|
const defaultConfig = require('../config/defaults.json')
|
|
10
10
|
const req = require('../util/request')
|
|
11
|
-
const {
|
|
11
|
+
const {performBulkPublish, publishEntry, initializeLogger} = require('../consumer/publish')
|
|
12
12
|
const retryFailedLogs = require('../util/retryfailed')
|
|
13
13
|
const {validateFile} = require('../util/fs')
|
|
14
|
-
const stack = require('../util/client.js').stack
|
|
15
14
|
const {setDelayForBulkPublish} = require('../util')
|
|
16
15
|
const {Command} = require('@contentstack/cli-command')
|
|
17
16
|
const command = new Command()
|
|
18
17
|
const {isEmpty} = require('../util')
|
|
19
18
|
|
|
20
19
|
const queue = getQueue()
|
|
21
|
-
queue.consumer =
|
|
20
|
+
queue.consumer = performBulkPublish
|
|
22
21
|
let logFileName
|
|
23
22
|
let bulkPublishSet = []
|
|
24
23
|
let filePath
|
|
@@ -38,7 +37,7 @@ const deleteFields = ['updated_by', 'created_by', 'created_at', 'updated_at', '_
|
|
|
38
37
|
function setConfig(conf, bp) {
|
|
39
38
|
if (bp) {
|
|
40
39
|
logFileName = 'bulk-add-fields'
|
|
41
|
-
queue.consumer =
|
|
40
|
+
queue.consumer = performBulkPublish
|
|
42
41
|
} else {
|
|
43
42
|
logFileName = 'add-fields'
|
|
44
43
|
queue.consumer = publishEntry
|
|
@@ -286,42 +285,38 @@ async function start({contentTypes, locales, environments, retryFailed, bulkPubl
|
|
|
286
285
|
process.exit(0)
|
|
287
286
|
})
|
|
288
287
|
|
|
289
|
-
|
|
290
|
-
if (retryFailed) {
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
288
|
+
if (retryFailed) {
|
|
289
|
+
if (typeof retryFailed === 'string') {
|
|
290
|
+
if (!validateFile(retryFailed, ['bulk-add-fields', 'add-fields'])) {
|
|
291
|
+
return false
|
|
292
|
+
}
|
|
295
293
|
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
bulkPublish = retryFailed.match(new RegExp('bulk')) ? true : false
|
|
295
|
+
setConfig(config, bulkPublish)
|
|
298
296
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
297
|
+
if (bulkPublish) {
|
|
298
|
+
await retryFailedLogs(retryFailed, queue, 'bulk')
|
|
299
|
+
} else {
|
|
300
|
+
await retryFailedLogs(retryFailed, {entryQueue: queue}, 'publish')
|
|
304
301
|
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
setConfig(config, bulkPublish)
|
|
305
|
+
for (let i = 0; i < contentTypes.length; i += 1) {
|
|
306
|
+
getContentTypeSchema(stack, contentTypes[i])
|
|
307
|
+
.then(async schema => {
|
|
308
|
+
for (let j = 0; j < locales.length; j += 1) {
|
|
309
|
+
try {
|
|
310
|
+
await getEntries(stack, config, schema, contentTypes[i], locales[j], bulkPublish, environments)
|
|
311
|
+
} catch (err) {
|
|
312
|
+
console.log(`Failed to get Entries with contentType ${contentTypes[i]} and locale ${locales[j]}`)
|
|
316
313
|
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
})
|
|
321
|
-
}
|
|
314
|
+
}
|
|
315
|
+
})
|
|
316
|
+
.catch(err => {
|
|
317
|
+
console.log(`Failed to fetch schema${JSON.stringify(err)}`)
|
|
318
|
+
})
|
|
322
319
|
}
|
|
323
|
-
} catch(error) {
|
|
324
|
-
throw error
|
|
325
320
|
}
|
|
326
321
|
}
|
|
327
322
|
|
|
@@ -7,11 +7,10 @@ const {getQueue} = require('../util/queue')
|
|
|
7
7
|
const defaults = require('../config/defaults.json')
|
|
8
8
|
const req = require('../util/request')
|
|
9
9
|
const {
|
|
10
|
-
|
|
10
|
+
performBulkPublish, publishEntry, publishAsset, initializeLogger,
|
|
11
11
|
} = require('../consumer/publish')
|
|
12
12
|
const retryFailedLogs = require('../util/retryfailed')
|
|
13
13
|
const {validateFile} = require('../util/fs')
|
|
14
|
-
const types = 'asset_published,entry_published'
|
|
15
14
|
const queue = getQueue()
|
|
16
15
|
const entryQueue = getQueue()
|
|
17
16
|
const assetQueue = getQueue()
|
|
@@ -38,71 +37,70 @@ function getQueryParams(filter) {
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
async function bulkAction(stack, items, bulkPublish, filter, destEnv) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
publish_details: [items[index].data.publish_details] || [],
|
|
55
|
-
})
|
|
56
|
-
}
|
|
40
|
+
return new Promise(async resolve => {
|
|
41
|
+
for (let index = 0; index < items.length; index++) {
|
|
42
|
+
changedFlag = true
|
|
43
|
+
|
|
44
|
+
if (bulkPublish) {
|
|
45
|
+
if (bulkPublishSet.length < 10 && items[index].type === 'entry_published') {
|
|
46
|
+
bulkPublishSet.push({
|
|
47
|
+
uid: items[index].data.uid,
|
|
48
|
+
content_type: items[index].content_type_uid,
|
|
49
|
+
locale: items[index].data.locale || 'en-us',
|
|
50
|
+
publish_details: [items[index].data.publish_details] || [],
|
|
51
|
+
})
|
|
52
|
+
}
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
if (bulkPublishAssetSet.length < 10 && items[index].type === 'asset_published') {
|
|
55
|
+
bulkPublishAssetSet.push({
|
|
56
|
+
uid: items[index].data.uid,
|
|
57
|
+
version: items[index].data._version,
|
|
58
|
+
publish_details: [items[index].data.publish_details] || [],
|
|
59
|
+
})
|
|
60
|
+
}
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
if (bulkPublishAssetSet.length === 10) {
|
|
63
|
+
await queue.Enqueue({
|
|
64
|
+
assets: bulkPublishAssetSet, Type: 'asset', locale: filter.locale, environments: destEnv, stack: stack
|
|
65
|
+
})
|
|
66
|
+
bulkPublishAssetSet = []
|
|
67
|
+
}
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
if (bulkPublishSet.length === 10) {
|
|
70
|
+
await queue.Enqueue({
|
|
71
|
+
entries: bulkPublishSet, locale: filter.locale, Type: 'entry', environments: destEnv, stack: stack
|
|
72
|
+
})
|
|
73
|
+
bulkPublishSet = []
|
|
74
|
+
}
|
|
79
75
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
if (index === items.length - 1 && bulkPublishAssetSet.length <= 10 && bulkPublishAssetSet.length > 0) {
|
|
77
|
+
await queue.Enqueue({
|
|
78
|
+
assets: bulkPublishAssetSet, Type: 'asset', locale: filter.locale, environments: destEnv, stack: stack
|
|
79
|
+
})
|
|
80
|
+
bulkPublishAssetSet = []
|
|
81
|
+
}
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
83
|
+
if (index === items.length - 1 && bulkPublishSet.length <= 10 && bulkPublishSet.length > 0) {
|
|
84
|
+
await queue.Enqueue({
|
|
85
|
+
entries: bulkPublishSet, locale: filter.locale, Type: 'entry', environments: destEnv, stack: stack
|
|
86
|
+
})
|
|
87
|
+
bulkPublishSet = []
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
if (items[index].type === 'entry_published') {
|
|
91
|
+
await entryQueue.Enqueue({
|
|
92
|
+
content_type: items[index].content_type_uid, publish_details: [items[index].data.publish_details], environments: destEnv, entryUid: items[index].data.uid, locale: items[index].data.locale || 'en-us', Type: 'entry', stack: stack
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
if (items[index].type === 'asset_published') {
|
|
96
|
+
await assetQueue.Enqueue({
|
|
97
|
+
assetUid: items[index].data.uid, publish_details: [items[index].data.publish_details], environments: destEnv, Type: 'asset', stack: stack
|
|
98
|
+
})
|
|
99
|
+
}
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
|
-
|
|
102
|
+
return resolve()
|
|
103
|
+
})
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
async function getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv, paginationToken = null) {
|
|
@@ -118,40 +116,39 @@ async function getSyncEntries(stack, config, queryParams, bulkPublish, filter, d
|
|
|
118
116
|
}
|
|
119
117
|
const entriesResponse = await req(conf)
|
|
120
118
|
if (entriesResponse.items.length > 0) {
|
|
121
|
-
bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv)
|
|
119
|
+
await bulkAction(stack, entriesResponse.items, bulkPublish, filter, destEnv)
|
|
122
120
|
}
|
|
123
121
|
if (!entriesResponse.pagination_token) {
|
|
124
122
|
if (!changedFlag) console.log('No Entries/Assets Found published on specified environment')
|
|
125
123
|
return resolve()
|
|
126
124
|
}
|
|
127
|
-
setTimeout(() => {
|
|
128
|
-
getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv, entriesResponse.pagination_token)
|
|
125
|
+
setTimeout(async () => {
|
|
126
|
+
await getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv, entriesResponse.pagination_token)
|
|
129
127
|
}, 3000)
|
|
130
128
|
} catch (error) {
|
|
131
129
|
reject(error)
|
|
132
130
|
}
|
|
131
|
+
return resolve()
|
|
133
132
|
})
|
|
134
|
-
// return true
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
function setConfig(conf, bp) {
|
|
138
136
|
if (bp) {
|
|
139
137
|
logFileName = 'bulk-cross-publish'
|
|
140
|
-
queue.consumer =
|
|
138
|
+
queue.consumer = performBulkPublish
|
|
141
139
|
} else {
|
|
142
140
|
logFileName = 'cross-publish'
|
|
143
141
|
entryQueue.consumer = publishEntry
|
|
144
142
|
assetQueue.consumer = publishAsset
|
|
145
143
|
}
|
|
146
144
|
|
|
147
|
-
config = conf
|
|
148
145
|
queue.config = conf
|
|
149
146
|
entryQueue.config = conf
|
|
150
147
|
assetQueue.config = conf
|
|
151
148
|
filePath = initializeLogger(logFileName)
|
|
152
149
|
}
|
|
153
150
|
|
|
154
|
-
async function start({retryFailed, bulkPublish, filter, deliveryToken, destEnv, f_types}, stack, config) {
|
|
151
|
+
async function start({retryFailed, bulkPublish, filter, deliveryToken, contentType, environment, locale, onlyAssets, onlyEntries, destEnv, f_types}, stack, config) {
|
|
155
152
|
process.on('beforeExit', async () => {
|
|
156
153
|
const isErrorLogEmpty = await isEmpty(`${filePath}.error`)
|
|
157
154
|
const isSuccessLogEmpty = await isEmpty(`${filePath}.success`)
|
|
@@ -163,34 +160,44 @@ async function start({retryFailed, bulkPublish, filter, deliveryToken, destEnv,
|
|
|
163
160
|
process.exit(0)
|
|
164
161
|
})
|
|
165
162
|
|
|
166
|
-
|
|
167
|
-
if (retryFailed) {
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
163
|
+
if (retryFailed) {
|
|
164
|
+
if (typeof retryFailed === 'string' && retryFailed.length > 0) {
|
|
165
|
+
if (!validateFile(retryFailed, ['cross-publish', 'bulk-cross-publish'])) {
|
|
166
|
+
return false
|
|
167
|
+
}
|
|
172
168
|
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
bulkPublish = retryFailed.match(new RegExp('bulk')) ? true : false
|
|
170
|
+
setConfig(config, bulkPublish)
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
setConfig(config, bulkPublish)
|
|
184
|
-
filter.type = (f_types) ? f_types : types // types mentioned in the config file (f_types) are given preference
|
|
185
|
-
const queryParams = getQueryParams(filter)
|
|
186
|
-
try {
|
|
187
|
-
await getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv)
|
|
188
|
-
} catch (error) {
|
|
189
|
-
throw error
|
|
172
|
+
if (bulkPublish) {
|
|
173
|
+
await retryFailedLogs(retryFailed, queue, 'bulk')
|
|
174
|
+
} else {
|
|
175
|
+
await retryFailedLogs(retryFailed, {entryQueue, assetQueue}, 'publish')
|
|
190
176
|
}
|
|
191
177
|
}
|
|
192
|
-
}
|
|
193
|
-
|
|
178
|
+
} else {
|
|
179
|
+
let filter = {
|
|
180
|
+
environment,
|
|
181
|
+
locale,
|
|
182
|
+
}
|
|
183
|
+
if (f_types)
|
|
184
|
+
filter.type = f_types
|
|
185
|
+
// filter.type = (f_types) ? f_types : types // types mentioned in the config file (f_types) are given preference
|
|
186
|
+
if (contentType) {
|
|
187
|
+
filter.content_type_uid = contentType
|
|
188
|
+
filter.type = 'entry_published'
|
|
189
|
+
}
|
|
190
|
+
if (onlyAssets) {
|
|
191
|
+
filter.type = 'asset_published'
|
|
192
|
+
delete filter.content_type_uid
|
|
193
|
+
}
|
|
194
|
+
if (onlyEntries) {
|
|
195
|
+
filter.type = 'entry_published'
|
|
196
|
+
}
|
|
197
|
+
setConfig(config, bulkPublish)
|
|
198
|
+
// filter.type = (f_types) ? f_types : types // types mentioned in the config file (f_types) are given preference
|
|
199
|
+
const queryParams = getQueryParams(filter)
|
|
200
|
+
await getSyncEntries(stack, config, queryParams, bulkPublish, filter, deliveryToken, destEnv)
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
203
|
|
|
@@ -199,4 +206,4 @@ module.exports = {
|
|
|
199
206
|
setConfig,
|
|
200
207
|
getQueryParams,
|
|
201
208
|
start,
|
|
202
|
-
}
|
|
209
|
+
}
|