Skip to content

Commit 4a0b162

Browse files
Merge pull request #2319 from contentstack/feat/DX-3820
feat: export and import config and code cleanup
2 parents e4ee650 + ba14f2e commit 4a0b162

File tree

104 files changed

+4527
-4768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4527
-4768
lines changed

.talismanrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fileignoreconfig:
22
- filename: pnpm-lock.yaml
3-
checksum: 9c2344275cd3f95e2ade032a77908dda40f412c6b77e4a493885aad67e10db12
3+
checksum: 41bc1d60449ab0682d9267172e54a5802c837869a1728b0560eea8052336c2fe
44
- filename: package-lock.json
5-
checksum: d523b3074e2441b4bca77213be6df16911e8ec699e51cc367520b8b56f0eaaf4
6-
version: "1.0"
5+
checksum: 0514f96f07a6c2c5be811d8973a0b1197943303cfcf224c0b01745342699f545
6+
version: "1.0"

package-lock.json

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

packages/contentstack-bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
1515
$ csdx COMMAND
1616
running command...
1717
$ csdx (--version)
18-
@contentstack/cli-cm-bootstrap/2.0.0-beta.3 darwin-arm64 node-v24.12.0
18+
@contentstack/cli-cm-bootstrap/2.0.0-beta.4 darwin-arm64 node-v24.12.0
1919
$ csdx --help [COMMAND]
2020
USAGE
2121
$ csdx COMMAND

packages/contentstack-bootstrap/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-cm-bootstrap",
33
"description": "Bootstrap contentstack apps",
4-
"version": "2.0.0-beta.3",
4+
"version": "2.0.0-beta.4",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {
@@ -16,7 +16,7 @@
1616
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
1717
},
1818
"dependencies": {
19-
"@contentstack/cli-cm-seed": "~2.0.0-beta.3",
19+
"@contentstack/cli-cm-seed": "~2.0.0-beta.4",
2020
"@contentstack/cli-command": "~1.7.0",
2121
"@contentstack/cli-utilities": "~1.15.0",
2222
"@oclif/core": "^4.3.0",
@@ -72,4 +72,4 @@
7272
}
7373
},
7474
"repository": "contentstack/cli"
75-
}
75+
}

packages/contentstack-clone/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone
1616
$ csdx COMMAND
1717
running command...
1818
$ csdx (--version)
19-
@contentstack/cli-cm-clone/2.0.0-beta.4 darwin-arm64 node-v24.12.0
19+
@contentstack/cli-cm-clone/2.0.0-beta.5 darwin-arm64 node-v24.12.0
2020
$ csdx --help [COMMAND]
2121
USAGE
2222
$ csdx COMMAND

packages/contentstack-clone/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "@contentstack/cli-cm-clone",
33
"description": "Contentstack stack clone plugin",
4-
"version": "2.0.0-beta.4",
4+
"version": "2.0.0-beta.5",
55
"author": "Contentstack",
66
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
77
"dependencies": {
88
"@colors/colors": "^1.6.0",
9-
"@contentstack/cli-cm-export": "~2.0.0-beta.4",
10-
"@contentstack/cli-cm-import": "~2.0.0-beta.3",
9+
"@contentstack/cli-cm-export": "~2.0.0-beta.5",
10+
"@contentstack/cli-cm-import": "~2.0.0-beta.4",
1111
"@contentstack/cli-command": "~1.7.0",
1212
"@contentstack/cli-utilities": "~1.15.0",
1313
"@oclif/core": "^4.3.0",
@@ -64,4 +64,4 @@
6464
"cm:stacks:clone": "CLN"
6565
}
6666
}
67-
}
67+
}

packages/contentstack-clone/src/lib/util/clone-handler.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class CloneHandler {
7676
cloneCommand = new Clone();
7777
this.pathDir = opt.pathDir;
7878
process.stdin.setMaxListeners(50);
79-
log.debug('Initializing CloneHandler', config.cloneContext, { pathDir: opt.pathDir, cloneType: opt.cloneType });
8079
}
8180
setClient(managementSDKClient) {
8281
client = managementSDKClient;
@@ -706,9 +705,14 @@ class CloneHandler {
706705
delete exportConfig.import;
707706
delete exportConfig.export;
708707

708+
// Map source_stack to apiKey for export config
709+
if (exportConfig.source_stack) {
710+
exportConfig.apiKey = exportConfig.source_stack;
711+
}
712+
709713
const exportDir = __dirname.split('src')[0] + 'contents';
710714
log.debug(`Export directory: ${exportDir}`, config.cloneContext);
711-
const cmd = ['-k', exportConfig.source_stack, '-d', exportDir];
715+
const cmd = ['-k', exportConfig.apiKey || exportConfig.source_stack, '-d', exportDir];
712716

713717
if (exportConfig.cloneType === 'a') {
714718
exportConfig.filteredModules = ['stack'].concat(structureList);
@@ -738,7 +742,7 @@ class CloneHandler {
738742
log.debug('Export command prepared', config.cloneContext, {
739743
cmd: cmd.join(' '),
740744
exportDir,
741-
sourceStack: exportConfig.source_stack,
745+
sourceStack: exportConfig.apiKey || exportConfig.source_stack,
742746
branch: exportConfig.sourceStackBranch
743747
});
744748
log.debug('Running export command', config.cloneContext, { cmd });
@@ -760,14 +764,22 @@ class CloneHandler {
760764
delete importConfig.import;
761765
delete importConfig.export;
762766

767+
// Map target_stack to apiKey and data to contentDir for import config
768+
if (importConfig.target_stack) {
769+
importConfig.apiKey = importConfig.target_stack;
770+
}
771+
if (importConfig.data) {
772+
importConfig.contentDir = importConfig.data;
773+
}
774+
763775
const configFilePath = path.join(__dirname, 'dummyConfig.json');
764776
const cmd = ['-c', configFilePath];
765777

766778
if (importConfig.destination_alias) {
767779
cmd.push('-a', importConfig.destination_alias);
768780
log.debug(`Using destination alias: ${importConfig.destination_alias}`, config.cloneContext);
769781
}
770-
if (!importConfig.data && importConfig.sourceStackBranch) {
782+
if (!importConfig.contentDir && !importConfig.data && importConfig.sourceStackBranch) {
771783
const dataPath = path.join(importConfig.pathDir, importConfig.sourceStackBranch);
772784
cmd.push('-d', dataPath);
773785
log.debug(`Import data path: ${dataPath}`, config.cloneContext);
@@ -795,9 +807,9 @@ class CloneHandler {
795807
fs.writeFileSync(configFilePath, JSON.stringify(importConfig));
796808
log.debug('Import command prepared', config.cloneContext, {
797809
cmd: cmd.join(' '),
798-
targetStack: importConfig.target_stack,
810+
targetStack: importConfig.apiKey || importConfig.target_stack,
799811
targetBranch: importConfig.targetStackBranch,
800-
dataPath: importConfig.data || path.join(importConfig.pathDir, importConfig.sourceStackBranch)
812+
dataPath: importConfig.contentDir || importConfig.data || path.join(importConfig.pathDir, importConfig.sourceStackBranch)
801813
});
802814
log.debug('Running import command', config.cloneContext, { cmd });
803815
await importCmd.run(cmd);

packages/contentstack-export-to-csv/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@
6565
}
6666
},
6767
"repository": "https://github.com/contentstack/cli"
68-
}
68+
}

packages/contentstack-export/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $ npm install -g @contentstack/cli-cm-export
4848
$ csdx COMMAND
4949
running command...
5050
$ csdx (--version)
51-
@contentstack/cli-cm-export/2.0.0-beta.4 darwin-arm64 node-v24.12.0
51+
@contentstack/cli-cm-export/2.0.0-beta.5 darwin-arm64 node-v24.12.0
5252
$ csdx --help [COMMAND]
5353
USAGE
5454
$ csdx COMMAND

packages/contentstack-export/example_config/auth_config.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"contentVersion": 2,
32
"master_locale": {
43
"name": "English - United States",
54
"code": "en-us"

0 commit comments

Comments
 (0)