Skip to content

Commit

Permalink
Merge pull request #39 from contentstack/clone-stack
Browse files Browse the repository at this point in the history
Clone stack branch merge
  • Loading branch information
rohitmishra209 authored Mar 26, 2021
2 parents f9fd520 + dca1e2a commit d33fa75
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/contentstack-clone/src/lib/util/clone-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let stackName = {

let orgUidList = {}
let stackUidList = {}
let masterLocaleList = {}

let structureList = ['locales',
'environments',
Expand Down Expand Up @@ -60,6 +61,7 @@ class CloneHandler {
.then(async (stackList)=> {
let stackSelected = await inquirer.prompt(stackList)
config.source_stack = stackUidList[stackSelected.stack]
master_locale = masterLocaleList[stackSelected.stack]
config.sourceStackName = stackSelected.stack
stackName.default = "Copy of " + stackSelected.stack
let cmdExport = this.cmdExport()
Expand Down Expand Up @@ -162,6 +164,7 @@ class CloneHandler {
.then(async stacklist => {
for (let j = 0; j < stacklist.items.length; j++) {
stackUidList[stacklist.items[j].name] = stacklist.items[j].api_key
masterLocaleList[stacklist.items[j].name] = stacklist.items[j].master_locale
stackChoice.choices.push(stacklist.items[j].name)
}
spinner.succeed("Fetched stack")
Expand All @@ -180,15 +183,14 @@ class CloneHandler {
async createNewStack(orgUid) {
return new Promise(async (resolve, reject) => {
let inputvalue = await inquirer.prompt(stackName)
let stack = { name: inputvalue.stack }
let stack = { name: inputvalue.stack, master_locale: master_locale }
const spinner = ora('Creating New stack').start()
let newStack = client.stack().create({ stack }, { organization_uid: orgUid })
newStack
.then(result => {
spinner.succeed("New Stack created Successfully name as " + result.name)
config.target_stack = result.api_key
config.destinationStackName = result.name
master_locale = result.master_locale
return resolve(result)
}).catch(error => {
spinner.fail()
Expand Down

0 comments on commit d33fa75

Please sign in to comment.