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

[Upgrade-Tool] Refactor the CLI and add codemods commands #19984

Merged
merged 7 commits into from
Apr 3, 2024

Conversation

Convly
Copy link
Member

@Convly Convly commented Apr 2, 2024

What does it do?

  • Clean-up & reorganize the upgrade-tool CLI
  • Refactors the codemods command, split it in two and add sub-commands
    • codemods run [uid] to run codemods (optionally provide a single codemod UID)
    • codemods ls to get a list of available codemods
  • other small refactoring in codemods related modules (codemod-runner, codemod-repository, codemod)

Why is it needed?

Allow listing available codemods and running specific ones, especially useful when developing codemods for a version that's not available now.

How to test it?

  • Try playing with the commands (codemods ls, codemods run [UID]) and make sure everything works according to the help description

@Convly Convly added pr: enhancement This PR adds or updates some part of the codebase or features source: utils:upgrade Source is utils/upgrade labels Apr 2, 2024
Copy link

vercel bot commented Apr 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 2:41pm

@innerdvations
Copy link
Contributor

codemods ls always gives me the error Invalid codemods directory provided

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

First review looks good! I'll check it out closer tomorrow.

@@ -79,7 +79,7 @@ export class Upgrader implements UpgraderInterface {
`${this.target.major}.${this.target.minor}.${this.target.patch}`
);

this.logger?.debug(
this.logger?.debug?.(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we don't require a logger everywhere? and/or if we don't want one we create a stub that doesn't actually log anything?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the future, we might want to programmatically create an upgrader instance that won't log anything (silent).

We could create a stub, but I found it simpler to assume we might not have a logger at all. What do you think?

@innerdvations
Copy link
Contributor

There's a small issue with logging when running multiple codemods with the run option
image

@Convly
Copy link
Member Author

Convly commented Apr 3, 2024

There's a small issue with logging when running multiple codemods with the run option image

Fixed, thanks!

@hanpaine
Copy link

hanpaine commented Apr 3, 2024

FYI @Marc-Roig

Copy link
Contributor

@innerdvations innerdvations left a comment

Choose a reason for hiding this comment

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

Looks great and works for me now!

Copy link
Contributor

@christiancp100 christiancp100 left a comment

Choose a reason for hiding this comment

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

QAed it and it works!

@Convly Convly merged commit 6c15ef6 into v5/main Apr 3, 2024
79 of 84 checks passed
@Convly Convly deleted the v5/upgrade-tool/enhance-codemods-command branch April 3, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: enhancement This PR adds or updates some part of the codebase or features source: utils:upgrade Source is utils/upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants