@@ -53,7 +53,6 @@ module.exports = function(grunt) {
5353 webpackFiles = [
5454 'wp-includes/assets/*' ,
5555 'wp-includes/css/dist' ,
56- 'wp-includes/blocks/**/*.css' ,
5756 '!wp-includes/assets/script-loader-packages.min.php' ,
5857 '!wp-includes/assets/script-modules-packages.min.php' ,
5958 ] ,
@@ -588,7 +587,108 @@ module.exports = function(grunt) {
588587 certificates : {
589588 src : 'vendor/composer/ca-bundle/res/cacert.pem' ,
590589 dest : SOURCE_DIR + 'wp-includes/certificates/ca-bundle.crt'
591- }
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+ / _ _ D I R _ _ \s * \. \s * ( [ ' " ] ) \/ ..\/ \. .\/ m o d u l e s \/ b o o t \/ i n d e x \. m i n \. a s s e t \. p h p \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-js' : {
616+ files : [ {
617+ expand : true ,
618+ cwd : 'gutenberg/build' ,
619+ src : [
620+ 'pages/**/*.js' ,
621+ 'routes/**/*.js' ,
622+ ] ,
623+ dest : WORKING_DIR + 'wp-includes/build/' ,
624+ } ] ,
625+ } ,
626+ 'gutenberg-modules' : {
627+ files : [ {
628+ expand : true ,
629+ cwd : 'gutenberg/build/modules' ,
630+ src : [ '**/*' , '!**/*.map' ] ,
631+ dest : WORKING_DIR + 'wp-includes/js/dist/script-modules/' ,
632+ } ] ,
633+ } ,
634+ 'gutenberg-styles' : {
635+ files : [ {
636+ expand : true ,
637+ cwd : 'gutenberg/build/styles' ,
638+ src : [ '**/*' , '!**/*.map' ] ,
639+ dest : WORKING_DIR + 'wp-includes/css/dist/' ,
640+ } ] ,
641+ } ,
642+ 'gutenberg-theme-json' : {
643+ options : {
644+ process : function ( content , srcpath ) {
645+ // Replace the local schema URL with the canonical public URL for Core.
646+ if ( path . basename ( srcpath ) === 'theme.json' ) {
647+ return content . replace (
648+ '"$schema": "../schemas/json/theme.json"' ,
649+ '"$schema": "https://schemas.wp.org/trunk/theme.json"'
650+ ) ;
651+ }
652+ return content ;
653+ }
654+ } ,
655+ files : [
656+ {
657+ src : 'gutenberg/lib/theme.json' ,
658+ dest : WORKING_DIR + 'wp-includes/theme.json' ,
659+ } ,
660+ {
661+ src : 'gutenberg/lib/theme-i18n.json' ,
662+ dest : WORKING_DIR + 'wp-includes/theme-i18n.json' ,
663+ } ,
664+ ] ,
665+ } ,
666+ 'gutenberg-icons' : {
667+ options : {
668+ process : function ( content , srcpath ) {
669+ // Remove the 'gutenberg' text domain from _x() calls in manifest.php.
670+ if ( path . basename ( srcpath ) === 'manifest.php' ) {
671+ return content . replace (
672+ / _ x \( \s * ( [ ^ , ] + ) , \s * ( [ ^ , ] + ) , \s * [ ' " ] g u t e n b e r g [ ' " ] \s * \) / g,
673+ '_x( $1, $2 )'
674+ ) ;
675+ }
676+ return content ;
677+ }
678+ } ,
679+ files : [
680+ {
681+ src : 'gutenberg/packages/icons/src/manifest.php' ,
682+ dest : WORKING_DIR + 'wp-includes/icons/manifest.php' ,
683+ } ,
684+ {
685+ expand : true ,
686+ cwd : 'gutenberg/packages/icons/src/library' ,
687+ src : '*.svg' ,
688+ dest : WORKING_DIR + 'wp-includes/icons/library/' ,
689+ } ,
690+ ] ,
691+ } ,
592692 } ,
593693 sass : {
594694 colors : {
@@ -1323,20 +1423,21 @@ module.exports = function(grunt) {
13231423 } ,
13241424 {
13251425 expand : true ,
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/'
1426+ cwd : BUILD_DIR + 'wp-includes/js/dist/' ,
1427+ src : [ '*.js' ] ,
1428+ dest : BUILD_DIR + 'wp-includes/js/dist/' ,
13321429 } ,
13331430 {
13341431 expand : true ,
1335- flatten : true ,
1336- src : [
1337- BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
1338- ] ,
1339- dest : BUILD_DIR + 'wp-includes/js/dist/vendor/'
1432+ cwd : BUILD_DIR + 'wp-includes/js/dist/vendor/' ,
1433+ src : [ '**/*.js' ] ,
1434+ dest : BUILD_DIR + 'wp-includes/js/dist/vendor/' ,
1435+ } ,
1436+ {
1437+ expand : true ,
1438+ cwd : BUILD_DIR + 'wp-includes/js/dist/script-modules/' ,
1439+ src : [ '**/*.js' ] ,
1440+ dest : BUILD_DIR + 'wp-includes/js/dist/script-modules/' ,
13401441 }
13411442 ]
13421443 }
@@ -1475,45 +1576,38 @@ module.exports = function(grunt) {
14751576 } ) ;
14761577
14771578 // Gutenberg integration tasks.
1478- grunt . registerTask ( 'gutenberg-checkout ' , 'Checks out the Gutenberg repository .' , function ( ) {
1579+ grunt . registerTask ( 'gutenberg:verify ' , 'Verifies the installed Gutenberg version matches the expected SHA .' , function ( ) {
14791580 const done = this . async ( ) ;
14801581 grunt . util . spawn ( {
14811582 cmd : 'node' ,
1482- args : [ 'tools/gutenberg/checkout-gutenberg .js' ] ,
1583+ args : [ 'tools/gutenberg/utils .js' ] ,
14831584 opts : { stdio : 'inherit' }
14841585 } , function ( error ) {
14851586 done ( ! error ) ;
14861587 } ) ;
14871588 } ) ;
14881589
1489- grunt . registerTask ( 'gutenberg-build ' , 'Builds the Gutenberg repository .' , function ( ) {
1590+ grunt . registerTask ( 'gutenberg:download ' , 'Downloads the built Gutenberg artifact .' , function ( ) {
14901591 const done = this . async ( ) ;
1592+ const args = [ 'tools/gutenberg/download.js' ] ;
1593+ if ( grunt . option ( 'force' ) ) {
1594+ args . push ( '--force' ) ;
1595+ }
14911596 grunt . util . spawn ( {
14921597 cmd : 'node' ,
1493- args : [ 'tools/gutenberg/build-gutenberg.js' ] ,
1598+ args,
14941599 opts : { stdio : 'inherit' }
14951600 } , function ( error ) {
14961601 done ( ! error ) ;
14971602 } ) ;
14981603 } ) ;
14991604
1500- grunt . registerTask ( 'gutenberg- copy' , 'Copies Gutenberg build output to WordPress Core.' , function ( ) {
1605+ grunt . registerTask ( 'gutenberg: copy' , 'Copies Gutenberg JS packages and block assets to WordPress Core.' , function ( ) {
15011606 const done = this . async ( ) ;
15021607 const buildDir = grunt . option ( 'dev' ) ? 'src' : 'build' ;
15031608 grunt . util . spawn ( {
15041609 cmd : 'node' ,
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' ] ,
1610+ args : [ 'tools/gutenberg/copy.js' , `--build-dir=${ buildDir } ` ] ,
15171611 opts : { stdio : 'inherit' }
15181612 } , function ( error ) {
15191613 done ( ! error ) ;
@@ -1956,26 +2050,36 @@ module.exports = function(grunt) {
19562050 } ) ;
19572051 } ) ;
19582052
2053+ grunt . registerTask ( 'build:gutenberg' , [
2054+ 'copy:gutenberg-php' ,
2055+ 'copy:gutenberg-js' ,
2056+ 'gutenberg:copy' ,
2057+ 'copy:gutenberg-modules' ,
2058+ 'copy:gutenberg-styles' ,
2059+ 'copy:gutenberg-theme-json' ,
2060+ 'copy:gutenberg-icons' ,
2061+ ] ) ;
2062+
19592063 grunt . registerTask ( 'build' , function ( ) {
19602064 if ( grunt . option ( 'dev' ) ) {
19612065 grunt . task . run ( [
2066+ 'gutenberg:verify' ,
19622067 'build:js' ,
19632068 'build:css' ,
19642069 'build:codemirror' ,
1965- 'gutenberg-sync' ,
1966- 'gutenberg-copy' ,
2070+ 'build:gutenberg' ,
19672071 'copy-vendor-scripts' ,
19682072 'build:certificates'
19692073 ] ) ;
19702074 } else {
19712075 grunt . task . run ( [
2076+ 'gutenberg:verify' ,
19722077 'build:certificates' ,
19732078 'build:files' ,
19742079 'build:js' ,
19752080 'build:css' ,
19762081 'build:codemirror' ,
1977- 'gutenberg-sync' ,
1978- 'gutenberg-copy' ,
2082+ 'build:gutenberg' ,
19792083 'copy-vendor-scripts' ,
19802084 'replace:source-maps' ,
19812085 'verify:build'
0 commit comments