@contentstack/cli-cm-branches 1.4.0 → 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/README.md CHANGED
@@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
37
37
  $ csdx COMMAND
38
38
  running command...
39
39
  $ csdx (--version)
40
- @contentstack/cli-cm-branches/1.4.0 linux-x64 node-v22.14.0
40
+ @contentstack/cli-cm-branches/1.4.1 linux-x64 node-v22.14.0
41
41
  $ csdx --help [COMMAND]
42
42
  USAGE
43
43
  $ csdx COMMAND
@@ -5,6 +5,7 @@ const os_1 = tslib_1.__importDefault(require("os"));
5
5
  const path_1 = tslib_1.__importDefault(require("path"));
6
6
  const forEach_1 = tslib_1.__importDefault(require("lodash/forEach"));
7
7
  const cli_utilities_1 = require("@contentstack/cli-utilities");
8
+ const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
9
  const utils_1 = require("../utils");
9
10
  class MergeHandler {
10
11
  constructor(options) {
@@ -83,6 +84,10 @@ class MergeHandler {
83
84
  deleted: [],
84
85
  };
85
86
  const selectedItems = await (0, utils_1.selectCustomPreferences)(module, this.branchCompareData[module]);
87
+ if (!selectedItems.length) {
88
+ cli_utilities_1.cliux.print(chalk_1.default.red('No items were selected'));
89
+ process.exit(1);
90
+ }
86
91
  (0, forEach_1.default)(selectedItems, (item) => {
87
92
  this.mergeSettings.mergeContent[module][item.status].push(item.value);
88
93
  this.mergeSettings.itemMergeStrategies.push(item.value);
@@ -115,7 +120,12 @@ class MergeHandler {
115
120
  else if (this.strategy === 'overwrite_with_compare') {
116
121
  this.mergeSettings.strategy = 'overwrite_with_compare';
117
122
  }
118
- await this.displayMergeSummary();
123
+ if (this.checkEmptySelection()) {
124
+ cli_utilities_1.cliux.print(chalk_1.default.red('No items selected'));
125
+ }
126
+ else {
127
+ await this.displayMergeSummary();
128
+ }
119
129
  if (!this.executeOption) {
120
130
  const executionResponse = await (0, utils_1.selectMergeExecution)();
121
131
  if (executionResponse === 'previous') {
@@ -135,6 +145,17 @@ class MergeHandler {
135
145
  }
136
146
  }
137
147
  }
148
+ checkEmptySelection() {
149
+ var _a, _b, _c, _d, _e, _f;
150
+ for (let module in this.branchCompareData) {
151
+ if (((_b = (_a = this.mergeSettings.mergeContent[module]) === null || _a === void 0 ? void 0 : _a.modified) === null || _b === void 0 ? void 0 : _b.length)
152
+ || ((_d = (_c = this.mergeSettings.mergeContent[module]) === null || _c === void 0 ? void 0 : _c.added) === null || _d === void 0 ? void 0 : _d.length)
153
+ || ((_f = (_e = this.mergeSettings.mergeContent[module]) === null || _e === void 0 ? void 0 : _e.deleted) === null || _f === void 0 ? void 0 : _f.length)) {
154
+ return false;
155
+ }
156
+ }
157
+ return true;
158
+ }
138
159
  displayMergeSummary() {
139
160
  if (this.mergeSettings.strategy !== 'ignore') {
140
161
  for (let module in this.branchCompareData) {
@@ -181,13 +181,19 @@ function printCompactTextView(branchTextRes) {
181
181
  if (((_a = branchTextRes.modified) === null || _a === void 0 ? void 0 : _a.length) || ((_b = branchTextRes.added) === null || _b === void 0 ? void 0 : _b.length) || ((_c = branchTextRes.deleted) === null || _c === void 0 ? void 0 : _c.length)) {
182
182
  cli_utilities_1.cliux.print(' ');
183
183
  (0, forEach_1.default)(branchTextRes.added, (diff) => {
184
- cli_utilities_1.cliux.print(chalk_1.default.green(`+ '${diff.title}' ${(0, startCase_1.default)((0, camelCase_1.default)(diff.type))}`));
184
+ if (diff.merge_strategy !== 'ignore') {
185
+ cli_utilities_1.cliux.print(chalk_1.default.green(`+ '${diff.title}' ${(0, startCase_1.default)((0, camelCase_1.default)(diff.type))}`));
186
+ }
185
187
  });
186
188
  (0, forEach_1.default)(branchTextRes.modified, (diff) => {
187
- cli_utilities_1.cliux.print(chalk_1.default.blue(`± '${diff.title}' ${(0, startCase_1.default)((0, camelCase_1.default)(diff.type))}`));
189
+ if (diff.merge_strategy !== 'ignore') {
190
+ cli_utilities_1.cliux.print(chalk_1.default.blue(`± '${diff.title}' ${(0, startCase_1.default)((0, camelCase_1.default)(diff.type))}`));
191
+ }
188
192
  });
189
193
  (0, forEach_1.default)(branchTextRes.deleted, (diff) => {
190
- cli_utilities_1.cliux.print(chalk_1.default.red(`- '${diff.title}' ${(0, startCase_1.default)((0, camelCase_1.default)(diff.type))}`));
194
+ if (diff.merge_strategy !== 'ignore') {
195
+ cli_utilities_1.cliux.print(chalk_1.default.red(`- '${diff.title}' ${(0, startCase_1.default)((0, camelCase_1.default)(diff.type))}`));
196
+ }
191
197
  });
192
198
  }
193
199
  }
@@ -355,5 +355,5 @@
355
355
  ]
356
356
  }
357
357
  },
358
- "version": "1.4.0"
358
+ "version": "1.4.1"
359
359
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-branches",
3
3
  "description": "Contentstack CLI plugin to do branches operations",
4
- "version": "1.4.0",
4
+ "version": "1.4.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {