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 codemod for v1 to v2 migration #5038

Closed
kkemple opened this issue Apr 18, 2018 · 13 comments
Closed

Add codemod for v1 to v2 migration #5038

kkemple opened this issue Apr 18, 2018 · 13 comments
Labels
type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change

Comments

@kkemple
Copy link
Contributor

kkemple commented Apr 18, 2018

It would make upgrading much easier if users could run a codemod to convert any breaking changes programatically.

Some things to consider/questions to be answered:

  • seems like this could be a plugin and use existing Gatsby APIs to figure out necessary changes
  • would need to convert layout queries to static queries
  • ???
@kkemple kkemple added the type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change label Apr 18, 2018
@m-allanson
Copy link
Contributor

m-allanson commented Apr 18, 2018

I love codemods, it's like having magic wizards in my computer. It might not be practical to have codemods for every change, but the more the better.

I'd guess the codemod writing process would be:

  • manually upgrade some sites to v2
  • use that experience to write upgrading to v2 doc
  • pick out parts from that doc that can be automated and write codemods for them
  • update upgrade doc with codemod details
  • upgrade more sites
  • write more codemods
  • etc etc

@kkemple
Copy link
Contributor Author

kkemple commented Apr 19, 2018

Seems facebook is working on a nice interactive version of codemod
https://github.com/facebookincubator/fastmod

@rdela
Copy link
Contributor

rdela commented Apr 19, 2018

I started my site on canary branch based on Kyle’s tweet/branch, so maybe in good spot to diff with starter-blog and make that upgrading to v2 doc?

https://github.com/rdela/rdela.com

https://github.com/KyleAMathews/blog/tree/gatsby-v2-canary?files=1

https://github.com/KyleAMathews/blog/pull/21/files

https://twitter.com/kylemathews/status/954905518874664960?s=20

@rdela
Copy link
Contributor

rdela commented Apr 20, 2018

Inspiring prior art https://svelte.technology/blog/version-2

@rdela
Copy link
Contributor

rdela commented May 11, 2018

Everything from here down in this PR seems relevant
#4887 (comment)
Relevant parts start earlier:
#4887 (comment)

@rdela
Copy link
Contributor

rdela commented May 11, 2018

Particularly this PR where Kyle updates his blog
https://github.com/KyleAMathews/blog/pull/21/files

I remember the boundActionCreators => actions step, that seems ripe for codemod
rdela/rdela.com@0042e19#diff-fda05457e393bada716f508859bfc604

Need to dig into both of those PRs more; unsure currently about how <StaticQuery> changes will play out for codemod: whether that ends up being a suggestion codemod could make or item in aforementioned upgrading to v2 doc

@m-allanson
Copy link
Contributor

m-allanson commented Aug 8, 2018

Taking a look through the migration guide, things it might possible to codemod are:

@tsriram
Copy link
Contributor

tsriram commented Aug 18, 2018

I'll give import link from gatsby codemod a try this weekend

@tsriram
Copy link
Contributor

tsriram commented Sep 7, 2018

Doing another - rename boundActionCreators to actions

@DSchau
Copy link
Contributor

DSchau commented Sep 7, 2018

@tsriram that would be great :) I'm not even 100% sure if you get file name, but if you do, you may want to restrict it to only certain files where that's valid. But looking forward to it!

@pieh
Copy link
Contributor

pieh commented Sep 7, 2018

@DSchau It's already opened - #7955 :)

@DSchau
Copy link
Contributor

DSchau commented Sep 7, 2018

@pieh that's what I get for scrolling through the feed and replying before I get all the way to the bottom 😛 Commented on it :)

@m-allanson
Copy link
Contributor

I think we can call this done. Thanks folks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: maintenance An issue or pull request describing a change that isn't a bug, feature or documentation change
Projects
None yet
Development

No branches or pull requests

6 participants