Skip to content

Commit ffaa404

Browse files
Merge pull request #2126 from contentstack/staging
DX | 22-09-2025 | Release
2 parents c3a0e4a + 99ebda1 commit ffaa404

File tree

25 files changed

+3161
-2398
lines changed

25 files changed

+3161
-2398
lines changed

.talismanrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fileignoreconfig:
22
- filename: package-lock.json
3-
checksum: e99f717f726226d79c6d484b44fa3d8e758038fbaca671301377741e36802b6d
3+
checksum: b07cb236b78aa3149b89e2ed18851ee005db8ef735062f91e0e91b2adf013c12
44
- filename: pnpm-lock.yaml
5-
checksum: d26dfe4137bcd958a79beff8a2867fbbad531f81ef0c8c8a8786e8680b79b52e
5+
checksum: 577582ed82062ad359d8bc2bc0a309ab4d344a2a4122573d8cf77aeb481268f2
66
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
77
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
88
- filename: packages/contentstack-import-setup/test/config.json
@@ -86,5 +86,5 @@ fileignoreconfig:
8686
- filename: packages/contentstack-import-setup/src/utils/backup-handler.ts
8787
checksum: 7db02c6f2627400b28fc96d505bf074d477080a45ba13943709d4845b6ca0908
8888
- filename: packages/contentstack-import/src/utils/backup-handler.ts
89-
checksum: 4f7a8bea92ebffbc34a0979b3a63fef327562a899b773481d67a675140cfa4bf
89+
checksum: 0a9accdafce01837166223ed00cd801e2ebb39a4ef952231f67232859a5beea8
9090
version: "1.0"

package-lock.json

Lines changed: 807 additions & 775 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-branches/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
3737
$ csdx COMMAND
3838
running command...
3939
$ csdx (--version)
40-
@contentstack/cli-cm-branches/1.5.0 darwin-arm64 node-v23.11.0
40+
@contentstack/cli-cm-branches/1.6.0 darwin-arm64 node-v22.13.0
4141
$ csdx --help [COMMAND]
4242
USAGE
4343
$ csdx COMMAND
@@ -51,7 +51,7 @@ USAGE
5151
* [`csdx cm:branches`](#csdx-cmbranches)
5252
* [`csdx cm:branches:create`](#csdx-cmbranchescreate)
5353
* [`csdx cm:branches:delete [-uid <value>] [-k <value>]`](#csdx-cmbranchesdelete--uid-value--k-value)
54-
* [`csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>]`](#csdx-cmbranchesdiff---base-branch-value---compare-branch-value--k-value--module-value)
54+
* [`csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format <value>] [--csv-path <value>]`](#csdx-cmbranchesdiff---base-branch-value---compare-branch-value--k-value--module-value---format-value---csv-path-value)
5555
* [`csdx cm:branches:merge [-k <value>][--compare-branch <value>] [--no-revert] [--export-summary-path <value>] [--use-merge-summary <value>] [--comment <value>] [--base-branch <value>]`](#csdx-cmbranchesmerge--k-value--compare-branch-value---no-revert---export-summary-path-value---use-merge-summary-value---comment-value---base-branch-value)
5656

5757
## `csdx cm:branches`
@@ -136,18 +136,21 @@ EXAMPLES
136136

137137
_See code: [src/commands/cm/branches/delete.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/delete.ts)_
138138

139-
## `csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>]`
139+
## `csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format <value>] [--csv-path <value>]`
140140

141141
Differences between two branches
142142

143143
```
144144
USAGE
145-
$ csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>]
145+
$ csdx cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format
146+
<value>] [--csv-path <value>]
146147
147148
FLAGS
148149
-k, --stack-api-key=<value> [optional] Provide the stack API key to show the difference between branches.
149150
--base-branch=<value> [optional] Base branch (Target branch).
150151
--compare-branch=<value> [optional] Compare branch (Source branch).
152+
--csv-path=<value> [optional] Custom path for CSV output file. If not provided, will use the current
153+
working directory.
151154
--format=<option> [default: compact-text] [default: compact-text] [optional] Type of flags to show the
152155
difference between two branches. <options: compact-text, detailed-text>
153156
<options: compact-text|detailed-text>
@@ -181,6 +184,10 @@ EXAMPLES
181184
$ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types"
182185
183186
$ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "detailed-text"
187+
188+
$ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "compact-text"
189+
190+
$ csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "detailed-text" --csv-path "./reports/diff-report.csv"
184191
```
185192

186193
_See code: [src/commands/cm/branches/diff.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-export/src/commands/cm/branches/diff.ts)_

packages/contentstack-branches/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-branches",
33
"description": "Contentstack CLI plugin to do branches operations",
4-
"version": "1.5.2",
4+
"version": "1.6.0",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"dependencies": {

packages/contentstack-branches/src/branch/diff-handler.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import startCase from 'lodash/startCase';
22
import camelCase from 'lodash/camelCase';
33
import { cliux } from '@contentstack/cli-utilities';
44
import { getbranchConfig } from '../utils';
5-
import { BranchOptions, BranchDiffRes, BranchDiffPayload } from '../interfaces';
5+
import { BranchOptions, BranchDiffPayload } from '../interfaces';
66
import { askBaseBranch, askCompareBranch, askStackAPIKey, selectModule } from '../utils/interactive';
77
import {
88
fetchBranchesDiff,
@@ -14,6 +14,7 @@ import {
1414
printVerboseTextView,
1515
filterBranchDiffDataByModule,
1616
} from '../utils/branch-diff-utility';
17+
import { exportCSVReport } from '../utils/csv-utility';
1718

1819
export default class BranchDiffHandler {
1920
private options: BranchOptions;
@@ -55,6 +56,10 @@ export default class BranchDiffHandler {
5556
this.options.module = await selectModule();
5657
}
5758

59+
if (this.options.format === 'detailed-text' && !this.options.csvPath) {
60+
this.options.csvPath = process.cwd();
61+
}
62+
5863
if(baseBranch){
5964
cliux.print(`\nBase branch: ${baseBranch}`, { color: 'grey' });
6065
}
@@ -87,15 +92,15 @@ export default class BranchDiffHandler {
8792

8893
if(this.options.module === 'all'){
8994
for (let module in diffData) {
90-
const branchDiff = diffData[module];
95+
const branchDiff = diffData[module];
9196
payload.module = module;
9297
this.displaySummary(branchDiff, module);
9398
await this.displayBranchDiffTextAndVerbose(branchDiff, payload);
9499
}
95100
}else{
96-
const branchDiff = diffData[payload.module];
97-
this.displaySummary(branchDiff, this.options.module);
98-
await this.displayBranchDiffTextAndVerbose(branchDiff, payload);
101+
const branchDiff = diffData[payload.module];
102+
this.displaySummary(branchDiff, this.options.module);
103+
await this.displayBranchDiffTextAndVerbose(branchDiff, payload);
99104
}
100105
}
101106

@@ -126,6 +131,8 @@ export default class BranchDiffHandler {
126131
const verboseRes = await parseVerbose(branchDiffData, payload);
127132
cliux.loaderV2('', spinner);
128133
printVerboseTextView(verboseRes);
134+
135+
exportCSVReport(payload.module, verboseRes, this.options.csvPath);
129136
}
130137
}
131138
}

packages/contentstack-branches/src/commands/cm/branches/diff.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ export default class BranchDiffCommand extends Command {
2020
'csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --module "content-types"',
2121
'csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types"',
2222
'csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "detailed-text"',
23-
]
23+
'csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "compact-text"',
24+
'csdx cm:branches:diff --stack-api-key "bltxxxxxxxx" --base-branch "main" --compare-branch "develop" --module "content-types" --format "detailed-text" --csv-path "./reports/diff-report.csv"',
25+
];
2426

25-
static usage: string = 'cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>]';
27+
static usage: string =
28+
'cm:branches:diff [--base-branch <value>] [--compare-branch <value>] [-k <value>][--module <value>] [--format <value>] [--csv-path <value>]';
2629

2730
static flags = {
2831
'base-branch': flags.string({
@@ -43,9 +46,13 @@ export default class BranchDiffCommand extends Command {
4346
default: 'compact-text',
4447
multiple: false,
4548
options: ['compact-text', 'detailed-text'],
46-
description: '[default: compact-text] [optional] Type of flags to show the difference between two branches. <options: compact-text, detailed-text>',
49+
description:
50+
'[default: compact-text] [optional] Type of flags to show the difference between two branches. <options: compact-text, detailed-text>',
4751
}),
48-
};
52+
'csv-path': flags.string({
53+
description: '[optional] Custom path for CSV output file. If not provided, will use the current working directory.',
54+
}),
55+
};
4956

5057
static aliases: string[] = []; // Note: alternative usage if any
5158

@@ -58,7 +65,8 @@ export default class BranchDiffCommand extends Command {
5865
compareBranch: branchDiffFlags['compare-branch'],
5966
module: branchDiffFlags.module,
6067
format: branchDiffFlags.format,
61-
host: this.cmaHost
68+
csvPath: branchDiffFlags['csv-path'],
69+
host: this.cmaHost,
6270
};
6371
if (!isAuthenticated()) {
6472
const err = { errorMessage: 'You are not logged in. Please login with command $ csdx auth:login' };

packages/contentstack-branches/src/interfaces/index.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface BranchOptions {
66
baseBranch?: string;
77
authToken?: string;
88
host?: string;
9+
csvPath?: string;
910
}
1011

1112
export interface BranchDiffRes {
@@ -64,6 +65,46 @@ export interface ModifiedFieldsType {
6465
displayName: string;
6566
path: string;
6667
field: string;
68+
propertyChanges?: PropertyChange[];
69+
changeCount?: number;
70+
changeDetails?: string;
71+
oldValue?: any;
72+
newValue?: any;
73+
}
74+
75+
export interface PropertyChange {
76+
property: string;
77+
changeType: 'modified' | 'added' | 'deleted';
78+
oldValue?: any;
79+
newValue?: any;
80+
}
81+
82+
export interface CSVRow {
83+
srNo: number;
84+
contentTypeName: string;
85+
fieldName: string;
86+
fieldPath: string;
87+
operation: string;
88+
sourceBranchValue: string;
89+
targetBranchValue: string;
90+
}
91+
92+
export interface AddCSVRowParams {
93+
srNo: number;
94+
contentTypeName: string;
95+
fieldName: string;
96+
fieldType: string;
97+
sourceValue: string;
98+
targetValue: string;
99+
}
100+
101+
export const FIELD_TYPES = ['modified', 'added', 'deleted'] as const;
102+
103+
export const CSV_HEADER = 'Sr No,Content Type Name,Field Name,Field Path,Operation,Source Branch Value,Target Branch Value\n';
104+
105+
export interface ContentTypeItem {
106+
title?: string;
107+
uid?: string;
67108
}
68109

69110
export interface ModifiedFieldsInput {
@@ -81,6 +122,7 @@ export interface BranchDiffVerboseRes {
81122
modified?: BranchModifiedDetails[];
82123
added?: BranchDiffRes[];
83124
deleted?: BranchDiffRes[];
125+
csvData?: CSVRow[]; // Pre-processed CSV data
84126
}
85127

86128
export interface BranchDiffPayload {

0 commit comments

Comments
 (0)