Changeset 62079
- Timestamp:
- 03/20/2026 04:31:45 PM (8 weeks ago)
- File:
-
- 1 edited
-
trunk/Gruntfile.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gruntfile.js
r62077 r62079 604 604 dest: SOURCE_DIR + 'wp-includes/certificates/ca-bundle.crt' 605 605 }, 606 // Gutenberg PHP infrastructure files (routes.php, pages.php, constants.php, pages/ , routes/).606 // Gutenberg PHP infrastructure files (routes.php, pages.php, constants.php, pages/). 607 607 'gutenberg-php': { 608 608 options: { … … 623 623 'constants.php', 624 624 'pages/**/*.php', 625 'routes/**/*.php',626 625 ], 627 626 dest: WORKING_DIR + 'wp-includes/build/', 628 627 } ], 628 }, 629 /* 630 * Only copy files relevant to the routes specified in the registry file. 631 * 632 * While the registry file does not contain any experimental routes, the `gutenberg/build/routes` directory 633 * includes the files for all registered routes. Only the files related to the routes specified in the 634 * registry should be included in the WordPress build. 635 * 636 * The `src` list is populated at task runtime by `routes:setup`, which reads the registry after 637 * `gutenberg:download` has run. See the `routes:setup` task registration for implementation details. 638 */ 639 routes: { 640 expand: true, 641 cwd: 'gutenberg/build', 642 src: [], 643 dest: WORKING_DIR + 'wp-includes/build/', 629 644 }, 630 645 'gutenberg-js': { … … 634 649 src: [ 635 650 'pages/**/*.js', 636 'routes/**/*.js',637 651 ], 638 652 dest: WORKING_DIR + 'wp-includes/build/', … … 2059 2073 } ); 2060 2074 2075 grunt.registerTask( 'routes:setup', 'Reads the routes registry and configures the copy:routes task.', function() { 2076 const registryPath = 'gutenberg/build/routes/registry.php'; 2077 let registryContent; 2078 try { 2079 registryContent = fs.readFileSync( registryPath, 'utf8' ); 2080 } catch ( e ) { 2081 grunt.fatal( 2082 'Route registry not found at ' + registryPath + '. Run `grunt gutenberg:download` first.' 2083 ); 2084 } 2085 const namePattern = /'name'\s*=>\s*'([^']+)'/g; 2086 const routeNames = []; 2087 let match; 2088 while ( ( match = namePattern.exec( registryContent ) ) !== null ) { 2089 routeNames.push( match[ 1 ] ); 2090 } 2091 2092 if ( routeNames.length === 0 ) { 2093 grunt.fatal( 2094 'No route names found in ' + registryPath + '. The format of the file may have changed.' 2095 ); 2096 } 2097 2098 const validName = /^[A-Za-z0-9_-]+$/; 2099 routeNames.forEach( function( name ) { 2100 if ( ! validName.test( name ) ) { 2101 grunt.fatal( 2102 'Invalid route name \'' + name + '\' in ' + registryPath + '. Expected only letters, digits, hyphens, and underscores.' 2103 ); 2104 } 2105 } ); 2106 2107 grunt.config( [ 'copy', 'routes', 'src' ], [ 'routes/registry.php' ].concat( 2108 routeNames.flatMap( function( name ) { 2109 return [ 2110 'routes/' + name + '/**/*.php', 2111 'routes/' + name + '/**/*.js', 2112 ]; 2113 } ) 2114 ) ); 2115 } ); 2116 2061 2117 grunt.registerTask( 'build:gutenberg', [ 2062 2118 'copy:gutenberg-php', 2119 'routes:setup', 2120 'copy:routes', 2063 2121 'copy:gutenberg-js', 2064 2122 'gutenberg:copy',
Note: See TracChangeset
for help on using the changeset viewer.