Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default sandbox confirmation prompt #904

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/cli/commands/project/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const { uiAccountDescription, uiBetaMessage, uiLine } = require('../../lib/ui');
const { confirmPrompt } = require('../../lib/prompts/promptUtils');
const {
selectTargetAccountPrompt,
confirmDefaultSandboxAccountPrompt,
} = require('../../lib/prompts/projectDevTargetAccountPrompt');
const SpinniesManager = require('../../lib/SpinniesManager');
const LocalDevManager = require('../../lib/LocalDevManager');
Expand Down Expand Up @@ -88,7 +89,17 @@ exports.handler = async options => {
const defaultAccountIsSandbox = isSandbox(accountConfig);

if (!targetAccountId && defaultAccountIsSandbox) {
targetAccountId = accountId;
const useDefaultSandboxAccount = await confirmDefaultSandboxAccountPrompt(
accountConfig.name,
accountConfig.sandboxAccountType
);

if (useDefaultSandboxAccount) {
targetAccountId = accountId;
} else {
logger.log(i18n(`${i18nKey}.logs.declineDefaultSandboxExplanation`));
process.exit(EXIT_CODES.SUCCESS);
}
}

if (!targetAccountId) {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ en:
projectMustExistExplanation: "The project {{ projectName }} does not exist in the target account {{ accountIdentifier}}. This command requires the project to exist in the target account."
choseNotToCreateProject: "Exiting because this command requires the project to exist in the target account."
initialUploadMessage: "HubSpot Local Dev Server Startup"
declineDefaultSandboxExplanation: "To develop on a different account, run {{#bold}}`hs accounts use`{{/bold}} to change your default account, then re-run {{#bold}}`hs project dev`{{/bold}}."
status:
creatingProject: "Creating project {{ projectName }} in {{ accountIdentifier }}"
createdProject: "Created project {{ projectName }} in {{ accountIdentifier }}"
Expand Down Expand Up @@ -971,6 +972,7 @@ en:
chooseDefaultAccountOption: "<{{#bold}}\U00002757{{/bold}} Test on this production account {{#bold}}\U00002757{{/bold}}>"
promptMessage: "[--account] Choose a sandbox under {{ accountIdentifier }} to test with:"
sandboxLimit: "You’ve reached the limit of {{ limit }} development sandboxes"
confirmDefaultSandboxAccount: "Continue testing on {{#bold}}{{ accountName }} ({{ accountType }}){{/bold}}? (Y/n)"
projectLogsPrompt:
projectName:
message: "[--project] Enter the project name:"
Expand Down
15 changes: 15 additions & 0 deletions packages/cli/lib/prompts/projectDevTargetAccountPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ const selectTargetAccountPrompt = async (accounts, defaultAccountConfig) => {
return targetAccountInfo;
};

const confirmDefaultSandboxAccountPrompt = async (accountName, accountType) => {
const { useDefaultAccount } = await promptUser([
{
name: 'useDefaultAccount',
type: 'confirm',
message: i18n(`${i18nKey}.confirmDefaultSandboxAccount`, {
accountName,
accountType,
}),
},
]);
return useDefaultAccount;
};

module.exports = {
selectTargetAccountPrompt,
confirmDefaultSandboxAccountPrompt,
};
Loading