-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Block: Migrate Inquirer.js dependency to the new API #67877
Conversation
Size Change: 0 B Total Size: 1.84 MB ℹ️ View Unchanged
|
Flaky tests detected in 29683d7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12410450664
|
ce6eb21
to
3b146d7
Compare
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes LGTM. I've testing in both interactive and quick mode and everything seems to work as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have confirmed that it works correctly on a Windows host OS.
One concern is that an error occurs when I cancel the prompt. In my environment, this occurs on both a Windows host OS and an Ubuntu OS:
$ npx wp-create-block
Let's customize your WordPress plugin with blocks:
? The template variant to use for this block: (Use arrow keys)
❯ static
dynamic
/home/t-hamano/projects/gutenberg/node_modules/@inquirer/core/dist/commonjs/lib/create-prompt.js:84
reject(new errors_js_1.ExitPromptError(`User force closed the prompt with ${code} ${signal}`));
^
ExitPromptError: User force closed the prompt with 0 null
at /home/t-hamano/projects/gutenberg/node_modules/@inquirer/core/dist/commonjs/lib/create-prompt.js:84:20
at Emitter.emit (/home/t-hamano/projects/gutenberg/node_modules/@inquirer/core/node_modules/signal-exit/dist/cjs/index.js:71:19)
at #processEmit (/home/t-hamano/projects/gutenberg/node_modules/@inquirer/core/node_modules/signal-exit/dist/cjs/index.js:240:27)
at #process.emit (/home/t-hamano/projects/gutenberg/node_modules/@inquirer/core/node_modules/signal-exit/dist/cjs/index.js:191:37)
at process.callbackTrampoline (node:internal/async_hooks:130:17)
This error doesn't seem to occur on trunk 🤔
Update: This might be a problem with the library.
3b146d7
to
db0658e
Compare
const blockPrompts = getPrompts( | ||
pluginTemplate, | ||
const blockAnswers = await runPrompts( | ||
projectTemplate, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the name from pluginTemplate
to projectTemplate
as I realized that the name became confusing after we introduced the concept of scaffolding a block without a plugin. This part is used to scaffold only the block. Consequently, the name getPluginTemplate
became getProjectTemplate
. It's also a step towards the potential introduction of the template for a theme that needs dev tools for JavaScript and CSS.
if ( ! configurePlugin ) { | ||
return {}; | ||
} | ||
! plugin && 'textdomain', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing, the textdomain
prompt only makes sense when --no-plugin
option is selected. Otherwise, it should be equal to the plugin slug name.
6a1e4d9
to
f5c8e69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I have confirmed that ctrl+c
works on both Windows OS and Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, we may also need to update the env command.
$ npm run wp-env destroy
> [email protected] wp-env
> wp-env destroy
ℹ WARNING! This will remove Docker containers, volumes, networks, and images associated with the WordPress instance.
✖ inquirer.prompt is not a function
TypeError: inquirer.prompt is not a function
at destroy (/home/t-hamano/projects/gutenberg/packages/env/lib/commands/destroy.js:43:39)
@t-hamano, for consistency, I updated all occurrences so it's handled the same way. That also covers: Consequently, the Gutenberg repository uses only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I have tested again and everything seems to be working as expected.
Co-authored-by: Aki Hamano <[email protected]>
What?
Prerequisite for the work started by @eduwass:
Why?
Let's ensure that the new custom prompts support for Create Block uses the latest API to avoid the lockdown on the legacy version of the
inquirer
library.How?
Replaces usage of
inquirer
with the recommended@inquirer/prompts
.Testing Instructions
Everything should work as before. The best way to test is to run locally the following commands:
create-block-demo.mov