From 3d60673445a5228b06cbdaa6b94c68dba4ff24ab Mon Sep 17 00:00:00 2001 From: Rohit Mishra Date: Thu, 11 Mar 2021 12:32:58 +0530 Subject: [PATCH 1/2] Updated the text accordng to doc team suggestions --- .../src/commands/cm/stack-clone.js | 5 +-- .../src/lib/util/clone-handler.js | 40 +++++++++++-------- packages/contentstack-export/src/app.js | 2 +- .../src/lib/export/assets.js | 2 +- .../src/lib/export/content-types.js | 2 +- .../src/lib/export/entries.js | 4 +- .../src/lib/export/environments.js | 2 +- .../src/lib/export/extensions.js | 2 +- .../src/lib/export/global-fields.js | 2 +- .../src/lib/export/labels.js | 2 +- .../src/lib/export/locales.js | 2 +- .../src/lib/export/webhooks.js | 2 +- .../src/lib/import/releases.js | 5 ++- 13 files changed, 39 insertions(+), 33 deletions(-) diff --git a/packages/contentstack-clone/src/commands/cm/stack-clone.js b/packages/contentstack-clone/src/commands/cm/stack-clone.js index a8dd9ceeea..b9df030df6 100644 --- a/packages/contentstack-clone/src/commands/cm/stack-clone.js +++ b/packages/contentstack-clone/src/commands/cm/stack-clone.js @@ -16,16 +16,15 @@ class StackCloneCommand extends Command { const cloneHandler = new CloneHandler(config) let result = await cloneHandler.start() fs.rmdirSync(path.join(__dirname.split("src")[0], 'contents'), { recursive: true }); - console.log(result); } else { console.log("AuthToken is not present in local drive, Hence use 'csdx auth:login' command for login"); } } } -StackCloneCommand.description = `This plugin allows you to perform content or only structure migration tasks +StackCloneCommand.description = `This command allows you to migrate data (structure or content or both) from one stack to another stack (either new or existing) ... -By using this plugin, you can automate the content export and import operations for your stacks in your organization. +Use this plugin to automate the process of cloning a stack in a few steps. ` StackCloneCommand.examples = [ diff --git a/packages/contentstack-clone/src/lib/util/clone-handler.js b/packages/contentstack-clone/src/lib/util/clone-handler.js index 030ebda8bf..a00e4cb6bf 100644 --- a/packages/contentstack-clone/src/lib/util/clone-handler.js +++ b/packages/contentstack-clone/src/lib/util/clone-handler.js @@ -15,14 +15,14 @@ let config let stackCreationConfirmation = [{ type: 'confirm', name: 'stackCreate', - message: 'Do you want to create new stack ?', + message: 'Want to clone content into a new stack ?', initial: true }] let stackName = { type: 'input', name: 'stack', - message: 'Please Enter New stack name, which you want to create for import ?', + message: 'Enter name for the new stack to store the cloned content ?', default: "ABC" } @@ -36,6 +36,7 @@ let structureList = ['locales', 'global-fields', 'content-types', 'labels'] +var oraMessage let master_locale class CloneHandler { @@ -46,12 +47,14 @@ class CloneHandler { async start() { return new Promise(async (resolve, reject) => { + oraMessage = "Choose an organization where your source stack exists:" // export section starts from here - let orgdetails = this.getOrganizationChoices() + let orgdetails = this.getOrganizationChoices(oraMessage) orgdetails .then(async (orgList)=>{ + var stackMessage = 'Select the source stack' var orgSelected = await inquirer.prompt(orgList) - let stackDetails = this.getStack(orgSelected) + let stackDetails = this.getStack(orgSelected, stackMessage) stackDetails .then(async (stackList)=> { let stackSelected = await inquirer.prompt(stackList) @@ -62,11 +65,13 @@ class CloneHandler { //Import section starts from here var stackCreateConfirmation = await inquirer.prompt(stackCreationConfirmation) if (stackCreateConfirmation.stackCreate !== true) { - let orgdetails = this.getOrganizationChoices() + oraMessage = 'Choose an organization where the destination stack exists: ' + let orgdetails = this.getOrganizationChoices(oraMessage) orgdetails .then(async (orgList)=>{ + var stackMessage = 'Select the source stack' var orgSelected = await inquirer.prompt(orgList) - let stackDetails = this.getStack(orgSelected) + let stackDetails = this.getStack(orgSelected, stackMessage) stackDetails .then(async (stackList)=> { let stackSelected = await inquirer.prompt(stackList) @@ -84,7 +89,8 @@ class CloneHandler { return reject(error.errorMessage) }) } else { - let orgdetails = this.getOrganizationChoices() + oraMessage = 'Choose an organization where you want to create a stack: ' + let orgdetails = this.getOrganizationChoices(oraMessage) orgdetails .then(async (orgList)=>{ var orgSelected = await inquirer.prompt(orgList) @@ -112,15 +118,15 @@ class CloneHandler { }) } - getOrganizationChoices = async () => { + getOrganizationChoices = async (oraMessage) => { let orgChoice = { type: 'list', name: 'Organization', - message: '', + message: oraMessage, choices: [], } return new Promise(async (resolve, reject) => { - const spinner = ora('Fetching Organization').start() + const spinner = ora("Fetching Organization").start() try { let organizations = await client.organization().fetchAll({ limit: 100 }) spinner.succeed("Fetched Organization") @@ -136,15 +142,15 @@ class CloneHandler { }) } - getStack = async (answer) => { + getStack = async (answer, stkMessage) => { return new Promise(async (resolve, reject) => { let stackChoice = { type: 'list', name: 'stack', - message: 'Choose Stack ...', + message: stkMessage, choices: [], } - const spinner = ora('Fetching stack List').start() + const spinner = ora('Fetching stacks').start() try { let orgUid = orgUidList[answer.Organization] let stackList = client.stack().query({ organization_uid: orgUid }).find() @@ -154,7 +160,7 @@ class CloneHandler { stackUidList[stacklist.items[j].name] = stacklist.items[j].api_key stackChoice.choices.push(stacklist.items[j].name) } - spinner.succeed("Fetched stack List") + spinner.succeed("Fetched stack") return resolve(stackChoice) }).catch(error => { spinner.fail() @@ -191,13 +197,13 @@ class CloneHandler { let cloneTypeSelection = [{ type: 'list', name: 'type', - message: 'Choose the type to clone the stack', - choices: ["structure", "structure and content"] + message: 'Choose the type of data to clone:', + choices: ["Structure (all modules except entries & assets)", "Structure with content (all modules including entries & assets)"] }] var selectedValue = await inquirer.prompt(cloneTypeSelection) let cloneType = selectedValue.type config['data'] = path.join(__dirname.split("src")[0], 'contents') - if (cloneType === "structure") { + if (cloneType === "Structure (all modules except entries & assets)") { config['modules'] = structureList let cmdImport = this.cmdImport() cmdImport.then(() => { diff --git a/packages/contentstack-export/src/app.js b/packages/contentstack-export/src/app.js index cc70deb224..7b750c54b3 100755 --- a/packages/contentstack-export/src/app.js +++ b/packages/contentstack-export/src/app.js @@ -77,7 +77,7 @@ var allExport = async (config, types) => { return }) } - addlogs(config, chalk.green('Stack: ' + config.source_stack + ' has been exported succesfully!'), 'success') + addlogs(config, chalk.green('The content of the ' + config.source_stack + ' has been exported succesfully!'), 'success') addlogs(config, 'The log for this is stored at ' + path.join(config.data, 'logs', 'export'), 'success') return resolve() } catch (error) { diff --git a/packages/contentstack-export/src/lib/export/assets.js b/packages/contentstack-export/src/lib/export/assets.js index 00e6b76295..3c07569b9d 100644 --- a/packages/contentstack-export/src/lib/export/assets.js +++ b/packages/contentstack-export/src/lib/export/assets.js @@ -50,7 +50,7 @@ ExportAssets.prototype = { return new Promise(function (resolve, reject) { return self.getAssetCount().then(function (count) { if (typeof count !== 'number' || count === 0) { - addlogs(config, 'There were no assets to be download', 'success') + addlogs(config, 'No assets found', 'success') return resolve() } const assetBatches = [] diff --git a/packages/contentstack-export/src/lib/export/content-types.js b/packages/contentstack-export/src/lib/export/content-types.js index 46b67f4f3e..583c009dd2 100644 --- a/packages/contentstack-export/src/lib/export/content-types.js +++ b/packages/contentstack-export/src/lib/export/content-types.js @@ -97,7 +97,7 @@ ExportContentTypes.prototype = { helper.writeFile(path.join(contentTypesFolderPath, content_type.uid + '.json'), content_type) }) - addlogs(config, chalk.green('Content type export completed successfully'), 'success') + addlogs(config, chalk.green('Content type(s) exported successfully'), 'success') return resolve() }) }, diff --git a/packages/contentstack-export/src/lib/export/entries.js b/packages/contentstack-export/src/lib/export/entries.js index 0bff87ce8e..308b94760c 100755 --- a/packages/contentstack-export/src/lib/export/entries.js +++ b/packages/contentstack-export/src/lib/export/entries.js @@ -180,8 +180,8 @@ exportEntries.prototype.getEntries = function (apiDetails) { }) } if (apiDetails.skip > entriesList.items.length) { - addlogs(config, 'Completed exporting ' + apiDetails.content_type + - ' content type\'s entries in ' + apiDetails.locale + ' locale', 'success') + addlogs(config, 'Exported entries of ' + apiDetails.content_type + + ' to the ' + apiDetails.locale + ' language successfully', 'success') return resolve() } apiDetails.skip += limit diff --git a/packages/contentstack-export/src/lib/export/environments.js b/packages/contentstack-export/src/lib/export/environments.js index 5810f7275d..01f0f0834e 100644 --- a/packages/contentstack-export/src/lib/export/environments.js +++ b/packages/contentstack-export/src/lib/export/environments.js @@ -50,7 +50,7 @@ ExportEnvironments.prototype.start = function (mergConfig) { return resolve() } if (environmentResponse.items.length === 0) { - addlogs(config, 'No environments were found in the Stack', 'success') + addlogs(config, 'No environments found', 'success') return resolve() } }).catch(error => { diff --git a/packages/contentstack-export/src/lib/export/extensions.js b/packages/contentstack-export/src/lib/export/extensions.js index 6fe518fae3..eacefe1c08 100644 --- a/packages/contentstack-export/src/lib/export/extensions.js +++ b/packages/contentstack-export/src/lib/export/extensions.js @@ -47,7 +47,7 @@ ExportExtensions.prototype.start = function (mergeConfig) { addlogs(config, chalk.green('All the extensions have been exported successfully'), 'success') return resolve() } - addlogs(config, 'No extensions were found in the Stack', 'success') + addlogs(config, 'No extensions found', 'success') return resolve() }).catch(error => { addlogs(config, error, 'error') diff --git a/packages/contentstack-export/src/lib/export/global-fields.js b/packages/contentstack-export/src/lib/export/global-fields.js index 44b214ba71..2b14697160 100644 --- a/packages/contentstack-export/src/lib/export/global-fields.js +++ b/packages/contentstack-export/src/lib/export/global-fields.js @@ -73,7 +73,7 @@ ExportGlobalFields.prototype = { .then(globalFieldResponse => { try { if (globalFieldResponse.items.length === 0) { - addlogs(config, 'No Global Fields were found in the Stack', 'success') + addlogs(config, 'No global fields found', 'success') return resolve('No Global Fields') } globalFieldResponse.items.forEach(function (globalField) { diff --git a/packages/contentstack-export/src/lib/export/labels.js b/packages/contentstack-export/src/lib/export/labels.js index 6b4239106d..ddacea1c0c 100644 --- a/packages/contentstack-export/src/lib/export/labels.js +++ b/packages/contentstack-export/src/lib/export/labels.js @@ -46,7 +46,7 @@ ExportLabels.prototype.start = function (credentialConfig) { }) addlogs(config, chalk.green('All the labels have been exported successfully'), 'success') } else { - addlogs(config, 'No labels, other than master-labels were found in the Stack', 'success') + addlogs(config, 'No labels found', 'success') } helper.writeFile(path.join(labelsFolderPath, labelConfig.fileName), self.labels) return resolve() diff --git a/packages/contentstack-export/src/lib/export/locales.js b/packages/contentstack-export/src/lib/export/locales.js index 9a2a683ef1..c94b23333c 100644 --- a/packages/contentstack-export/src/lib/export/locales.js +++ b/packages/contentstack-export/src/lib/export/locales.js @@ -56,7 +56,7 @@ ExportLocales.prototype.start = function (credentialConfig) { }) addlogs(credentialConfig, chalk.green('All the locales have been exported successfully'), 'success') } else if (localeResponse.items.length === 0) { - addlogs(credentialConfig, 'No locales, other than master-locale were found in the Stack', 'success') + addlogs(credentialConfig, 'No languages found except the master language', 'success') } helper.writeFile(path.join(localesFolderPath, localeConfig.fileName), self.locales) resolve() diff --git a/packages/contentstack-export/src/lib/export/webhooks.js b/packages/contentstack-export/src/lib/export/webhooks.js index 67264ae7f0..6febd98a51 100644 --- a/packages/contentstack-export/src/lib/export/webhooks.js +++ b/packages/contentstack-export/src/lib/export/webhooks.js @@ -49,7 +49,7 @@ ExportWebhooks.prototype.start = function (credentialConfig) { addlogs(config, chalk.green('All the webhooks have been exported successfully'), 'success') return resolve() } - addlogs(config, 'No webhooks were found in the Stack', 'success') + addlogs(config, 'No webhooks found', 'success') return resolve() }).catch(function (error) { if (error.statusCode === 401) { diff --git a/packages/contentstack-import/src/lib/import/releases.js b/packages/contentstack-import/src/lib/import/releases.js index 0e0c0784da..097b1a52ec 100644 --- a/packages/contentstack-import/src/lib/import/releases.js +++ b/packages/contentstack-import/src/lib/import/releases.js @@ -82,10 +82,11 @@ importReleases.prototype = { item.uid = self.entriesUids[item.uid] } response.item().create({item}) - .then(() => { + .then((responseData) => { + // responseData.deploy({environment: ''}) // addlogs(config, chalk.white("Item added under "+ response.name), 'success') }).catch((error) => { - addlogs(config, error, 'error') + addlogs(config, error, 'error') addlogs(config, chalk.white("Fail to add items under "+ response.name), 'error') }) }) From f9cd0f810274bc6b237469610fe1c1f0221652de Mon Sep 17 00:00:00 2001 From: Rohit Mishra Date: Thu, 11 Mar 2021 12:52:36 +0530 Subject: [PATCH 2/2] Updated the text accordng to doc team suggestions --- packages/contentstack-export/src/lib/export/locales.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contentstack-export/src/lib/export/locales.js b/packages/contentstack-export/src/lib/export/locales.js index c94b23333c..e8c75e8e4a 100644 --- a/packages/contentstack-export/src/lib/export/locales.js +++ b/packages/contentstack-export/src/lib/export/locales.js @@ -46,7 +46,7 @@ ExportLocales.prototype.start = function (credentialConfig) { .then(localeResponse => { if (localeResponse.items.length !== 0) { localeResponse.items.forEach(function (locale) { - addlogs(credentialConfig, 'locale was exported successfully', 'success') + addlogs(credentialConfig, locale.name + ' locale was exported successfully', 'success') for (const key in locale) { if (requiredKeys.indexOf(key) === -1) { delete locale.key