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

Improve robustness when upgrading #15038

Merged
merged 5 commits into from
Nov 19, 2024
Merged

Improve robustness when upgrading #15038

merged 5 commits into from
Nov 19, 2024

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Nov 19, 2024

This PR improves the robustness when running the upgrade script.

Right now when you run it and if you run into issues, it could be that an error with stack trace is printed in the terminal. This PR improves most of the cases where this happens to ensure the output is easier to parse as a human.

Test plan:

Used SourceGraph to find some popular open source repositories that use Tailwind and tried to run the upgrade tool on those repositories. If a repository fails to upgrade, then that's a good candidate for this PR to showcase the improved error messages.

github.com/docker/docs

Before After
image image

github.com/parcel-bundler/parcel

Before After
image image

github.com/vercel/next.js

Before After
image image

Instead of logging the full error when trying to resolve imports, just
log the error message and where it's being imported.
Moving the `error(…)` logic to where we are migrating the stylesheet
allows us to use the `sheet` available in the current scope to improve
the error messages.
If we are printing a message with some prefix, then we do want to add
the prefix to the first line, and indent the subsequent lines (in case
we need to wrap) with the same width as the prefix.

This means that if we had an error message that looked like this:
```
│ ↳ Cannot find any CSS files that reference Tailwind CSS.
│ Before your project can be upgraded you need to create a CSS file that imports Tailwind CSS
│ or uses `@tailwind`.
```

Now prints as:
```
│ ↳ Cannot find any CSS files that reference Tailwind CSS.
│   Before your project can be upgraded you need to create a CSS file that imports Tailwind CSS
│   or uses `@tailwind`.
```
@RobinMalfait RobinMalfait requested a review from a team as a code owner November 19, 2024 12:32
@RobinMalfait RobinMalfait merged commit 93f9c99 into next Nov 19, 2024
1 check passed
@RobinMalfait RobinMalfait deleted the feat/increase-robustness branch November 19, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants