@contentstack/cli-cm-bulk-publish 1.2.0 → 1.3.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/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.2.0 linux-x64 node-v16.19.1
21
+ @contentstack/cli-cm-bulk-publish/1.3.1 linux-x64 node-v16.20.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.0",
2
+ "version": "1.3.1",
3
3
  "commands": {
4
4
  "cm:assets:publish": {
5
5
  "id": "cm:assets:publish",
@@ -810,7 +810,7 @@
810
810
  },
811
811
  "cm:entries:publish": {
812
812
  "id": "cm:entries:publish",
813
- "description": "Publish entries from multiple contenttypes to multiple environments and locales\nThe publish command is used to publish entries from the specified content types, to the\nspecified environments and locales \n\nNote: Content Types, Environments and Locales are required to execute the command successfully\nBut, if retry-failed flag is set, then only a logfile is required\n",
813
+ "description": "Publish entries from multiple contenttypes to multiple environments and locales\nThe publish command is used to publish entries from the specified content types, to the\nspecified environments and locales\n\nNote: Content Types, Environments and Locales are required to execute the command successfully\nBut, if retry-failed flag is set, then only a logfile is required\n",
814
814
  "strict": true,
815
815
  "usage": "cm:entries:publish [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--publish-all-content-types] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>] [--delivery-token <value>] [--source-env <value>]",
816
816
  "pluginName": "@contentstack/cli-cm-bulk-publish",
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.2.0",
4
+ "version": "1.3.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "^1.2.0",
9
- "@contentstack/cli-utilities": "^1.2.0",
8
+ "@contentstack/cli-command": "^1.2.2",
9
+ "@contentstack/cli-utilities": "^1.3.1",
10
10
  "@contentstack/management": "^1.6.1",
11
11
  "bluebird": "^3.7.2",
12
12
  "chalk": "^4.1.2",
@@ -63,6 +63,30 @@
63
63
  "cm:bulk-publish:unpublish": "csdx cm:stacks:unpublish or cm:entries:unpublish or cm:assets:unpublish",
64
64
  "cm:bulk-publish:cross-publish": "csdx cm:entries:publish or csdx cm:assets:publish with source-env flag",
65
65
  "cm:bulk-publish:entry-edits": "csdx cm:entries:publish-modified"
66
+ },
67
+ "shortCommandName": {
68
+ "cm:assets:publish": "PB-A",
69
+ "cm:assets:unpublish": "UNPB-A",
70
+ "cm:entries:publish-modified": "PB-MF-E",
71
+ "cm:entries:publish-non-localized-fields": "PB-NLCF-E",
72
+ "cm:entries:publish-only-unpublished": "PB-UNPB-E",
73
+ "cm:entries:publish": "PB-E",
74
+ "cm:entries:unpublish": "UNPB-E",
75
+ "cm:entries:update-and-publish": "PB-UPD-E",
76
+ "cm:stacks:publish-clear-logs": "PB-CLRLG-S",
77
+ "cm:stacks:publish-configure": "PB-CNF-S",
78
+ "cm:stacks:publish-revert": "PB-RVT-S",
79
+ "cm:bulk-publish:unpublish": "O-BP-UNPB",
80
+ "cm:bulk-publish:entry-edits": "O-BP-EE",
81
+ "cm:bulk-publish:nonlocalized-field-changes": "O-BP-NLCF",
82
+ "cm:bulk-publish:clear": "O-BP-CLR",
83
+ "cm:bulk-publish:assets": "O-BP-A",
84
+ "cm:bulk-publish:cross-publish": "O-BP-CRS",
85
+ "cm:bulk-publish:entries": "O-BP-E",
86
+ "cm:bulk-publish:unpublished-entries": "O-BP-UNPB-E",
87
+ "cm:bulk-publish:add-fields": "O-BP-ADFLD",
88
+ "cm:bulk-publish:revert": "O-BP-RVT",
89
+ "cm:bulk-publish:configure": "O-BP-CNF"
66
90
  }
67
91
  },
68
92
  "repository": "https://github.com/contentstack/cli",
@@ -47,8 +47,8 @@ class AssetsPublishCommand extends Command {
47
47
  }
48
48
  config = {
49
49
  alias: updatedFlags.alias,
50
- host: this.region.cma,
51
- cda: this.region.cda,
50
+ host: this.cmaHost,
51
+ cda: this.cdaHost,
52
52
  branch: assetsFlags.branch,
53
53
  };
54
54
  stack = await getStack(config);
@@ -49,8 +49,8 @@ class UnpublishCommand extends Command {
49
49
  }
50
50
  config = {
51
51
  alias: updatedFlags.alias,
52
- host: this.region.cma,
53
- cda: this.region.cda,
52
+ host: this.cmaHost,
53
+ cda: this.cdaHost,
54
54
  branch: unpublishFlags.branch,
55
55
  };
56
56
  stack = await getStack(config);
@@ -40,8 +40,8 @@ class CrossPublishCommand extends Command {
40
40
  }
41
41
  config = {
42
42
  alias: updatedFlags.alias,
43
- host: this.region.cma,
44
- cda: this.region.cda,
43
+ host: this.cmaHost,
44
+ cda: this.cdaHost,
45
45
  branch: crossPublishFlags.branch,
46
46
  };
47
47
  stack = await getStack(config);
@@ -38,11 +38,15 @@ class PublishModifiedCommand extends Command {
38
38
  try {
39
39
  this.getToken(updatedFlags.alias);
40
40
  } catch (error) {
41
- this.error(`The configured management token alias ${updatedFlags.alias} has not been added yet. Add it using 'csdx auth:tokens:add -a ${updatedFlags.alias}'`, { exit: 2 })
41
+ this.error(
42
+ `The configured management token alias ${updatedFlags.alias} has not been added yet. Add it using 'csdx auth:tokens:add -a ${updatedFlags.alias}'`,
43
+ { exit: 2 },
44
+ );
42
45
  }
43
46
  config = {
44
47
  alias: updatedFlags.alias,
45
- host: this.region.cma,
48
+ host: this.cmaHost,
49
+ cda: this.cdaHost,
46
50
  branch: entryEditsFlags.branch,
47
51
  };
48
52
  stack = await getStack(config);
@@ -143,7 +147,7 @@ PublishModifiedCommand.flags = {
143
147
  parse: printFlagDeprecation(['-s', '--sourceEnv'], ['--source-env']),
144
148
  }),
145
149
  'source-env': flags.string({
146
- description: 'Environment from which edited entries will be published'
150
+ description: 'Environment from which edited entries will be published',
147
151
  }),
148
152
  contentTypes: flags.string({
149
153
  char: 't',
@@ -190,8 +194,9 @@ PublishModifiedCommand.examples = [
190
194
  'csdx cm:entries:publish-modified --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] --source-env [SOURCE_ENV] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --branch [BRANCH NAME]',
191
195
  ];
192
196
 
193
- PublishModifiedCommand.aliases = ['cm:bulk-publish:entry-edits']
197
+ PublishModifiedCommand.aliases = ['cm:bulk-publish:entry-edits'];
194
198
 
195
- PublishModifiedCommand.usage = 'cm:entries:publish-modified [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--source-env <value>] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>]'
199
+ PublishModifiedCommand.usage =
200
+ 'cm:entries:publish-modified [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--source-env <value>] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>]';
196
201
 
197
202
  module.exports = PublishModifiedCommand;
@@ -49,7 +49,8 @@ class NonlocalizedFieldChangesCommand extends Command {
49
49
  }
50
50
  config = {
51
51
  alias: updatedFlags.alias,
52
- host: this.region.cma,
52
+ host: this.cmaHost,
53
+ cda: this.cdaHost,
53
54
  branch: nonlocalizedFieldChangesFlags.branch,
54
55
  };
55
56
  stack = await getStack(config);
@@ -105,7 +106,6 @@ class NonlocalizedFieldChangesCommand extends Command {
105
106
  return true;
106
107
  }
107
108
  return cliux.confirm('Do you want to continue with this configuration ? [yes or no]');
108
-
109
109
  }
110
110
  }
111
111
 
@@ -203,6 +203,7 @@ NonlocalizedFieldChangesCommand.examples = [
203
203
 
204
204
  NonlocalizedFieldChangesCommand.aliases = ['cm:bulk-publish:nonlocalized-field-changes'];
205
205
 
206
- NonlocalizedFieldChangesCommand.usage = 'cm:entries:publish-non-localized-fields [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--source-env <value>] [--content-types <value>] [-e <value>] [-c <value>] [-y] [--branch <value>]'
206
+ NonlocalizedFieldChangesCommand.usage =
207
+ 'cm:entries:publish-non-localized-fields [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--source-env <value>] [--content-types <value>] [-e <value>] [-c <value>] [-y] [--branch <value>]';
207
208
 
208
209
  module.exports = NonlocalizedFieldChangesCommand;
@@ -18,7 +18,8 @@ class PublishEntriesCommand extends Command {
18
18
  entriesFlags.retryFailed = entriesFlags['retry-failed'] || entriesFlags.retryFailed || false;
19
19
  entriesFlags.contentTypes = entriesFlags['content-types'] || entriesFlags.contentTypes;
20
20
  entriesFlags.bulkPublish = entriesFlags['bulk-publish'] || entriesFlags.bulkPublish;
21
- entriesFlags.publishAllContentTypes = entriesFlags['publish-all-content-types'] || entriesFlags.publishAllContentTypes || false;
21
+ entriesFlags.publishAllContentTypes =
22
+ entriesFlags['publish-all-content-types'] || entriesFlags.publishAllContentTypes || false;
22
23
  delete entriesFlags['retry-failed'];
23
24
  delete entriesFlags['content-types'];
24
25
  delete entriesFlags['bulk-publish'];
@@ -26,7 +27,7 @@ class PublishEntriesCommand extends Command {
26
27
 
27
28
  let updatedFlags;
28
29
  try {
29
- const storeConfigKey = entriesFlags['source-env'] ? configKeyCrossEnv : configKey
30
+ const storeConfigKey = entriesFlags['source-env'] ? configKeyCrossEnv : configKey;
30
31
  updatedFlags = entriesFlags.config ? store.updateMissing(storeConfigKey, entriesFlags) : entriesFlags;
31
32
  } catch (error) {
32
33
  this.error(error.message, { exit: 2 });
@@ -42,19 +43,21 @@ class PublishEntriesCommand extends Command {
42
43
  try {
43
44
  this.getToken(updatedFlags.alias);
44
45
  } catch (error) {
45
- this.error(`The configured management token alias ${updatedFlags.alias} has not been added yet. Add it using 'csdx auth:tokens:add -a ${updatedFlags.alias}'`, { exit: 2 })
46
+ this.error(
47
+ `The configured management token alias ${updatedFlags.alias} has not been added yet. Add it using 'csdx auth:tokens:add -a ${updatedFlags.alias}'`,
48
+ { exit: 2 },
49
+ );
46
50
  }
47
51
  config = {
48
52
  alias: updatedFlags.alias,
49
- host: this.region.cma,
50
- cda: this.region.cda,
53
+ host: this.cmaHost,
54
+ cda: this.cdaHost,
51
55
  branch: entriesFlags.branch,
52
56
  };
53
57
  stack = await getStack(config);
54
58
  }
55
59
  if (await this.confirmFlags(updatedFlags)) {
56
60
  try {
57
-
58
61
  const publishFunction = async (func) => {
59
62
  // eslint-disable-next-line no-negated-condition
60
63
  if (!updatedFlags.retryFailed) {
@@ -62,28 +65,25 @@ class PublishEntriesCommand extends Command {
62
65
  } else {
63
66
  await func(updatedFlags);
64
67
  }
65
- }
68
+ };
66
69
 
67
70
  if (updatedFlags['source-env']) {
68
- updatedFlags.deliveryToken = updatedFlags['delivery-token']
69
- updatedFlags.destEnv = updatedFlags.environments
70
- updatedFlags.environment = updatedFlags['source-env']
71
- updatedFlags.onlyEntries = true
71
+ updatedFlags.deliveryToken = updatedFlags['delivery-token'];
72
+ updatedFlags.destEnv = updatedFlags.environments;
73
+ updatedFlags.environment = updatedFlags['source-env'];
74
+ updatedFlags.onlyEntries = true;
72
75
  if (updatedFlags.locales instanceof Array) {
73
- updatedFlags.locales.forEach(locale => {
74
- updatedFlags.locale = locale
75
- publishFunction(startCrossPublish)
76
+ updatedFlags.locales.forEach((locale) => {
77
+ updatedFlags.locale = locale;
78
+ publishFunction(startCrossPublish);
76
79
  });
77
80
  } else {
78
- updatedFlags.locale = locales
79
- publishFunction(startCrossPublish)
81
+ updatedFlags.locale = locales;
82
+ publishFunction(startCrossPublish);
80
83
  }
81
-
82
- }
83
- else {
84
- publishFunction(startPublish)
84
+ } else {
85
+ publishFunction(startPublish);
85
86
  }
86
-
87
87
  } catch (error) {
88
88
  let message = formatError(error);
89
89
  this.error(message, { exit: 2 });
@@ -94,17 +94,22 @@ class PublishEntriesCommand extends Command {
94
94
  }
95
95
  }
96
96
 
97
- validate({ contentTypes, locales, environments, retryFailed, publishAllContentTypes, 'source-env': sourceEnv, 'delivery-token': deliveryToken }) {
97
+ validate({
98
+ contentTypes,
99
+ locales,
100
+ environments,
101
+ retryFailed,
102
+ publishAllContentTypes,
103
+ 'source-env': sourceEnv,
104
+ 'delivery-token': deliveryToken,
105
+ }) {
98
106
  let missing = [];
99
107
  if (retryFailed) {
100
108
  return true;
101
109
  }
102
110
 
103
111
  if (sourceEnv && !deliveryToken) {
104
- this.error(
105
- 'Specify source environment delivery token. Please check --help for more details',
106
- { exit: 2 },
107
- );
112
+ this.error('Specify source environment delivery token. Please check --help for more details', { exit: 2 });
108
113
  }
109
114
 
110
115
  if (publishAllContentTypes && contentTypes && contentTypes.length > 0) {
@@ -149,7 +154,7 @@ class PublishEntriesCommand extends Command {
149
154
 
150
155
  PublishEntriesCommand.description = `Publish entries from multiple contenttypes to multiple environments and locales
151
156
  The publish command is used to publish entries from the specified content types, to the
152
- specified environments and locales
157
+ specified environments and locales
153
158
 
154
159
  Note: Content Types, Environments and Locales are required to execute the command successfully
155
160
  But, if retry-failed flag is set, then only a logfile is required
@@ -247,8 +252,9 @@ PublishEntriesCommand.examples = [
247
252
  'csdx cm:entries:publish --content-types [CONTENT TYPE 1] [CONTENT TYPE 2] -e [ENVIRONMENT 1] [ENVIRONMENT 2] --locales [LOCALE 1] [LOCALE 2] -a [MANAGEMENT TOKEN ALIAS] --source-env [SOURCE ENVIRONMENT] --delivery-token [DELIVERY TOKEN]',
248
253
  ];
249
254
 
250
- PublishEntriesCommand.aliases = ['cm:bulk-publish:entries']
255
+ PublishEntriesCommand.aliases = ['cm:bulk-publish:entries'];
251
256
 
252
- PublishEntriesCommand.usage = 'cm:entries:publish [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--publish-all-content-types] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>] [--delivery-token <value>] [--source-env <value>]'
257
+ PublishEntriesCommand.usage =
258
+ 'cm:entries:publish [-a <value>] [--retry-failed <value>] [--bulk-publish <value>] [--publish-all-content-types] [--content-types <value>] [--locales <value>] [-e <value>] [-c <value>] [-y] [--branch <value>] [--delivery-token <value>] [--source-env <value>]';
253
259
 
254
260
  module.exports = PublishEntriesCommand;
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable node/no-extraneous-require */
3
3
  const { Command } = require('@contentstack/cli-command');
4
- const { cliux, flags} = require('@contentstack/cli-utilities');
4
+ const { cliux, flags } = require('@contentstack/cli-utilities');
5
5
  const { start } = require('../../../producer/unpublish');
6
6
  const store = require('../../../util/store.js');
7
7
  const configKey = 'Unpublish';
@@ -51,8 +51,8 @@ class UnpublishCommand extends Command {
51
51
  }
52
52
  config = {
53
53
  alias: updatedFlags.alias,
54
- host: this.region.cma,
55
- cda: this.region.cda,
54
+ host: this.cmaHost,
55
+ cda: this.cdaHost,
56
56
  branch: unpublishFlags.branch,
57
57
  };
58
58
  stack = await getStack(config);
@@ -43,7 +43,8 @@ class UpdateAndPublishCommand extends Command {
43
43
  }
44
44
  config = {
45
45
  alias: updatedFlags.alias,
46
- host: this.region.cma,
46
+ host: this.cmaHost,
47
+ cda: this.cdaHost,
47
48
  branch: addFieldsFlags.branch,
48
49
  };
49
50
  stack = await getStack(config);
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable node/no-extraneous-require */
3
3
  const { Command } = require('@contentstack/cli-command');
4
- const { printFlagDeprecation, cliux , flags } = require('@contentstack/cli-utilities');
4
+ const { printFlagDeprecation, cliux, flags } = require('@contentstack/cli-utilities');
5
5
  const { start } = require('../../../producer/unpublish');
6
6
  const store = require('../../../util/store.js');
7
7
  const configKey = 'Unpublish';
@@ -53,8 +53,8 @@ class UnpublishCommand extends Command {
53
53
  }
54
54
  config = {
55
55
  alias: updatedFlags.alias,
56
- host: this.region.cma,
57
- cda: this.region.cda,
56
+ host: this.cmaHost,
57
+ cda: this.cdaHost,
58
58
  branch: unpublishFlags.branch,
59
59
  };
60
60
  stack = await getStack(config);
@@ -11,7 +11,7 @@ const configKey = 'publish_unpublished_env';
11
11
 
12
12
  async function publishOnlyUnpublishedService(UnpublishedEntriesCommand) {
13
13
  let config;
14
- const _flags = await this.parse(UnpublishedEntriesCommand)
14
+ const _flags = await this.parse(UnpublishedEntriesCommand);
15
15
  const unpublishedEntriesFlags = flagsAdapter(_flags.flags);
16
16
  let updatedFlags;
17
17
  try {
@@ -39,7 +39,8 @@ async function publishOnlyUnpublishedService(UnpublishedEntriesCommand) {
39
39
  }
40
40
  config = {
41
41
  alias: updatedFlags.alias,
42
- host: this.region.cma,
42
+ host: this.cmaHost,
43
+ cda: this.cdaHost,
43
44
  branch: unpublishedEntriesFlags.branch,
44
45
  };
45
46
  stack = await getStack(config);
@@ -2,12 +2,10 @@ const { managementSDKClient } = require('@contentstack/cli-utilities');
2
2
  const { Command } = require('@contentstack/cli-command');
3
3
  const command = new Command();
4
4
 
5
- const { formatHostname } = require('../util');
6
-
7
5
  async function getStack(data) {
8
6
  const tokenDetails = command.getToken(data.alias);
9
- const managementClient = await managementSDKClient({ host: formatHostname(data.host), branchName: data.branch })
10
- const stack = managementClient.stack({ api_key: tokenDetails.apiKey, management_token: tokenDetails.token })
7
+ const managementClient = await managementSDKClient({ host: data.host, branchName: data.branch });
8
+ const stack = managementClient.stack({ api_key: tokenDetails.apiKey, management_token: tokenDetails.token });
11
9
  stack.alias = data.alias;
12
10
  stack.host = data.host;
13
11
  return stack;
package/src/util/index.js CHANGED
@@ -31,10 +31,6 @@ function formatError(error) {
31
31
  return message;
32
32
  }
33
33
 
34
- function formatHostname(hostname) {
35
- return hostname.split('//').pop();
36
- }
37
-
38
34
  function setDelayForBulkPublish(_queue) {
39
35
  // empty block
40
36
  // queue.requestBatchSize = 1
@@ -62,7 +58,6 @@ function isEmpty(file) {
62
58
  module.exports = {
63
59
  prettyPrint,
64
60
  formatError,
65
- formatHostname,
66
61
  setDelayForBulkPublish,
67
62
  getNumberOfBulkPublishRequests,
68
63
  isEmpty,