diff --git a/src/lib/dev-environment/dev-environment-cli.ts b/src/lib/dev-environment/dev-environment-cli.ts index 329491a41..327eee282 100644 --- a/src/lib/dev-environment/dev-environment-cli.ts +++ b/src/lib/dev-environment/dev-environment-cli.ts @@ -695,7 +695,7 @@ export async function promptForPhpVersion( initialValue: string ): Promise< stri } export async function promptForWordPress( - defaultObject: WordPressConfig | null + defaultObject: WordPressConfig | string | null ): Promise< WordPressConfig > { debug( `Prompting for wordpress with default:`, defaultObject ); const componentDisplayName = componentDisplayNames.wordpress; @@ -704,7 +704,17 @@ export async function promptForWordPress( // image with selection const tagChoices = await getTagChoices(); - let option = defaultObject?.tag ?? tagChoices[ 0 ].value; + + if ( + typeof defaultObject === 'string' && + ! tagChoices.find( choice => choice.value === defaultObject ) + ) { + throw new Error( `Unknown or unsupported WordPress version: ${ defaultObject }.` ); + } + + let option = + typeof defaultObject === 'string' ? defaultObject : defaultObject?.tag ?? tagChoices[ 0 ].value; + if ( isStdinTTY ) { const message = `${ messagePrefix }Which version would you like`; const selectTag = new Select( { diff --git a/src/lib/dev-environment/dev-environment-core.ts b/src/lib/dev-environment/dev-environment-core.ts index edfcf230c..0d9cf29b1 100644 --- a/src/lib/dev-environment/dev-environment-core.ts +++ b/src/lib/dev-environment/dev-environment-core.ts @@ -790,7 +790,7 @@ async function maybeUpdateWordPressImage( lando: Lando, slug: string ): Promise< console.log( 'Upgrading from: ' + chalk.yellow( currentWordPressTag ) + ' to:' ); // Select a new image - const choice: WordPressConfig = await promptForWordPress( null ); + const choice: WordPressConfig = await promptForWordPress( newestWordPressImage?.tag ?? null ); const version: WordPressTag | undefined = versions.find( ( { tag } ) => tag.trim() === choice.tag.trim() );