Skip to content

Commit

Permalink
Add forceCreate flag to prompt flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kemmerle committed Feb 13, 2024
1 parent f23f24e commit 16ef707
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
12 changes: 4 additions & 8 deletions packages/cli/commands/project/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,10 @@ exports.handler = async options => {

await showPlatformVersionWarning(accountId, projectConfig);

logger.log('');
logger.log(i18n(`${i18nKey}.describe`));
logger.log(
"$0 project upload myProjectFolder --forceCreate=true --message='Add a message when you upload your project'"
);
logger.log('');

await ensureProjectExists(accountId, projectConfig.name, { forceCreate });
await ensureProjectExists(accountId, projectConfig.name, {
forceCreate,
uploadCommand: true,
});

try {
const result = await handleProjectUpload(
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lang/en.lyaml
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ en:
fileFiltered: "Ignore rule triggered for \"{{ filename }}\""
ensureProjectExists:
createPrompt: "The project {{ projectName }} does not exist in {{ accountIdentifier }}. Would you like to create it?"
createPromptUpload: "[--forceCreate] The project {{ projectName }} does not exist in {{ accountIdentifier }}. Would you like to create it?"
createSuccess: "New project {{#bold}}{{ projectName }}{{/bold}} successfully created in {{#bold}}{{ accountIdentifier }}{{/bold}}."
notFound: "Your project {{#bold}}{{ projectName }}{{/bold}} could not be found in {{#bold}}{{ accountIdentifier }}{{/bold}}."
pollFetchProject:
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/lib/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ const ensureProjectExists = async (
allowCreate = true,
noLogs = false,
withPolling = false,
uploadCommand = false,
} = {}
) => {
const accountIdentifier = uiAccountDescription(accountId);
Expand All @@ -251,10 +252,11 @@ const ensureProjectExists = async (
let shouldCreateProject = forceCreate;

if (allowCreate && !shouldCreateProject) {
const promptKey = uploadCommand ? 'createPromptUpload' : 'createPrompt';
const promptResult = await promptUser([
{
name: 'shouldCreateProject',
message: i18n(`${i18nKey}.ensureProjectExists.createPrompt`, {
message: i18n(`${i18nKey}.ensureProjectExists.${promptKey}`, {
projectName,
accountIdentifier,
}),
Expand Down

0 comments on commit 16ef707

Please sign in to comment.