@contentstack/cli-cm-branches 1.0.10 → 1.0.12
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 +1 -1
- package/lib/branch/merge-handler.js +55 -4
- package/lib/commands/cm/branches/merge.js +1 -1
- package/lib/utils/asset-folder-create-script.js +161 -0
- package/lib/utils/create-merge-scripts.js +53 -20
- package/lib/utils/entry-create-script.js +497 -58
- package/lib/utils/entry-create-update-script.js +571 -0
- package/lib/utils/entry-update-script.js +547 -103
- package/lib/utils/interactive.js +84 -1
- package/lib/utils/merge-helper.js +8 -8
- package/oclif.manifest.json +1 -1
- package/package.json +6 -6
package/lib/utils/interactive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.askBranchNameConfirmation = exports.selectCustomPreferences = exports.askMergeComment = exports.askExportMergeSummaryPath = exports.selectMergeExecution = exports.selectMergeStrategySubOptions = exports.selectMergeStrategy = exports.inquireRequireFieldValidation = exports.askConfirmation = exports.askBranchUid = exports.askSourceBranch = exports.askBaseBranch = exports.askStackAPIKey = exports.askCompareBranch = exports.selectModule = void 0;
|
|
3
|
+
exports.selectContentMergeCustomPreferences = exports.askBranchNameConfirmation = exports.selectCustomPreferences = exports.askMergeComment = exports.askExportMergeSummaryPath = exports.selectContentMergePreference = exports.selectMergeExecution = exports.selectMergeStrategySubOptions = exports.selectMergeStrategy = exports.inquireRequireFieldValidation = exports.askConfirmation = exports.askBranchUid = exports.askSourceBranch = exports.askBaseBranch = exports.askStackAPIKey = exports.askCompareBranch = exports.selectModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const isEmpty_1 = tslib_1.__importDefault(require("lodash/isEmpty"));
|
|
6
6
|
const startCase_1 = tslib_1.__importDefault(require("lodash/startCase"));
|
|
@@ -133,6 +133,8 @@ async function selectMergeExecution() {
|
|
|
133
133
|
choices: [
|
|
134
134
|
{ name: 'Execute Merge', value: 'both' },
|
|
135
135
|
{ name: 'Export Merge Summary', value: 'export' },
|
|
136
|
+
{ name: 'Execute Merge and Generate Content Migration Scripts', value: 'merge_n_scripts' },
|
|
137
|
+
{ name: 'Export Summary and Generate Content Migration Scripts', value: 'summary_n_scripts' },
|
|
136
138
|
{ name: 'Go Back', value: 'previous' },
|
|
137
139
|
{ name: 'Start Over', value: 'restart' },
|
|
138
140
|
],
|
|
@@ -146,6 +148,27 @@ async function selectMergeExecution() {
|
|
|
146
148
|
return strategy;
|
|
147
149
|
}
|
|
148
150
|
exports.selectMergeExecution = selectMergeExecution;
|
|
151
|
+
async function selectContentMergePreference() {
|
|
152
|
+
const strategy = await cli_utilities_1.cliux
|
|
153
|
+
.inquire({
|
|
154
|
+
type: 'list',
|
|
155
|
+
name: 'module',
|
|
156
|
+
choices: [
|
|
157
|
+
{ name: 'Both existing and new', value: 'existing_new' },
|
|
158
|
+
{ name: 'New only', value: 'new' },
|
|
159
|
+
{ name: 'Existing only', value: 'existing' },
|
|
160
|
+
{ name: 'Ask for preference', value: 'ask_preference' },
|
|
161
|
+
],
|
|
162
|
+
message: 'What content entries do you want to migrate?',
|
|
163
|
+
})
|
|
164
|
+
.then((name) => name)
|
|
165
|
+
.catch((err) => {
|
|
166
|
+
cli_utilities_1.cliux.error('Failed to collect the preference');
|
|
167
|
+
process.exit(1);
|
|
168
|
+
});
|
|
169
|
+
return strategy;
|
|
170
|
+
}
|
|
171
|
+
exports.selectContentMergePreference = selectContentMergePreference;
|
|
149
172
|
async function askExportMergeSummaryPath() {
|
|
150
173
|
return await cli_utilities_1.cliux.inquire({
|
|
151
174
|
type: 'input',
|
|
@@ -242,3 +265,63 @@ async function askBranchNameConfirmation() {
|
|
|
242
265
|
});
|
|
243
266
|
}
|
|
244
267
|
exports.askBranchNameConfirmation = askBranchNameConfirmation;
|
|
268
|
+
async function selectContentMergeCustomPreferences(payload) {
|
|
269
|
+
var _a, _b;
|
|
270
|
+
// parse rows
|
|
271
|
+
const tableRows = [];
|
|
272
|
+
if (((_a = payload.modified) === null || _a === void 0 ? void 0 : _a.length) || ((_b = payload.added) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
273
|
+
(0, forEach_1.default)(payload.added, (item) => {
|
|
274
|
+
const row = {};
|
|
275
|
+
row.name = `+ ${item.title}`;
|
|
276
|
+
row.status = 'added';
|
|
277
|
+
row.value = item;
|
|
278
|
+
tableRows.push(row);
|
|
279
|
+
});
|
|
280
|
+
(0, forEach_1.default)(payload.modified, (item) => {
|
|
281
|
+
const row = {};
|
|
282
|
+
row.name = `± ${item.title}`;
|
|
283
|
+
row.status = 'modified';
|
|
284
|
+
row.value = item;
|
|
285
|
+
tableRows.push(row);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const selectedStrategies = await cli_utilities_1.cliux.inquire({
|
|
292
|
+
type: 'table',
|
|
293
|
+
message: `Select the Content Entry changes for merge`,
|
|
294
|
+
name: 'mergeContentEntriesPreferences',
|
|
295
|
+
selectAll: true,
|
|
296
|
+
pageSize: 10,
|
|
297
|
+
columns: [
|
|
298
|
+
{
|
|
299
|
+
name: 'Merge New Only',
|
|
300
|
+
value: 'merge_new',
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: 'Merge Modified Only',
|
|
304
|
+
value: 'merge_existing',
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: 'Merge Both',
|
|
308
|
+
value: 'merge_existing_new',
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: 'Ignore',
|
|
312
|
+
value: 'ignore',
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
rows: tableRows,
|
|
316
|
+
});
|
|
317
|
+
let updatedArray = [];
|
|
318
|
+
(0, forEach_1.default)(selectedStrategies, (strategy, index) => {
|
|
319
|
+
const selectedItem = tableRows[index];
|
|
320
|
+
if (strategy && selectedItem) {
|
|
321
|
+
selectedItem.value.entry_merge_strategy = strategy;
|
|
322
|
+
updatedArray.push(selectedItem);
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
return updatedArray; // selected items
|
|
326
|
+
}
|
|
327
|
+
exports.selectContentMergeCustomPreferences = selectContentMergeCustomPreferences;
|
|
@@ -54,14 +54,6 @@ const setupMergeInputs = async (mergeFlags) => {
|
|
|
54
54
|
if (!mergeFlags['stack-api-key']) {
|
|
55
55
|
mergeFlags['stack-api-key'] = await (0, _1.askStackAPIKey)();
|
|
56
56
|
}
|
|
57
|
-
if (!mergeFlags['compare-branch']) {
|
|
58
|
-
if (!compare_branch) {
|
|
59
|
-
mergeFlags['compare-branch'] = await (0, _1.askCompareBranch)();
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
mergeFlags['compare-branch'] = compare_branch;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
57
|
if (!mergeFlags['base-branch']) {
|
|
66
58
|
if (!base_branch) {
|
|
67
59
|
mergeFlags['base-branch'] = (0, _1.getbranchConfig)(mergeFlags['stack-api-key']);
|
|
@@ -76,6 +68,14 @@ const setupMergeInputs = async (mergeFlags) => {
|
|
|
76
68
|
mergeFlags['base-branch'] = base_branch;
|
|
77
69
|
}
|
|
78
70
|
}
|
|
71
|
+
if (!mergeFlags['compare-branch']) {
|
|
72
|
+
if (!compare_branch) {
|
|
73
|
+
mergeFlags['compare-branch'] = await (0, _1.askCompareBranch)();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
mergeFlags['compare-branch'] = compare_branch;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
79
|
return mergeFlags;
|
|
80
80
|
};
|
|
81
81
|
exports.setupMergeInputs = setupMergeInputs;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-cm-branches",
|
|
3
3
|
"description": "Contentstack CLI plugin to do branches operations",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@contentstack/cli-command": "
|
|
9
|
-
"@contentstack/cli-utilities": "
|
|
8
|
+
"@contentstack/cli-command": "~1.2.12",
|
|
9
|
+
"@contentstack/cli-utilities": "~1.5.2",
|
|
10
10
|
"@oclif/command": "^1.8.16",
|
|
11
11
|
"@oclif/config": "^1.18.3",
|
|
12
12
|
"@oclif/core": "^2.9.3",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"winston": "^3.7.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@contentstack/cli-auth": "
|
|
31
|
-
"@contentstack/cli-config": "
|
|
32
|
-
"@contentstack/cli-dev-dependencies": "
|
|
30
|
+
"@contentstack/cli-auth": "~1.3.13",
|
|
31
|
+
"@contentstack/cli-config": "~1.4.11",
|
|
32
|
+
"@contentstack/cli-dev-dependencies": "~1.2.3",
|
|
33
33
|
"@oclif/plugin-help": "^5.1.19",
|
|
34
34
|
"@oclif/test": "^1.2.6",
|
|
35
35
|
"@types/flat": "^5.0.2",
|