@contentstack/cli-cm-branches 1.0.22 → 1.0.24
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/commands/cm/branches/merge.js +22 -16
- package/lib/utils/asset-folder-create-script.js +2 -2
- package/lib/utils/entry-create-script.js +10 -34
- package/lib/utils/entry-create-update-script.js +1 -20
- package/lib/utils/entry-update-script.js +1 -20
- package/lib/utils/index.js +21 -1
- package/oclif.manifest.json +1 -1
- package/package.json +5 -5
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.0.
|
|
40
|
+
@contentstack/cli-cm-branches/1.0.24 linux-x64 node-v18.19.1
|
|
41
41
|
$ csdx --help [COMMAND]
|
|
42
42
|
USAGE
|
|
43
43
|
$ csdx COMMAND
|
|
@@ -21,22 +21,28 @@ class BranchMergeCommand extends cli_command_1.Command {
|
|
|
21
21
|
host: this.cmaHost,
|
|
22
22
|
format: 'compact-text',
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
const isCompareDataValid = (0, utils_1.validateCompareData)(branchCompareData);
|
|
25
|
+
if (isCompareDataValid) {
|
|
26
|
+
await new branch_1.MergeHandler({
|
|
27
|
+
stackAPIKey: branchMergeFlags['stack-api-key'],
|
|
28
|
+
compareBranch: branchMergeFlags['compare-branch'],
|
|
29
|
+
strategy: branchMergeFlags.strategy,
|
|
30
|
+
strategySubOption: branchMergeFlags['strategy-sub-options'],
|
|
31
|
+
baseBranch: branchMergeFlags['base-branch'],
|
|
32
|
+
branchCompareData: branchCompareData,
|
|
33
|
+
mergeComment: branchMergeFlags.comment,
|
|
34
|
+
executeOption: branchMergeFlags['merge-action'],
|
|
35
|
+
noRevert: branchMergeFlags['no-revert'],
|
|
36
|
+
format: 'compact-text',
|
|
37
|
+
exportSummaryPath: branchMergeFlags['export-summary-path'],
|
|
38
|
+
mergeSummary: branchMergeFlags.mergeSummary,
|
|
39
|
+
host: this.cmaHost,
|
|
40
|
+
enableEntryExp: false,
|
|
41
|
+
}).start();
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
cli_utilities_1.cliux.print("No changes found to merge.");
|
|
45
|
+
}
|
|
40
46
|
}
|
|
41
47
|
catch (error) {
|
|
42
48
|
console.log('Error in Merge operations', error);
|
|
@@ -117,9 +117,9 @@ function assetFolderCreateScript(contentType) {
|
|
|
117
117
|
|
|
118
118
|
const createAssetTask = () => {
|
|
119
119
|
return {
|
|
120
|
-
title: '
|
|
120
|
+
title: 'Check and create asset folder in base branch',
|
|
121
121
|
successTitle: 'Assets folder Created Successfully',
|
|
122
|
-
failedTitle: 'Failed to create assets folder',
|
|
122
|
+
failedTitle: 'Failed to create assets folder in base branch',
|
|
123
123
|
task: async () => {
|
|
124
124
|
try {
|
|
125
125
|
const baseAssetsFolderCount = await getAssetCount(branch, true);
|
|
@@ -12,7 +12,6 @@ function entryCreateScript(contentType) {
|
|
|
12
12
|
const omit = require('lodash/omit');
|
|
13
13
|
const compact = require('lodash/compact')
|
|
14
14
|
const isPlainObject = require('lodash/isPlainObject');
|
|
15
|
-
const {cliux, LoggerService} = require('@contentstack/cli-utilities')
|
|
16
15
|
module.exports = async ({ migration, stackSDKInstance, managementAPIClient, config, branch, apiKey }) => {
|
|
17
16
|
const keysToRemove = [
|
|
18
17
|
'content_type_uid',
|
|
@@ -44,7 +43,6 @@ function entryCreateScript(contentType) {
|
|
|
44
43
|
let assetRefPath = {};
|
|
45
44
|
let downloadedAssets = [];
|
|
46
45
|
let parent=[];
|
|
47
|
-
let logger;
|
|
48
46
|
|
|
49
47
|
function getValueByPath(obj, path) {
|
|
50
48
|
return path.split('[').reduce((o, key) => o && o[key.replace(/\]$/, '')], obj);
|
|
@@ -473,10 +471,6 @@ function entryCreateScript(contentType) {
|
|
|
473
471
|
successTitle: 'Entries Created Successfully',
|
|
474
472
|
failedTitle: 'Failed to create entries',
|
|
475
473
|
task: async () => {
|
|
476
|
-
//logger file
|
|
477
|
-
if(!fs.existsSync(path.join(filePath, 'entry-migration'))){
|
|
478
|
-
logger = new LoggerService(filePath, 'entry-migration');
|
|
479
|
-
}
|
|
480
474
|
|
|
481
475
|
const compareBranchEntries = await managementAPIClient
|
|
482
476
|
.stack({ api_key: stackSDKInstance.api_key, branch_uid: compareBranch })
|
|
@@ -523,17 +517,7 @@ function entryCreateScript(contentType) {
|
|
|
523
517
|
|
|
524
518
|
async function updateEntry(entry, entryDetails) {
|
|
525
519
|
Object.assign(entry, { ...entryDetails });
|
|
526
|
-
await entry.update()
|
|
527
|
-
let errorMsg = 'Entry update failed for uid: ' + entry?.uid + ', title: ' + entry?.title + '. ';
|
|
528
|
-
if(err?.errors?.title){
|
|
529
|
-
errorMsg += 'title'+ err?.errors?.title;
|
|
530
|
-
}else if(err?.errors?.entry){
|
|
531
|
-
errorMsg += err?.errors?.entry;
|
|
532
|
-
}else{
|
|
533
|
-
errorMsg += (err?.entry?.errorMessage || err?.errorMessage || err?.message) ?? 'Something went wrong!';
|
|
534
|
-
}
|
|
535
|
-
logger.error(errorMsg)
|
|
536
|
-
});
|
|
520
|
+
await entry.update()
|
|
537
521
|
}
|
|
538
522
|
|
|
539
523
|
async function updateReferences(entryDetails, baseEntry, references) {
|
|
@@ -561,29 +545,21 @@ function entryCreateScript(contentType) {
|
|
|
561
545
|
}
|
|
562
546
|
|
|
563
547
|
try {
|
|
564
|
-
compareFilteredProperties.length !== 0
|
|
565
|
-
compareFilteredProperties.
|
|
566
|
-
|
|
548
|
+
if (compareFilteredProperties.length !== 0) {
|
|
549
|
+
for (let i = 0; i < compareFilteredProperties.length; i++) {
|
|
550
|
+
let entryDetails = compareFilteredProperties[i];
|
|
551
|
+
if (entryDetails !== undefined) {
|
|
567
552
|
entryDetails = updateAssetDetailsInEntries(entryDetails);
|
|
568
|
-
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails })
|
|
569
|
-
|
|
570
|
-
if(err?.errors?.title){
|
|
571
|
-
errorMsg += err?.errors?.title;
|
|
572
|
-
}else if(err?.errors?.entry){
|
|
573
|
-
errorMsg += err?.errors?.entry;
|
|
574
|
-
}else{
|
|
575
|
-
errorMsg += (err?.entry?.errorMessage || err?.errorMessage || err?.message) ?? 'Something went wrong!';
|
|
576
|
-
}
|
|
577
|
-
logger.error(errorMsg)
|
|
578
|
-
});
|
|
579
|
-
if(createdEntry){
|
|
553
|
+
let createdEntry = await stackSDKInstance.contentType('${contentType}').entry().create({ entry: entryDetails })
|
|
554
|
+
if (createdEntry) {
|
|
580
555
|
if (flag.references) {
|
|
581
556
|
await updateReferences(entryDetails, createdEntry, references);
|
|
582
557
|
}
|
|
583
|
-
await updateEntry(createdEntry, entryDetails)
|
|
558
|
+
await updateEntry(createdEntry, entryDetails)
|
|
584
559
|
}
|
|
585
560
|
}
|
|
586
|
-
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
587
563
|
} catch (error) {
|
|
588
564
|
throw error;
|
|
589
565
|
}
|
|
@@ -12,7 +12,6 @@ function entryCreateUpdateScript(contentType) {
|
|
|
12
12
|
const omit = require('lodash/omit');
|
|
13
13
|
const compact = require('lodash/compact')
|
|
14
14
|
const isPlainObject = require('lodash/isPlainObject');
|
|
15
|
-
const {cliux, LoggerService} = require('@contentstack/cli-utilities')
|
|
16
15
|
module.exports = async ({ migration, stackSDKInstance, managementAPIClient, config, branch, apiKey }) => {
|
|
17
16
|
const keysToRemove = [
|
|
18
17
|
'content_type_uid',
|
|
@@ -45,7 +44,6 @@ function entryCreateUpdateScript(contentType) {
|
|
|
45
44
|
let assetUrlMapper = {};
|
|
46
45
|
let assetRefPath = {};
|
|
47
46
|
let parent=[];
|
|
48
|
-
let logger;
|
|
49
47
|
|
|
50
48
|
function converter(data) {
|
|
51
49
|
let arr = [];
|
|
@@ -488,10 +486,6 @@ function entryCreateUpdateScript(contentType) {
|
|
|
488
486
|
successMessage: 'Entries Updated Successfully',
|
|
489
487
|
failedMessage: 'Failed to update entries',
|
|
490
488
|
task: async () => {
|
|
491
|
-
//logger file
|
|
492
|
-
if(!fs.existsSync(path.join(filePath, 'entry-migration'))){
|
|
493
|
-
logger = new LoggerService(filePath, 'entry-migration');
|
|
494
|
-
}
|
|
495
489
|
let compareBranchEntries = await managementAPIClient
|
|
496
490
|
.stack({ api_key: stackSDKInstance.api_key, branch_uid: compareBranch })
|
|
497
491
|
.contentType('${contentType}')
|
|
@@ -542,17 +536,7 @@ function entryCreateUpdateScript(contentType) {
|
|
|
542
536
|
async function updateEntry(entry, entryDetails) {
|
|
543
537
|
if (entry) {
|
|
544
538
|
Object.assign(entry, { ...entryDetails });
|
|
545
|
-
await entry.update()
|
|
546
|
-
let errorMsg = 'Entry update failed for uid: ' + entry?.uid + ', title: ' + entry?.title + '.';
|
|
547
|
-
if(err?.errors?.title){
|
|
548
|
-
errorMsg += err?.errors?.title;
|
|
549
|
-
}else if(err?.errors?.entry){
|
|
550
|
-
errorMsg += err?.errors?.entry;
|
|
551
|
-
}else{
|
|
552
|
-
errorMsg += (err?.entry?.errorMessage || err?.errorMessage || err?.message) ?? 'Something went wrong!';
|
|
553
|
-
}
|
|
554
|
-
logger.error(errorMsg)
|
|
555
|
-
});
|
|
539
|
+
await entry.update();
|
|
556
540
|
}
|
|
557
541
|
}
|
|
558
542
|
|
|
@@ -625,9 +609,6 @@ function entryCreateUpdateScript(contentType) {
|
|
|
625
609
|
.contentType('${contentType}')
|
|
626
610
|
.entry()
|
|
627
611
|
.create({ entry: entryDetails })
|
|
628
|
-
.catch(err => {
|
|
629
|
-
(err?.errorMessage || err?.message) ? err?.errorMessage || err?.message : 'Something went wrong!'
|
|
630
|
-
})
|
|
631
612
|
|
|
632
613
|
if(createdEntry){
|
|
633
614
|
if (flag.references) {
|
|
@@ -12,7 +12,6 @@ function entryUpdateScript(contentType) {
|
|
|
12
12
|
const omit = require('lodash/omit');
|
|
13
13
|
const compact = require('lodash/compact')
|
|
14
14
|
const isPlainObject = require('lodash/isPlainObject');
|
|
15
|
-
const {cliux, LoggerService} = require('@contentstack/cli-utilities')
|
|
16
15
|
module.exports = async ({ migration, stackSDKInstance, managementAPIClient, config, branch, apiKey }) => {
|
|
17
16
|
const keysToRemove = [
|
|
18
17
|
'content_type_uid',
|
|
@@ -45,7 +44,6 @@ function entryUpdateScript(contentType) {
|
|
|
45
44
|
let assetUrlMapper = {};
|
|
46
45
|
let assetRefPath = {};
|
|
47
46
|
let parent=[];
|
|
48
|
-
let logger;
|
|
49
47
|
|
|
50
48
|
function converter(data) {
|
|
51
49
|
let arr = [];
|
|
@@ -487,10 +485,6 @@ function entryUpdateScript(contentType) {
|
|
|
487
485
|
successMessage: 'Entries Updated Successfully',
|
|
488
486
|
failedMessage: 'Failed to update entries',
|
|
489
487
|
task: async () => {
|
|
490
|
-
//logger file
|
|
491
|
-
if(!fs.existsSync(path.join(filePath, 'entry-migration'))){
|
|
492
|
-
logger = new LoggerService(filePath, 'entry-migration');
|
|
493
|
-
}
|
|
494
488
|
|
|
495
489
|
let compareBranchEntries = await managementAPIClient
|
|
496
490
|
.stack({ api_key: stackSDKInstance.api_key, branch_uid: compareBranch })
|
|
@@ -541,17 +535,7 @@ function entryUpdateScript(contentType) {
|
|
|
541
535
|
|
|
542
536
|
async function updateEntry(entry, entryDetails) {
|
|
543
537
|
Object.assign(entry, { ...entryDetails });
|
|
544
|
-
await entry.update()
|
|
545
|
-
let errorMsg = 'Entry update failed for uid: ' + entry?.uid + ', title: ' + entry?.title + '.';
|
|
546
|
-
if(err?.errors?.title){
|
|
547
|
-
errorMsg += err?.errors?.title;
|
|
548
|
-
}else if(err?.errors?.entry){
|
|
549
|
-
errorMsg += err?.errors?.entry;
|
|
550
|
-
}else{
|
|
551
|
-
errorMsg += (err?.entry?.errorMessage || err?.errorMessage || err?.message) ?? 'Something went wrong!';
|
|
552
|
-
}
|
|
553
|
-
logger.error(errorMsg)
|
|
554
|
-
});
|
|
538
|
+
await entry.update();
|
|
555
539
|
}
|
|
556
540
|
|
|
557
541
|
async function updateReferences(entryDetails, baseEntry, references) {
|
|
@@ -622,9 +606,6 @@ function entryUpdateScript(contentType) {
|
|
|
622
606
|
.contentType('${contentType}')
|
|
623
607
|
.entry()
|
|
624
608
|
.create({ entry: entryDetails })
|
|
625
|
-
.catch(err => {
|
|
626
|
-
(err?.errorMessage || err?.message) ? err?.errorMessage || err?.message : 'Something went wrong!'
|
|
627
|
-
})
|
|
628
609
|
|
|
629
610
|
if(createdEntry){
|
|
630
611
|
if (flag.references) {
|
package/lib/utils/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deleteBranchUtility = exports.branchDiffUtility = exports.interactive = exports.handleErrorMsg = exports.executeMergeRequest = exports.getMergeQueueStatus = exports.readFile = exports.writeFile = exports.refreshbranchConfig = exports.getbranchConfig = exports.getbranchesList = void 0;
|
|
3
|
+
exports.deleteBranchUtility = exports.branchDiffUtility = exports.interactive = exports.validateCompareData = exports.handleErrorMsg = exports.executeMergeRequest = exports.getMergeQueueStatus = exports.readFile = exports.writeFile = exports.refreshbranchConfig = exports.getbranchConfig = exports.getbranchesList = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/**
|
|
6
6
|
* Command specific utilities can be written here
|
|
7
7
|
*/
|
|
8
8
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
9
9
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
|
+
const forEach_1 = tslib_1.__importDefault(require("lodash/forEach"));
|
|
10
11
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
11
12
|
const getbranchesList = (branchResult, baseBranch) => {
|
|
12
13
|
const branches = [];
|
|
@@ -106,6 +107,25 @@ function handleErrorMsg(err) {
|
|
|
106
107
|
process.exit(1);
|
|
107
108
|
}
|
|
108
109
|
exports.handleErrorMsg = handleErrorMsg;
|
|
110
|
+
function validateCompareData(branchCompareData) {
|
|
111
|
+
let validCompareData = false;
|
|
112
|
+
if (branchCompareData.content_types) {
|
|
113
|
+
(0, forEach_1.default)(branchCompareData.content_types, (value, key) => {
|
|
114
|
+
if ((value === null || value === void 0 ? void 0 : value.length) > 0) {
|
|
115
|
+
validCompareData = true;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (branchCompareData.global_fields) {
|
|
120
|
+
(0, forEach_1.default)(branchCompareData.global_fields, (value, key) => {
|
|
121
|
+
if ((value === null || value === void 0 ? void 0 : value.length) > 0) {
|
|
122
|
+
validCompareData = true;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return validCompareData;
|
|
127
|
+
}
|
|
128
|
+
exports.validateCompareData = validateCompareData;
|
|
109
129
|
tslib_1.__exportStar(require("./interactive"), exports);
|
|
110
130
|
tslib_1.__exportStar(require("./merge-helper"), exports);
|
|
111
131
|
tslib_1.__exportStar(require("./create-merge-scripts"), exports);
|
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.24",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@contentstack/cli-command": "~1.2.16",
|
|
9
|
-
"@contentstack/cli-utilities": "~1.
|
|
9
|
+
"@contentstack/cli-utilities": "~1.6.0",
|
|
10
10
|
"@oclif/core": "^2.9.3",
|
|
11
11
|
"async": "^3.2.4",
|
|
12
12
|
"big-json": "^3.2.0",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@contentstack/cli-auth": "~1.3.17",
|
|
29
|
-
"@contentstack/cli-config": "~1.6.
|
|
29
|
+
"@contentstack/cli-config": "~1.6.1",
|
|
30
30
|
"@contentstack/cli-dev-dependencies": "~1.2.4",
|
|
31
31
|
"@oclif/plugin-help": "^5.1.19",
|
|
32
|
-
"@oclif/test": "^
|
|
32
|
+
"@oclif/test": "^2.5.6",
|
|
33
33
|
"@types/flat": "^5.0.2",
|
|
34
34
|
"assert": "^2.0.0",
|
|
35
35
|
"chai": "^4.2.0",
|
|
@@ -95,4 +95,4 @@
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
"repository": "https://github.com/contentstack/cli"
|
|
98
|
-
}
|
|
98
|
+
}
|