Skip to content

Commit

Permalink
Create Block: Migrate Inquirer.js dependency to the new API (#67877)
Browse files Browse the repository at this point in the history
* Create Block: Update `inquirer` dependency to the latest version

* Refactor first prompts to the new API

* Fix TypeScript error

* Refactor handling for plugin and block prompts

* Final touches after refactoring

* Add changelog entry

* Refactor after rebasing with `trunk`

* Handling `ctrl+c` gracefully

* Ensure that exiting the prompts is handled gracefully

* Add changelong entry to env package

* Update packages/create-block/lib/index.js

Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>

---------

Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>

Co-authored-by: gziolo <gziolo@git.wordpress.org>
Co-authored-by: ryanwelcher <welcher@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
  • Loading branch information
4 people authored Dec 19, 2024
1 parent a4abb4d commit bdd9afa
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 274 deletions.
19 changes: 12 additions & 7 deletions bin/plugin/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
// @ts-ignore
const inquirer = require( 'inquirer' );
const { confirm } = require( '@inquirer/prompts' );
const fs = require( 'fs' );
const childProcess = require( 'child_process' );
const { v4: uuid } = require( 'uuid' );
Expand Down Expand Up @@ -97,14 +97,19 @@ async function askForConfirmation(
isDefault = true,
abortMessage = 'Aborting.'
) {
const { isReady } = await inquirer.prompt( [
{
type: 'confirm',
name: 'isReady',
let isReady = false;
try {
isReady = await confirm( {
default: isDefault,
message,
},
] );
} );
} catch ( error ) {
if ( error instanceof Error && error.name === 'ExitPromptError' ) {
console.log( 'Cancelled.' );
process.exit( 1 );
}
throw error;
}

if ( ! isReady ) {
log( formats.error( '\n' + abortMessage ) );
Expand Down
Loading

1 comment on commit bdd9afa

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in bdd9afa.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12411037904
📝 Reported issues:

Please sign in to comment.