Make WordPress Core

Changeset 53311


Ignore:
Timestamp:
04/29/2022 01:59:49 PM (3 years ago)
Author:
gziolo
Message:

Tools: Further automate backporting from Gutenberg to Core

Follow-up for #51491.

Updating WordPress packages is currently a manual process that takes some reading and trial & error to figure out. This PR adds a single npm task called sync-gutenberg-packages that automates this entire process.

Props zieladam.
Fixes #55642.

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r53140 r53311  
    1414        BUILD_DIR = 'build/',
    1515        WORKING_DIR = grunt.option( 'dev' ) ? SOURCE_DIR : BUILD_DIR,
    16         BANNER_TEXT = '/*! This file is auto-generated */',
     16        BANNER_TEXT = '/*! This file is auto-generated */',
    1717        autoprefixer = require( 'autoprefixer' ),
    1818        sass = require( 'sass' ),
     
    8181            }
    8282        },
    83         usebanner: {
     83        usebanner: {
    8484            options: {
    8585                position: 'top',
     
    12171217    ] );
    12181218
     1219    grunt.registerTask( 'sync-gutenberg-packages', function() {
     1220        if ( grunt.option( 'update-browserlist' ) ) {
     1221            // Updating the browserlist database is opt-in and up to the release lead.
     1222            //
     1223            // Browserlist database should be updated:
     1224            // * In each release cycle up until RC1
     1225            // * If Webpack throws a warning about an outdated database
     1226            //
     1227            // It should not be updated:
     1228            // * After the RC1
     1229            // * When backporting fixes to older WordPress releases.
     1230            //
     1231            // For more context, see:
     1232            // https://github.com/WordPress/wordpress-develop/pull/2621#discussion_r859840515
     1233            // https://core.trac.wordpress.org/ticket/55559
     1234            grunt.task.run( 'browserslist:update' );
     1235        }
     1236
     1237        // Install the latest version of the packages already listed in package.json.
     1238        grunt.task.run( 'wp-packages:update' );
     1239
     1240        // Install any new @wordpress packages that are now required.
     1241        // Update any non-@wordpress deps to the same version as required in the @wordpress packages (e.g. react 16 -> 17).
     1242        grunt.task.run( 'wp-packages:refresh-deps' );
     1243
     1244        // Build the files stored in the src/ directory.
     1245        grunt.task.run( 'build:dev' );
     1246    } );
     1247
    12191248    grunt.renameTask( 'watch', '_watch' );
    12201249
     
    16381667    } );
    16391668
     1669    grunt.registerTask( 'wp-packages:update', 'Update WordPress packages', function() {
     1670        const distTag = grunt.option('dist-tag') || 'latest';
     1671        grunt.log.writeln( `Updating WordPress packages (--dist-tag=${distTag})` );
     1672        spawn( 'npx', [ 'wp-scripts', 'packages-update', '--', `--dist-tag=${distTag}` ], {
     1673            cwd: __dirname,
     1674            stdio: 'inherit',
     1675        } );
     1676    } );
     1677
     1678    grunt.registerTask( 'browserslist:update', 'Update the local database of browser supports', function() {
     1679        grunt.log.writeln( `Updating browsers list` );
     1680        spawn( 'npx', [ 'browserslist@latest', '--update-db' ], {
     1681            cwd: __dirname,
     1682            stdio: 'inherit',
     1683        } );
     1684    } );
     1685
     1686    grunt.registerTask( 'wp-packages:refresh-deps', 'Update version of dependencies in package.json to match the ones listed in the latest WordPress packages', function() {
     1687        const distTag = grunt.option('dist-tag') || 'latest';
     1688        grunt.log.writeln( `Updating versions of dependencies listed in package.json (--dist-tag=${distTag})` );
     1689        spawn( 'node', [ 'tools/release/sync-gutenberg-packages.js', `--dist-tag=${distTag}` ], {
     1690            cwd: __dirname,
     1691            stdio: 'inherit',
     1692        } );
     1693    } );
     1694
    16401695    // Patch task.
    16411696    grunt.renameTask('patch_wordpress', 'patch');
  • trunk/package.json

    r53297 r53311  
    175175        "test:e2e": "node ./tests/e2e/run-tests.js",
    176176        "test:visual": "node ./tests/visual-regression/run-tests.js",
    177         "wp-packages-update": "wp-scripts packages-update"
     177        "sync-gutenberg-packages": "grunt sync-gutenberg-packages"
    178178    }
    179179}
Note: See TracChangeset for help on using the changeset viewer.