Skip to content

Automate updating JS packages - #2621

Closed
adamziel wants to merge 13 commits into
WordPress:trunkfrom
adamziel:try/automate-backports
Closed

Automate updating JS packages#2621
adamziel wants to merge 13 commits into
WordPress:trunkfrom
adamziel:try/automate-backports

Conversation

@adamziel

@adamzieladamziel commented Apr 22, 2022

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Trac ticket: https://core.trac.wordpress.org/ticket/55642

Updating @wordpress packages is currently a manual process that takes some reading and trial&error to figure out:

  1. Update browserslist database
  2. Update @wordpress packages
  3. Install any new @wordpress required by the existing dependencies
  4. Update React and other non-@wordpress dependencies to the versions required by the @wordpress packages
  5. Run npm build:dev

(see #2564)

This PR adds a single task called sync-gutenberg-packages that automates this entire process.

Ideally, the next step will be a GitHub action that runs it for you.

Test plan

Run the following commands:

; git checkout bab610091d59f6dd21c7db84ba3e1ca0bab6a211~1
# ^ This repo right before the first round of backports for WP 6.0 Beta1

Then merge this branch into your local copy:

git merge adamziel:try/automate-backports

Then run the command:

; npm install
; npx grunt sync-gutenberg-packages --dist-tag=wp-6.0

Then run git status and confirm it reports the following:

 modified: package-lock.json
modified: package.json
modified: src/wp-includes/blocks/archives.php
modified: src/wp-includes/blocks/archives/block.json
modified: src/wp-includes/blocks/audio/block.json
modified: src/wp-includes/blocks/block.php
modified: src/wp-includes/blocks/block/block.json
modified: src/wp-includes/blocks/button/block.json
modified: src/wp-includes/blocks/buttons/block.json
modified: src/wp-includes/blocks/calendar.php
modified: src/wp-includes/blocks/calendar/block.json
modified: src/wp-includes/blocks/categories.php
modified: src/wp-includes/blocks/categories/block.json
modified: src/wp-includes/blocks/code/block.json
modified: src/wp-includes/blocks/column/block.json
modified: src/wp-includes/blocks/columns/block.json
modified: src/wp-includes/blocks/cover/block.json
modified: src/wp-includes/blocks/embed/block.json
modified: src/wp-includes/blocks/file.php
modified: src/wp-includes/blocks/file/block.json
modified: src/wp-includes/blocks/freeform/block.json
modified: src/wp-includes/blocks/gallery.php
modified: src/wp-includes/blocks/gallery/block.json
modified: src/wp-includes/blocks/group/block.json
modified: src/wp-includes/blocks/heading/block.json
modified: src/wp-includes/blocks/html/block.json
modified: src/wp-includes/blocks/image.php
modified: src/wp-includes/blocks/image/block.json
modified: src/wp-includes/blocks/latest-comments.php
modified: src/wp-includes/blocks/latest-comments/block.json
modified: src/wp-includes/blocks/latest-posts.php
modified: src/wp-includes/blocks/latest-posts/block.json
modified: src/wp-includes/blocks/legacy-widget.php
modified: src/wp-includes/blocks/list/block.json
modified: src/wp-includes/blocks/loginout/block.json
modified: src/wp-includes/blocks/media-text/block.json
modified: src/wp-includes/blocks/missing/block.json
modified: src/wp-includes/blocks/more/block.json
modified: src/wp-includes/blocks/navigation-link.php
modified: src/wp-includes/blocks/navigation-link/block.json
modified: src/wp-includes/blocks/navigation-submenu.php
modified: src/wp-includes/blocks/navigation-submenu/block.json
modified: src/wp-includes/blocks/navigation.php
modified: src/wp-includes/blocks/navigation/block.json
modified: src/wp-includes/blocks/nextpage/block.json
modified: src/wp-includes/blocks/page-list.php
modified: src/wp-includes/blocks/page-list/block.json
modified: src/wp-includes/blocks/paragraph/block.json
modified: src/wp-includes/blocks/pattern/block.json
modified: src/wp-includes/blocks/post-author.php
modified: src/wp-includes/blocks/post-author/block.json
modified: src/wp-includes/blocks/post-comments/block.json
modified: src/wp-includes/blocks/post-content.php
modified: src/wp-includes/blocks/post-content/block.json
modified: src/wp-includes/blocks/post-date.php
modified: src/wp-includes/blocks/post-date/block.json
modified: src/wp-includes/blocks/post-excerpt.php
modified: src/wp-includes/blocks/post-excerpt/block.json
modified: src/wp-includes/blocks/post-featured-image.php
modified: src/wp-includes/blocks/post-featured-image/block.json
modified: src/wp-includes/blocks/post-navigation-link.php
modified: src/wp-includes/blocks/post-navigation-link/block.json
modified: src/wp-includes/blocks/post-template.php
modified: src/wp-includes/blocks/post-template/block.json
modified: src/wp-includes/blocks/post-terms.php
modified: src/wp-includes/blocks/post-terms/block.json
modified: src/wp-includes/blocks/post-title.php
modified: src/wp-includes/blocks/post-title/block.json
modified: src/wp-includes/blocks/preformatted/block.json
modified: src/wp-includes/blocks/pullquote/block.json
modified: src/wp-includes/blocks/query-pagination-next.php
modified: src/wp-includes/blocks/query-pagination-next/block.json
modified: src/wp-includes/blocks/query-pagination-numbers/block.json
modified: src/wp-includes/blocks/query-pagination-previous.php
modified: src/wp-includes/blocks/query-pagination-previous/block.json
modified: src/wp-includes/blocks/query-pagination.php
modified: src/wp-includes/blocks/query-pagination/block.json
modified: src/wp-includes/blocks/query-title/block.json
modified: src/wp-includes/blocks/query/block.json
modified: src/wp-includes/blocks/quote/block.json
modified: src/wp-includes/blocks/rss.php
modified: src/wp-includes/blocks/rss/block.json
modified: src/wp-includes/blocks/search.php
modified: src/wp-includes/blocks/search/block.json
modified: src/wp-includes/blocks/separator/block.json
modified: src/wp-includes/blocks/shortcode/block.json
modified: src/wp-includes/blocks/site-logo.php
modified: src/wp-includes/blocks/site-logo/block.json
modified: src/wp-includes/blocks/site-tagline/block.json
modified: src/wp-includes/blocks/site-title.php
modified: src/wp-includes/blocks/site-title/block.json
modified: src/wp-includes/blocks/social-link.php
modified: src/wp-includes/blocks/social-link/block.json
modified: src/wp-includes/blocks/social-links/block.json
modified: src/wp-includes/blocks/spacer/block.json
modified: src/wp-includes/blocks/table/block.json
modified: src/wp-includes/blocks/tag-cloud.php
modified: src/wp-includes/blocks/tag-cloud/block.json
modified: src/wp-includes/blocks/template-part.php
modified: src/wp-includes/blocks/template-part/block.json
modified: src/wp-includes/blocks/term-description/block.json
modified: src/wp-includes/blocks/text-columns/block.json
modified: src/wp-includes/blocks/verse/block.json
modified: src/wp-includes/blocks/video/block.json

cc @gziolo

@gziolo

Copy link
Copy Markdown
Member

I'm looking forward to give it a spin on Monday/Tuesday 🎉

Comment threadpackage.json Outdated
@adamziel
adamzielforce-pushed the try/automate-backports branch from 9974030 to 7403279CompareApril 22, 2022 13:29
@adamziel
adamziel marked this pull request as ready for review April 22, 2022 13:40
@adamziel
adamzielforce-pushed the try/automate-backports branch 2 times, most recently from 9d9518e to a3d7ef4CompareApril 22, 2022 13:49
@ocean90

Copy link
Copy Markdown
Member

It's right that "backporting" here means updating the packages to the same packages used by Gutenberg? I think this can be misleading as backporting in WordPress is more about cherry-picking a commit from trunk into a branch which the command is clearly not doing.

@adamzieladamziel changed the title Automate backporting JS packagesAutomate updating JS packagesApr 26, 2022
@gziolo

Copy link
Copy Markdown
Member

It's right that "backporting" here means updating the packages to the same packages used by Gutenberg? I think this can be misleading as backporting in WordPress is more about cherry-picking a commit from trunk into a branch which the command is clearly not doing.

Good perspective. It should be reworded so it's all clear it's about bringing changes from Gutenberg to WP core 👍🏻

Comment threadpackage.json Outdated
Comment threadtools/release/refresh-packages.js Outdated
Comment threadtools/release/refresh-packages.js Outdated
@adamziel

Copy link
Copy Markdown
ContributorAuthor

Good notes! I renamed backport-js-packages to sync-gutenberg-packages to make the purpose clearer.

@adamziel
adamzielforce-pushed the try/automate-backports branch from b10c503 to a452b08CompareApril 27, 2022 09:45
@adamziel
adamzielforce-pushed the try/automate-backports branch from 04ebbe8 to 38eceedCompareApril 27, 2022 09:46
Comment threadGruntfile.js
BUILD_DIR = 'build/',
WORKING_DIR = grunt.option( 'dev' ) ? SOURCE_DIR : BUILD_DIR,
BANNER_TEXT = '/*! This file is auto-generated */',
BANNER_TEXT = '/*! This file is auto-generated */',

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My linting tool caught this. Seems fine to merge.

Comment threadtools/release/sync-gutenberg-packages.js Outdated
Comment threadGruntfile.js Outdated
Comment threadGruntfile.js Outdated
} );
} );

grunt.registerTask( 'browserslist:update', 'Update WordPress packages', function() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@desrosj, how do you feel about running this command every time we refresh WordPress packages from Gutenberg?

I know you open tickets to document the changes for supported browsers.

@adamzieladamzielApr 28, 2022

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gziolo this just downloads the latest browserlist database, it doesn't affect the browsers supported by WordPress in any way.

@gziologzioloApr 29, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know it’s expected to run this command regularly (browserslist/browserslist#492). It's perfectly fine for trunk, but it might not be expected for older major WordPress releases when you want only to update packages to fix security vulnerabilities.

See also https://core.trac.wordpress.org/ticket/52331 as a reference. I know from experience that overall the goal is to minimize JS and CSS changes in minor releases so it doesn’t prime all caches for WordPress. Those changes to the list of browsers might impact the generated content of files in both CSS and JS when Babel polyfills or vendor prefixes get removed.

@desrosj opened https://core.trac.wordpress.org/ticket/55559 to document supported browsers in the 6.0 cycle with a note that the list shouldn’t change after RC1.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm that's a fair point. Let's make this opt-out then, and I'll add a CLI flag to enable it on demand.

@gziologziolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need still to clarify the final strategy for browserslist, but it can be revised later. Everything looks good and we successfully tested it with WordPress 6.0 Beta 3 🎉

Let’s land this useful utility tool to make the backporting from Gutenberg easier. We also have plans how to improve keeping blocks in sync between Gutenberg and WordPress core.

@adamziel
adamzielforce-pushed the try/automate-backports branch from d3f20ad to d112751CompareApril 29, 2022 09:26
@adamziel
adamzielforce-pushed the try/automate-backports branch from d112751 to 0801f0cCompareApril 29, 2022 09:31
@adamziel

Copy link
Copy Markdown
ContributorAuthor

@gziolo I've made the browserlist command opt-in in 0801f0c. This PR is now up to you to merge as I'm not a core committer.

@gziolo

Copy link
Copy Markdown
Member

I've made the browserlist command opt-in in 0801f0c. This PR is now up to you to merge as I'm not a core committer.

Excellent, I will commit while we work on backports today 👍🏻

@gziolo

Copy link
Copy Markdown
Member

Committed with https://core.trac.wordpress.org/changeset/53311.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@adamziel@gziolo@ocean90