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

feat(upgrade): run migrations from upgrade cli #10494

Merged

Conversation

tay1orjones
Copy link
Member

@tay1orjones tay1orjones commented Jan 21, 2022

Closes #10466

This PR updates the @carbon/upgrade CLI to be able to run one or more migrations as part of an upgrade flow. These migrations contain a migrate function that can run jscodeshift codemods.

The following is now possible:

  • @carbon/upgrade: upgrade and run all available migrations for a given upgrade
  • @carbon/upgrade migrate: prompt a list of all available migrations, select one to run removed based on feedback
  • @carbon/upgrade migrate list: list all available migrations
  • @carbon/upgrade migrate <migration-name>: run a specific migration

Changelog

New

Changed

  • Modify the upgrade flow to run all available migrations for a given upgrade flow by default
  • Move transforms from codemods package to live within the upgrade package

Removed

  • Remove codemods package

Testing / Reviewing

  • Try out the CLI locally by:
    • Pulling down this PR
    • Run cd packages/upgrade
    • Run yarn build to build the CLI
    • Run cd fixtures/sample-project to use our sample project fixture
    • Run ../../bin/carbon-upgrade.js --help to verify the CLI is up-and-running
    • Take a look at the options / capabilities of what's there to see if it makes sense
    • Run ../../bin/carbon-upgrade.js and choose an upgrade path. Verify the CLI runs all the available migrations for that upgrade path. In the case of v11: carbon-components, two stub migrations should be called and log out to the console.
    • Run ../../bin/carbon-upgrade.js migrate list to see a list of migrations should be shown
    • Run ../../bin/carbon-upgrade.js migrate to see a prompt of migrations should be shown allowing a single selection removed based on feedback

@netlify
Copy link

netlify bot commented Jan 21, 2022

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: 904f70e

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/61f2d32ac680430007b04e6a

😎 Browse the preview: https://deploy-preview-10494--carbon-react-next.netlify.app

@netlify
Copy link

netlify bot commented Jan 21, 2022

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: 904f70e

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61f2d32adca11a00073e430a

😎 Browse the preview: https://deploy-preview-10494--carbon-elements.netlify.app

@netlify
Copy link

netlify bot commented Jan 21, 2022

✔️ Deploy Preview for carbon-components-react ready!
Built without sensitive environment variables

🔨 Explore the source changes: 904f70e

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61f2d32a301159000855a521

😎 Browse the preview: https://deploy-preview-10494--carbon-components-react.netlify.app

@joshblack
Copy link
Contributor

Was thinking about this the other day, one thing that could simplify our upgrade paths is that we blanket run migrations associated with the upgrade (in this case we would not prompt users to select migrations).

For those who would like to select a specific migration, we could have a migrate command that is like:

  • @carbon/upgrade migrate list, list all available migrations
  • @carbon/upgrade migrate <name>, run the migration with the given name

@tay1orjones
Copy link
Member Author

@joshblack Great point! Having to navigate through the upgrade flow to run a migration is cumbersome.

I just pushed an update to run all migrations with an upgrade, and provide separate migrate commands to run migrations individually.

@tay1orjones tay1orjones changed the title feat(upgrade): run codemods from upgrade cli feat(upgrade): run migrations from upgrade cli Jan 24, 2022
@tay1orjones tay1orjones marked this pull request as ready for review January 24, 2022 23:00
@tay1orjones tay1orjones requested a review from a team as a code owner January 24, 2022 23:00
packages/upgrade/src/cli.js Outdated Show resolved Hide resolved
packages/upgrade/src/cli.js Outdated Show resolved Hide resolved
packages/upgrade/src/jscodeshift.js Outdated Show resolved Hide resolved
packages/upgrade/src/jscodeshift.js Outdated Show resolved Hide resolved
packages/upgrade/src/spawn.js Outdated Show resolved Hide resolved
packages/upgrade/.gitignore Outdated Show resolved Hide resolved
packages/upgrade/src/commands/migrate.js Outdated Show resolved Hide resolved
packages/upgrade/src/commands/migrate.js Outdated Show resolved Hide resolved
@tay1orjones
Copy link
Member Author

@joshblack Amazing suggestions, thank you! All have been addressed and feedback incorporated. execa works great, and getting the bin directly like you proposed was flawless ✨

@tay1orjones tay1orjones requested a review from joshblack January 25, 2022 18:39
@tay1orjones
Copy link
Member Author

tay1orjones commented Jan 25, 2022

I've removed the imports-to-unified-package codemod and put it in it's own PR based off of this PR, #10523

The cli now runs the icons-react-size-prop codemod instead

Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

🎉 🚀

@kodiakhq kodiakhq bot merged commit 4035903 into carbon-design-system:main Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to run codemods to @carbon/upgrade
3 participants