From 3c795f447deeff316ed0d4150a97c20b09103f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Thu, 5 May 2022 17:00:55 +0200 Subject: [PATCH 1/5] Make sync-gutenberg-packages task regenerate PHP packages by running the build task before build:dev --- Gruntfile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gruntfile.js b/Gruntfile.js index 2ff1b92bf6d7f..423842d7ddb9e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1247,6 +1247,8 @@ module.exports = function(grunt) { */ grunt.task.run( 'wp-packages:refresh-deps' ); + grunt.task.run( 'build' ); + // Build the files stored in the src/ directory. grunt.task.run( 'build:dev' ); } ); From c5b4370fa6a2731ddc48861fb20e63fb427636a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 10 May 2022 15:38:55 +0200 Subject: [PATCH 2/5] Set dev option to true in order to trigger the development version of the build task --- Gruntfile.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 423842d7ddb9e..72c7a22564b09 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1250,7 +1250,9 @@ module.exports = function(grunt) { grunt.task.run( 'build' ); // Build the files stored in the src/ directory. - grunt.task.run( 'build:dev' ); + // Set the --dev option to true + grunt.option( 'dev', true ); + grunt.task.run( 'build' ); } ); grunt.renameTask( 'watch', '_watch' ); From 61562427d8c2fa1f81b35b219991f7607db3a8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 10 May 2022 15:46:57 +0200 Subject: [PATCH 3/5] Restruct the browserlist:update to the latest dist tag on trunk --- Gruntfile.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 72c7a22564b09..3a2496b30ae05 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1219,22 +1219,24 @@ 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 - */ + /* + * 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' ], { + cwd: __dirname, + } ).stdout.toString().trim(); + + if ( distTag === 'latest' && currentBranch === 'trunk' ) { grunt.task.run( 'browserslist:update' ); } From ea2506d4dee9effc37711c1a7e14ddae9b2fc028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 10 May 2022 16:26:43 +0200 Subject: [PATCH 4/5] Require the --dev flag from CLI --- Gruntfile.js | 12 ++++++++---- package.json | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 3a2496b30ae05..a451f68f91f2c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1219,6 +1219,14 @@ module.exports = function(grunt) { ] ); grunt.registerTask( 'sync-gutenberg-packages', function() { + 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. @@ -1249,11 +1257,7 @@ module.exports = function(grunt) { */ grunt.task.run( 'wp-packages:refresh-deps' ); - grunt.task.run( 'build' ); - // Build the files stored in the src/ directory. - // Set the --dev option to true - grunt.option( 'dev', true ); grunt.task.run( 'build' ); } ); diff --git a/package.json b/package.json index 4ed33eac1a886..0c3a4715ae716 100644 --- a/package.json +++ b/package.json @@ -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" } } From 259685e51f4d22bb4bea94a2c10162444dec820f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Tue, 10 May 2022 16:34:48 +0200 Subject: [PATCH 5/5] Restore the previous way of updating browserlist --- Gruntfile.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a451f68f91f2c..ccb4c697954ac 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1227,24 +1227,22 @@ module.exports = function(grunt) { 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' ], { - cwd: __dirname, - } ).stdout.toString().trim(); - - if ( distTag === 'latest' && currentBranch === 'trunk' ) { + 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 + */ grunt.task.run( 'browserslist:update' ); }