-
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
Scripts: Add create-block
script for bootstrapping a minimal block development plugin.
#18650
Conversation
|
||
```sh | ||
$ wp-scripts create-block "My Fancy Block" | ||
$ cd ./my-fancy-block-plugin |
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.
If the plugin is called "My Fancy Block" does it append -plugin
to the folder created?
If not, then:
$ cd ./my-fancy-block-plugin | |
$ cd ./my-fancy-block |
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.
If the plugin is called "My Fancy Block" does it append -plugin to the folder created?
Yes, "My Fancy Block" is the block name.
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.
Why append -plugin
to the plugin name? Why not just my-fancy-block
for the slug?
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.
So that they are not the same.
Is there a convention for this?
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.
With create-react-app
whatever name I use is converted to kebab-case, no extra -app
or -plugin
is appended to the name.
And for the most part if I would expect the name to be what name I gave, if I gave "My Fancy Block Plugin" then I would expect the -plugin
included in the slug
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.
So that they are not the same.
Is there any concerns where having the plugin name and plugin slug the same that would be of concern?
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.
With create-react-app whatever name I use is converted to snake-case, no extra -app or -plugin is appended to the name.
Yes, because you are naming the app, and the app only.
And for the most part if I would expect the name to be what name I gave, if I gave "My Fancy Block Plugin" then I would expect the -plugin included in the slug
You are not naming the plugin, you are naming the block, and the plugin name gets generated from that.
Is there any concerns where having the plugin name and plugin slug the same that would be of concern?
No, I think it's just a style thing. I don't have a strong opinion on it.
Previous work by @ajitbohra #10628. There is also a related full proposal what could be implemented in #10629. |
* | ||
* @since 1.0.0 | ||
*/ | ||
function block_plugin_name_enqueue_block_assets() { |
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.
Testing this PR
Uncaught Error: syntax error, unexpected '-', expecting '(' in /wp-content/plugins/my-block-plugin/plugin.php on line 16
The function name is being generated as:
my-block-plugin_enqueue_block_assets()
Instead of kebabCase, the my-block-plugin
needs to be snakeCase:
my_block_plugin_enqueue_block_assets()
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.
Oops, should be fixed now. Thanks for catching this!
Having now read and tested the other PR @gziolo highlighted above I'd prefer we continued working on that plugin, thoughts @epiqueras ? |
That makes sense. Do you think it's worth our time to be working on this at all right now though? The block registration RFC should make this so much easier right? Maybe that's a better start to making block authoring easier. |
Description
This PR adds a new command to
@wordpress/scripts
that takes a new name for a block and creates a minimal plugin development environment for it in the current working directory.Example:
It's good to have a tool like this in the monorepo so that it can be kept up to date with updates to block registration APIs.
How has this been tested?
It was verified that running the commands in the example works as expected.
Types of Changes
New Feature:
@wordpress/scripts
now has acreate-block
command for bootstrapping a minimal block plugin development environment.Checklist: