@contentstack/cli-cm-bulk-publish 1.1.0 → 1.3.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) 2022 Contentstack
3
+ Copyright (c) 2023 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.1.0 linux-x64 node-v16.19.0
21
+ @contentstack/cli-cm-bulk-publish/1.3.0 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.1.0",
2
+ "version": "1.3.0",
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,31 +1,33 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-bulk-publish",
3
3
  "description": "Contentstack CLI plugin for bulk publish actions",
4
- "version": "1.1.0",
4
+ "version": "1.3.0",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "^1.1.0",
9
- "@contentstack/cli-utilities": "^1.1.0",
8
+ "@contentstack/cli-command": "^1.2.1",
9
+ "@contentstack/cli-utilities": "^1.2.1",
10
10
  "@contentstack/management": "^1.6.1",
11
11
  "bluebird": "^3.7.2",
12
+ "chalk": "^4.1.2",
13
+ "inquirer": "8.2.4",
12
14
  "lodash": "^4.17.15",
13
15
  "nock": "^13.0.2",
14
- "winston": "^3.7.2",
15
- "inquirer": "8.2.4"
16
+ "winston": "^3.7.2"
16
17
  },
17
18
  "devDependencies": {
18
- "oclif": "^3.1.2",
19
19
  "@oclif/test": "^1.2.6",
20
20
  "chai": "^4.2.0",
21
21
  "eslint": "^8.18.0",
22
- "eslint-config-oclif": "^3.1.0",
22
+ "eslint-config-oclif": "^4.0.0",
23
23
  "globby": "^10.0.2",
24
24
  "mocha": "^10.0.0",
25
- "nyc": "^15.1.0"
25
+ "nyc": "^15.1.0",
26
+ "tslib": "^1.13.0",
27
+ "oclif": "^3.1.2"
26
28
  },
27
29
  "engines": {
28
- "node": ">=8.0.0"
30
+ "node": ">=14.0.0"
29
31
  },
30
32
  "files": [
31
33
  "/npm-shrinkwrap.json",
@@ -61,6 +63,30 @@
61
63
  "cm:bulk-publish:unpublish": "csdx cm:stacks:unpublish or cm:entries:unpublish or cm:assets:unpublish",
62
64
  "cm:bulk-publish:cross-publish": "csdx cm:entries:publish or csdx cm:assets:publish with source-env flag",
63
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"
64
90
  }
65
91
  },
66
92
  "repository": "https://github.com/contentstack/cli",
@@ -69,6 +95,7 @@
69
95
  "prepack": "oclif manifest && oclif readme",
70
96
  "test": "nyc mocha --forbid-only \"test/**/*.test.js\"",
71
97
  "posttest": "eslint .",
72
- "version": "oclif readme && git add README.md"
98
+ "version": "oclif readme && git add README.md",
99
+ "clean": "rm -rf ./node_modules tsconfig.build.tsbuildinfo"
73
100
  }
74
101
  }
@@ -1,11 +1,11 @@
1
- const { Command, flags } = require('@contentstack/cli-command');
1
+ const { Command } = require('@contentstack/cli-command');
2
+ const { printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
2
3
  const { start: startPublish } = require('../../../producer/publish-assets');
3
4
  const { start: startCrossPublish } = require('../../../producer/cross-publish');
4
5
  const store = require('../../../util/store.js');
5
6
  const { cliux } = require('@contentstack/cli-utilities');
6
7
  const { prettyPrint, formatError } = require('../../../util');
7
8
  const { getStack } = require('../../../util/client.js');
8
- const { printFlagDeprecation } = require('@contentstack/cli-utilities');
9
9
  let config;
10
10
 
11
11
  class AssetsPublishCommand extends Command {
@@ -47,11 +47,11 @@ 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
- stack = getStack(config);
54
+ stack = await getStack(config);
55
55
  }
56
56
  if (await this.confirmFlags(updatedFlags)) {
57
57
  try {
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable node/no-extraneous-require */
3
- const { Command, flags } = require('@contentstack/cli-command');
4
- const { cliux } = require('@contentstack/cli-utilities');
3
+ const { Command } = require('@contentstack/cli-command');
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';
@@ -49,11 +49,11 @@ 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
- stack = getStack(config);
56
+ stack = await getStack(config);
57
57
  }
58
58
  if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) {
59
59
  this.error('Delivery Token is required for executing this command', { exit: 2 });
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable node/no-extraneous-require */
2
- const { Command, flags } = require('@contentstack/cli-command');
3
- const { cliux, printFlagDeprecation } = require('@contentstack/cli-utilities');
2
+ const { Command } = require('@contentstack/cli-command');
3
+ const { cliux, printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
4
4
  const { start } = require('../../../producer/cross-publish');
5
5
  const store = require('../../../util/store.js');
6
6
  const configKey = 'cross_env_publish';
@@ -40,11 +40,11 @@ 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
- stack = getStack(config);
47
+ stack = await getStack(config);
48
48
  }
49
49
 
50
50
  if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) {
@@ -1,4 +1,4 @@
1
- const { Command, flags } = require('@contentstack/cli-command');
1
+ const { Command } = require('@contentstack/cli-command');
2
2
 
3
3
  class HelloCommand extends Command {
4
4
  async run() {
@@ -1,4 +1,5 @@
1
- const { Command, flags } = require('@contentstack/cli-command');
1
+ const { Command } = require('@contentstack/cli-command');
2
+ const { printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
2
3
  const { start } = require('../../../producer/publish-edits');
3
4
  const store = require('../../../util/store.js');
4
5
  // eslint-disable-next-line node/no-extraneous-require
@@ -6,7 +7,6 @@ const { cliux } = require('@contentstack/cli-utilities');
6
7
  const configKey = 'publish_edits_on_env';
7
8
  const { prettyPrint, formatError } = require('../../../util');
8
9
  const { getStack } = require('../../../util/client.js');
9
- const { printFlagDeprecation } = require('@contentstack/cli-utilities');
10
10
  let config;
11
11
 
12
12
  class PublishModifiedCommand extends Command {
@@ -38,14 +38,18 @@ 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
- stack = getStack(config);
52
+ stack = await getStack(config);
49
53
  }
50
54
  if (await this.confirmFlags(updatedFlags)) {
51
55
  try {
@@ -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;
@@ -1,11 +1,11 @@
1
- const { Command, flags } = require('@contentstack/cli-command');
1
+ const { Command } = require('@contentstack/cli-command');
2
2
  const { start } = require('../../../producer/nonlocalized-field-changes');
3
3
  const store = require('../../../util/store.js');
4
4
  const { cliux } = require('@contentstack/cli-utilities');
5
5
  const configKey = 'nonlocalized_field_changes';
6
6
  const { prettyPrint, formatError } = require('../../../util');
7
7
  const { getStack } = require('../../../util/client.js');
8
- const { printFlagDeprecation } = require('@contentstack/cli-utilities');
8
+ const { printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
9
9
  let config;
10
10
 
11
11
  class NonlocalizedFieldChangesCommand extends Command {
@@ -49,10 +49,11 @@ 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
- stack = getStack(config);
56
+ stack = await getStack(config);
56
57
  }
57
58
  if (await this.confirmFlags(updatedFlags)) {
58
59
  try {
@@ -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;
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
-
3
- const { Command, flags } = require('@contentstack/cli-command');
4
- const { printFlagDeprecation } = require('@contentstack/cli-utilities');
2
+ const { Command } = require('@contentstack/cli-command');
3
+ const { printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
5
4
  const { publishOnlyUnpublishedService } = require('../../../services/publish-only-unpublished');
6
5
 
7
6
  class PublishOnlyUnpublished extends Command {
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable node/no-extraneous-require */
3
- const { Command, flags } = require('@contentstack/cli-command');
3
+ const { Command } = require('@contentstack/cli-command');
4
+ const { printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
4
5
  const { start: startPublish } = require('../../../producer/publish-entries');
5
6
  const { start: startCrossPublish } = require('../../../producer/cross-publish');
6
7
  const store = require('../../../util/store.js');
@@ -9,7 +10,6 @@ const configKey = 'publish_entries';
9
10
  const configKeyCrossEnv = 'cross_env_publish';
10
11
  const { prettyPrint, formatError } = require('../../../util');
11
12
  const { getStack } = require('../../../util/client.js');
12
- const { printFlagDeprecation } = require('@contentstack/cli-utilities');
13
13
  let config;
14
14
 
15
15
  class PublishEntriesCommand extends Command {
@@ -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
- stack = getStack(config);
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
- const { Command, flags } = require('@contentstack/cli-command');
4
- const { cliux } = require('@contentstack/cli-utilities');
3
+ const { Command } = require('@contentstack/cli-command');
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,11 +51,11 @@ 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
- stack = getStack(config);
58
+ stack = await getStack(config);
59
59
  }
60
60
  if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) {
61
61
  this.error('Delivery Token is required for executing this command', { exit: 2 });
@@ -1,5 +1,5 @@
1
- const { Command, flags } = require('@contentstack/cli-command');
2
- const { printFlagDeprecation, cliux } = require('@contentstack/cli-utilities');
1
+ const { Command } = require('@contentstack/cli-command');
2
+ const { printFlagDeprecation, cliux, flags } = require('@contentstack/cli-utilities');
3
3
 
4
4
  const store = require('../../../util/store.js');
5
5
  const { getStack } = require('../../../util/client.js');
@@ -43,10 +43,11 @@ 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
- stack = getStack(config);
50
+ stack = await getStack(config);
50
51
  }
51
52
  if (await this.confirmFlags(updatedFlags)) {
52
53
  try {
@@ -1,6 +1,6 @@
1
1
  const fs = require('fs');
2
- const { Command, flags } = require('@contentstack/cli-command');
3
- const { cliux, printFlagDeprecation } = require('@contentstack/cli-utilities');
2
+ const { Command } = require('@contentstack/cli-command');
3
+ const { cliux, printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
4
4
 
5
5
  const { getLogsDirPath } = require('../../../util/logger.js');
6
6
 
@@ -1,7 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
- const { Command, flags } = require('@contentstack/cli-command');
4
- const { cliux } = require('@contentstack/cli-utilities');
3
+ const { Command } = require('@contentstack/cli-command');
4
+ const { cliux, flags } = require('@contentstack/cli-utilities');
5
5
 
6
6
  let config = require('../../../config/index.js');
7
7
 
@@ -1,5 +1,5 @@
1
- const { Command, flags } = require('@contentstack/cli-command');
2
- const { cliux, printFlagDeprecation } = require('@contentstack/cli-utilities');
1
+ const { Command } = require('@contentstack/cli-command');
2
+ const { cliux, printFlagDeprecation, flags } = require('@contentstack/cli-utilities');
3
3
 
4
4
  const store = require('../../../util/store.js');
5
5
  const { start } = require('../../../producer/revert');
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable no-console */
2
2
  /* eslint-disable node/no-extraneous-require */
3
- const { Command, flags } = require('@contentstack/cli-command');
3
+ const { Command } = require('@contentstack/cli-command');
4
+ const { printFlagDeprecation, cliux, flags } = require('@contentstack/cli-utilities');
4
5
  const { start } = require('../../../producer/unpublish');
5
6
  const store = require('../../../util/store.js');
6
7
  const configKey = 'Unpublish';
7
8
  const { prettyPrint, formatError } = require('../../../util');
8
9
  const { getStack } = require('../../../util/client.js');
9
- const { printFlagDeprecation, cliux } = require('@contentstack/cli-utilities');
10
10
  let config;
11
11
 
12
12
  class UnpublishCommand extends Command {
@@ -53,11 +53,11 @@ 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
- stack = getStack(config);
60
+ stack = await getStack(config);
61
61
  }
62
62
  if (!updatedFlags.deliveryToken && updatedFlags.deliveryToken.length === 0) {
63
63
  this.error('Delivery Token is required for executing this command', { exit: 2 });
@@ -178,7 +178,7 @@ async function revertUsingLogs(logFileName) {
178
178
 
179
179
  if (response.file.length > 0) {
180
180
  initializeLogger(revertLogFileName);
181
- const stack = getStack({
181
+ const stack = await getStack({
182
182
  apikey: response.file[0].message.api_key,
183
183
  alias: response.file[0].message.alias,
184
184
  host: response.file[0].message.host,
@@ -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,10 +39,11 @@ 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
- stack = getStack(config);
46
+ stack = await getStack(config);
46
47
  }
47
48
  if (await confirmFlags(updatedFlags)) {
48
49
  try {
@@ -1,22 +1,11 @@
1
- const contentstackSdk = require('@contentstack/management');
1
+ 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
- function getStack(data) {
5
+ async function getStack(data) {
8
6
  const tokenDetails = command.getToken(data.alias);
9
- const client = contentstackSdk.client({
10
- headers: {
11
- branch: data.branch,
12
- },
13
- host: formatHostname(data.host),
14
- // eslint-disable-next-line no-unused-vars
15
- logHandler: (_level) => {
16
- // empty block
17
- },
18
- });
19
- const stack = client.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 });
20
9
  stack.alias = data.alias;
21
10
  stack.host = data.host;
22
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,
@@ -4,9 +4,9 @@ const { getStack } = require('./client.js');
4
4
  module.exports = async (filename, queue, Type) => {
5
5
  const logs = await getAllLogs(filename);
6
6
  if (logs.file.length > 0) {
7
- logs.file.forEach((log) => {
7
+ logs.file.forEach(async (log) => {
8
8
  if (Type === 'bulk') {
9
- log.message.options.stack = getStack({ alias: log.message.alias, host: log.message.host });
9
+ log.message.options.stack = await getStack({ alias: log.message.alias, host: log.message.host });
10
10
  queue.Enqueue(log.message.options);
11
11
  }
12
12
  if (Type === 'publish') {
@@ -18,7 +18,7 @@ module.exports = async (filename, queue, Type) => {
18
18
  entryUid: log.message.options.entryUid,
19
19
  locale: log.message.options.locale,
20
20
  Type: 'entry',
21
- stack: getStack({ alias: log.message.alias, host: log.message.host }),
21
+ stack: await getStack({ alias: log.message.alias, host: log.message.host }),
22
22
  });
23
23
  } else {
24
24
  queue.assetQueue.Enqueue({
@@ -26,7 +26,7 @@ module.exports = async (filename, queue, Type) => {
26
26
  publish_details: log.message.options.publish_assets,
27
27
  environments: log.message.options.environments,
28
28
  Type: 'asset',
29
- stack: getStack({ alias: log.message.alias, host: log.message.host }),
29
+ stack: await getStack({ alias: log.message.alias, host: log.message.host }),
30
30
  });
31
31
  }
32
32
  }