Skip to content
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

Regenerate PHP packages in the sync-gutenberg-packages task #2679

Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 27 additions & 17 deletions Gruntfile.js
Expand Up @@ -1219,22 +1219,32 @@ module.exports = function(grunt) {
] );

grunt.registerTask( 'sync-gutenberg-packages', function() {
if ( grunt.option( 'update-browserlist' ) ) {
/*
* Updating the browserlist database is opt-in and up to the release lead.
*
* Browserlist database should be updated:
* - In each release cycle up until RC1
* - If Webpack throws a warning about an outdated database
*
* It should not be updated:
* - After the RC1
* - When backporting fixes to older WordPress releases.
*
* For more context, see:
* https://github.com/WordPress/wordpress-develop/pull/2621#discussion_r859840515
* https://core.trac.wordpress.org/ticket/55559
*/
if ( ! grunt.option( 'dev' ) ) {
console.log( 'You must manually pass the --dev flag to the sync-gutenberg-packages task as follows:' );
console.log( 'npx grunt sync-gutenberg-packages --dev' );
console.log( 'Otherwise the webpack build tasks are executed in the production mode and do not ');
console.log( 'regenerate the src/wp-includes/assets/script-loader-packages.php.' );
process.exit( 0 );
}

/*
* Browserlist database should be updated when the packages are
* being updated to their latest version in the trunk branch.
*
* It should not happen during the patch releases. Otherwise,
* we'd be changing the supported browsers of a WP release on patch release.
*
* For more context, see:
*
* https://github.com/WordPress/gutenberg/issues/33344
* https://core.trac.wordpress.org/ticket/55559
*/
const distTag = grunt.option('dist-tag') || 'latest';
const currentBranch = spawn( 'git', [ 'branch', '--show-current' ], {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't work for svn users 😅

However, I think it's very unlikely you would run latest outside of the trunk branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not block this PR on that and move this discussion to a separate one

cwd: __dirname,
} ).stdout.toString().trim();

if ( distTag === 'latest' && currentBranch === 'trunk' ) {
grunt.task.run( 'browserslist:update' );
}

Expand All @@ -1248,7 +1258,7 @@ module.exports = function(grunt) {
grunt.task.run( 'wp-packages:refresh-deps' );

// Build the files stored in the src/ directory.
grunt.task.run( 'build:dev' );
grunt.task.run( 'build' );
} );

grunt.renameTask( 'watch', '_watch' );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -175,6 +175,6 @@
"test:php": "node ./tools/local-env/scripts/docker.js run -T php composer update -W && node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit",
"test:e2e": "node ./tests/e2e/run-tests.js",
"test:visual": "node ./tests/visual-regression/run-tests.js",
"sync-gutenberg-packages": "grunt sync-gutenberg-packages"
"sync-gutenberg-packages": "grunt sync-gutenberg-packages --dev"
}
}