ruby_cms 0.2.0.2 → 0.2.0.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 +4 -0
- data/README.md +20 -2
- data/lib/generators/ruby_cms/install_generator.rb +33 -65
- data/lib/ruby_cms/engine.rb +12 -5
- data/lib/ruby_cms/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6812068b183da96c729d26ae664a39d599aea509a17a11ac0851b715c652cdcf
|
|
4
|
+
data.tar.gz: b087d0fe4f6bb7af6db0aef47e195e7f4f179ab65476a2b6f1048bef514444ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e0f9ca986cdc2d3c5caa5681261e49d015940c9e19be90406e341fffa215c5d1092ae9f47a30d64a39db9a221d2add4e6caac4eccaa3b79f9a8d3afd8e79343f
|
|
7
|
+
data.tar.gz: 5043cc31c3d8adcd61480d3fafc64b851d468d57ee7daf6e251793150c663c4d6cae9c94e43a880bfbd940d414b38408a7d32148bcd63db18404cf8e8b579c07
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -493,9 +493,27 @@ rails ruby_cms:css:compile_gem
|
|
|
493
493
|
### Faster Docker Builds (`assets:precompile`)
|
|
494
494
|
|
|
495
495
|
`assets:precompile` loads the Rails app in production mode and can be slow in Docker/Fly builds.
|
|
496
|
-
RubyCMS
|
|
496
|
+
RubyCMS skips non-asset runtime initializers during this phase (navigation registration,
|
|
497
497
|
dashboard registration, versioning hook, settings import, and permission seeding), which reduces
|
|
498
|
-
precompile overhead.
|
|
498
|
+
precompile overhead. Detection uses `ARGV` (not only `$PROGRAM_NAME`) so it still applies when the
|
|
499
|
+
Ruby program name is `ruby` instead of `rails`.
|
|
500
|
+
|
|
501
|
+
**Tailwind CSS:** Do not add multiple `@source` globs that point at the same RubyCMS gem (e.g. both
|
|
502
|
+
`../../../../gems/ruby_cms/...` and `/usr/local/bundle/.../ruby_cms-*`). That scans the engine twice
|
|
503
|
+
and slows `tailwindcss:build` a lot. Instead, rely on [tailwindcss-rails engine support](https://github.com/rails/tailwindcss-rails#rails-engines-support-experimental):
|
|
504
|
+
|
|
505
|
+
1. RubyCMS ships `app/assets/tailwind/ruby_cms_engine/engine.css` with `@source` paths relative to the gem
|
|
506
|
+
(the directory matches Rails’ `engine_name` for `RubyCms::Engine`, which is `ruby_cms_engine`).
|
|
507
|
+
2. `rails tailwindcss:engines` (run automatically before `tailwindcss:build`) generates
|
|
508
|
+
`app/assets/builds/tailwind/ruby_cms_engine.css` in the host app.
|
|
509
|
+
3. In the host’s `app/assets/tailwind/application.css`, add **once**:
|
|
510
|
+
|
|
511
|
+
```css
|
|
512
|
+
@import "../builds/tailwind/ruby_cms_engine";
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
Place it next to your other `@import` lines (e.g. after `@import "tailwindcss";`). Remove any
|
|
516
|
+
hand-written `@source` lines aimed at the RubyCMS gem.
|
|
499
517
|
|
|
500
518
|
Recommended Docker layer order:
|
|
501
519
|
|
|
@@ -855,18 +855,45 @@ module RubyCms
|
|
|
855
855
|
end.join("\n")
|
|
856
856
|
end
|
|
857
857
|
|
|
858
|
-
#
|
|
859
|
-
#
|
|
858
|
+
# Adds a single @import for tailwindcss-rails' engine shim (see gem app/assets/tailwind/ruby_cms_engine/engine.css).
|
|
859
|
+
# Avoids duplicate @source globs to the gem, which makes tailwindcss:build much slower.
|
|
860
860
|
def add_ruby_cms_tailwind_source(tailwind_css_path)
|
|
861
861
|
return unless tailwind_css_path.to_s.present? && File.exist?(tailwind_css_path)
|
|
862
862
|
|
|
863
863
|
content = File.read(tailwind_css_path)
|
|
864
|
-
|
|
865
|
-
return if gem_source_lines.all? {|line| content.include?(line) }
|
|
864
|
+
return if content.match?(%r{builds/tailwind/ruby_cms_engine})
|
|
866
865
|
|
|
867
|
-
|
|
866
|
+
injection = +"\n/* RubyCMS: Tailwind content via tailwindcss-rails engine (see ruby_cms README). */\n"
|
|
867
|
+
injection << "@import \"../builds/tailwind/ruby_cms_engine\";\n"
|
|
868
|
+
|
|
869
|
+
inserted = inject_ruby_cms_engine_import_after_tailwind!(tailwind_css_path, content, injection)
|
|
870
|
+
unless inserted
|
|
871
|
+
inject_into_file tailwind_css_path.to_s, after: /\A/ do
|
|
872
|
+
injection
|
|
873
|
+
end
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
say "✓ Task tailwind/source: Added RubyCMS engine import to #{tailwind_css_path}.", :green
|
|
868
877
|
rescue StandardError => e
|
|
869
|
-
say "⚠ Task tailwind/source: Could not add
|
|
878
|
+
say "⚠ Task tailwind/source: Could not add engine import: #{e.message}. Add manually.", :yellow
|
|
879
|
+
end
|
|
880
|
+
|
|
881
|
+
def inject_ruby_cms_engine_import_after_tailwind!(tailwind_css_path, content, injection)
|
|
882
|
+
patterns = [
|
|
883
|
+
%(@import "tailwindcss";\n),
|
|
884
|
+
%(@import "tailwindcss";),
|
|
885
|
+
%(@import "tailwindcss"\n),
|
|
886
|
+
%(@import "tailwindcss")
|
|
887
|
+
]
|
|
888
|
+
patterns.each do |after_pattern|
|
|
889
|
+
next unless content.include?(after_pattern)
|
|
890
|
+
|
|
891
|
+
inject_into_file tailwind_css_path.to_s, after: after_pattern do
|
|
892
|
+
injection
|
|
893
|
+
end
|
|
894
|
+
return true
|
|
895
|
+
end
|
|
896
|
+
false
|
|
870
897
|
end
|
|
871
898
|
|
|
872
899
|
# Tailwind v3 support (tailwind.config.js content array)
|
|
@@ -905,65 +932,6 @@ module RubyCms
|
|
|
905
932
|
]
|
|
906
933
|
end
|
|
907
934
|
|
|
908
|
-
def build_gem_source_lines(tailwind_css_path)
|
|
909
|
-
css_dir = Pathname.new(tailwind_css_path).dirname
|
|
910
|
-
gem_views = path_relative_to_css_or_absolute(RubyCms::Engine.root.join("app/views"),
|
|
911
|
-
css_dir)
|
|
912
|
-
gem_components = path_relative_to_css_or_absolute(
|
|
913
|
-
RubyCms::Engine.root.join("app/components"), css_dir
|
|
914
|
-
)
|
|
915
|
-
[
|
|
916
|
-
%(@source "#{gem_views}/**/*.erb";),
|
|
917
|
-
%(@source "#{gem_components}/**/*.rb";)
|
|
918
|
-
]
|
|
919
|
-
end
|
|
920
|
-
|
|
921
|
-
def path_relative_to_css_or_absolute(target_path, css_dir)
|
|
922
|
-
Pathname.new(target_path).relative_path_from(css_dir).to_s
|
|
923
|
-
rescue ArgumentError
|
|
924
|
-
# Different mount/volume: fall back to absolute path.
|
|
925
|
-
Pathname.new(target_path).to_s
|
|
926
|
-
end
|
|
927
|
-
|
|
928
|
-
def inject_tailwind_source(tailwind_css_path, content, gem_source_lines)
|
|
929
|
-
to_inject = build_tailwind_source_injection(gem_source_lines)
|
|
930
|
-
inserted = try_insert_after_patterns?(tailwind_css_path, content, to_inject)
|
|
931
|
-
inject_at_start(tailwind_css_path, to_inject) unless inserted
|
|
932
|
-
say "✓ Task tailwind/source: Added @source for RubyCMS views/components to " \
|
|
933
|
-
"tailwind/application.css.",
|
|
934
|
-
:green
|
|
935
|
-
end
|
|
936
|
-
|
|
937
|
-
def build_tailwind_source_injection(gem_source_lines)
|
|
938
|
-
to_inject = +"\n/* Include RubyCMS views/components so Tailwind finds utility classes. */\n"
|
|
939
|
-
Array(gem_source_lines).each {|line| to_inject << line << "\n" }
|
|
940
|
-
to_inject << "\n"
|
|
941
|
-
to_inject
|
|
942
|
-
end
|
|
943
|
-
|
|
944
|
-
def try_insert_after_patterns?(tailwind_css_path, content, to_inject)
|
|
945
|
-
patterns = [
|
|
946
|
-
%(@import "tailwindcss";\n),
|
|
947
|
-
%(@import "tailwindcss";),
|
|
948
|
-
%(@import "tailwindcss"\n),
|
|
949
|
-
%(@import "tailwindcss")
|
|
950
|
-
]
|
|
951
|
-
patterns.each do |after_pattern|
|
|
952
|
-
next unless content.include?(after_pattern)
|
|
953
|
-
|
|
954
|
-
inject_into_file tailwind_css_path.to_s, after: after_pattern do
|
|
955
|
-
to_inject
|
|
956
|
-
end
|
|
957
|
-
return true
|
|
958
|
-
end
|
|
959
|
-
false
|
|
960
|
-
end
|
|
961
|
-
|
|
962
|
-
def inject_at_start(tailwind_css_path, to_inject)
|
|
963
|
-
inject_into_file tailwind_css_path.to_s, after: /\A/ do
|
|
964
|
-
to_inject
|
|
965
|
-
end
|
|
966
|
-
end
|
|
967
935
|
end
|
|
968
936
|
|
|
969
937
|
def run_migrate
|
data/lib/ruby_cms/engine.rb
CHANGED
|
@@ -100,7 +100,8 @@ module RubyCms
|
|
|
100
100
|
# For importmap: ensure engine's importmap is loaded
|
|
101
101
|
if app.config.respond_to?(:importmap)
|
|
102
102
|
app.config.importmap.paths << config.root.join("config/importmap.rb")
|
|
103
|
-
|
|
103
|
+
# Only sweep the engine's Stimulus tree (not the whole app/javascript tree)
|
|
104
|
+
app.config.importmap.cache_sweepers << config.root.join("app/javascript/controllers/ruby_cms")
|
|
104
105
|
end
|
|
105
106
|
end
|
|
106
107
|
|
|
@@ -262,12 +263,18 @@ module RubyCms
|
|
|
262
263
|
end
|
|
263
264
|
end
|
|
264
265
|
|
|
266
|
+
# True during asset pipeline tasks so we skip DB-heavy initializers (permissions, settings import).
|
|
267
|
+
# Detect by ARGV first: $PROGRAM_NAME is often "ruby" when using `ruby bin/rails`, which would
|
|
268
|
+
# miss the old rake/rails basename check; tailwindcss:build runs as a prerequisite of
|
|
269
|
+
# assets:precompile and keeps the same ARGV, but a standalone `rails tailwindcss:build` must match too.
|
|
265
270
|
def self.assets_precompile_phase?
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
argv = Array(ARGV).map(&:to_s)
|
|
272
|
+
return true if argv.include?("assets:precompile")
|
|
273
|
+
return true if argv.any? {|a| a.start_with?("tailwindcss:") }
|
|
274
|
+
return true if argv.include?("propshaft:compile")
|
|
269
275
|
|
|
270
|
-
|
|
276
|
+
command = File.basename($PROGRAM_NAME.to_s)
|
|
277
|
+
(command == "rake" || command == "rails") && argv.include?("assets:precompile")
|
|
271
278
|
end
|
|
272
279
|
end
|
|
273
280
|
end
|
data/lib/ruby_cms/version.rb
CHANGED