@contentstack/cli-cm-bulk-publish 1.3.15 → 1.4.1

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Contentstack
3
+ Copyright (c) 2024 Contentstack
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-cm-bulk-publish
18
18
  $ csdx COMMAND
19
19
  running command...
20
20
  $ csdx (--version)
21
- @contentstack/cli-cm-bulk-publish/1.3.14 darwin-arm64 node-v21.1.0
21
+ @contentstack/cli-cm-bulk-publish/1.4.0 darwin-arm64 node-v20.8.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-bulk-publish",
3
3
  "description": "Contentstack CLI plugin for bulk publish actions",
4
- "version": "1.3.15",
4
+ "version": "1.4.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
8
  "@contentstack/cli-command": "~1.2.16",
9
- "@contentstack/cli-utilities": "~1.5.7",
9
+ "@contentstack/cli-utilities": "~1.5.11",
10
10
  "bluebird": "^3.7.2",
11
11
  "chalk": "^4.1.2",
12
12
  "dotenv": "^16.1.4",
@@ -17,7 +17,7 @@
17
17
  "winston": "^3.7.2"
18
18
  },
19
19
  "devDependencies": {
20
- "@oclif/test": "^1.2.6",
20
+ "@oclif/test": "^2.5.6",
21
21
  "chai": "^4.2.0",
22
22
  "eslint": "^8.18.0",
23
23
  "eslint-config-oclif": "^4.0.0",
@@ -43,6 +43,7 @@ async function publishEntry(data, _config, queue) {
43
43
  .publish({
44
44
  publishDetails: { environments: entryObj.environments, locales: lang },
45
45
  locale: entryObj.locale || 'en-us',
46
+ version: entryObj.version
46
47
  })
47
48
  .then((publishEntryResponse) => {
48
49
  if (!publishEntryResponse.error_message) {
@@ -3,6 +3,7 @@
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable complexity */
5
5
  /* eslint-disable max-params */
6
+ const { configHandler } = require('@contentstack/cli-utilities');
6
7
  const { getQueue } = require('../util/queue');
7
8
  const defaults = require('../config/defaults.json');
8
9
  const { performBulkPublish, publishEntry, publishAsset, initializeLogger } = require('../consumer/publish');
@@ -43,6 +44,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
43
44
  uid: items[index].data.uid,
44
45
  content_type: items[index].content_type_uid,
45
46
  locale: items[index].data.locale || 'en-us',
47
+ version: items[index].data._version,
46
48
  publish_details: [items[index].data.publish_details] || [],
47
49
  });
48
50
  }
@@ -62,7 +64,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
62
64
  locale: filter.locale,
63
65
  environments: destEnv,
64
66
  stack: stack,
65
- apiVersion
67
+ apiVersion,
66
68
  });
67
69
  bulkPublishAssetSet = [];
68
70
  }
@@ -74,7 +76,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
74
76
  Type: 'entry',
75
77
  environments: destEnv,
76
78
  stack: stack,
77
- apiVersion
79
+ apiVersion,
78
80
  });
79
81
  bulkPublishSet = [];
80
82
  }
@@ -86,7 +88,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
86
88
  locale: filter.locale,
87
89
  environments: destEnv,
88
90
  stack: stack,
89
- apiVersion
91
+ apiVersion,
90
92
  });
91
93
  bulkPublishAssetSet = [];
92
94
  }
@@ -98,7 +100,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
98
100
  Type: 'entry',
99
101
  environments: destEnv,
100
102
  stack: stack,
101
- apiVersion
103
+ apiVersion,
102
104
  });
103
105
  bulkPublishSet = [];
104
106
  }
@@ -110,6 +112,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
110
112
  environments: destEnv,
111
113
  entryUid: items[index].data.uid,
112
114
  locale: items[index].data.locale || 'en-us',
115
+ version: items[index].data._version,
113
116
  Type: 'entry',
114
117
  stack: stack,
115
118
  });
@@ -156,13 +159,21 @@ async function getSyncEntries(
156
159
  queryParamsObj[decodeURIComponent(split[0])] = decodeURIComponent(split[1]);
157
160
  }
158
161
 
159
- const Stack = new command.deliveryAPIClient.Stack({
162
+ const deliveryAPIOptions = {
160
163
  api_key: tokenDetails.apiKey,
161
164
  delivery_token: deliveryToken,
162
165
  environment: queryParamsObj.environment,
163
166
  branch: config.branch,
164
- });
165
- Stack.setHost(config.cda)
167
+ };
168
+
169
+ const earlyAccessHeaders = configHandler.get(`earlyAccessHeaders`);
170
+ if (earlyAccessHeaders && Object.keys(earlyAccessHeaders).length > 0) {
171
+ deliveryAPIOptions.early_access = Object.values(earlyAccessHeaders);
172
+ }
173
+
174
+ const Stack = new command.deliveryAPIClient.Stack(deliveryAPIOptions);
175
+
176
+ Stack.setHost(config.cda);
166
177
 
167
178
  const syncData = {};
168
179
 
@@ -236,7 +247,7 @@ async function start(
236
247
  onlyEntries,
237
248
  destEnv,
238
249
  f_types,
239
- apiVersion
250
+ apiVersion,
240
251
  },
241
252
  stack,
242
253
  config,
@@ -3,6 +3,7 @@
3
3
  /* eslint-disable complexity */
4
4
  /* eslint-disable no-console */
5
5
  /* eslint-disable camelcase */
6
+ const { configHandler } = require('@contentstack/cli-utilities');
6
7
  const { getQueue } = require('../util/queue');
7
8
  const defaults = require('../config/defaults.json');
8
9
  const { performBulkUnPublish, UnpublishEntry, UnpublishAsset, initializeLogger } = require('../consumer/publish');
@@ -79,7 +80,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale, apiVersion
79
80
  locale: locale,
80
81
  environments: [environment],
81
82
  stack: stack,
82
- apiVersion
83
+ apiVersion,
83
84
  });
84
85
  bulkUnPulishAssetSet = [];
85
86
  }
@@ -91,7 +92,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale, apiVersion
91
92
  Type: 'entry',
92
93
  environments: [environment],
93
94
  stack: stack,
94
- apiVersion
95
+ apiVersion,
95
96
  });
96
97
  bulkUnPublishSet = [];
97
98
  }
@@ -102,7 +103,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale, apiVersion
102
103
  locale: locale,
103
104
  environments: [environment],
104
105
  stack: stack,
105
- apiVersion
106
+ apiVersion,
106
107
  });
107
108
  bulkUnPulishAssetSet = [];
108
109
  }
@@ -114,7 +115,7 @@ function bulkAction(stack, items, bulkUnpublish, environment, locale, apiVersion
114
115
  Type: 'entry',
115
116
  environments: [environment],
116
117
  stack: stack,
117
- apiVersion
118
+ apiVersion,
118
119
  });
119
120
  bulkUnPublishSet = [];
120
121
  }
@@ -171,13 +172,21 @@ async function getSyncEntries(
171
172
  queryParamsObj[decodeURIComponent(split[0])] = decodeURIComponent(split[1]);
172
173
  }
173
174
 
174
- const Stack = new command.deliveryAPIClient.Stack({
175
+ const deliveryAPIOptions = {
175
176
  api_key: tokenDetails.apiKey,
176
177
  delivery_token: deliveryToken,
177
178
  environment: queryParamsObj.environment,
178
179
  branch: config.branch,
179
- });
180
- Stack.setHost(config.cda)
180
+ };
181
+
182
+ const earlyAccessHeaders = configHandler.get(`earlyAccessHeaders`);
183
+ if (earlyAccessHeaders && Object.keys(earlyAccessHeaders).length > 0) {
184
+ deliveryAPIOptions.early_access = Object.values(earlyAccessHeaders);
185
+ }
186
+
187
+ const Stack = new command.deliveryAPIClient.Stack(deliveryAPIOptions);
188
+
189
+ Stack.setHost(config.cda);
181
190
 
182
191
  const syncData = {};
183
192
 
@@ -203,7 +212,17 @@ async function getSyncEntries(
203
212
  return resolve();
204
213
  }
205
214
  setTimeout(async () => {
206
- await getSyncEntries(stack, config, locale, queryParams, bulkUnpublish, environment, deliveryToken, apiVersion, null);
215
+ await getSyncEntries(
216
+ stack,
217
+ config,
218
+ locale,
219
+ queryParams,
220
+ bulkUnpublish,
221
+ environment,
222
+ deliveryToken,
223
+ apiVersion,
224
+ null,
225
+ );
207
226
  }, 3000);
208
227
  } catch (error) {
209
228
  reject(error);
@@ -212,7 +231,18 @@ async function getSyncEntries(
212
231
  }
213
232
 
214
233
  async function start(
215
- { retryFailed, bulkUnpublish, contentType, locale, environment, deliveryToken, onlyAssets, onlyEntries, f_types, apiVersion },
234
+ {
235
+ retryFailed,
236
+ bulkUnpublish,
237
+ contentType,
238
+ locale,
239
+ environment,
240
+ deliveryToken,
241
+ onlyAssets,
242
+ onlyEntries,
243
+ f_types,
244
+ apiVersion,
245
+ },
216
246
  stack,
217
247
  config,
218
248
  ) {