tailwindcss-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c1163e758264ac53f96714d98fc94a2bea5fd6d271750e18387e0aeab94c11e1
4
+ data.tar.gz: a0dc1753bbe2302d2c43d5856c49178a1fa717fed6ff20825a6da43b1c3db8f3
5
+ SHA512:
6
+ metadata.gz: 73a2a8ac0954d8dd882cd5b341a59d1d904404b227f889907817a5b6268a27b5bf404a690fda7d270b1b04ed97eb4d00bb898d3662f27a87711c7b36bccde17c
7
+ data.tar.gz: e012f02964ab2aababaf643dabf8a3f25383c9ca364db91c3218c9cd5d5add8b8d10c6d66e7f831ad0e7c71c4f6ae0b22beb2e2597688f517c8eeeb12ee42d15
data/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Tailwindcss::Ruby
2
+
3
+ A self-contained `tailwindcss` executable, wrapped up in a ruby gem. That's it. Nothing else.
4
+
5
+ If you're looking to leverage tailwindcss in your Rails project, please see https://github.com/rails/tailwindcss-rails for integration that is supported by the Rails team.
6
+
7
+
8
+ ## Installation
9
+
10
+ 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.
11
+
12
+ Supported platforms are:
13
+
14
+ - arm64-darwin (macos-arm64)
15
+ - x64-mingw32 (windows-x64)
16
+ - x64-mingw-ucr (windows-x64)
17
+ - x86_64-darwin (macos-x64)
18
+ - x86_64-linux (linux-x64)
19
+ - aarch64-linux (linux-arm64)
20
+ - arm-linux (linux-armv7)
21
+
22
+ Install the gem and add to the application's Gemfile by executing:
23
+
24
+ ```bash
25
+ bundle add tailwindcss-ruby
26
+ ```
27
+
28
+ If bundler is not being used to manage dependencies, install the gem by executing:
29
+
30
+ ```bash
31
+ gem install tailwindcss-ruby
32
+ ```
33
+
34
+ ### Using a local installation of `tailwindcss`
35
+
36
+ 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.
37
+
38
+ 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:
39
+
40
+ ``` sh
41
+ TAILWINDCSS_INSTALL_DIR=/path/to/node_modules/bin
42
+ ```
43
+
44
+ or, for relative paths like `./node_modules/.bin/tailwindcss`:
45
+
46
+ ``` sh
47
+ TAILWINDCSS_INSTALL_DIR=node_modules/.bin
48
+ ```
49
+
50
+
51
+ ## Versioning
52
+
53
+ This gem will always have the same version number as the underlying TailwindCSS release. For example, the gem with version v3.4.13 will package upstream TailwindCSS v3.4.13.
54
+
55
+ If there ever needs to be multiple releases for the same version of TailwindCSS, the version will contain an additional digit. For example, if we re-released TailwindCSS v3.4.13, it might be shipped in gem version v3.4.13.1 or v3.4.13.2.
56
+
57
+
58
+ ## Usage
59
+
60
+ ### Ruby
61
+
62
+ The gem makes available `Tailwindcss::Ruby.executable` which is the path to the vendored standalone executable.
63
+
64
+ ``` ruby
65
+ require "tailwindcss/ruby"
66
+ Tailwindcss::Ruby.executable
67
+ # => "/path/to/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/tailwindcss-ruby-0.1.0-x86_64-linux/exe/x86_64-linux/tailwindcss"
68
+ ```
69
+
70
+
71
+ ### Command line
72
+
73
+ This gem provides an executable `tailwindcss` shim that will run the vendored standalone executable.
74
+
75
+ ``` bash
76
+ # where is the shim?
77
+ $ bundle exec which tailwindcss
78
+ /path/to/installs/ruby/3.3/bin/tailwindcss
79
+
80
+ # run the actual executable through the shim
81
+ $ bundle exec tailwindcss --help
82
+ ["/path/to/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/tailwindcss-rails-2.6.0-x86_64-linux/exe/x86_64-linux/tailwindcss", "--help"]
83
+
84
+ tailwindcss v3.4.3
85
+
86
+ Usage:
87
+ tailwindcss [--input input.css] [--output output.css] [--watch] [options...]
88
+ tailwindcss init [--full] [--postcss] [options...]
89
+
90
+ Commands:
91
+ init [options]
92
+
93
+ Options:
94
+ -i, --input Input file
95
+ -o, --output Output file
96
+ -w, --watch Watch for changes and rebuild as needed
97
+ -p, --poll Use polling instead of filesystem events when watching
98
+ --content Content paths to use for removing unused classes
99
+ --postcss Load custom PostCSS configuration
100
+ -m, --minify Minify the output
101
+ -c, --config Path to a custom config file
102
+ --no-autoprefixer Disable autoprefixer
103
+ -h, --help Display usage information
104
+ ```
105
+
106
+
107
+ ## Troubleshooting
108
+
109
+ ### `ERROR: Cannot find the tailwindcss executable` for supported platform
110
+
111
+ Some users are reporting this error even when running on one of the supported native platforms:
112
+
113
+ - arm64-darwin
114
+ - x64-mingw32
115
+ - x64-mingw-ucrt
116
+ - x86_64-darwin
117
+ - x86_64-linux
118
+ - aarch64-linux
119
+
120
+ #### Check Bundler PLATFORMS
121
+
122
+ 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:
123
+
124
+ ``` sh
125
+ bundle lock --add-platform <platform-name>
126
+ ```
127
+
128
+ and re-bundle.
129
+
130
+
131
+ #### Check BUNDLE_FORCE_RUBY_PLATFORM
132
+
133
+ Another common cause of this is that bundler is configured to always use the "ruby" platform via the
134
+ `BUNDLE_FORCE_RUBY_PLATFORM` config parameter being set to `true`. Please remove this configuration:
135
+
136
+ ``` sh
137
+ bundle config unset force_ruby_platform
138
+ # or
139
+ bundle config set --local force_ruby_platform false
140
+ ```
141
+
142
+ and re-bundle.
143
+
144
+ See https://bundler.io/man/bundle-config.1.html for more information.
145
+
146
+
147
+ ## Contributing
148
+
149
+ Bug reports and pull requests are welcome on GitHub at https://github.com/flavorjones/tailwindcss-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CODE_OF_CONDUCT.md).
150
+
151
+ ## License
152
+
153
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
154
+
155
+ Tailwind CSS is [released under the MIT License](https://github.com/tailwindlabs/tailwindcss/blob/next/LICENSE).
156
+
157
+ ## Code of Conduct
158
+
159
+ Everyone interacting in the Tailwindcss::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/flavorjones/tailwindcss-ruby/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[test standard]
data/exe/tailwindcss ADDED
@@ -0,0 +1,19 @@
1
+ #! /usr/bin/env ruby
2
+ # because rubygems shims assume a gem's executables are Ruby
3
+
4
+ require "tailwindcss/commands"
5
+
6
+ begin
7
+ command = [Tailwindcss::Ruby.executable, *ARGV]
8
+ puts command.inspect
9
+ if Gem.win_platform?
10
+ # use system rather than exec as exec inexplicably fails to find the executable on Windows
11
+ # see related https://github.com/rubys/sprockets-esbuild/pull/4
12
+ system(*command, exception: true)
13
+ else
14
+ exec(*command)
15
+ end
16
+ rescue Tailwindcss::Ruby::UnsupportedPlatformException, Tailwindcss::Ruby::ExecutableNotFoundException => e
17
+ STDERR.puts("ERROR: " + e.message)
18
+ exit 1
19
+ end
@@ -0,0 +1,18 @@
1
+ module Tailwindcss
2
+ module Ruby
3
+ 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
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tailwindcss
4
+ module Ruby
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ruby/version"
4
+ require_relative "ruby/upstream"
5
+
6
+ module Tailwindcss
7
+ module Ruby
8
+ DEFAULT_DIR = File.expand_path(File.join(__dir__, "..", "..", "exe"))
9
+ GEM_NAME = "tailwindcss-rails"
10
+
11
+ # raised when the host platform is not supported by upstream tailwindcss's binary releases
12
+ class UnsupportedPlatformException < StandardError
13
+ end
14
+
15
+ # raised when the tailwindcss executable could not be found where we expected it to be
16
+ class ExecutableNotFoundException < StandardError
17
+ end
18
+
19
+ # raised when TAILWINDCSS_INSTALL_DIR does not exist
20
+ class DirectoryNotFoundException < StandardError
21
+ end
22
+
23
+ class << self
24
+ def platform
25
+ [:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
26
+ end
27
+
28
+ def executable(exe_path: DEFAULT_DIR)
29
+ tailwindcss_install_dir = ENV["TAILWINDCSS_INSTALL_DIR"]
30
+ if tailwindcss_install_dir
31
+ if File.directory?(tailwindcss_install_dir)
32
+ warn "NOTE: using TAILWINDCSS_INSTALL_DIR to find tailwindcss executable: #{tailwindcss_install_dir}"
33
+ exe_path = tailwindcss_install_dir
34
+ exe_file = File.expand_path(File.join(tailwindcss_install_dir, "tailwindcss"))
35
+ else
36
+ raise DirectoryNotFoundException, <<~MESSAGE
37
+ TAILWINDCSS_INSTALL_DIR is set to #{tailwindcss_install_dir}, but that directory does not exist.
38
+ MESSAGE
39
+ end
40
+ else
41
+ if Tailwindcss::Ruby::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) }
42
+ raise UnsupportedPlatformException, <<~MESSAGE
43
+ tailwindcss-rails does not support the #{platform} platform
44
+ Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation
45
+ MESSAGE
46
+ end
47
+
48
+ exe_file = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f|
49
+ Gem::Platform.match_gem?(Gem::Platform.new(File.basename(File.dirname(f))), GEM_NAME)
50
+ end
51
+ end
52
+
53
+ if exe_file.nil? || !File.exist?(exe_file)
54
+ raise ExecutableNotFoundException, <<~MESSAGE
55
+ Cannot find the tailwindcss executable for #{platform} in #{exe_path}
56
+
57
+ If you're using bundler, please make sure you're on the latest bundler version:
58
+
59
+ gem install bundler
60
+ bundle update --bundler
61
+
62
+ Then make sure your lock file includes this platform by running:
63
+
64
+ bundle lock --add-platform #{platform}
65
+ bundle install
66
+
67
+ See `bundle lock --help` output for details.
68
+
69
+ If you're still seeing this message after taking those steps, try running
70
+ `bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
71
+ https://github.com/rails/tailwindcss-rails#check-bundle_force_ruby_platform
72
+ for more details.
73
+ MESSAGE
74
+ end
75
+
76
+ exe_file
77
+ end
78
+ end
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tailwindcss-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Dalessio
8
+ - David Heinemeier Hansson
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2024-09-25 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A self-contained `tailwindcss` executable, wrapped up in a ruby gem.
15
+ That's it. Nothing else.
16
+ email:
17
+ - mike.dalessio@gmail.com
18
+ - david@loudthinking.com
19
+ executables:
20
+ - tailwindcss
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - README.md
25
+ - Rakefile
26
+ - exe/tailwindcss
27
+ - lib/tailwindcss/ruby.rb
28
+ - lib/tailwindcss/ruby/upstream.rb
29
+ - lib/tailwindcss/ruby/version.rb
30
+ homepage: https://github.com/flavorjones/tailwindcss-ruby
31
+ licenses:
32
+ - MIT
33
+ metadata:
34
+ source_code_uri: https://github.com/flavorjones/tailwindcss-ruby
35
+ changelog_uri: https://github.com/flavorjones/tailwindcss-ruby/blob/main/CHANGELOG.md
36
+ rubygems_mfa_required: 'true'
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.0
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubygems_version: 3.5.16
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: A self-contained `tailwindcss` executable.
56
+ test_files: []