-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Show version mismatch when running upgrade tool #19028
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
Conversation
| error( | ||
| [ | ||
| 'Version mismatch', | ||
| '', | ||
| pc.dim('```diff'), | ||
| `${pc.red('-')} ${`${pc.dim('"tailwindcss":')} ${`${pc.dim('"')}${pc.blue(version.expectedTailwindVersion(base))}${pc.dim('"')}`}`} (expected version in package.json / lockfile)`, | ||
| `${pc.green('+')} ${`${pc.dim('"tailwindcss":')} ${`${pc.dim('"')}${pc.blue(version.installedTailwindVersion(base))}${pc.dim('"')}`}`} (installed version in \`node_modules\`)`, | ||
| pc.dim('```'), | ||
| '', | ||
| `Make sure to run ${highlight(`${pkgManager} install`)}, and try again.`, | ||
| ].join('\n'), | ||
| { | ||
| prefix: '↳ ', | ||
| }, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open to suggestions here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think i would say "Tailwind CSS version mismatch" but other than that this seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aside: I don't think it needs to change since tailwindcss is also prevent in the diff so if you don't wanna change it that's fine imo. 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change if we want to show more issues. But I used the '↳' as well because it's sort of a continuation of the previous Tailwind CSS version
When splitting `'foo\n\nbar'` by `\n`, you will get `['foo', '', 'bar']`. The `''` value will result in `[]` after the word wrapping. This information gets lost when we `flatMap`, so let's keep the newline using `['']` as the fallback.
This is used for some tests that interact with `git` and have to commit things during tests.
eef6bd8 to
11e1d71
Compare
This PR fixes an issue where sometimes people try to run the upgrade tool, reset the changes and then try again.
If this happens, then the
package.jsonand/or your lock file will point to the old Tailwind CSS v3 version, but the actual installed version will be v4.This will also cause the upgrade tool to now upgrade from v4 to v4, which is not what most people want if they were trying to upgrade from v3 to v4. This in turn will cause some issues because now we won't try to migrate the config file, or v3-specific classes that also exist in v4 but are only safe to upgrade from v3 to v4.
This PR uses
npm ls tailwindcssto determine the actual installed version. This command already errors if there is a mismatch between the installed version and the version inpackage.jsonor the lock file. This also happens to work in pnpm and bun projects (added integration tests for these).If for whatever reason we can't determine the expected version, we fall back to the old behavior of just upgrading. In this scenario, the changes introduced in #19026 will at least give you a hint of what version was actually installed.
Test plan
Tested it in a v3 project where I performed the following steps:
npx tailwindcss-upgrade)git reset --hard && git clean -df)This resulted in the following output:
Added some integration tests to make sure this also works in pnpm, bun and normal npm projects.
[ci-all]