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(remix-dev/cli): add DX improvements for migrate command & replace-remix-imports migration #2670

Merged
merged 31 commits into from
Apr 12, 2022

Conversation

pcattori
Copy link
Contributor

@pcattori pcattori commented Apr 6, 2022

Migration should guide the user through 3 steps:

  1. Replacing the remix package with @remix-run/* packages.
  2. Removing remix setup from the postinstall script
  3. Replacing import {...} from "remix" with import {...} from "@remix-run/{some package}"

Try it!

git fetch origin # or whatever you call remix-run/remix
git checkout pedro/fix-migrate
yarn build
node ./build/node_modules/@remix-run/dev/cli.js migrate

Example

Screen Shot 2022-04-10 at 10 09 38 AM

@pcattori pcattori changed the base branch from main to dev April 6, 2022 19:35
@pcattori pcattori changed the title Pedro/fix migrate DX improvements for migrate command and replace-remix-imports migration Apr 6, 2022
@MichaelDeBoey MichaelDeBoey changed the title DX improvements for migrate command and replace-remix-imports migration feat(remix-dev/cli): add DX improvements for migrate command & replace-remix-imports migration Apr 6, 2022
@MichaelDeBoey MichaelDeBoey added package:dev feat:dx Issues related to the developer experience labels Apr 6, 2022
@pcattori pcattori force-pushed the pedro/fix-migrate branch 2 times, most recently from 1829eb3 to 58267dc Compare April 6, 2022 21:53
@ryanflorence
Copy link
Member

I ran it on a couple apps, works great!

@pcattori pcattori force-pushed the pedro/fix-migrate branch 2 times, most recently from 6d93edd to db33d4b Compare April 10, 2022 14:23
@pcattori
Copy link
Contributor Author

pcattori commented Apr 10, 2022

I added types for @npmcli/package-json in packages/remiv-dev/types/ and tsconfig.json is configured to include **/* from remix-dev/. VS Code finds these custom types just fine, but our build step calls tsc -b and that command cannot find our custom types.

Blocked on this^

@MichaelDeBoey
Copy link
Member

I added types for @npmcli/package-json in packages/remiv-dev/types/ and tsconfig.json is configured to include **/* from remix-dev/. VS Code finds these custom types just fine, but our build step calls tsc -b and that command cannot find our custom types.

@pcattori I had the same problem when I was first using is-git-clean & added types for it.
Creating a PR in https://github.com/DefinitelyTyped/DefinitelyTyped & using @types/is-git-clean fixed it.

I created DefinitelyTyped/DefinitelyTyped#59806, so this PR isn't blocked anymore and we can investigate the root cause later.

@MichaelDeBoey
Copy link
Member

MichaelDeBoey commented Apr 10, 2022

@pcattori I created #2718 (this PR is the base branch) as that was easier to do instead of typing it all out as a review here 🙈

@pcattori
Copy link
Contributor Author

@pcattori I created #2718 (this PR is the base branch) as that was easier to do instead of typing it all out as a review here 🙈

@MichaelDeBoey I've incorporated the feedback from your PR into this PR.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Looking great! Just a few small things.

@@ -0,0 +1,205 @@
name: 🚀 Deploy
Copy link
Member

Choose a reason for hiding this comment

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

Could we remove unnecessary files from the fixtures? I worry that including them will cause confusion and issues in the future when people are doing a big find/replace sort of thing in the codebase and they come across files like this and spend extra time to make sure they make proper changes when it actually doesn't even matter.

So let's include only the files that can justify their existence in the fixture (which is to say that most of the files here should probably be deleted or, at the very least, drastically simplified).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed a ton of files. Let me know if you think there's still too much cruft left in here.

};

describe("`replace-remix-imports` migration", () => {
it("runs successfully", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a couple assertions in here that look for the text from "remix" and ensures it no longer exists in the codebase.

Copy link
Member

Choose a reason for hiding this comment

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

And perhaps we could run the build script in the fixture after the migration to make sure imports can be resolved properly.

Copy link
Contributor Author

@pcattori pcattori Apr 11, 2022

Choose a reason for hiding this comment

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

I added checks that from "remix" is purged from the app post-migration.

As for running build, adding npm install and npm run build to the test makes the test go from sub-second to more than 1 minute on my machine (M1 Max) and becomes network dependent. I think I prefer leaving out the build check and keeping this test lean. What do you think @kentcdodds ?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, definitely don't want it to be network dependent 👍 We could probably simplify the app further (remove all the deps and stuff and make remix reference the local remix), but that's more work than it's worth. This is enough 👍

Copy link
Member

@MichaelDeBoey MichaelDeBoey left a comment

Choose a reason for hiding this comment

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

I'm just wondering why we need baa2183 & 6e1bc21.

Since we're building the whole @remix-run/dev package, it shouldn't matter if jscodeshift supports it out of the box or not I think? 🤔

…ts in transformations

by design, transformations have a default export for compatibility with jscodeshift. but we also
want to share code from transforms, necessitating named exports.
…hem to do post-migration steps

also, improved DX by clearly delineating separate migration sections
once DefinitelyTyped/DefinitelyTyped#59806 is merged, we can install
`@types/@npmcli/package-json` instead
…ansform

because jscodeshift does not have full typescript support for transforms
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

This is great! Lots here that should hopefully help in future code transformations we will inevitably need to make 👍 Thanks!

};

describe("`replace-remix-imports` migration", () => {
it("runs successfully", async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, definitely don't want it to be network dependent 👍 We could probably simplify the app further (remove all the deps and stuff and make remix reference the local remix), but that's more work than it's worth. This is enough 👍

@kentcdodds kentcdodds merged commit adb5def into dev Apr 12, 2022
@kentcdodds kentcdodds deleted the pedro/fix-migrate branch April 12, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed feat:dx Issues related to the developer experience package:dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants