-
-
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
Merged
+290
−1
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
357221d
ensure `\n\n` are kept as `\n\n`
RobinMalfait ab7dda1
add expected Tailwind CSS version
RobinMalfait 294fa85
error when there is a version mismatch
RobinMalfait c9dd535
add integration tests for pnpm, npm and bun
RobinMalfait f53cd0a
update changelog
RobinMalfait c9537f0
setup git config in CI
RobinMalfait ac36a04
set config globally
RobinMalfait 11e1d71
strip VTControl characters to make CI happy
RobinMalfait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,227 @@ | ||
| import { stripVTControlCharacters } from 'node:util' | ||
| // @ts-expect-error This path does exist | ||
| import { version } from '../../packages/tailwindcss/package.json' | ||
| import { css, html, js, json, test } from '../utils' | ||
|
|
||
| test( | ||
| 'upgrades half-upgraded v3 project to v4 (pnpm)', | ||
| { | ||
| fs: { | ||
| 'package.json': json` | ||
| { | ||
| "dependencies": { | ||
| "tailwindcss": "^3", | ||
| "@tailwindcss/upgrade": "workspace:^" | ||
| }, | ||
| "devDependencies": { | ||
| "@tailwindcss/cli": "workspace:^" | ||
| } | ||
| } | ||
| `, | ||
| 'tailwind.config.js': js` | ||
| /** @type {import('tailwindcss').Config} */ | ||
| module.exports = { | ||
| content: ['./src/**/*.{html,js}'], | ||
| } | ||
| `, | ||
| 'src/index.html': html` | ||
| <div class="!flex">Hello World</div> | ||
| `, | ||
| 'src/input.css': css` | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| `, | ||
| }, | ||
| }, | ||
| async ({ exec, expect }) => { | ||
| // Ensure we are in a git repo | ||
| await exec('git init') | ||
| await exec('git add --all') | ||
| await exec('git commit -m "before migration"') | ||
|
|
||
| // Fully upgrade to v4 | ||
| await exec('npx @tailwindcss/upgrade') | ||
|
|
||
| // Undo all changes to the current repo. This will bring the repo back to a | ||
| // v3 state, but the `node_modules` will now have v4 installed. | ||
| await exec('git reset --hard HEAD') | ||
|
|
||
| // Re-running the upgrade should result in an error | ||
| return expect(() => { | ||
| return exec('npx @tailwindcss/upgrade', {}, { ignoreStdErr: true }).catch((e) => { | ||
| // Replacing the current version with a hardcoded `v4` to make it stable | ||
| // when we release new minor/patch versions. | ||
| return Promise.reject(stripVTControlCharacters(e.message.replaceAll(version, '4.0.0'))) | ||
| }) | ||
| }).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
| "Command failed: npx @tailwindcss/upgrade | ||
| ≈ tailwindcss v4.0.0 | ||
|
|
||
| │ ↳ Upgrading from Tailwind CSS \`v4.0.0\` | ||
|
|
||
| │ ↳ Version mismatch | ||
| │ | ||
| │ \`\`\`diff | ||
| │ - "tailwindcss": "^3" (expected version in package.json / lockfile) | ||
| │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`) | ||
| │ \`\`\` | ||
| │ | ||
| │ Make sure to run \`pnpm install\`, and try again. | ||
|
|
||
| " | ||
| `) | ||
| }, | ||
| ) | ||
|
|
||
| test( | ||
| 'upgrades half-upgraded v3 project to v4 (bun)', | ||
| { | ||
| fs: { | ||
| 'package.json': json` | ||
| { | ||
| "dependencies": { | ||
| "tailwindcss": "^3", | ||
| "@tailwindcss/upgrade": "workspace:^" | ||
| }, | ||
| "devDependencies": { | ||
| "@tailwindcss/cli": "workspace:^", | ||
| "bun": "^1.0.0" | ||
| } | ||
| } | ||
| `, | ||
| 'tailwind.config.js': js` | ||
| /** @type {import('tailwindcss').Config} */ | ||
| module.exports = { | ||
| content: ['./src/**/*.{html,js}'], | ||
| } | ||
| `, | ||
| 'src/index.html': html` | ||
| <div class="!flex">Hello World</div> | ||
| `, | ||
| 'src/input.css': css` | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| `, | ||
| }, | ||
| }, | ||
| async ({ exec, expect }) => { | ||
| // Use `bun` to install dependencies | ||
| await exec('rm ./pnpm-lock.yaml') | ||
| await exec('npx bun install') | ||
|
|
||
| // Ensure we are in a git repo | ||
| await exec('git init') | ||
| await exec('git add --all') | ||
| await exec('git commit -m "before migration"') | ||
|
|
||
| // Fully upgrade to v4 | ||
| await exec('npx @tailwindcss/upgrade') | ||
|
|
||
| // Undo all changes to the current repo. This will bring the repo back to a | ||
| // v3 state, but the `node_modules` will now have v4 installed. | ||
| await exec('git reset --hard HEAD') | ||
|
|
||
| // Re-running the upgrade should result in an error | ||
| return expect(() => { | ||
| return exec('npx @tailwindcss/upgrade', {}, { ignoreStdErr: true }).catch((e) => { | ||
| // Replacing the current version with a hardcoded `v4` to make it stable | ||
| // when we release new minor/patch versions. | ||
| return Promise.reject(stripVTControlCharacters(e.message.replaceAll(version, '4.0.0'))) | ||
| }) | ||
| }).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
| "Command failed: npx @tailwindcss/upgrade | ||
| ≈ tailwindcss v4.0.0 | ||
|
|
||
| │ ↳ Upgrading from Tailwind CSS \`v4.0.0\` | ||
|
|
||
| │ ↳ Version mismatch | ||
| │ | ||
| │ \`\`\`diff | ||
| │ - "tailwindcss": "^3" (expected version in package.json / lockfile) | ||
| │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`) | ||
| │ \`\`\` | ||
| │ | ||
| │ Make sure to run \`bun install\`, and try again. | ||
|
|
||
| " | ||
| `) | ||
| }, | ||
| ) | ||
|
|
||
| test( | ||
| 'upgrades half-upgraded v3 project to v4 (npm)', | ||
| { | ||
| fs: { | ||
| 'package.json': json` | ||
| { | ||
| "dependencies": { | ||
| "tailwindcss": "^3", | ||
| "@tailwindcss/upgrade": "workspace:^" | ||
| }, | ||
| "devDependencies": { | ||
| "@tailwindcss/cli": "workspace:^" | ||
| } | ||
| } | ||
| `, | ||
| 'tailwind.config.js': js` | ||
| /** @type {import('tailwindcss').Config} */ | ||
| module.exports = { | ||
| content: ['./src/**/*.{html,js}'], | ||
| } | ||
| `, | ||
| 'src/index.html': html` | ||
| <div class="!flex">Hello World</div> | ||
| `, | ||
| 'src/input.css': css` | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| `, | ||
| }, | ||
| }, | ||
| async ({ exec, expect }) => { | ||
| // Use `bun` to install dependencies | ||
| await exec('rm ./pnpm-lock.yaml') | ||
| await exec('rm -rf ./node_modules') | ||
| await exec('npm install') | ||
|
|
||
| // Ensure we are in a git repo | ||
| await exec('git init') | ||
| await exec('git add --all') | ||
| await exec('git commit -m "before migration"') | ||
|
|
||
| // Fully upgrade to v4 | ||
| await exec('npx @tailwindcss/upgrade') | ||
|
|
||
| // Undo all changes to the current repo. This will bring the repo back to a | ||
| // v3 state, but the `node_modules` will now have v4 installed. | ||
| await exec('git reset --hard HEAD') | ||
|
|
||
| // Re-running the upgrade should result in an error | ||
| return expect(() => { | ||
| return exec('npx @tailwindcss/upgrade', {}, { ignoreStdErr: true }).catch((e) => { | ||
| // Replacing the current version with a hardcoded `v4` to make it stable | ||
| // when we release new minor/patch versions. | ||
| return Promise.reject(stripVTControlCharacters(e.message.replaceAll(version, '4.0.0'))) | ||
| }) | ||
| }).rejects.toThrowErrorMatchingInlineSnapshot(` | ||
| "Command failed: npx @tailwindcss/upgrade | ||
| ≈ tailwindcss v4.0.0 | ||
|
|
||
| │ ↳ Upgrading from Tailwind CSS \`v4.0.0\` | ||
|
|
||
| │ ↳ Version mismatch | ||
| │ | ||
| │ \`\`\`diff | ||
| │ - "tailwindcss": "^3" (expected version in package.json / lockfile) | ||
| │ + "tailwindcss": "4.0.0" (installed version in \`node_modules\`) | ||
| │ \`\`\` | ||
| │ | ||
| │ Make sure to run \`npm install\`, and try again. | ||
|
|
||
| " | ||
| `) | ||
| }, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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
tailwindcssis 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