Skip to content

Commit

Permalink
Pre-select latest version
Browse files Browse the repository at this point in the history
Pre-select latest version
  • Loading branch information
rebeccahum committed Jun 20, 2024
1 parent c65f1f5 commit f779765
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/lib/dev-environment/dev-environment-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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( {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dev-environment/dev-environment-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down

0 comments on commit f779765

Please sign in to comment.