Skip to content

Commit 27ba067

Browse files
committedOct 2, 2024
Remove the upstream tailwindcss packaging
This is being extracted into the tailwindcss-ruby gem.
1 parent 97dce5f commit 27ba067

15 files changed

+86
-547
lines changed
 

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@
1313
*.gem
1414
.idea/
1515
**/tmp/
16-
/exe/*/tailwindcss

‎CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## next / unreleased
2+
3+
### Notable changes
4+
5+
* The upstream `tailwindcss` executable has been extracted from this gem into a new dependency, `tailwindcss-ruby`.
6+
7+
In advance of the upcoming TailwindCSS v4 release, we are decoupling the `tailwindcss` executable
8+
from the Rails integration. This will allow users to upgrade TailwindCSS at a time of their
9+
choosing, and allow early adopters to start using the beta releases.
10+
11+
112
## v2.7.7 / 2024-10-02
213

314
* Proactively support changes to Rails's authentication templates shipping in Rails 8.0.0.beta2 (which is not yet released). (#407, #408) @seanpdoyle @flavorjones

‎CONTRIBUTING.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,14 @@ gem "tailwindcss-rails", path: "/path/to/tailwindcss-rails"
2323
```
2424

2525

26-
## Updating to the latest upstream tailwindcss version
27-
28-
Update `lib/tailwindcss/upstream.rb` with the upstream version.
29-
30-
Run `bundle exec rake clobber` then `bundle exec rake download` to ensure the tailwindcss binaries can be downloaded, and that you have the correct versions on local disk.
31-
3226
## Cutting a release of tailwindcss-rails
3327

3428
- bump the version
3529
- [ ] update `lib/tailwindcss/version.rb`
3630
- [ ] update `CHANGELOG.md`
3731
- [ ] commit and create a git tag
38-
- build the native gems:
39-
- [ ] `bundle exec rake clobber` to clean up possibly-old tailwindcss executables
40-
- [ ] `bundle exec rake package`
4132
- push
42-
- [ ] `for g in pkg/*.gem ; do gem push $g ; done`
33+
- [ ] `gem push pkg/*.gem`
4334
- [ ] `git push && git push --tags`
4435
- announce
4536
- [ ] create a release at https://github.com/rails/tailwindcss-rails/releases

‎Gemfile.lock

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PATH
33
specs:
44
tailwindcss-rails (2.7.7)
55
railties (>= 7.0.0)
6+
tailwindcss-ruby
67

78
GEM
89
remote: https://rubygems.org/
@@ -128,6 +129,7 @@ GEM
128129
io-console (~> 0.5)
129130
securerandom (0.3.1)
130131
stringio (3.1.1)
132+
tailwindcss-ruby (0.1.0-x86_64-linux)
131133
thor (1.3.1)
132134
timeout (0.4.1)
133135
tzinfo (2.0.6)

‎LICENSE-DEPENDENCIES

-26
This file was deleted.

‎README.md

+2-64
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,7 @@ With Rails 7 you can generate a new application preconfigured with Tailwind by u
3535
1. Run `./bin/bundle add tailwindcss-rails`
3636
2. Run `./bin/rails tailwindcss:install`
3737

38-
This gem wraps [the standalone executable version](https://tailwindcss.com/blog/standalone-cli) of the Tailwind CSS v3 framework. These executables are platform specific, so there are actually separate underlying gems per platform, but the correct gem will automatically be picked for your platform.
39-
40-
Supported platforms are:
41-
42-
- arm64-darwin (macos-arm64)
43-
- x64-mingw32 (windows-x64)
44-
- x64-mingw-ucr (windows-x64)
45-
- x86_64-darwin (macos-x64)
46-
- x86_64-linux (linux-x64)
47-
- aarch64-linux (linux-arm64)
48-
- arm-linux (linux-armv7)
49-
50-
51-
### Using a local installation of `tailwindcss`
52-
53-
If you are not able to use the vendored standalone executables (for example, if you're on an unsupported platform), you can use a local installation of the `tailwindcss` executable by setting an environment variable named `TAILWINDCSS_INSTALL_DIR` to the directory path containing the executable.
54-
55-
For example, if you've installed `tailwindcss` so that the executable is found at `/path/to/node_modules/bin/tailwindcss`, then you should set your environment variable like so:
56-
57-
``` sh
58-
TAILWINDCSS_INSTALL_DIR=/path/to/node_modules/bin
59-
```
60-
61-
or, for relative paths like `./node_modules/.bin/tailwindcss`:
62-
63-
``` sh
64-
TAILWINDCSS_INSTALL_DIR=node_modules/.bin
65-
```
38+
This gem depends on the `tailwindcss-ruby` gem to install a working tailwind executable. You can also use a local (npm-based) installation if you prefer, please go to https://github.com/flavorjones/tailwindcss-ruby for more information.
6639

6740

6841
## Developing with Tailwindcss
@@ -206,41 +179,7 @@ For Tailwind to work, your class names need to be spelled out. If you need to ma
206179

207180
### `ERROR: Cannot find the tailwindcss executable` for supported platform
208181

209-
Some users are reporting this error even when running on one of the supported native platforms:
210-
211-
- arm64-darwin
212-
- x64-mingw32
213-
- x64-mingw-ucrt
214-
- x86_64-darwin
215-
- x86_64-linux
216-
- aarch64-linux
217-
218-
#### Check Bundler PLATFORMS
219-
220-
A possible cause of this is that Bundler has not been told to include native gems for your current platform. Please check your `Gemfile.lock` file to see whether your native platform is included in the `PLATFORMS` section. If necessary, run:
221-
222-
``` sh
223-
bundle lock --add-platform <platform-name>
224-
```
225-
226-
and re-bundle.
227-
228-
229-
#### Check BUNDLE_FORCE_RUBY_PLATFORM
230-
231-
Another common cause of this is that bundler is configured to always use the "ruby" platform via the
232-
`BUNDLE_FORCE_RUBY_PLATFORM` config parameter being set to `true`. Please remove this configuration:
233-
234-
``` sh
235-
bundle config unset force_ruby_platform
236-
# or
237-
bundle config set --local force_ruby_platform false
238-
```
239-
240-
and re-bundle.
241-
242-
See https://bundler.io/man/bundle-config.1.html for more information.
243-
182+
See https://github.com/flavorjones/tailwindcss-ruby for help.
244183

245184
### Using asset-pipeline assets
246185

@@ -280,5 +219,4 @@ Or, if you do want to keep using the asset pipeline in parallel, make sure to re
280219
## License
281220

282221
Tailwind for Rails is released under the [MIT License](https://opensource.org/licenses/MIT).
283-
Tailwind CSS is released under the [MIT License](https://opensource.org/licenses/MIT).
284222
The Inter font is released under the [SIL Open Font License, Version 1.1](https://github.com/rsms/inter/blob/master/LICENSE.txt).

‎exe/tailwindcss

-19
This file was deleted.

‎lib/tailwindcss-rails.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module Tailwindcss
22
end
33

4-
require_relative "tailwindcss/upstream"
54
require_relative "tailwindcss/version"
65
require_relative "tailwindcss/engine"
76
require_relative "tailwindcss/commands"

‎lib/tailwindcss/commands.rb

+2-72
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,11 @@
1-
require_relative "upstream"
1+
require "tailwindcss/ruby"
22

33
module Tailwindcss
44
module Commands
5-
DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe"))
6-
GEM_NAME = "tailwindcss-rails"
7-
8-
# raised when the host platform is not supported by upstream tailwindcss's binary releases
9-
class UnsupportedPlatformException < StandardError
10-
end
11-
12-
# raised when the tailwindcss executable could not be found where we expected it to be
13-
class ExecutableNotFoundException < StandardError
14-
end
15-
16-
# raised when TAILWINDCSS_INSTALL_DIR does not exist
17-
class DirectoryNotFoundException < StandardError
18-
end
19-
205
class << self
21-
def platform
22-
[:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
23-
end
24-
25-
def executable(exe_path: DEFAULT_DIR)
26-
tailwindcss_install_dir = ENV["TAILWINDCSS_INSTALL_DIR"]
27-
if tailwindcss_install_dir
28-
if File.directory?(tailwindcss_install_dir)
29-
warn "NOTE: using TAILWINDCSS_INSTALL_DIR to find tailwindcss executable: #{tailwindcss_install_dir}"
30-
exe_path = tailwindcss_install_dir
31-
exe_file = File.expand_path(File.join(tailwindcss_install_dir, "tailwindcss"))
32-
else
33-
raise DirectoryNotFoundException, <<~MESSAGE
34-
TAILWINDCSS_INSTALL_DIR is set to #{tailwindcss_install_dir}, but that directory does not exist.
35-
MESSAGE
36-
end
37-
else
38-
if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) }
39-
raise UnsupportedPlatformException, <<~MESSAGE
40-
tailwindcss-rails does not support the #{platform} platform
41-
Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation
42-
MESSAGE
43-
end
44-
45-
exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f|
46-
Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME)
47-
end
48-
end
49-
50-
if exe_file.nil? || !File.exist?(exe_file)
51-
raise ExecutableNotFoundException, <<~MESSAGE
52-
Cannot find the tailwindcss executable for #{platform} in #{exe_path}
53-
54-
If you're using bundler, please make sure you're on the latest bundler version:
55-
56-
gem install bundler
57-
bundle update --bundler
58-
59-
Then make sure your lock file includes this platform by running:
60-
61-
bundle lock --add-platform #{platform}
62-
bundle install
63-
64-
See `bundle lock --help` output for details.
65-
66-
If you're still seeing this message after taking those steps, try running
67-
`bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
68-
https://github.com/rails/tailwindcss-rails#check-bundle_force_ruby_platform
69-
for more details.
70-
MESSAGE
71-
end
72-
73-
exe_file
74-
end
75-
766
def compile_command(debug: false, **kwargs)
777
command = [
78-
executable(**kwargs),
8+
Tailwindcss::Ruby.executable(**kwargs),
799
"-i", Rails.root.join("app/assets/stylesheets/application.tailwind.css").to_s,
8010
"-o", Rails.root.join("app/assets/builds/tailwind.css").to_s,
8111
"-c", Rails.root.join("config/tailwind.config.js").to_s,

‎lib/tailwindcss/upstream.rb

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
module Tailwindcss
2-
# constants describing the upstream tailwindcss project
32
module Upstream
4-
VERSION = "v3.4.13"
5-
6-
# rubygems platform name => upstream release filename
7-
NATIVE_PLATFORMS = {
8-
"arm64-darwin" => "tailwindcss-macos-arm64",
9-
"x64-mingw32" => "tailwindcss-windows-x64.exe",
10-
"x64-mingw-ucrt" => "tailwindcss-windows-x64.exe",
11-
"x86_64-darwin" => "tailwindcss-macos-x64",
12-
"x86_64-linux" => "tailwindcss-linux-x64",
13-
"aarch64-linux" => "tailwindcss-linux-arm64",
14-
"arm-linux" => "tailwindcss-linux-armv7",
15-
}
3+
VERSION = Tailwindcss::Ruby::Upstream::VERSION
4+
deprecate_constant :VERSION
165
end
176
end

‎package/tailwindcss-v3.4.7-checksums.txt

-6
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.