Skip to content

Commit bac8bfc

Browse files
authored
Merge pull request #2090 from contentstack/feat/DX-3471
Feat: Added branch alias support in clone command
2 parents ac661f6 + 235aab1 commit bac8bfc

File tree

7 files changed

+370
-418
lines changed

7 files changed

+370
-418
lines changed

.talismanrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
fileignoreconfig:
22
- filename: package-lock.json
3-
checksum: 16a20411514058d2030b6240573078fad7640b745545a0463e9b70985f92425c
3+
checksum: 60cf06e944b51a620589f6785874c0c771e6e12a01cb561ec60fc92bfddf70ee
44
- filename: pnpm-lock.yaml
5-
checksum: d28afee9b463d66004354b9476b1e39344f903e2db3a15c5f83bd84e688c01d6
5+
checksum: bee7058cd14780ac1a012ca95dccb89e62918f0e1bc9ea0d13d4c58d284e21e0
66
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
77
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
88
- filename: packages/contentstack-import-setup/test/config.json

package-lock.json

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

packages/contentstack-clone/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-clone",
33
"description": "Contentstack stack clone plugin",
4-
"version": "1.15.2",
4+
"version": "1.16.0",
55
"author": "Contentstack",
66
"bugs": "https://github.com/rohitmishra209/cli-cm-clone/issues",
77
"dependencies": {

packages/contentstack-clone/src/commands/cm/stacks/clone.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class StackCloneCommand extends Command {
1818
type: cloneType,
1919
'stack-name': stackName,
2020
'source-branch': sourceStackBranch,
21+
'source-branch-alias': sourceStackBranchAlias,
2122
'target-branch': targetStackBranch,
23+
'target-branch-alias': targetStackBranchAlias,
2224
'source-stack-api-key': sourceStackApiKey,
2325
'destination-stack-api-key': destinationStackApiKey,
2426
'source-management-token-alias': sourceManagementTokenAlias,
@@ -47,8 +49,14 @@ class StackCloneCommand extends Command {
4749
if (sourceStackBranch) {
4850
config.sourceStackBranch = sourceStackBranch;
4951
}
52+
if (sourceStackBranchAlias) {
53+
config.sourceStackBranchAlias = sourceStackBranchAlias;
54+
}
5055
if (targetStackBranch) {
5156
config.targetStackBranch = targetStackBranch;
57+
}
58+
if (targetStackBranchAlias) {
59+
config.targetStackBranchAlias = targetStackBranchAlias;
5260
}
5361
if (sourceStackApiKey) {
5462
config.source_stack = sourceStackApiKey;
@@ -202,11 +210,25 @@ StackCloneCommand.flags = {
202210
required: false,
203211
multiple: false,
204212
description: 'Branch of the source stack.',
213+
exclusive: ['source-branch-alias']
214+
}),
215+
'source-branch-alias': flags.string({
216+
required: false,
217+
multiple: false,
218+
description: 'Alias of Branch of the source stack.',
219+
exclusive: ['source-branch']
205220
}),
206221
'target-branch': flags.string({
207222
required: false,
208223
multiple: false,
209224
description: 'Branch of the target stack.',
225+
exclusive: ['target-branch-alias']
226+
}),
227+
'target-branch-alias': flags.string({
228+
required: false,
229+
multiple: false,
230+
description: 'Alias of Branch of the target stack.',
231+
exclusive: ['target-branch']
210232
}),
211233
'source-management-token-alias': flags.string({
212234
required: false,
@@ -229,8 +251,8 @@ StackCloneCommand.flags = {
229251
multiple: false,
230252
options: ['a', 'b'],
231253
description: ` Type of data to clone. You can select option a or b.
232-
a) Structure (all modules except entries & assets).
233-
b) Structure with content (all modules including entries & assets).
254+
a) Structure (all modules except entries & assets).
255+
b) Structure with content (all modules including entries & assets).
234256
`,
235257
}),
236258
'source-stack-api-key': flags.string({

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ class CloneHandler {
634634
cmd.push('--branch', exportConfig.sourceStackBranch);
635635
}
636636

637+
if (!exportConfig.sourceStackBranch && exportConfig.sourceStackBranchAlias) {
638+
cmd.push('--branch-alias', exportConfig.sourceStackBranchAlias);
639+
}
640+
637641
if (exportConfig.forceStopMarketplaceAppsPrompt) cmd.push('-y');
638642

639643
cmd.push('-c');
@@ -663,6 +667,10 @@ class CloneHandler {
663667
if (importConfig.targetStackBranch) {
664668
cmd.push('--branch', importConfig.targetStackBranch);
665669
}
670+
671+
if (!importConfig.targetStackBranch && importConfig.targetStackBranchAlias) {
672+
cmd.push('--branch-alias', importConfig.targetStackBranchAlias);
673+
}
666674
if (importConfig.importWebhookStatus) {
667675
cmd.push('--import-webhook-status', importConfig.importWebhookStatus);
668676
}

packages/contentstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@contentstack/cli-cm-bootstrap": "~1.15.1",
2828
"@contentstack/cli-cm-branches": "~1.5.1",
2929
"@contentstack/cli-cm-bulk-publish": "~1.9.1",
30-
"@contentstack/cli-cm-clone": "~1.15.2",
30+
"@contentstack/cli-cm-clone": "~1.16.0",
3131
"@contentstack/cli-cm-export": "~1.20.0",
3232
"@contentstack/cli-cm-export-to-csv": "~1.9.1",
3333
"@contentstack/cli-cm-import": "~1.26.3",

0 commit comments

Comments
 (0)