Skip to content

Commit 9108d53

Browse files
committed
prefactor: expose constants related to upstream tailwindcss
The following constants have been moved from rakelib/package.rake into lib/tailwindcss/upstream.rb to be accessible from within the installed gem: - TAILWINDCSS_VERSION → Tailwindcss::Upstream::VERSION - TAILWINDCSS_NATIVE_PLATFORMS -> Tailwindcss::Upstream::NATIVE_PLATFORMS
1 parent 3fdd00f commit 9108d53

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

lib/tailwindcss-rails.rb

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

4+
require "tailwindcss/upstream"
45
require "tailwindcss/version"
56
require "tailwindcss/engine"

lib/tailwindcss/upstream.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Tailwindcss
2+
# constants describing the upstream tailwindcss project
3+
module Upstream
4+
VERSION = "v3.0.5"
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+
"x86_64-darwin" => "tailwindcss-macos-x64",
11+
"x86_64-linux" => "tailwindcss-linux-x64",
12+
}
13+
end
14+
end

rakelib/package.rake

+5-14
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#
55
# TL;DR: run "rake package"
66
#
7-
# The native platform gems (defined by TAILWINDCSS_NATIVE_PLATFORMS below) will each contain two
8-
# files in addition to what the vanilla ruby gem contains:
7+
# The native platform gems (defined by Tailwindcss::Upstream::NATIVE_PLATFORMS) will each contain
8+
# two files in addition to what the vanilla ruby gem contains:
99
#
1010
# exe/
1111
# ├── tailwindcss # generic ruby script to find and run the binary
@@ -56,19 +56,10 @@
5656
#
5757
require "rubygems/package_task"
5858
require "open-uri"
59-
60-
TAILWINDCSS_VERSION = "v3.0.5" # string used to generate the download URL
61-
62-
# rubygems platform name => upstream release filename
63-
TAILWINDCSS_NATIVE_PLATFORMS = {
64-
"arm64-darwin" => "tailwindcss-macos-arm64",
65-
"x64-mingw32" => "tailwindcss-windows-x64.exe",
66-
"x86_64-darwin" => "tailwindcss-macos-x64",
67-
"x86_64-linux" => "tailwindcss-linux-x64",
68-
}
59+
require_relative "../lib/tailwindcss/upstream"
6960

7061
def tailwindcss_download_url(filename)
71-
"https://github.com/tailwindlabs/tailwindcss/releases/download/#{TAILWINDCSS_VERSION}/#{filename}"
62+
"https://github.com/tailwindlabs/tailwindcss/releases/download/#{Tailwindcss::Upstream::VERSION}/#{filename}"
7263
end
7364

7465
TAILWINDCSS_RAILS_GEMSPEC = Bundler.load_gemspec("tailwindcss-rails.gemspec")
@@ -78,7 +69,7 @@ desc "Build the ruby gem"
7869
task "gem:ruby" => [gem_path]
7970

8071
exepaths = []
81-
TAILWINDCSS_NATIVE_PLATFORMS.each do |platform, filename|
72+
Tailwindcss::Upstream::NATIVE_PLATFORMS.each do |platform, filename|
8273
TAILWINDCSS_RAILS_GEMSPEC.dup.tap do |gemspec|
8374
exedir = File.join(gemspec.bindir, platform) # "exe/x86_64-linux"
8475
exepath = File.join(exedir, "tailwindcss") # "exe/x86_64-linux/tailwindcss"

0 commit comments

Comments
 (0)