stimulus_plumbers_tailwind 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +21 -5
- data/lib/generators/stimulus_plumbers_tailwind/install/install_generator.rb +78 -0
- data/lib/stimulus_plumbers_tailwind/engine.rb +4 -0
- data/lib/stimulus_plumbers_tailwind/version.rb +1 -1
- data/lib/tasks/stimulus_plumbers_tailwind.rake +15 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9eb6bbfe958bd425b443843724ef2b3a66041f04fe40ec4b041a72accd9ec497
|
|
4
|
+
data.tar.gz: f1928462ed5485e7560a1993e72aeddbd90dd734db280703ae50e751bfcb6306
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce4edf07b1b20042b73e67c4d16d86eb6213e0e08a3fdb2049a362c4042941fe7672b5503e185da78c4e85394a4592e7a51971fcfca01802c14d4df5c2cf4bad
|
|
7
|
+
data.tar.gz: 625987458573abbe7ab612323c81ce300b2ac993347e6af4903e1a034b35c7153a81d716695a79531c38578d78f0884feddfe15655b0e252cbccc0f254d05ae5
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
---
|
|
6
|
+
## [0.4.3](https://github.com/ryancyq/stimulus-plumbers/compare/stimulus-plumbers-tailwind/v0.4.2..stimulus-plumbers-tailwind/v0.4.3) - 2026-06-30
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- tailwind generator ([#149](https://github.com/ryancyq/stimulus-plumbers/issues/149)) - ([9dafae0](https://github.com/ryancyq/stimulus-plumbers/commit/9dafae03b5d49fb543d08f84cdb718d944dce49f)) - Ryan Chang
|
|
11
|
+
|
|
5
12
|
---
|
|
6
13
|
## [0.4.2](https://github.com/ryancyq/stimulus-plumbers/compare/stimulus-plumbers-tailwind/v0.4.0..stimulus-plumbers-tailwind/v0.4.2) - 2026-06-30
|
|
7
14
|
|
data/README.md
CHANGED
|
@@ -31,14 +31,30 @@ StimulusPlumbers.configure do |config|
|
|
|
31
31
|
end
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Run the install generator once to inject the required `@source` directive into your Tailwind CSS entry file:
|
|
35
35
|
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
@source "/path/to/gems/stimulus_plumbers_tailwind-VERSION/lib/**/*.rb";
|
|
36
|
+
```bash
|
|
37
|
+
bin/rails generate stimulus_plumbers_tailwind:install
|
|
39
38
|
```
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
The generator checks these files in order:
|
|
41
|
+
|
|
42
|
+
- `app/assets/stylesheets/application.tailwind.css`
|
|
43
|
+
- `app/assets/stylesheets/application.css`
|
|
44
|
+
- `app/javascript/entrypoints/application.css`
|
|
45
|
+
|
|
46
|
+
Override the detected file for both the generator and rake task with `TAILWIND_CSS_FILE=/path/to/entry.css`.
|
|
47
|
+
|
|
48
|
+
After the initial install, the `@source` path is kept current automatically — no manual re-run needed after `bundle update`. The engine hooks `stimulus_plumbers_tailwind:install` as a prerequisite of:
|
|
49
|
+
|
|
50
|
+
- `assets:precompile` (Sprockets and Propshaft both define this task)
|
|
51
|
+
- `tailwindcss:build` (when `tailwindcss-rails` is present)
|
|
52
|
+
|
|
53
|
+
To trigger an update manually without a full compile (useful for debugging or after `bundle update`):
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bin/rails stimulus_plumbers_tailwind:install
|
|
57
|
+
```
|
|
42
58
|
|
|
43
59
|
## Theming
|
|
44
60
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
|
|
5
|
+
module StimulusPlumbersTailwind
|
|
6
|
+
module Generators
|
|
7
|
+
class InstallGenerator < Rails::Generators::Base
|
|
8
|
+
GEM_NAME = "stimulus_plumbers_tailwind"
|
|
9
|
+
TAILWIND_CSS_FILE = "TAILWIND_CSS_FILE"
|
|
10
|
+
CSS_CANDIDATES = %w[
|
|
11
|
+
app/assets/stylesheets/application.tailwind.css
|
|
12
|
+
app/assets/stylesheets/application.css
|
|
13
|
+
app/javascript/entrypoints/application.css
|
|
14
|
+
].freeze
|
|
15
|
+
|
|
16
|
+
def install
|
|
17
|
+
css_file = entry_css_file
|
|
18
|
+
return warn_entry_css_not_found unless css_file
|
|
19
|
+
|
|
20
|
+
apply_edit(css_file)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def warn_entry_css_not_found
|
|
26
|
+
tried = CSS_CANDIDATES.map { |c| File.join(destination_root, c) }
|
|
27
|
+
tried.unshift(File.expand_path(ENV[TAILWIND_CSS_FILE])) if ENV[TAILWIND_CSS_FILE]
|
|
28
|
+
say "Could not find a Tailwind CSS entry file. Tried: #{tried.join(", ")}. " \
|
|
29
|
+
"Set #{TAILWIND_CSS_FILE}=/path/to/entry.css and re-run.",
|
|
30
|
+
:red
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def apply_edit(css_file)
|
|
34
|
+
content = File.read(css_file)
|
|
35
|
+
new_content, status = content_edit(content, source_directive)
|
|
36
|
+
|
|
37
|
+
if new_content
|
|
38
|
+
File.write(css_file, new_content)
|
|
39
|
+
say_status status, relative_to_destination(css_file), :green
|
|
40
|
+
else
|
|
41
|
+
say_status :identical, relative_to_destination(css_file)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def content_edit(content, source_line)
|
|
46
|
+
if content.include?(source_line)
|
|
47
|
+
nil
|
|
48
|
+
elsif (existing = content.match(%r{@source "[^"]*#{Regexp.escape(GEM_NAME)}[^"]*";}))
|
|
49
|
+
[content.sub(existing[0], source_line), :update]
|
|
50
|
+
elsif (import_line = content.match(%r{@import "tailwindcss"[^;]*;}))
|
|
51
|
+
[content.sub(import_line[0], "#{import_line[0]}\n#{source_line}"), :insert]
|
|
52
|
+
else
|
|
53
|
+
["#{content.rstrip}\n#{source_line}\n", :append]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def source_directive
|
|
58
|
+
spec = Gem.loaded_specs[GEM_NAME]
|
|
59
|
+
%(@source "#{spec.gem_dir}/lib/**/*.rb";)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def entry_css_file
|
|
63
|
+
if ENV[TAILWIND_CSS_FILE]
|
|
64
|
+
path = File.expand_path(ENV[TAILWIND_CSS_FILE])
|
|
65
|
+
return path if File.exist?(path)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
CSS_CANDIDATES
|
|
69
|
+
.map { |c| File.join(destination_root, c) }
|
|
70
|
+
.find { |f| File.exist?(f) }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def relative_to_destination(path)
|
|
74
|
+
path.delete_prefix("#{destination_root}/")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :stimulus_plumbers_tailwind do
|
|
4
|
+
desc "Add @source directive for stimulus_plumbers_tailwind into Tailwind CSS entry file"
|
|
5
|
+
task install: :environment do
|
|
6
|
+
require "generators/stimulus_plumbers_tailwind/install/install_generator"
|
|
7
|
+
StimulusPlumbersTailwind::Generators::InstallGenerator.new(
|
|
8
|
+
[], {}, { destination_root: Rails.root.to_s }
|
|
9
|
+
).invoke_all
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Rake::Task["assets:precompile"].enhance(["stimulus_plumbers_tailwind:install"]) if Rake::Task.task_defined?("assets:precompile")
|
|
14
|
+
|
|
15
|
+
Rake::Task["tailwindcss:build"].enhance(["stimulus_plumbers_tailwind:install"]) if Rake::Task.task_defined?("tailwindcss:build")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stimulus_plumbers_tailwind
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Chang
|
|
@@ -33,6 +33,7 @@ files:
|
|
|
33
33
|
- CHANGELOG.md
|
|
34
34
|
- LICENSE-DEPENDENCIES
|
|
35
35
|
- README.md
|
|
36
|
+
- lib/generators/stimulus_plumbers_tailwind/install/install_generator.rb
|
|
36
37
|
- lib/stimulus_plumbers/themes/tailwind/avatar.rb
|
|
37
38
|
- lib/stimulus_plumbers/themes/tailwind/button.rb
|
|
38
39
|
- lib/stimulus_plumbers/themes/tailwind/button/group.rb
|
|
@@ -704,6 +705,7 @@ files:
|
|
|
704
705
|
- lib/stimulus_plumbers_tailwind.rb
|
|
705
706
|
- lib/stimulus_plumbers_tailwind/engine.rb
|
|
706
707
|
- lib/stimulus_plumbers_tailwind/version.rb
|
|
708
|
+
- lib/tasks/stimulus_plumbers_tailwind.rake
|
|
707
709
|
homepage: https://github.com/ryancyq/stimulus-plumbers
|
|
708
710
|
licenses:
|
|
709
711
|
- MIT
|