-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Automatically sync stable blocks from Gutenberg to wordpress-develop on release #2647
Automatically sync stable blocks from Gutenberg to wordpress-develop on release #2647
Conversation
6156cc3
to
561afb3
Compare
fd53449
to
da8e778
Compare
da8e778
to
9193299
Compare
…he autogenerated files
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 looks great. I left some minor comments but overall it's ready for testing with the real changes coming from the Gutenberg repository and the most recent version of WordPress packages. We should give it a try updating WP packages in trunk
next week with all the automations we have in place now and see if that is ready to land.
A good example of what type of issues this patch would prevent: WordPress/gutenberg#41292 (comment). |
…whether the file is being called directly
Co-authored-by: Pascal Birchler <[email protected]>
…wordpress-develop into add/sync-stable-blocks-utility
This one should be ready to go @gziolo @swissspidy! |
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'll give it a spin with the trunk
and see if it works as intended. Otherwise, it feels like it's ready to land and improve the way we handle syncing blocks. Excellent work @adamziel! ❤️
require ABSPATH . WPINC . '/blocks/widget-group.php'; | ||
require ABSPATH . WPINC . '/blocks/require-blocks.php'; |
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.
Nit: Let's move /blocks/require-blocks.php
as the first import before all special cases.
@@ -1698,6 +1703,12 @@ module.exports = function(grunt) { | |||
} ); | |||
} ); | |||
|
|||
grunt.registerTask( 'wp-packages:sync-stable-blocks', 'Refresh the PHP files referring to stable @wordpress/block-library blocks.', function() { | |||
grunt.log.writeln( `Syncing stable blocks from @wordpress/block-library to src/` ); | |||
const { main } = require( __dirname + '/tools/release/sync-stable-blocks' ); |
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.
Any reason we can't use?
const { main } = require( __dirname + '/tools/release/sync-stable-blocks' ); | |
const { main } = require( './tools/release/sync-stable-blocks' ); |
Is there also any reason why it has to be required dynamically rather than in the header of the file?
I'm seeing the following error after executing in the most recent
I noticed two things:
So I might find the answer to my question from #2647 (comment). We update all the packages first, and we should dynamically discover core blocks at this point. We probably do it before and that would be the reason of this error. |
The good news is that second run of There is also an edge case which we probably can ignore. We have now two folders There is one more place where the list of block names is hardcoded and it would be great to move it to automatically generated file: wordpress-develop/src/wp-includes/blocks/index.php Lines 78 to 106 in 0abc2b2
Otherwise, new core blocks that are static (no PHP file) won't get registered on the server. |
I had to open #2940 to rebase this branch with |
What problem does this PR solve?
Syncing stable blocks from the Gutenberg repository to
wordpress-develop
is currently a manual process.The thing is, it can be automated.
That's what this PR does.
How does this PR solve it?
The big idea is to:
block.json
files from the@wordpress/block-library
directory.__experimental
restrictions – these are the stable blocks.require
s appropriate dynamic blocks PHP files.remove_action
with appropriate arguments in PHP unit tests.All of this is possible thanks to WordPress/gutenberg#40655
To make the process smooth,
require
andremove_action
calls were extracted to separate PPH files that can be easily autogenerated and overwritten:wp-includes/blocks/require-blocks.php
tests/phpunit/includes/unregister-blocks-hooks.php
How to test?
npx grunt sync-gutenberg-packages
post-author-name
were excluded from both listscc @gziolo