33/* globals Set */
44var webpackConfig = require ( './webpack.config' ) ;
55var installChanged = require ( 'install-changed' ) ;
6+ var json2php = require ( 'json2php' ) ;
67
78module . exports = function ( grunt ) {
89 var path = require ( 'path' ) ,
@@ -1278,14 +1279,6 @@ module.exports = function(grunt) {
12781279 BUILD_DIR + 'wp-includes/js/dist/commands.js' ,
12791280 ] ,
12801281 dest : BUILD_DIR + 'wp-includes/js/dist/'
1281- } ,
1282- {
1283- expand : true ,
1284- flatten : true ,
1285- src : [
1286- BUILD_DIR + 'wp-includes/js/dist/vendor/**/*.js'
1287- ] ,
1288- dest : BUILD_DIR + 'wp-includes/js/dist/vendor/'
12891282 }
12901283 ]
12911284 }
@@ -1421,59 +1414,6 @@ module.exports = function(grunt) {
14211414 grunt . task . run ( 'wp-packages:refresh-deps' ) ;
14221415 } ) ;
14231416
1424- // Gutenberg integration tasks.
1425- grunt . registerTask ( 'gutenberg-checkout' , 'Checks out the Gutenberg repository.' , function ( ) {
1426- const done = this . async ( ) ;
1427- grunt . util . spawn ( {
1428- cmd : 'node' ,
1429- args : [ 'tools/gutenberg/checkout-gutenberg.js' ] ,
1430- opts : { stdio : 'inherit' }
1431- } , function ( error ) {
1432- done ( ! error ) ;
1433- } ) ;
1434- } ) ;
1435-
1436- grunt . registerTask ( 'gutenberg-build' , 'Builds the Gutenberg repository.' , function ( ) {
1437- const done = this . async ( ) ;
1438- grunt . util . spawn ( {
1439- cmd : 'node' ,
1440- args : [ 'tools/gutenberg/build-gutenberg.js' ] ,
1441- opts : { stdio : 'inherit' }
1442- } , function ( error ) {
1443- done ( ! error ) ;
1444- } ) ;
1445- } ) ;
1446-
1447- grunt . registerTask ( 'gutenberg-copy' , 'Copies Gutenberg build output to WordPress Core.' , function ( ) {
1448- const done = this . async ( ) ;
1449- const buildDir = grunt . option ( 'dev' ) ? 'src' : 'build' ;
1450- grunt . util . spawn ( {
1451- cmd : 'node' ,
1452- args : [ 'tools/gutenberg/copy-gutenberg-build.js' , `--build-dir=${ buildDir } ` ] ,
1453- opts : { stdio : 'inherit' }
1454- } , function ( error ) {
1455- done ( ! error ) ;
1456- } ) ;
1457- } ) ;
1458-
1459- grunt . registerTask ( 'gutenberg-integrate' , 'Complete Gutenberg integration workflow.' , [
1460- 'gutenberg-checkout' ,
1461- 'gutenberg-build' ,
1462- 'gutenberg-copy'
1463- ] ) ;
1464-
1465- grunt . registerTask ( 'copy-vendor-scripts' , 'Copies vendor scripts from node_modules to wp-includes/js/dist/vendor/.' , function ( ) {
1466- const done = this . async ( ) ;
1467- const buildDir = grunt . option ( 'dev' ) ? 'src' : 'build' ;
1468- grunt . util . spawn ( {
1469- cmd : 'node' ,
1470- args : [ 'tools/vendors/copy-vendors.js' , `--build-dir=${ buildDir } ` ] ,
1471- opts : { stdio : 'inherit' }
1472- } , function ( error ) {
1473- done ( ! error ) ;
1474- } ) ;
1475- } ) ;
1476-
14771417 grunt . renameTask ( 'watch' , '_watch' ) ;
14781418
14791419 grunt . registerTask ( 'watch' , function ( ) {
@@ -1629,6 +1569,23 @@ module.exports = function(grunt) {
16291569 }
16301570 } ) ;
16311571
1572+ grunt . registerTask ( 'copy:block-json' , 'Copies block.json file contents to block-json.php.' , function ( ) {
1573+ var blocks = { } ;
1574+ grunt . file . recurse ( SOURCE_DIR + 'wp-includes/blocks' , function ( abspath , rootdir , subdir , filename ) {
1575+ if ( / ^ b l o c k \. j s o n $ / . test ( filename ) ) {
1576+ blocks [ subdir ] = grunt . file . readJSON ( abspath ) ;
1577+ }
1578+ } ) ;
1579+ grunt . file . write (
1580+ SOURCE_DIR + 'wp-includes/blocks/blocks-json.php' ,
1581+ '<?php return ' + json2php . make ( {
1582+ linebreak : '\n' ,
1583+ indent : ' ' ,
1584+ shortArraySyntax : false
1585+ } ) ( blocks ) + ';'
1586+ ) ;
1587+ } ) ;
1588+
16321589 grunt . registerTask ( 'copy:js' , [
16331590 'copy:npm-packages' ,
16341591 'copy:vendor-js' ,
@@ -1766,6 +1723,7 @@ module.exports = function(grunt) {
17661723 grunt . registerTask ( 'build:files' , [
17671724 'clean:files' ,
17681725 'copy:files' ,
1726+ 'copy:block-json' ,
17691727 'copy:version' ,
17701728 ] ) ;
17711729
@@ -1895,8 +1853,6 @@ module.exports = function(grunt) {
18951853 grunt . task . run ( [
18961854 'build:js' ,
18971855 'build:css' ,
1898- 'gutenberg-integrate' ,
1899- 'copy-vendor-scripts' ,
19001856 'build:certificates'
19011857 ] ) ;
19021858 } else {
@@ -1905,8 +1861,6 @@ module.exports = function(grunt) {
19051861 'build:files' ,
19061862 'build:js' ,
19071863 'build:css' ,
1908- 'gutenberg-integrate' ,
1909- 'copy-vendor-scripts' ,
19101864 'replace:source-maps' ,
19111865 'verify:build'
19121866 ] ) ;
0 commit comments