@hubspot/cli
Advanced tools
Comparing version 4.1.7-beta.2 to 4.1.7
@@ -21,2 +21,3 @@ const { | ||
removeSandboxAccountFromConfig, | ||
updateDefaultAccount, | ||
} = require('@hubspot/cli-lib/lib/config'); | ||
@@ -42,3 +43,3 @@ const { | ||
const { account } = options; | ||
const { account, force } = options; | ||
const config = getConfig(); | ||
@@ -48,4 +49,17 @@ | ||
if (!account) { | ||
accountPrompt = await deleteSandboxPrompt(config); | ||
if (!force) { | ||
accountPrompt = await deleteSandboxPrompt(config); | ||
} else { | ||
// Account is required, throw error if force flag is present and no account is specified | ||
logger.log(''); | ||
logger.error(i18n(`${i18nKey}.failure.noAccount`)); | ||
process.exit(EXIT_CODES.ERROR); | ||
} | ||
if (!accountPrompt) { | ||
logger.log(''); | ||
logger.error(i18n(`${i18nKey}.failure.noSandboxAccounts`)); | ||
process.exit(EXIT_CODES.ERROR); | ||
} | ||
} | ||
const sandboxAccountId = getAccountId({ | ||
@@ -60,2 +74,6 @@ account: account || accountPrompt.account, | ||
const baseUrl = getHubSpotWebsiteOrigin( | ||
getEnv(sandboxAccountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD | ||
); | ||
let parentAccountId; | ||
@@ -66,3 +84,3 @@ for (const portal of config.portals) { | ||
parentAccountId = portal.parentAccountId; | ||
} else { | ||
} else if (!force) { | ||
const parentAccountPrompt = await deleteSandboxPrompt(config, true); | ||
@@ -72,2 +90,5 @@ parentAccountId = getAccountId({ | ||
}); | ||
} else { | ||
logger.error(i18n(`${i18nKey}.failure.noParentAccount`)); | ||
process.exit(EXIT_CODES.ERROR); | ||
} | ||
@@ -77,13 +98,11 @@ } | ||
const url = `${baseUrl}/sandboxes/${parentAccountId}`; | ||
const command = `hs auth ${ | ||
getEnv(sandboxAccountId) === 'qa' ? '--qa' : '' | ||
} --account=${parentAccountId}`; | ||
if (!getAccountId({ account: parentAccountId })) { | ||
const baseUrl = getHubSpotWebsiteOrigin( | ||
getEnv(sandboxAccountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD | ||
); | ||
const url = `${baseUrl}/sandboxes/${parentAccountId}`; | ||
const command = `hs auth ${ | ||
getEnv(sandboxAccountId) === 'qa' ? '--qa' : '' | ||
} --account=${parentAccountId}`; | ||
logger.log(''); | ||
logger.error( | ||
i18n(`${i18nKey}.noParentPortalAvailable`, { | ||
i18n(`${i18nKey}.failure.noParentPortalAvailable`, { | ||
parentAccountId, | ||
@@ -113,13 +132,15 @@ url, | ||
try { | ||
const { confirmSandboxDeletePrompt: confirmed } = await promptUser([ | ||
{ | ||
name: 'confirmSandboxDeletePrompt', | ||
type: 'confirm', | ||
message: i18n(`${i18nKey}.confirm`, { | ||
account: account || accountPrompt.account, | ||
}), | ||
}, | ||
]); | ||
if (!confirmed) { | ||
process.exit(EXIT_CODES.SUCCESS); | ||
if (!force) { | ||
const { confirmSandboxDeletePrompt: confirmed } = await promptUser([ | ||
{ | ||
name: 'confirmSandboxDeletePrompt', | ||
type: 'confirm', | ||
message: i18n(`${i18nKey}.confirm`, { | ||
account: account || accountPrompt.account, | ||
}), | ||
}, | ||
]); | ||
if (!confirmed) { | ||
process.exit(EXIT_CODES.SUCCESS); | ||
} | ||
} | ||
@@ -144,4 +165,7 @@ | ||
); | ||
if (promptDefaultAccount) { | ||
if (promptDefaultAccount && !force) { | ||
await selectAndSetAsDefaultAccountPrompt(getConfig()); | ||
} else { | ||
// If force is specified, skip prompt and set the parent account id as the default account | ||
updateDefaultAccount(parentAccountId); | ||
} | ||
@@ -168,3 +192,3 @@ process.exit(EXIT_CODES.SUCCESS); | ||
logger.warn( | ||
i18n(`${i18nKey}.objectNotFound`, { | ||
i18n(`${i18nKey}.failure.objectNotFound`, { | ||
account: account || accountPrompt.account, | ||
@@ -178,4 +202,7 @@ }) | ||
); | ||
if (promptDefaultAccount) { | ||
if (promptDefaultAccount && !force) { | ||
await selectAndSetAsDefaultAccountPrompt(getConfig()); | ||
} else { | ||
// If force is specified, skip prompt and set the parent account id as the default account | ||
updateDefaultAccount(parentAccountId); | ||
} | ||
@@ -195,2 +222,7 @@ process.exit(EXIT_CODES.SUCCESS); | ||
}); | ||
yargs.option('f', { | ||
type: 'boolean', | ||
alias: 'force', | ||
describe: i18n(`${i18nKey}.examples.force`), | ||
}); | ||
@@ -197,0 +229,0 @@ yargs.example([ |
@@ -52,2 +52,3 @@ const { updateDefaultAccount } = require('@hubspot/cli-lib/lib/config'); | ||
selectAccountFromConfig, | ||
mapAccountChoices, | ||
}; |
@@ -18,2 +18,14 @@ const { promptUser } = require('./promptUtils'); | ||
const mapNonSandboxAccountChoices = portals => | ||
portals | ||
.filter( | ||
p => p.sandboxAccountType === null || p.sandboxAccountType === undefined | ||
) | ||
.map(p => { | ||
return { | ||
name: `${p.name} (${p.portalId})`, | ||
value: p.name || p.portalId, | ||
}; | ||
}); | ||
const createSandboxPrompt = () => { | ||
@@ -36,2 +48,8 @@ return promptUser([ | ||
const deleteSandboxPrompt = (config, promptParentAccount = false) => { | ||
const choices = promptParentAccount | ||
? mapNonSandboxAccountChoices(config.portals) | ||
: mapSandboxAccountChoices(config.portals); | ||
if (!choices.length) { | ||
return undefined; | ||
} | ||
return promptUser([ | ||
@@ -48,3 +66,3 @@ { | ||
pageSize: 20, | ||
choices: mapSandboxAccountChoices(config.portals), | ||
choices, | ||
default: config.defaultPortal, | ||
@@ -51,0 +69,0 @@ }, |
{ | ||
"name": "@hubspot/cli", | ||
"version": "4.1.7-beta.2", | ||
"version": "4.1.7", | ||
"description": "CLI for working with HubSpot", | ||
@@ -11,4 +11,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@hubspot/cli-lib": "4.1.7-beta.2", | ||
"@hubspot/serverless-dev-runtime": "4.1.7-beta.2", | ||
"@hubspot/cli-lib": "4.1.7", | ||
"@hubspot/serverless-dev-runtime": "4.1.7", | ||
"archiver": "^5.3.0", | ||
@@ -42,3 +42,3 @@ "chalk": "^4.1.2", | ||
}, | ||
"gitHead": "ce9f106f0da7a39fbf14ff0ead2d5d750adee428" | ||
"gitHead": "ef2292568ec8308feb0c5841e4d3dd25a64d1050" | ||
} |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
289449
9024
1
+ Added@hubspot/cli-lib@4.1.7(transitive)
+ Added@hubspot/serverless-dev-runtime@4.1.7(transitive)
- Removed@hubspot/cli-lib@4.1.7-beta.2(transitive)
- Removed@hubspot/serverless-dev-runtime@4.1.7-beta.2(transitive)
Updated@hubspot/cli-lib@4.1.7