-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Add initial codemod tooling #14434
Merged
Merged
Add initial codemod tooling #14434
Conversation
This file contains 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
64ac888
to
0fc5af9
Compare
philipp-spiess
approved these changes
Sep 16, 2024
0fc5af9
to
8dc023b
Compare
philipp-spiess
approved these changes
Sep 18, 2024
+ add codemod for migrating `@apply`
Copied some utils from `@tailwindcss/cli`. Initially referenced them, but we also rely on some dependencies that we have to install. One solution is to move it to an internal package and import it so that tsup can inline everything. This also has the same 'we need the correct dependencies' problem. Another solution is to create a proper `@tailwindcss/cli-utils` (or similar) package that we can import as a dependency. However, this one will require us to actually publish the package, and give it a proper name.
bc9b0a7
to
330dbff
Compare
Globby, created by Sindresorhus, is based on fast-glob but with additional features. One of those features is the `gitignore` feature which respects your `.gitignore` file, which is exactly what we need. See: https://github.com/sindresorhus/globby#gitignore
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds some initial tooling for codemods. We are currently only interested in migrating CSS files, so we will be using PostCSS under the hood to do this. This PR also implements the "migrate
@apply
" codemod from #14412.The usage will look like this:
You can pass in CSS files to transform as arguments:
But, if none are provided, it will search for CSS files in the current directory and its subdirectories.
The tooling also requires the Git repository to be in a clean state. This is a common convention to ensure that everything is undo-able. If we detect that the git repository is dirty, we will abort the migration.
This PR alsoo adds CSS codemods for migrating existing
@apply
directives to the new version.This PR has the ability to migrate the following cases:
In v4, the convention is to put the important modifier
!
at the end of the utility class instead of right before it. This makes it easier to reason about, especially when you are variants.Input:
Output:
In v4 we don't support
!important
as a marker at the end of@apply
directives. Instead, you can append the!
to each utility class to make it!important
.Input:
Output: