Skip to content

Commit 40e2ce0

Browse files
Revert "Build/Test Tools: Remove the requirement to clone/build Gutenberg."
This reverts commit 49d8c11.
1 parent 5078e32 commit 40e2ce0

10 files changed

Lines changed: 1092 additions & 522 deletions

File tree

Gruntfile.js

Lines changed: 34 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = function(grunt) {
5353
webpackFiles = [
5454
'wp-includes/assets/*',
5555
'wp-includes/css/dist',
56+
'wp-includes/blocks/**/*.css',
5657
'!wp-includes/assets/script-loader-packages.min.php',
5758
'!wp-includes/assets/script-modules-packages.min.php',
5859
],
@@ -587,97 +588,7 @@ module.exports = function(grunt) {
587588
certificates: {
588589
src: 'vendor/composer/ca-bundle/res/cacert.pem',
589590
dest: SOURCE_DIR + 'wp-includes/certificates/ca-bundle.crt'
590-
},
591-
// Gutenberg PHP infrastructure files (routes.php, pages.php, constants.php, pages/, routes/).
592-
'gutenberg-php': {
593-
options: {
594-
process: function( content ) {
595-
// Fix boot module asset file path for Core's different directory structure.
596-
return content.replace(
597-
/__DIR__\s*\.\s*(['"])\/..\/\..\/modules\/boot\/index\.min\.asset\.php\1/g,
598-
'ABSPATH . WPINC . \'/js/dist/script-modules/boot/index.min.asset.php\''
599-
);
600-
}
601-
},
602-
files: [ {
603-
expand: true,
604-
cwd: 'gutenberg/build',
605-
src: [
606-
'routes.php',
607-
'pages.php',
608-
'constants.php',
609-
'pages/**/*.php',
610-
'routes/**/*.php',
611-
],
612-
dest: WORKING_DIR + 'wp-includes/build/',
613-
} ],
614-
},
615-
'gutenberg-modules': {
616-
files: [ {
617-
expand: true,
618-
cwd: 'gutenberg/build/modules',
619-
src: [ '**/*', '!**/*.map' ],
620-
dest: WORKING_DIR + 'wp-includes/js/dist/script-modules/',
621-
} ],
622-
},
623-
'gutenberg-styles': {
624-
files: [ {
625-
expand: true,
626-
cwd: 'gutenberg/build/styles',
627-
src: [ '**/*', '!**/*.map' ],
628-
dest: WORKING_DIR + 'wp-includes/css/dist/',
629-
} ],
630-
},
631-
'gutenberg-theme-json': {
632-
options: {
633-
process: function( content, srcpath ) {
634-
// Replace the local schema URL with the canonical public URL for Core.
635-
if ( path.basename( srcpath ) === 'theme.json' ) {
636-
return content.replace(
637-
'"$schema": "../schemas/json/theme.json"',
638-
'"$schema": "https://schemas.wp.org/trunk/theme.json"'
639-
);
640-
}
641-
return content;
642-
}
643-
},
644-
files: [
645-
{
646-
src: 'gutenberg/lib/theme.json',
647-
dest: WORKING_DIR + 'wp-includes/theme.json',
648-
},
649-
{
650-
src: 'gutenberg/lib/theme-i18n.json',
651-
dest: WORKING_DIR + 'wp-includes/theme-i18n.json',
652-
},
653-
],
654-
},
655-
'gutenberg-icons': {
656-
options: {
657-
process: function( content, srcpath ) {
658-
// Remove the 'gutenberg' text domain from _x() calls in manifest.php.
659-
if ( path.basename( srcpath ) === 'manifest.php' ) {
660-
return content.replace(
661-
/_x\(\s*([^,]+),\s*([^,]+),\s*['"]gutenberg['"]\s*\)/g,
662-
'_x( $1, $2 )'
663-
);
664-
}
665-
return content;
666-
}
667-
},
668-
files: [
669-
{
670-
src: 'gutenberg/packages/icons/src/manifest.php',
671-
dest: WORKING_DIR + 'wp-includes/icons/manifest.php',
672-
},
673-
{
674-
expand: true,
675-
cwd: 'gutenberg/packages/icons/src/library',
676-
src: '*.svg',
677-
dest: WORKING_DIR + 'wp-includes/icons/library/',
678-
},
679-
],
680-
},
591+
}
681592
},
682593
sass: {
683594
colors: {
@@ -1412,21 +1323,20 @@ module.exports = function(grunt) {
14121323
},
14131324
{
14141325
expand: true,
1415-
cwd: BUILD_DIR + 'wp-includes/js/dist/',
1416-
src: [ '*.js' ],
1417-
dest: BUILD_DIR + 'wp-includes/js/dist/',
1418-
},
1419-
{
1420-
expand: true,
1421-
cwd: BUILD_DIR + 'wp-includes/js/dist/vendor/',
1422-
src: [ '**/*.js' ],
1423-
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/',
1326+
flatten: true,
1327+
src: [
1328+
BUILD_DIR + 'wp-includes/js/dist/block-editor.js',
1329+
BUILD_DIR + 'wp-includes/js/dist/commands.js',
1330+
],
1331+
dest: BUILD_DIR + 'wp-includes/js/dist/'
14241332
},
14251333
{
14261334
expand: true,
1427-
cwd: BUILD_DIR + 'wp-includes/js/dist/script-modules/',
1428-
src: [ '**/*.js' ],
1429-
dest: BUILD_DIR + 'wp-includes/js/dist/script-modules/',
1335+
flatten: true,
1336+
src: [
1337+
BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
1338+
],
1339+
dest: BUILD_DIR + 'wp-includes/js/dist/vendor/'
14301340
}
14311341
]
14321342
}
@@ -1565,38 +1475,45 @@ module.exports = function(grunt) {
15651475
} );
15661476

15671477
// Gutenberg integration tasks.
1568-
grunt.registerTask( 'gutenberg:verify', 'Verifies the installed Gutenberg version matches the expected SHA.', function() {
1478+
grunt.registerTask( 'gutenberg-checkout', 'Checks out the Gutenberg repository.', function() {
15691479
const done = this.async();
15701480
grunt.util.spawn( {
15711481
cmd: 'node',
1572-
args: [ 'tools/gutenberg/utils.js' ],
1482+
args: [ 'tools/gutenberg/checkout-gutenberg.js' ],
15731483
opts: { stdio: 'inherit' }
15741484
}, function( error ) {
15751485
done( ! error );
15761486
} );
15771487
} );
15781488

1579-
grunt.registerTask( 'gutenberg:download', 'Downloads the built Gutenberg artifact.', function() {
1489+
grunt.registerTask( 'gutenberg-build', 'Builds the Gutenberg repository.', function() {
15801490
const done = this.async();
1581-
const args = [ 'tools/gutenberg/download.js' ];
1582-
if ( grunt.option( 'force' ) ) {
1583-
args.push( '--force' );
1584-
}
15851491
grunt.util.spawn( {
15861492
cmd: 'node',
1587-
args,
1493+
args: [ 'tools/gutenberg/build-gutenberg.js' ],
15881494
opts: { stdio: 'inherit' }
15891495
}, function( error ) {
15901496
done( ! error );
15911497
} );
15921498
} );
15931499

1594-
grunt.registerTask( 'gutenberg:copy', 'Copies Gutenberg JS packages and block assets to WordPress Core.', function() {
1500+
grunt.registerTask( 'gutenberg-copy', 'Copies Gutenberg build output to WordPress Core.', function() {
15951501
const done = this.async();
15961502
const buildDir = grunt.option( 'dev' ) ? 'src' : 'build';
15971503
grunt.util.spawn( {
15981504
cmd: 'node',
1599-
args: [ 'tools/gutenberg/copy.js', `--build-dir=${ buildDir }` ],
1505+
args: [ 'tools/gutenberg/copy-gutenberg-build.js', `--build-dir=${ buildDir }` ],
1506+
opts: { stdio: 'inherit' }
1507+
}, function( error ) {
1508+
done( ! error );
1509+
} );
1510+
} );
1511+
1512+
grunt.registerTask( 'gutenberg-sync', 'Syncs Gutenberg checkout and build if ref has changed.', function() {
1513+
const done = this.async();
1514+
grunt.util.spawn( {
1515+
cmd: 'node',
1516+
args: [ 'tools/gutenberg/sync-gutenberg.js' ],
16001517
opts: { stdio: 'inherit' }
16011518
}, function( error ) {
16021519
done( ! error );
@@ -2039,35 +1956,26 @@ module.exports = function(grunt) {
20391956
} );
20401957
} );
20411958

2042-
grunt.registerTask( 'build:gutenberg', [
2043-
'copy:gutenberg-php',
2044-
'gutenberg:copy',
2045-
'copy:gutenberg-modules',
2046-
'copy:gutenberg-styles',
2047-
'copy:gutenberg-theme-json',
2048-
'copy:gutenberg-icons',
2049-
] );
2050-
20511959
grunt.registerTask( 'build', function() {
20521960
if ( grunt.option( 'dev' ) ) {
20531961
grunt.task.run( [
2054-
'gutenberg:verify',
20551962
'build:js',
20561963
'build:css',
20571964
'build:codemirror',
2058-
'build:gutenberg',
1965+
'gutenberg-sync',
1966+
'gutenberg-copy',
20591967
'copy-vendor-scripts',
20601968
'build:certificates'
20611969
] );
20621970
} else {
20631971
grunt.task.run( [
2064-
'gutenberg:verify',
20651972
'build:certificates',
20661973
'build:files',
20671974
'build:js',
20681975
'build:css',
20691976
'build:codemirror',
2070-
'build:gutenberg',
1977+
'gutenberg-sync',
1978+
'gutenberg-copy',
20711979
'copy-vendor-scripts',
20721980
'replace:source-maps',
20731981
'verify:build'

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"url": "https://develop.svn.wordpress.org/trunk"
88
},
99
"gutenberg": {
10-
"sha": "74a4f254a45f7a303bd27b8f8e104786380e8103",
11-
"ghcrRepo": "WordPress/gutenberg/gutenberg-wp-develop-build"
10+
"ref": "9b8144036fa5faf75de43d4502ff9809fcf689ad"
1211
},
1312
"engines": {
1413
"node": ">=20.10.0",
@@ -112,10 +111,9 @@
112111
"wicg-inert": "3.1.3"
113112
},
114113
"scripts": {
115-
"postinstall": "npm run gutenberg:download",
114+
"postinstall": "npm run gutenberg:sync && npm run gutenberg:copy -- --dev",
116115
"build": "grunt build",
117116
"build:dev": "grunt build --dev",
118-
"build:gutenberg": "grunt build:gutenberg",
119117
"dev": "grunt watch --dev",
120118
"test": "grunt test",
121119
"watch": "grunt watch",
@@ -139,8 +137,10 @@
139137
"test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.js",
140138
"test:visual": "wp-scripts test-playwright --config tests/visual-regression/playwright.config.js",
141139
"typecheck:php": "node ./tools/local-env/scripts/docker.js run --rm php composer phpstan",
142-
"gutenberg:copy": "node tools/gutenberg/copy.js",
143-
"gutenberg:download": "node tools/gutenberg/download.js",
140+
"gutenberg:checkout": "node tools/gutenberg/checkout-gutenberg.js",
141+
"gutenberg:build": "node tools/gutenberg/build-gutenberg.js",
142+
"gutenberg:copy": "node tools/gutenberg/copy-gutenberg-build.js",
143+
"gutenberg:sync": "node tools/gutenberg/sync-gutenberg.js",
144144
"vendor:copy": "node tools/vendors/copy-vendors.js",
145145
"sync-gutenberg-packages": "grunt sync-gutenberg-packages",
146146
"postsync-gutenberg-packages": "grunt wp-packages:sync-stable-blocks && grunt build --dev && grunt build"

tests/phpstan/base.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ parameters:
105105
- ../../src/wp-includes/deprecated.php
106106
- ../../src/wp-includes/ms-deprecated.php
107107
- ../../src/wp-includes/pluggable-deprecated.php
108-
# These files are autogenerated by tools/gutenberg/copy.js.
108+
# These files are sourced by wordpress/gutenberg in `tools/release/sync-stable-blocks.js`.
109109
- ../../src/wp-includes/blocks
110110
# Third-party libraries.
111111
- ../../src/wp-admin/includes/class-ftp-pure.php

0 commit comments

Comments
 (0)