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

Don't download a new binary if one is already present. #87

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sbrow
Copy link

@sbrow sbrow commented Jan 27, 2025

As discussed in #84, if a user has not configured a binary version, but has already downloaded an outdated tailwind binary, the outdated version will be used instead of downloading a new version.

This prevents builds from breaking when users unexpectedly are upgraded from v3.x to v4.

I could add a message that warns users they are not using the most up-to-date version, if necessary.

@sadikoff
Copy link

Hey, nice work, can you please fix CS and tests

@sbrow
Copy link
Author

sbrow commented Jan 28, 2025

Yep, sorry about that.

Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

@sbrow sbrow force-pushed the sbrow-patch-1 branch 2 times, most recently from bac7dc7 to 24c8321 Compare January 29, 2025 18:38
@bocharsky-bw
Copy link
Member

Thanks for more changes, I still think we need to tweak the docs as well: https://symfony.com/bundles/TailwindBundle/current/index.html#using-a-different-binary-version

To make it clear about the process of finding the binary, WDYT?

@sbrow
Copy link
Author

sbrow commented Jan 30, 2025

@bocharsky-bw My apologies. I did not realize that the docs were in the same repository as the plugin. I've done my best to explain the changes, but feel free to make edits as needed 😅

bocharsky-bw
bocharsky-bw previously approved these changes Jan 31, 2025
Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a few minor comments

doc/index.rst Outdated
update to a new version, delete your ``./var/tailwind`` directory before running
``tailwind:build``.

If instead you want to use only a specific version of tailwind, you can set the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If instead you want to use only a specific version of tailwind, you can set the
If instead, you want to use only a specific version of Tailwind, you can set the

Choose a reason for hiding this comment

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

My 2 cents here: for the exact same problem, on the minify bundle i added a --force option to the install command.

DX feels easier to me (and can be added with little time).

Maybe another option?

Copy link
Author

Choose a reason for hiding this comment

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

We certainly could add a force flag. If the team is amenable to that, I can add that to this PR.

Co-authored-by: Victor Bocharsky <[email protected]>
Co-authored-by: Victor Bocharsky <[email protected]>
@kbond
Copy link
Contributor

kbond commented Feb 2, 2025

I'm curious: is this still required after #83? Unless you manually set the version to null, you'll always get a specific version.

@sbrow
Copy link
Author

sbrow commented Feb 2, 2025

@kbond Required? No. But slapping a band-aid on the problem doesn't solve the underlying issue. Automatically pinning the version just tips the scale in the other direction- instead of having an issue where certain users expect a specific version but get a new one, after #83 you'll now have users expecting to get the latest version, but they'll get an outdated one.

I opened this PR because the bundle didn't work as I expected. I presumed that when I ran tailwind:build for the first time, it would download the latest version of Tailwind, and continue using that version until either:

  1. I Deleted ./var/tailwind
  2. I Specifically asked for an upgrade of some kind.

This is in line with how composer works, if, like me, you commit the composer.lock file.

However, what was happening was that it was always updating to the latest version every time I ran tailwind:build, which the v4 release broke for me and other users.


I think this PR, combined with an additional PR (which I'm happy to author), that informs users that their version is out of date, and provides clear and easy instructions on how to upgrade, would be the best solution to this problem.

i.e. If a user hasn't set a pinned version, and their latest downloaded version is outdated, display a warning message during tailwind:build that says like

You are using tailwind v3.4.17, but the latest available version is v4.0.0.
Run php bin/console tailwind:update to use the latest version

@kbond
Copy link
Contributor

kbond commented Feb 2, 2025

This is in line with how composer works, if, like me, you commit the composer.lock file.

This is what #83 does. It's not perfect but aside from developing a composer-like versioning/update system, I think it's the best we have.

This PR doesn't address the issue of a new developer or a CI downloading an unexpected version (because the binary isn't available in these cases).

I'd be in favour of leaving the version config null (but required), then having this bundle's recipe adding the latest version.

additional PR (which I'm happy to author), that informs users that their version is out of date

I'm totally in favour of this but should look at your config, not the binary that's installed.

@sbrow
Copy link
Author

sbrow commented Feb 3, 2025

The issue is that #83 sets the default version in the package itself, which means that as time goes on, that value will have to be updated as needed. When do we decide to set that number to v4.0.0? When is an appropriate time to upgrade? The answer will likely vary by company, by project, etc. Defaulting everyone to use the latest version that the tailwind-bundle that's confirmed to be compatible is different than defaulting to the latest version period.

This PR doesn't address the issue of a new developer or a CI downloading an unexpected version (because the binary isn't available in these cases).

This is by design. I was trying to preserve what I inferred was the intent of the plugin, so that existing users wouldn't be confused. If you want CI to work consistently, you need to pin every version of everything you can, that's why I love nix so much.

This PR is based on the assumption that there are two kinds of users:

  1. Those that want to strictly control the version used.
  2. Those that just want it to install something, and not have it suddenly break on them when they didn't ask it to update.

Frankly, I was just trying to help out so other users didn't fall in the same hole I did. If everyone is happy with #83, then feel free to close this PR.

@bocharsky-bw
Copy link
Member

I'd be in favour of leaving the version config null (but required), then having this bundle's recipe adding the latest version.

This is an interesting idea IMO, though is it possible? If so, it would be simpler (more straightforward) than trying to guess the latest installed version. It will solve the problem for new users, everything will happen out of the box and they will have the latest supported version of Tailwind. For current users - well, it will be a BC break but should be easy to fix, you just need to specify a binary version explicitly in your config. With this strategy even if reverted that #83 - it would still work for all as you want, no automatic jump to a newer version when released. To upgrade to a newer version - just change the version in your config file.

You are using tailwind v3.4.17, but the latest available version is v4.0.0.

About this warning - I like it. We could check if there's a newer version available and if so - mention something like this in the output, but instead of saying run tailwind:update say something like "change the version in your config file". Not sure we even need a command for this that we will need to maintain.

Wdyt?

@kbond kbond mentioned this pull request Feb 24, 2025
8 tasks
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.

5 participants