@contentstack/cli-cm-branches 1.0.23 → 1.0.25

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.0.23 linux-x64 node-v18.19.1
40
+ @contentstack/cli-cm-branches/1.0.25 linux-x64 node-v18.20.2
41
41
  $ csdx --help [COMMAND]
42
42
  USAGE
43
43
  $ csdx COMMAND
@@ -117,9 +117,9 @@ function assetFolderCreateScript(contentType) {
117
117
 
118
118
  const createAssetTask = () => {
119
119
  return {
120
- title: 'Create Assets Folder',
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().catch(err => {
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.forEach(async (entryDetails) => {
566
- if(entryDetails !== undefined){
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 }).catch(err => {
569
- let errorMsg = 'Entry creation failed for contentType: ' + contentType + ', title: ' + entryDetails?.title + '. ';
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().catch(err => {
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().catch(err => {
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) {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.23",
2
+ "version": "1.0.25",
3
3
  "commands": {
4
4
  "cm:branches:create": {
5
5
  "id": "cm:branches:create",
@@ -14,6 +14,7 @@
14
14
  "pluginAlias": "@contentstack/cli-cm-branches",
15
15
  "pluginType": "core",
16
16
  "aliases": [],
17
+ "hiddenAliases": [],
17
18
  "examples": [
18
19
  "csdx cm:branches:create",
19
20
  "csdx cm:branches:create --source main -uid new_branch -k bltxxxxxxxx",
@@ -54,6 +55,7 @@
54
55
  "pluginAlias": "@contentstack/cli-cm-branches",
55
56
  "pluginType": "core",
56
57
  "aliases": [],
58
+ "hiddenAliases": [],
57
59
  "examples": [
58
60
  "csdx cm:branches:delete",
59
61
  "csdx cm:branches:delete --uid main -k bltxxxxxxxx",
@@ -93,6 +95,7 @@
93
95
  "pluginAlias": "@contentstack/cli-cm-branches",
94
96
  "pluginType": "core",
95
97
  "aliases": [],
98
+ "hiddenAliases": [],
96
99
  "examples": [
97
100
  "csdx cm:branches:diff",
98
101
  "csdx cm:branches:diff --stack-api-key \"bltxxxxxxxx\"",
@@ -161,6 +164,7 @@
161
164
  "pluginAlias": "@contentstack/cli-cm-branches",
162
165
  "pluginType": "core",
163
166
  "aliases": [],
167
+ "hiddenAliases": [],
164
168
  "examples": [
165
169
  "csdx cm:branches",
166
170
  "csdx cm:branches --verbose",
@@ -192,6 +196,7 @@
192
196
  "pluginAlias": "@contentstack/cli-cm-branches",
193
197
  "pluginType": "core",
194
198
  "aliases": [],
199
+ "hiddenAliases": [],
195
200
  "examples": [
196
201
  "csdx cm:branches:merge --stack-api-key bltxxxxxxxx --compare-branch feature-branch",
197
202
  "csdx cm:branches:merge --stack-api-key bltxxxxxxxx --comment \"merge comment\"",
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.23",
4
+ "version": "1.0.25",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {
8
- "@contentstack/cli-command": "~1.2.16",
9
- "@contentstack/cli-utilities": "~1.6.0",
8
+ "@contentstack/cli-command": "~1.2.18",
9
+ "@contentstack/cli-utilities": "~1.6.1",
10
10
  "@oclif/core": "^2.9.3",
11
11
  "async": "^3.2.4",
12
12
  "big-json": "^3.2.0",
@@ -25,8 +25,8 @@
25
25
  "winston": "^3.7.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@contentstack/cli-auth": "~1.3.17",
29
- "@contentstack/cli-config": "~1.6.1",
28
+ "@contentstack/cli-auth": "~1.3.18",
29
+ "@contentstack/cli-config": "~1.6.4",
30
30
  "@contentstack/cli-dev-dependencies": "~1.2.4",
31
31
  "@oclif/plugin-help": "^5.1.19",
32
32
  "@oclif/test": "^2.5.6",
@@ -95,4 +95,4 @@
95
95
  }
96
96
  },
97
97
  "repository": "https://github.com/contentstack/cli"
98
- }
98
+ }