@contentstack/cli-cm-bulk-publish 1.3.14 → 1.4.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.
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.14",
4
+ "version": "1.4.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "~1.2.15",
9
- "@contentstack/cli-utilities": "~1.5.5",
8
+ "@contentstack/cli-command": "~1.2.16",
9
+ "@contentstack/cli-utilities": "~1.5.10",
10
10
  "bluebird": "^3.7.2",
11
11
  "chalk": "^4.1.2",
12
12
  "dotenv": "^16.1.4",
@@ -99,4 +99,4 @@
99
99
  "version": "oclif readme && git add README.md",
100
100
  "clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
101
101
  }
102
- }
102
+ }
@@ -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');
@@ -62,7 +63,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
62
63
  locale: filter.locale,
63
64
  environments: destEnv,
64
65
  stack: stack,
65
- apiVersion
66
+ apiVersion,
66
67
  });
67
68
  bulkPublishAssetSet = [];
68
69
  }
@@ -74,7 +75,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
74
75
  Type: 'entry',
75
76
  environments: destEnv,
76
77
  stack: stack,
77
- apiVersion
78
+ apiVersion,
78
79
  });
79
80
  bulkPublishSet = [];
80
81
  }
@@ -86,7 +87,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
86
87
  locale: filter.locale,
87
88
  environments: destEnv,
88
89
  stack: stack,
89
- apiVersion
90
+ apiVersion,
90
91
  });
91
92
  bulkPublishAssetSet = [];
92
93
  }
@@ -98,7 +99,7 @@ async function bulkAction(stack, items, bulkPublish, filter, destEnv, apiVersion
98
99
  Type: 'entry',
99
100
  environments: destEnv,
100
101
  stack: stack,
101
- apiVersion
102
+ apiVersion,
102
103
  });
103
104
  bulkPublishSet = [];
104
105
  }
@@ -156,13 +157,21 @@ async function getSyncEntries(
156
157
  queryParamsObj[decodeURIComponent(split[0])] = decodeURIComponent(split[1]);
157
158
  }
158
159
 
159
- const Stack = new command.deliveryAPIClient.Stack({
160
+ const deliveryAPIOptions = {
160
161
  api_key: tokenDetails.apiKey,
161
162
  delivery_token: deliveryToken,
162
163
  environment: queryParamsObj.environment,
163
164
  branch: config.branch,
164
- });
165
- Stack.setHost(config.cda)
165
+ };
166
+
167
+ const earlyAccessHeaders = configHandler.get(`earlyAccessHeaders`);
168
+ if (earlyAccessHeaders && Object.keys(earlyAccessHeaders).length > 0) {
169
+ deliveryAPIOptions.early_access = Object.values(earlyAccessHeaders);
170
+ }
171
+
172
+ const Stack = new command.deliveryAPIClient.Stack(deliveryAPIOptions);
173
+
174
+ Stack.setHost(config.cda);
166
175
 
167
176
  const syncData = {};
168
177
 
@@ -236,7 +245,7 @@ async function start(
236
245
  onlyEntries,
237
246
  destEnv,
238
247
  f_types,
239
- apiVersion
248
+ apiVersion,
240
249
  },
241
250
  stack,
242
251
  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
  ) {
@@ -5,8 +5,14 @@ module.exports = async (filename, queue, Type) => {
5
5
  const logs = await getAllLogs(filename);
6
6
  if (logs.file.length > 0) {
7
7
  logs.file.forEach(async (log) => {
8
- if (Type === 'bulk') {
9
- log.message.options.stack = await getStack({ alias: log.message.alias, host: log.message.host });
8
+ const stackOptions = {host: log.message.host };
9
+ if(log.message.alias) {
10
+ stackOptions["alias"] = log.message.alias
11
+ } else {
12
+ stackOptions["stackApiKey"] = log.message.api_key
13
+ }
14
+ if (Type === 'bulk') {
15
+ log.message.options.stack = await getStack(stackOptions);
10
16
  queue.Enqueue(log.message.options);
11
17
  }
12
18
  if (Type === 'publish') {
@@ -18,7 +24,7 @@ module.exports = async (filename, queue, Type) => {
18
24
  entryUid: log.message.options.entryUid,
19
25
  locale: log.message.options.locale,
20
26
  Type: 'entry',
21
- stack: await getStack({ alias: log.message.alias, host: log.message.host }),
27
+ stack: await getStack(stackOptions),
22
28
  });
23
29
  } else {
24
30
  queue.assetQueue.Enqueue({
@@ -26,7 +32,7 @@ module.exports = async (filename, queue, Type) => {
26
32
  publish_details: log.message.options.publish_assets,
27
33
  environments: log.message.options.environments,
28
34
  Type: 'asset',
29
- stack: await getStack({ alias: log.message.alias, host: log.message.host }),
35
+ stack: await getStack(stackOptions),
30
36
  });
31
37
  }
32
38
  }