Skip to content

Commit a58af85

Browse files
committed
Build/Test Tools: Copy block editor files to src after download.
The block editor-related files were previously present in the `src` directory and subject to version control. However, [61439] removed them from version control and has broken some workflows and testing setups that run the PHPUnit tests from `src`. There is work ongoing to restore those files to version control with their respective change history. But until that happens, this updates the `download.js` script and `gutenberg:download` Grunt task to run `build:gutenberg —dev` every time the build asset is downloaded to ensure the files are present in `src`. Props mywp459, amykamala, jorbin. Fixes #64716. See #64393. git-svn-id: https://develop.svn.wordpress.org/trunk@62052 602fd350-edb4-49c9-b593-d223f7449a82
1 parent dc20352 commit a58af85

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Gruntfile.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,25 @@ module.exports = function(grunt) {
16071607
args: [ 'tools/gutenberg/download.js' ],
16081608
opts: { stdio: 'inherit' }
16091609
}, function( error ) {
1610-
done( ! error );
1610+
if ( error ) {
1611+
done( false );
1612+
return;
1613+
}
1614+
/*
1615+
* Build block editor files into the src directory every time assets
1616+
* are downloaded. This prevents failures when running from src
1617+
* without running `build:dev` after those files were removed from
1618+
* version control in https://core.trac.wordpress.org/changeset/61438.
1619+
*
1620+
* See https://core.trac.wordpress.org/ticket/64393.
1621+
*/
1622+
grunt.util.spawn( {
1623+
grunt: true,
1624+
args: [ 'build:gutenberg', '--dev' ],
1625+
opts: { stdio: 'inherit' }
1626+
}, function( buildError ) {
1627+
done( ! buildError );
1628+
} );
16111629
} );
16121630
} );
16131631

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"typecheck:php": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan",
142142
"gutenberg:copy": "node tools/gutenberg/copy.js",
143143
"gutenberg:verify": "node tools/gutenberg/utils.js",
144-
"gutenberg:download": "node tools/gutenberg/download.js",
144+
"gutenberg:download": "node tools/gutenberg/download.js && grunt build:gutenberg --dev",
145145
"vendor:copy": "node tools/vendors/copy-vendors.js",
146146
"sync-gutenberg-packages": "grunt sync-gutenberg-packages",
147147
"postsync-gutenberg-packages": "grunt wp-packages:sync-stable-blocks && grunt build --dev && grunt build"

tools/gutenberg/utils.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@ function readGutenbergConfig() {
4242
}
4343

4444
/**
45-
* Trigger a fresh download of the Gutenberg artifact by spawning download.js.
46-
* Exits the process if the download fails.
45+
* Trigger a fresh download of the Gutenberg artifact by spawning download.js,
46+
* then run `grunt build:gutenberg --dev` to copy the build to src/.
47+
* Exits the process if either step fails.
4748
*/
4849
function downloadGutenberg() {
49-
const result = spawnSync( 'node', [ path.join( __dirname, 'download.js' ) ], { stdio: 'inherit' } );
50-
if ( result.status !== 0 ) {
51-
process.exit( result.status ?? 1 );
50+
const downloadResult = spawnSync( 'node', [ path.join( __dirname, 'download.js' ) ], { stdio: 'inherit' } );
51+
if ( downloadResult.status !== 0 ) {
52+
process.exit( downloadResult.status ?? 1 );
53+
}
54+
55+
const buildResult = spawnSync( 'grunt', [ 'build:gutenberg', '--dev' ], { stdio: 'inherit', shell: true } );
56+
if ( buildResult.status !== 0 ) {
57+
process.exit( buildResult.status ?? 1 );
5258
}
5359
}
5460

0 commit comments

Comments
 (0)