-
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: Improve custom project template configuration #39049
Create Block: Improve custom project template configuration #39049
Conversation
Size Change: 0 B Total Size: 1.15 MB ℹ️ View Unchanged
|
1bfc038
to
4a2aed3
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.
This is fantastic! Just a couple of small notes/questions.
57eb4fe
to
1cebad1
Compare
@ryanwelcher, can you check again? |
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!
* Create Block: Improve project template configuration * Update the tutorial for block creation * Create Block: Improve documentation
expected=6 | ||
actual=$( find src -maxdepth 1 -type f | wc -l ) | ||
if [ "$expected" -ne "$actual" ]; then | ||
error "Expected $expected files in the `src` directory, but found $actual." |
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.
@gziolo: In sh and bash, backticks are the old way to represent command substitution. Which means that the line above actually evals as:
error "Expected $expected files in the $(src) directory ..."
which will invoke src
as a command that it will try to find in $PATH
, which will either fail or do something that we don't want.
The fix should be to escape:
error "Expected $expected files in the \`src\` directory, but found $actual."
The same applies for this other occurrence in the file:
error "Expected $expected files in the `build` directory, but found $actual."
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.
Great to know. I'll update all that tomorrow. Thank you for the comment.
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.
It took me 20 days, but PR is ready: #40473 😅
Description
Part of #25188. It addresses the action items listed by @ryanwelcher in #25188 (comment):
Changes applied
Breaking Changes
templatesPath
option when configuring the custom project template for@wordpress/create-block
.@wordpress/create-block
will use default template files during scaffolding for the WordPress plugin shell and/or individual blocks. It is possible to replace them with a custom set of template files by using thepluginTemplatesPath
and/orblockTemplatesPath
options.esnext
project template got renamed tostatic
in@wordpress/create-block
.Deprecations
@wordpress/create-block
, thetemplatesPath
option got renamed topluginTemplatesPath
. The old name still works but is considered deprecated, and it might get removed in the futureDocumentation
@wordpress/create-block
package.Create a Block Tutorial
Fixes #27565. As part of the efforts, I updated
@wordpress/create-block-tutorial-template
package to become compatible with the new project template configuration. I also updated all pages inCreate a Block Tutorial
to align closely with the scaffolder project.Automated Testing
Finally, I extended
./bin/test-create-block.sh
script that runs verification on Continues Integration to cover two basic templates:static
es5
Testing Instructions
I scaffolded three test blocks using templates included in Gutenberg for the
@wordpress/create-block
package.npx wp-create-block example-static --no-wp-scripts cd example-static ../node_modules/.bin/wp-scripts build
npx wp-create-block gutenpride --template @wordpress/create-block-tutorial-template --no-wp-scripts cd gutenpride ../node_modules/.bin/wp-scripts build
I tested all 3 blocks and they still work as intended when inserted into the post or theme template.
I also ensured that all verification pass on CI and locally for the integration tests that can be executed with:
Types of changes
Breaking change (fix or feature that would cause existing functionality to not work as expected).
Checklist:
*.native.js
files for terms that need renaming or removal).