@contentstack/cli-cm-bulk-publish 0.1.1-beta.3 → 1.0.0

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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +533 -281
  3. package/oclif.manifest.json +1 -1
  4. package/package.json +27 -12
  5. package/src/commands/cm/assets/publish.js +233 -0
  6. package/src/commands/cm/assets/unpublish.js +179 -0
  7. package/src/commands/cm/bulk-publish/cross-publish.js +187 -68
  8. package/src/commands/cm/bulk-publish/index.js +5 -6
  9. package/src/commands/cm/entries/publish-modified.js +197 -0
  10. package/src/commands/cm/entries/publish-non-localized-fields.js +208 -0
  11. package/src/commands/cm/entries/publish-only-unpublished.js +109 -0
  12. package/src/commands/cm/entries/publish.js +254 -0
  13. package/src/commands/cm/entries/unpublish.js +184 -0
  14. package/src/commands/cm/entries/update-and-publish.js +191 -0
  15. package/src/commands/cm/stacks/publish-clear-logs.js +82 -0
  16. package/src/commands/cm/stacks/publish-configure.js +46 -0
  17. package/src/commands/cm/stacks/publish-revert.js +102 -0
  18. package/src/commands/cm/stacks/publish.js +110 -0
  19. package/src/commands/cm/stacks/unpublish.js +282 -0
  20. package/src/config/index.js +60 -99
  21. package/src/consumer/publish.js +600 -377
  22. package/src/producer/add-fields.js +209 -189
  23. package/src/producer/cross-publish.js +195 -136
  24. package/src/producer/nonlocalized-field-changes.js +235 -216
  25. package/src/producer/publish-assets.js +104 -98
  26. package/src/producer/publish-edits.js +126 -113
  27. package/src/producer/publish-entries.js +135 -112
  28. package/src/producer/publish-unpublished-env.js +126 -114
  29. package/src/producer/revert.js +261 -230
  30. package/src/producer/unpublish.js +175 -137
  31. package/src/services/publish-only-unpublished.js +130 -0
  32. package/src/util/client.js +21 -17
  33. package/src/util/command-helper.js +25 -0
  34. package/src/util/fs.js +10 -11
  35. package/src/util/index.js +15 -16
  36. package/src/util/logger.js +21 -25
  37. package/src/util/queue.js +13 -13
  38. package/src/util/retryfailed.js +8 -4
  39. package/src/util/store.js +44 -52
  40. package/src/commands/cm/bulk-publish/add-fields.js +0 -117
  41. package/src/commands/cm/bulk-publish/assets.js +0 -117
  42. package/src/commands/cm/bulk-publish/clear.js +0 -63
  43. package/src/commands/cm/bulk-publish/configure.js +0 -46
  44. package/src/commands/cm/bulk-publish/entries.js +0 -125
  45. package/src/commands/cm/bulk-publish/entry-edits.js +0 -123
  46. package/src/commands/cm/bulk-publish/nonlocalized-field-changes.js +0 -116
  47. package/src/commands/cm/bulk-publish/revert.js +0 -81
  48. package/src/commands/cm/bulk-publish/unpublish.js +0 -164
  49. package/src/commands/cm/bulk-publish/unpublished-entries.js +0 -122
  50. package/src/util/request.js +0 -57
@@ -4,354 +4,385 @@
4
4
  /* eslint-disable no-console */
5
5
  /* eslint-disable new-cap */
6
6
  /* eslint-disable camelcase */
7
- // const yesno = require('yesno')
8
- const chalk = require('chalk')
9
- const {getAllLogs} = require('../util/logger')
10
- const {getQueue} = require('../util/queue')
11
- const {validateFile} = require('../util/fs')
12
- const Configstore = require('configstore')
13
- let config = new Configstore('contentstack_cli')
14
- const {initializeLogger, bulkUnPublish, publishUsingVersion} = require('../consumer/publish')
15
- const getStack = require('../util/client.js').getStack
16
-
17
- // for checking if a logfile has been provided by user
18
- // function getRevertAndLogfile(args) {
19
- // if (args.length === 2) {
20
- // console.error('Please provide a logfile to use for unpublishing.')
21
- // }
22
- // const logfilenameProvidedByUser = args[args.length - 1]
23
- // return logfilenameProvidedByUser
24
- // }
25
-
26
- // const logfilenameProvidedByUser = getRevertAndLogfile(process.argv)
27
- const intervalBetweenPublishRequests = 3 // interval in seconds
28
-
29
- const unpublishQueue = getQueue()
30
- const publishQueue = getQueue()
31
-
32
- const revertLogFileName = 'revert'
7
+ const chalk = require('chalk');
8
+ const { getAllLogs } = require('../util/logger');
9
+ const { getQueue } = require('../util/queue');
10
+ const { validateFile } = require('../util/fs');
11
+ const { configHandler } = require('@contentstack/cli-utilities');
12
+ let config = configHandler
13
+ const { initializeLogger, performBulkUnPublish, publishUsingVersion } = require('../consumer/publish');
14
+ const getStack = require('../util/client.js').getStack;
15
+
16
+ const intervalBetweenPublishRequests = 3; // interval in seconds
17
+
18
+ const unpublishQueue = getQueue();
19
+ const publishQueue = getQueue();
20
+
21
+ const revertLogFileName = 'revert';
33
22
 
34
23
  function setConfig(conf) {
35
- config = conf
36
- unpublishQueue.config = conf
37
- publishQueue.config = conf
38
- unpublishQueue.consumer = bulkUnPublish
39
- publishQueue.consumer = publishUsingVersion
24
+ config = conf;
25
+ unpublishQueue.config = conf;
26
+ publishQueue.config = conf;
27
+ unpublishQueue.consumer = performBulkUnPublish;
28
+ publishQueue.consumer = publishUsingVersion;
40
29
  }
41
30
 
42
31
  function getLogFileDataType(data) {
43
- const element = data[0]
32
+ const element = data[0];
44
33
  if (element.message.options.Type) {
45
- return element.message.options.Type
34
+ return element.message.options.Type;
46
35
  }
47
36
  if (element.message.options.entryUid) {
48
- return 'entry'
37
+ return 'entry';
49
38
  }
50
- return 'asset'
39
+ return 'asset';
51
40
  }
52
41
 
53
42
  async function getEnvironmentUids(stack, environments) {
54
43
  return new Promise((resolve, reject) => {
55
- stack.environment().query().find()
56
- .then(allEnvironments => {
57
- const filteredEnvironments = allEnvironments.items.filter(environment => environments.indexOf(environment.name) !== -1).map(({name, uid}) => ({name, uid}))
58
- resolve(filteredEnvironments)
59
- })
60
- .catch(error => reject(error))
61
- })
44
+ stack
45
+ .environment()
46
+ .query()
47
+ .find()
48
+ .then((allEnvironments) => {
49
+ const filteredEnvironments = allEnvironments.items
50
+ .filter((environment) => environments.indexOf(environment.name) !== -1)
51
+ .map(({ name, uid }) => ({ name, uid }));
52
+ resolve(filteredEnvironments);
53
+ })
54
+ .catch((error) => reject(error));
55
+ });
62
56
  }
63
57
 
64
58
  function filterPublishDetails(elements, environments, locale) {
65
59
  if (locale && locale.length > 0) {
66
- locale.forEach(loc => {
67
- elements[loc].forEach(entry => {
60
+ locale.forEach((loc) => {
61
+ elements[loc].forEach((entry) => {
68
62
  if (entry.publish_details.length > 0) {
69
- entry.publish_details = entry.publish_details.filter(element => environments.indexOf(element.environment) !== -1 && element.locale === loc)
63
+ entry.publish_details = entry.publish_details.filter(
64
+ (element) => environments.indexOf(element.environment) !== -1 && element.locale === loc,
65
+ );
70
66
  }
71
- })
72
- })
67
+ });
68
+ });
73
69
  } else {
74
70
  for (let i = 0; i < elements.length; i += 1) {
75
71
  if (elements[i].publish_details.length > 0) {
76
- elements[i].publish_details = elements[i].publish_details.filter(element => environments.indexOf(element.environment) !== -1)
72
+ elements[i].publish_details = elements[i].publish_details.filter(
73
+ (element) => environments.indexOf(element.environment) !== -1,
74
+ );
77
75
  }
78
76
  }
79
77
  }
80
- return elements
78
+ return elements;
81
79
  }
82
80
 
83
81
  async function formatLogData(stack, data) {
84
- const formattedLogs = {}
85
- const type = getLogFileDataType(data)
82
+ const formattedLogs = {};
83
+ const type = getLogFileDataType(data);
86
84
 
87
85
  switch (type) {
88
- case 'entry':
89
- formattedLogs.entries = {}
90
- formattedLogs.locale = []
91
- for (let i = 0; i < data.length; i += 1) {
92
- if (formattedLogs.locale.indexOf(data[i].message.options.locale) === -1) {
93
- formattedLogs.locale.push(data[i].message.options.locale)
94
- }
95
- if (!formattedLogs.entries[data[i].message.options.locale]) formattedLogs.entries[data[i].message.options.locale] = []
96
- if (data[i].message.options.entries) {
97
- // for handling bulk-publish-entries logs
98
- formattedLogs.entries[data[i].message.options.locale] = formattedLogs.entries[data[i].message.options.locale].concat(data[i].message.options.entries)
99
- } else {
100
- // for handling logs created by publishing in a regular way
101
- formattedLogs.entries[data[i].message.options.locale].push({
102
- uid: data[i].message.options.entryUid,
103
- content_type: data[i].message.options.content_type,
104
- locale: data[i].message.options.locale,
105
- publish_details: data[i].message.options.publish_details,
106
- })
86
+ case 'entry':
87
+ formattedLogs.entries = {};
88
+ formattedLogs.locale = [];
89
+ for (let i = 0; i < data.length; i += 1) {
90
+ if (formattedLogs.locale.indexOf(data[i].message.options.locale) === -1) {
91
+ formattedLogs.locale.push(data[i].message.options.locale);
92
+ }
93
+ if (!formattedLogs.entries[data[i].message.options.locale])
94
+ formattedLogs.entries[data[i].message.options.locale] = [];
95
+ if (data[i].message.options.entries) {
96
+ // for handling bulk-publish-entries logs
97
+ formattedLogs.entries[data[i].message.options.locale] = formattedLogs.entries[
98
+ data[i].message.options.locale
99
+ ].concat(data[i].message.options.entries);
100
+ } else {
101
+ // for handling logs created by publishing in a regular way
102
+ formattedLogs.entries[data[i].message.options.locale].push({
103
+ uid: data[i].message.options.entryUid,
104
+ content_type: data[i].message.options.content_type,
105
+ locale: data[i].message.options.locale,
106
+ publish_details: data[i].message.options.publish_details,
107
+ });
108
+ }
109
+ if (!formattedLogs.environments) formattedLogs.environments = data[i].message.options.environments;
110
+ if (!formattedLogs.api_key) formattedLogs.api_key = data[i].message.api_key;
107
111
  }
108
- if (!formattedLogs.environments) formattedLogs.environments = data[i].message.options.environments
109
- if (!formattedLogs.api_key) formattedLogs.api_key = data[i].message.api_key
110
- }
111
- break
112
- case 'asset':
113
- formattedLogs.assets = []
114
- for (let i = 0; i < data.length; i += 1) {
115
- if (data[i].message.options.assets) {
116
- // for handling bulk-publish-assets logs
117
- formattedLogs.assets = formattedLogs.assets.concat(data[i].message.options.assets)
118
- } else {
119
- // for handling logs created by publishing assets in a regular way
120
- formattedLogs.assets.push({
121
- uid: data[i].message.options.assetUid,
122
- publish_details: data[i].message.options.publish_details,
123
- })
112
+ break;
113
+ case 'asset':
114
+ formattedLogs.assets = [];
115
+ for (let i = 0; i < data.length; i += 1) {
116
+ if (data[i].message.options.assets) {
117
+ // for handling bulk-publish-assets logs
118
+ formattedLogs.assets = formattedLogs.assets.concat(data[i].message.options.assets);
119
+ } else {
120
+ // for handling logs created by publishing assets in a regular way
121
+ formattedLogs.assets.push({
122
+ uid: data[i].message.options.assetUid,
123
+ publish_details: data[i].message.options.publish_details,
124
+ });
125
+ }
126
+ if (!formattedLogs.environments) formattedLogs.environments = data[i].message.options.environments;
127
+ if (!formattedLogs.api_key) formattedLogs.api_key = data[i].message.api_key;
124
128
  }
125
- if (!formattedLogs.environments) formattedLogs.environments = data[i].message.options.environments
126
- if (!formattedLogs.api_key) formattedLogs.api_key = data[i].message.api_key
127
- }
128
- break
129
- default: break
129
+ break;
130
+ default:
131
+ break;
130
132
  }
131
133
 
132
- formattedLogs.environments = await getEnvironmentUids(stack, formattedLogs.environments)
133
- formattedLogs.type = type
134
+ formattedLogs.environments = await getEnvironmentUids(stack, formattedLogs.environments);
135
+ formattedLogs.type = type;
134
136
  if (type === 'entry') {
135
- formattedLogs.entries = filterPublishDetails(formattedLogs.entries, formattedLogs.environments.map(({uid}) => uid), formattedLogs.locale)
137
+ formattedLogs.entries = filterPublishDetails(
138
+ formattedLogs.entries,
139
+ formattedLogs.environments.map(({ uid }) => uid),
140
+ formattedLogs.locale,
141
+ );
136
142
  } else {
137
- formattedLogs.assets = filterPublishDetails(formattedLogs.assets, formattedLogs.environments.map(({uid}) => uid))
143
+ formattedLogs.assets = filterPublishDetails(
144
+ formattedLogs.assets,
145
+ formattedLogs.environments.map(({ uid }) => uid),
146
+ );
138
147
  }
139
148
 
140
- return formattedLogs
149
+ return formattedLogs;
141
150
  }
142
151
 
143
152
  async function mapSeries(iterable, action) {
144
153
  for (let x of iterable) {
145
- await action(x)
154
+ await action(x);
146
155
  }
147
156
  }
148
157
 
149
158
  function sleep(ms) {
150
- return new Promise(resolve => {
151
- setTimeout(resolve, ms)
152
- })
159
+ return new Promise((resolve) => {
160
+ setTimeout(resolve, ms);
161
+ });
153
162
  }
154
163
 
155
164
  function processPublishRequests(data) {
156
165
  return sleep(intervalBetweenPublishRequests * 1000).then(() => {
157
- publishQueue.Enqueue(data)
158
- })
166
+ publishQueue.Enqueue(data);
167
+ });
159
168
  }
160
169
 
161
170
  async function revertUsingLogs(logFileName) {
162
- let bulkUnpublishSet = []
163
- const setOfBulkPublishRequestPayloads = []
164
- let bulkPublishSet = []
165
- // const bulkPublishRegex = new RegExp(`bulkPublishEntries`);
171
+ let bulkUnpublishSet = [];
172
+ const setOfBulkPublishRequestPayloads = [];
173
+ let bulkPublishSet = [];
166
174
 
167
175
  if (validateFile(logFileName)) {
168
- const response = await getAllLogs(logFileName)
169
- let logs
176
+ const response = await getAllLogs(logFileName);
177
+ let logs;
170
178
 
171
179
  if (response.file.length > 0) {
172
- initializeLogger(revertLogFileName)
173
- const stack = getStack({apikey: response.file[0].message.api_key, managementTokenAlias: response.file[0].message.alias})
174
- logs = await formatLogData(stack, response.file)
180
+ initializeLogger(revertLogFileName);
181
+ const stack = getStack({
182
+ apikey: response.file[0].message.api_key,
183
+ alias: response.file[0].message.alias,
184
+ host: response.file[0].message.host,
185
+ branch: response.file[0].message.branch || 'main'
186
+ });
187
+ logs = await formatLogData(stack, response.file);
175
188
 
176
189
  logs.environments.forEach((environment, envIndex) => {
177
190
  switch (logs.type) {
178
- case 'entry':
179
- logs.locale.forEach((loc, locIndex) => {
180
- logs.entries[loc].forEach(({
181
- publish_details, uid, locale, content_type,
182
- }, entryIndex) => {
183
- const publishDetailsForThisEnvironment = publish_details.filter(publishDetail => publishDetail.environment === environment.uid)
191
+ case 'entry':
192
+ logs.locale.forEach((loc, locIndex) => {
193
+ logs.entries[loc].forEach(({ publish_details, uid, locale, content_type }, entryIndex) => {
194
+ const publishDetailsForThisEnvironment = publish_details.filter(
195
+ (publishDetail) => publishDetail.environment === environment.uid,
196
+ );
197
+
198
+ if (publishDetailsForThisEnvironment.length > 0) {
199
+ // handle revert case
200
+
201
+ publishDetailsForThisEnvironment.forEach((publishDetail) => {
202
+ if (bulkPublishSet.length < 10) {
203
+ bulkPublishSet.push({
204
+ uid,
205
+ version: publishDetail.version,
206
+ locale,
207
+ content_type,
208
+ publish_details: [publishDetail],
209
+ });
210
+ }
211
+
212
+ if (bulkPublishSet.length === 10) {
213
+ const data = {
214
+ entries: bulkPublishSet,
215
+ environments: [environment.name],
216
+ locale: loc,
217
+ Type: 'entry',
218
+ stack: stack,
219
+ };
220
+ setOfBulkPublishRequestPayloads.push(data);
221
+ bulkPublishSet = [];
222
+ }
223
+ });
224
+ } else {
225
+ if (bulkUnpublishSet.length < 10) {
226
+ bulkUnpublishSet.push({
227
+ uid,
228
+ locale,
229
+ content_type,
230
+ publish_details: [],
231
+ });
232
+ }
233
+
234
+ if (bulkUnpublishSet.length === 10) {
235
+ unpublishQueue.Enqueue({
236
+ entries: bulkUnpublishSet,
237
+ environments: [environment.name],
238
+ locale: loc,
239
+ Type: 'entry',
240
+ stack: stack,
241
+ });
242
+ bulkUnpublishSet = [];
243
+ }
244
+ }
245
+
246
+ if (entryIndex === logs.entries[loc].length - 1) {
247
+ if (bulkUnpublishSet.length <= 10 && bulkUnpublishSet.length !== 0) {
248
+ unpublishQueue.Enqueue({
249
+ entries: bulkUnpublishSet,
250
+ environments: [environment.name],
251
+ locale: loc,
252
+ Type: 'entry',
253
+ stack: stack,
254
+ });
255
+ bulkUnpublishSet = [];
256
+ }
257
+
258
+ if (bulkPublishSet.length <= 10 && bulkPublishSet.length !== 0) {
259
+ const data = {
260
+ entries: bulkPublishSet,
261
+ environments: [environment.name],
262
+ locale: loc,
263
+ Type: 'entry',
264
+ stack: stack,
265
+ };
266
+ setOfBulkPublishRequestPayloads.push(data);
267
+ bulkPublishSet = [];
268
+ }
269
+ }
270
+
271
+ if (
272
+ envIndex === logs.environments.length - 1 &&
273
+ locIndex === logs.locale.length - 1 &&
274
+ entryIndex === logs.entries[loc].length - 1
275
+ ) {
276
+ mapSeries(setOfBulkPublishRequestPayloads, processPublishRequests);
277
+ }
278
+ });
279
+ });
280
+ break;
281
+ case 'asset':
282
+ logs.assets.forEach(({ publish_details, uid }, assetIndex) => {
283
+ const publishDetailsForThisEnvironment = publish_details.filter(
284
+ (publishDetail) => publishDetail.environment === environment.uid,
285
+ );
184
286
 
185
287
  if (publishDetailsForThisEnvironment.length > 0) {
186
288
  // handle revert case
187
289
 
188
- publishDetailsForThisEnvironment.forEach(publishDetail => {
290
+ publishDetailsForThisEnvironment.forEach((publishDetail) => {
189
291
  if (bulkPublishSet.length < 10) {
190
292
  bulkPublishSet.push({
191
293
  uid,
192
294
  version: publishDetail.version,
193
- locale,
194
- content_type,
195
295
  publish_details: [publishDetail],
196
- })
296
+ });
197
297
  }
198
298
 
199
299
  if (bulkPublishSet.length === 10) {
200
300
  const data = {
201
- entries: bulkPublishSet,
301
+ assets: bulkPublishSet,
202
302
  environments: [environment.name],
203
- locale: loc,
204
- Type: 'entry',
205
- stack: stack
206
- }
207
- setOfBulkPublishRequestPayloads.push(data)
208
- bulkPublishSet = []
303
+ locale: 'en-us',
304
+ Type: 'asset',
305
+ stack: stack,
306
+ };
307
+ setOfBulkPublishRequestPayloads.push(data);
308
+ bulkPublishSet = [];
209
309
  }
210
- })
310
+ });
211
311
  } else {
212
312
  if (bulkUnpublishSet.length < 10) {
213
313
  bulkUnpublishSet.push({
214
314
  uid,
215
- locale,
216
- content_type,
217
315
  publish_details: [],
218
- })
316
+ });
219
317
  }
220
318
 
221
319
  if (bulkUnpublishSet.length === 10) {
222
320
  unpublishQueue.Enqueue({
223
- entries: bulkUnpublishSet, environments: [environment.name], locale: loc, Type: 'entry', stack: stack
224
- })
225
- bulkUnpublishSet = []
321
+ assets: bulkUnpublishSet,
322
+ environments: [environment.name],
323
+ Type: 'asset',
324
+ stack: stack,
325
+ });
326
+ bulkUnpublishSet = [];
226
327
  }
227
328
  }
228
329
 
229
- if (entryIndex === logs.entries[loc].length - 1) {
330
+ if (assetIndex === logs.assets.length - 1) {
230
331
  if (bulkUnpublishSet.length <= 10 && bulkUnpublishSet.length !== 0) {
231
332
  unpublishQueue.Enqueue({
232
- entries: bulkUnpublishSet, environments: [environment.name], locale: loc, Type: 'entry', stack: stack
233
- })
234
- bulkUnpublishSet = []
235
- }
236
-
237
- if (bulkPublishSet.length <= 10 && bulkPublishSet.length !== 0) {
238
- const data = {
239
- entries: bulkPublishSet,
333
+ assets: bulkUnpublishSet,
240
334
  environments: [environment.name],
241
- locale: loc,
242
- Type: 'entry',
243
- stack: stack
244
- }
245
- setOfBulkPublishRequestPayloads.push(data)
246
- bulkPublishSet = []
247
- }
248
- }
249
-
250
- if (envIndex === logs.environments.length - 1 && locIndex === logs.locale.length - 1 && entryIndex === logs.entries[loc].length - 1) {
251
- mapSeries(setOfBulkPublishRequestPayloads, processPublishRequests)
252
- }
253
- })
254
- })
255
- break
256
- case 'asset':
257
- logs.assets.forEach(({publish_details, uid}, assetIndex) => {
258
- const publishDetailsForThisEnvironment = publish_details.filter(publishDetail => publishDetail.environment === environment.uid)
259
-
260
- if (publishDetailsForThisEnvironment.length > 0) {
261
- // handle revert case
262
-
263
- publishDetailsForThisEnvironment.forEach(publishDetail => {
264
- if (bulkPublishSet.length < 10) {
265
- bulkPublishSet.push({
266
- uid,
267
- version: publishDetail.version,
268
- publish_details: [publishDetail],
269
- })
335
+ Type: 'asset',
336
+ stack: stack,
337
+ });
338
+ bulkUnpublishSet = [];
270
339
  }
271
340
 
272
- if (bulkPublishSet.length === 10) {
341
+ if (bulkPublishSet.length <= 10 && bulkPublishSet.length !== 0) {
273
342
  const data = {
274
343
  assets: bulkPublishSet,
275
344
  environments: [environment.name],
276
345
  locale: 'en-us',
277
346
  Type: 'asset',
278
- stack: stack
279
- }
280
- setOfBulkPublishRequestPayloads.push(data)
281
- bulkPublishSet = []
347
+ stack: stack,
348
+ };
349
+ setOfBulkPublishRequestPayloads.push(data);
350
+ bulkPublishSet = [];
282
351
  }
283
- })
284
- } else {
285
- if (bulkUnpublishSet.length < 10) {
286
- bulkUnpublishSet.push({
287
- uid,
288
- publish_details: [],
289
- })
290
352
  }
291
353
 
292
- if (bulkUnpublishSet.length === 10) {
293
- unpublishQueue.Enqueue({assets: bulkUnpublishSet, environments: [environment.name], Type: 'asset', stack: stack})
294
- bulkUnpublishSet = []
354
+ if (envIndex === logs.environments.length - 1 && assetIndex === logs.assets.length - 1) {
355
+ mapSeries(setOfBulkPublishRequestPayloads, processPublishRequests);
295
356
  }
296
- }
297
-
298
- if (assetIndex === logs.assets.length - 1) {
299
- if (bulkUnpublishSet.length <= 10 && bulkUnpublishSet.length !== 0) {
300
- unpublishQueue.Enqueue({assets: bulkUnpublishSet, environments: [environment.name], Type: 'asset', stack: stack})
301
- bulkUnpublishSet = []
302
- }
303
-
304
- if (bulkPublishSet.length <= 10 && bulkPublishSet.length !== 0) {
305
- const data = {
306
- assets: bulkPublishSet,
307
- environments: [environment.name],
308
- locale: 'en-us',
309
- Type: 'asset',
310
- stack: stack
311
- }
312
- setOfBulkPublishRequestPayloads.push(data)
313
- bulkPublishSet = []
314
- }
315
- }
316
-
317
- if (envIndex === logs.environments.length - 1 && assetIndex === logs.assets.length - 1) {
318
- mapSeries(setOfBulkPublishRequestPayloads, processPublishRequests)
319
- }
320
- })
321
- break
322
- default: break
357
+ });
358
+ break;
359
+ default:
360
+ break;
323
361
  }
324
- })
362
+ });
325
363
  } else {
326
- console.log(chalk.red('Error: This log file is empty. Please check error logs if any'))
364
+ console.log(chalk.red('Error: This log file is empty. Please check error logs if any'));
327
365
  }
328
366
  }
329
367
  }
330
368
 
331
- async function start({retryFailed, logFile}, config) {
332
- setConfig(config)
369
+ async function start({ retryFailed, logFile }, cfg) {
370
+ setConfig(cfg);
333
371
  if (retryFailed) {
334
372
  if (typeof retryFailed === 'string') {
335
373
  if (!validateFile(retryFailed, ['revert'])) {
336
- return false
374
+ return false;
337
375
  }
338
376
 
339
- revertUsingLogs(retryFailed)
377
+ revertUsingLogs(retryFailed);
340
378
  }
341
379
  } else {
342
- // const ok = await yesno({
343
- // question: `Are you sure you want to revert using the file "${logfilenameProvidedByUser}" ?`,
344
- // });
345
- // if (ok) {
346
- revertUsingLogs(logFile)
347
- // }
380
+ revertUsingLogs(logFile);
348
381
  }
349
382
  }
350
383
 
351
- // start()
352
-
353
384
  module.exports = {
354
385
  setConfig,
355
386
  revertUsingLogs,
356
387
  start,
357
- }
388
+ };