-
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: Support Custom Prompts in External Templates #67806
base: trunk
Are you sure you want to change the base?
Conversation
Enhance the create-block functionality allowing the inclusion of custom prompts. This change enables template configurations to specify additional prompts beyond the built-in ones, facilitating more flexible block creation. - Validate custom prompts for required properties: type, name, and message. - Merge custom prompts with built-in prompts to offer a comprehensive query set. - Ensure compatibility with existing template definitions by handling cases with null or non-object customPrompts gracefully.
…n into the block creation process. - Merge built-in and custom prompts into a single array. - Allow custom prompts to be included wherever keys are specified. - Ensure default values for custom prompts are correctly retrieved and utilized. - Simplify the logic for aggregating both built-in and custom prompts into a single comprehensive list. This change enhances flexibility for developers using custom prompts with create-block.
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. |
This is looking very promising. One note is that the proposed API depends on
The most recent version is |
I started migrating Inquirer.js to the latest version: The recommend using now |
#67877 is ready to review. There were a few API changes which are essential before we offered support for custom prompts. Let's land that one first and update this PR accordingly. |
I've approved #67877. |
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've added some suggestions that will fix the whitespace issues in the PR.
Co-authored-by: Ryan Welcher <[email protected]>
@wordpress/create-block
to Support Custom Prompts in External Templates
Hey @ryanwelcher, @gziolo! I’ve been thinking about the ideal structure of how this should work, before working on an actual implementation. I put together a document trying to cover all the edge cases. I'd love for you to check it out and let me know if it makes sense or if I’m missing anything. Overview
Proposed Design
Next Steps
Thanks for checking it out! |
Closes #47524
What?
This PR enhances the
@wordpress/create-block
package by allowing external project templates to define custom prompts, enabling developers to specify additional parameters during block or plugin creation.Why?
Currently, the
@create-block
package limits users to a predefined set of prompts, restricting customization based on specific project needs. Allowing custom prompts provides greater flexibility and aligns the tool with diverse development requirements.How?
The implementation involves modifying the
getDefaultValues
andgetPrompts
functions within thetemplates.js
file to recognize and incorporate custom parameters defined in external templates. This ensures that during the scaffolding process, any additional prompts specified are presented to the user and their inputs are integrated into the generated project files.Testing Instructions
@create-block
package to generate a new block or plugin with the custom template.Testing Instructions for Keyboard
Screenshots or screencast
This quick demo contains a couple of examples of how I'd envision this working:
000445.mp4
Heres the code for: my-template/index.js
This enhancement addresses the need for customizable prompts in the
@create-block
package, as discussed in issue #47524.