Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to automatically update core packages #19448

Merged

Conversation

jorgefilipecosta
Copy link
Member

@jorgefilipecosta jorgefilipecosta commented Jan 6, 2020

Description

This PR adds a script that automatically updates core WordPress packages to their latest version.

Patch with updates generated using this script https://core.trac.wordpress.org/ticket/49142 (PR: WordPress/wordpress-develop#128)

How has this been tested?

I opened the WordPress develop dir on the terminal.
I executed "/.../gutenberg/bin/commander.js update-core" against that folder and verified the package.json package-lock.json and the block PHP files were changed.

@jorgefilipecosta jorgefilipecosta added the [Type] Project Management Meta-issues related to project management of Gutenberg label Jan 6, 2020
@jorgefilipecosta jorgefilipecosta changed the title Add script automatically update core packages Add script to automatically update core packages Jan 6, 2020
bin/commander.js Outdated
* Internal dependencies
*/
const { readJSONFile, runShellScript, askForConfirmationToContinue } = require( './utils' );
const { updateCorePackages } = require( './update-core-packages' );
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this command is separate but not the others? Should we be consistent?

Should we create a dedicated folder for this tool, now that it's split into multiple files?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why this command is separate but not the others? Should we be consistent?

The main file got too big, I thought it was not a good idea to add the implementation of another command there. I think we should reorganize and split the commands into multiple files, I avoided doing this here to make reviewing easier. As soon as we land this PR I plan on proposing a PR that refactors our commands.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I didn't test but this is cool.

@gziolo
Copy link
Member

gziolo commented Jan 8, 2020

I have just tested the WordPress core patch and everything works perfectly fine. Excellent work on this tool. As discussed in the private chat, it feels like it would be easier to have a way to run this script directly from wordpress-develop repository, knowing that you still need to run npm run build and sometimes apply some manual changes afterward.

@youknowriad
Copy link
Contributor

I think this release tool entirely could be a separate repo/tool/package instead of just a script in the gutenberg repo.

@youknowriad
Copy link
Contributor

I feel we could just update the script a bit to generate a .diff file and give you the patch so you can apply it wherever you want.

@gziolo
Copy link
Member

gziolo commented Jan 9, 2020

I feel we could just update the script a bit to generate a .diff file and give you the patch so you can apply it wherever you want.

I love the idea, this way we could use it with all projects that use WordPress packages. It could also become a way to self-update @wordpress/scripts by running wp-scripts packages-update :)

Update 1:

In WordPress core it would become:

{
  "scripts": {
    "packages-update": "wp-scripts packages-update",
    "postpackages-update": "npm run build"
  }
}

Update 2:

I realized, that it doesn't cover the .diff part in the workflow proposed. Well, maybe it's something each project can handle on its own since projects can use different systems for source control.

@jorgefilipecosta
Copy link
Member Author

Hi @youknowriad, @gziolo,

I have considered the idea of generating a .diff file but it is much slower because one needs to clone the wordpress-develop repository again (to not depend on the user having it previously cloned) and given that to generate the diff we need npm install and npm run build we would always need to do a full npm install on a blank repository which is very slow (e.g: chromium is downloaded).

@gziolo I like the idea of making this part of @wordpress/scripts so other plugins/third parties can use this to update their package versions.
I will look into how I could make this part of wp-scripts and use that in core.

@gziolo
Copy link
Member

gziolo commented Jan 13, 2020

I will look into how I could make this part of wp-scripts and use that in core.

I'm looking forward to it, thank you for working on this script. It's going to be totally awesome :)

@jorgefilipecosta jorgefilipecosta force-pushed the add/script-automatically-update-core-packages branch from 53b17d1 to 58ed668 Compare January 15, 2020 18:22
@jorgefilipecosta
Copy link
Member Author

This PR was updated to follow @gziolo suggestion, and the script is now part of @wordpress/scripts.

I tested the script by setting the current path on the terminal to the WordPress develop directory and then executing "/Users/.../gutenberg/packages/scripts/bin/wp-scripts.js packages-update" followed by "npm run build". The generated patch can be checked in https://core.trac.wordpress.org/ticket/49204 and WordPress/wordpress-develop#132.

The plan is to make the script easier to use. After the next package release we should add the following config in core:

{
  "scripts": {
    "packages-update": "wp-scripts packages-update",
    "postpackages-update": "npm run build"
  }
}

So we can simply do npm run packages-update in core to update the WordPress packages.

Third-party users can easily do the same by importing @wordpress/scripts.

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Awesome work. It still needs to be documented in the README file and includes a new feature in the CHANGELOG file. You pick how you proceed, one or two PRs 🚢

@youknowriad
Copy link
Contributor

It would be good to rewrite some blog posts about the scripts package

@jorgefilipecosta jorgefilipecosta merged commit 2057349 into master Jan 16, 2020
@jorgefilipecosta jorgefilipecosta deleted the add/script-automatically-update-core-packages branch January 16, 2020 11:37
@gziolo
Copy link
Member

gziolo commented Jan 16, 2020

It would be good to rewrite some blog posts about the scripts package

@youknowriad – can you expand what should be covered? I'd be more than happy to take care of it.

@youknowriad
Copy link
Contributor

We could write a series of posts:

  • How the setup,
  • how to use the packages and update them
  • how to build
  • how to test
  • how to lint and format
    ...

I know we have some of these in docs, but the blog post format works well I think for awareness.

@ellatrix ellatrix added this to the Gutenberg 7.3 milestone Jan 20, 2020
nylen pushed a commit to nylen/wordpress-develop-svn that referenced this pull request Oct 12, 2020
This ticket exposes the packages-update script implemented at WordPress/gutenberg#19448 on WordPress core.
By running "npm run wp-packages-update" all the WordPress packages are updated to the latest version. The command is very useful when updating the Gutenberg editor core exposes.

Props isabel_brison.
Fixes #51491.

git-svn-id: https://develop.svn.wordpress.org/trunk@49129 602fd350-edb4-49c9-b593-d223f7449a82
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Oct 12, 2020
This ticket exposes the packages-update script implemented at WordPress/gutenberg#19448 on WordPress core.
By running "npm run wp-packages-update" all the WordPress packages are updated to the latest version. The command is very useful when updating the Gutenberg editor core exposes.

Props isabel_brison.
Fixes #51491.

git-svn-id: https://develop.svn.wordpress.org/trunk@49129 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 12, 2020
This ticket exposes the packages-update script implemented at WordPress/gutenberg#19448 on WordPress core.
By running "npm run wp-packages-update" all the WordPress packages are updated to the latest version. The command is very useful when updating the Gutenberg editor core exposes.

Props isabel_brison.
Fixes #51491.
Built from https://develop.svn.wordpress.org/trunk@49129


git-svn-id: http://core.svn.wordpress.org/trunk@48891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
gMagicScott pushed a commit to gMagicScott/core.wordpress-mirror that referenced this pull request Oct 12, 2020
This ticket exposes the packages-update script implemented at WordPress/gutenberg#19448 on WordPress core.
By running "npm run wp-packages-update" all the WordPress packages are updated to the latest version. The command is very useful when updating the Gutenberg editor core exposes.

Props isabel_brison.
Fixes #51491.
Built from https://develop.svn.wordpress.org/trunk@49129


git-svn-id: https://core.svn.wordpress.org/trunk@48891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
enricocarraro pushed a commit to enricocarraro/wordpress-develop that referenced this pull request Oct 13, 2020
This ticket exposes the packages-update script implemented at WordPress/gutenberg#19448 on WordPress core.
By running "npm run wp-packages-update" all the WordPress packages are updated to the latest version. The command is very useful when updating the Gutenberg editor core exposes.

Props isabel_brison.
Fixes #51491.

git-svn-id: https://develop.svn.wordpress.org/trunk@49129 602fd350-edb4-49c9-b593-d223f7449a82
ClashProducts pushed a commit to ClashProducts/wordpress553 that referenced this pull request Nov 16, 2020
This ticket exposes the packages-update script implemented at WordPress/gutenberg#19448 on WordPress core.
By running "npm run wp-packages-update" all the WordPress packages are updated to the latest version. The command is very useful when updating the Gutenberg editor core exposes.

Props isabel_brison.
Fixes #51491.
Built from https://develop.svn.wordpress.org/trunk@49129
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Project Management Meta-issues related to project management of Gutenberg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants