From 16ef707e4b6589d6d951229bdf6826c58c5d80b6 Mon Sep 17 00:00:00 2001 From: Allison Kemmerle Date: Tue, 13 Feb 2024 14:56:36 -0500 Subject: [PATCH] Add forceCreate flag to prompt flow --- packages/cli/commands/project/upload.js | 12 ++++-------- packages/cli/lang/en.lyaml | 1 + packages/cli/lib/projects.js | 4 +++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/cli/commands/project/upload.js b/packages/cli/commands/project/upload.js index 037077722..f57aae747 100644 --- a/packages/cli/commands/project/upload.js +++ b/packages/cli/commands/project/upload.js @@ -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( diff --git a/packages/cli/lang/en.lyaml b/packages/cli/lang/en.lyaml index 1ac92971f..40873dcd9 100644 --- a/packages/cli/lang/en.lyaml +++ b/packages/cli/lang/en.lyaml @@ -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: diff --git a/packages/cli/lib/projects.js b/packages/cli/lib/projects.js index 3c660b651..a9dbc9bc5 100644 --- a/packages/cli/lib/projects.js +++ b/packages/cli/lib/projects.js @@ -238,6 +238,7 @@ const ensureProjectExists = async ( allowCreate = true, noLogs = false, withPolling = false, + uploadCommand = false, } = {} ) => { const accountIdentifier = uiAccountDescription(accountId); @@ -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, }),