ruby_cms 0.2.0.3 → 0.2.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6812068b183da96c729d26ae664a39d599aea509a17a11ac0851b715c652cdcf
4
- data.tar.gz: b087d0fe4f6bb7af6db0aef47e195e7f4f179ab65476a2b6f1048bef514444ab
3
+ metadata.gz: 747105700c925ba3d9140a015fa477116795644d8a99c52b3aee53c4e786678d
4
+ data.tar.gz: 8a7bf4cea26c24f7f73f5c6800c6a8dcfb784031a8f313bf2fb7e421fb8bbf31
5
5
  SHA512:
6
- metadata.gz: e0f9ca986cdc2d3c5caa5681261e49d015940c9e19be90406e341fffa215c5d1092ae9f47a30d64a39db9a221d2add4e6caac4eccaa3b79f9a8d3afd8e79343f
7
- data.tar.gz: 5043cc31c3d8adcd61480d3fafc64b851d468d57ee7daf6e251793150c663c4d6cae9c94e43a880bfbd940d414b38408a7d32148bcd63db18404cf8e8b579c07
6
+ metadata.gz: 78ebfe96b5853ad7ab9698bdc0fca3eaa568f6a02ae691d7ba007c804e4076afe5bde33380d966875f2e24eb72f554d6918408f8fbe04ab80b3644808c11f9ae
7
+ data.tar.gz: e410f195decbe969b4a873624e440b9331a47081a305bd504eea5a44c0ae90b63e6fe4d0b734fd72a01ea09c471cff7ee7c733eca971525fa9ff0c094b5e0e2c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [0.2.0.3] - 2026-04-02
4
4
 
5
+ - The host app no longer needs to scan de gem for tailwind
6
+
7
+ ## [0.2.0.3] - 2026-04-02
8
+
5
9
  - Whole repo was scanned for comiling so it was slow.
6
10
 
7
11
  ## [0.2.0.2] - 2026-04-02
data/README.md CHANGED
@@ -493,27 +493,9 @@ 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 skips non-asset runtime initializers during this phase (navigation registration,
496
+ RubyCMS now 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. 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.
498
+ precompile overhead.
517
499
 
518
500
  Recommended Docker layer order:
519
501
 
@@ -15,7 +15,7 @@
15
15
  <link rel="manifest" href="<%= asset_path("site.webmanifest") %>">
16
16
 
17
17
  <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
18
- <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>
18
+ <%= stylesheet_link_tag "ruby_cms/admin", "data-turbo-track": "reload" rescue nil %>
19
19
  <%= stylesheet_link_tag "actiontext", "data-turbo-track": "reload" if asset_path("actiontext.css") rescue nil %>
20
20
  <%= javascript_importmap_tags "admin" %>
21
21
  </head>
@@ -21,7 +21,7 @@ module RubyCms
21
21
  - If the host uses /admin already, remove or change those routes.
22
22
  - Avoid root to: redirect("/admin") — use a real root or ruby_cms.unauthorized_redirect_path.
23
23
  - Review config/initializers/ruby_cms.rb (session, CSP).
24
- - Add 'css: bin/rails tailwindcss:watch' to Procfile.dev for Tailwind in development.
24
+ - RubyCMS admin styles are compiled once on install to app/assets/stylesheets/ruby_cms/admin.css.
25
25
  - Visit /admin (sign in as the admin you configured).
26
26
 
27
27
  Tracking:
@@ -215,7 +215,18 @@ module RubyCms
215
215
  no_tasks do
216
216
  def copy_admin_css(dest_dir)
217
217
  admin_css_dest = dest_dir.join("admin.css")
218
+ precompiled_admin_css = RubyCms::Engine.root.join("app/assets/stylesheets/ruby_cms/admin.css")
219
+ if File.exist?(precompiled_admin_css) && File.size(precompiled_admin_css).to_i.positive?
220
+ FileUtils.cp(precompiled_admin_css, admin_css_dest)
221
+ return
222
+ end
223
+
218
224
  RubyCms::Engine.compile_admin_css(admin_css_dest)
225
+ return if File.size(admin_css_dest).to_i > 64
226
+
227
+ say "⚠ Task css/copy: Generated admin.css is very small. " \
228
+ "Ensure RubyCMS ships precompiled CSS at app/assets/stylesheets/ruby_cms/admin.css.",
229
+ :yellow
219
230
  end
220
231
 
221
232
  def copy_components_css(src_dir, dest_dir)
@@ -478,8 +489,8 @@ module RubyCms
478
489
  end
479
490
 
480
491
  def configure_tailwind(tailwind_css)
481
- add_ruby_cms_tailwind_source(tailwind_css)
482
- add_ruby_cms_tailwind_content_paths
492
+ remove_ruby_cms_tailwind_source(tailwind_css)
493
+ remove_ruby_cms_tailwind_content_paths
483
494
  run "bin/rails tailwindcss:build" if File.exist?(tailwind_css)
484
495
  # Importmap pins are provided by the engine via `ruby_cms/config/importmap.rb`.
485
496
  add_importmap_pins
@@ -855,83 +866,45 @@ module RubyCms
855
866
  end.join("\n")
856
867
  end
857
868
 
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
- def add_ruby_cms_tailwind_source(tailwind_css_path)
869
+ # RubyCMS admin styles are precompiled to app/assets/stylesheets/ruby_cms/admin.css.
870
+ # Remove RubyCMS-specific Tailwind source globs to keep host-app builds fast.
871
+ # Not a generator task.
872
+ def remove_ruby_cms_tailwind_source(tailwind_css_path)
861
873
  return unless tailwind_css_path.to_s.present? && File.exist?(tailwind_css_path)
862
874
 
863
875
  content = File.read(tailwind_css_path)
864
- return if content.match?(%r{builds/tailwind/ruby_cms_engine})
865
-
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
876
+ cleaned_content = remove_legacy_ruby_cms_tailwind_sources(content)
877
+ return if cleaned_content == content
875
878
 
876
- say "✓ Task tailwind/source: Added RubyCMS engine import to #{tailwind_css_path}.", :green
879
+ File.write(tailwind_css_path, cleaned_content)
880
+ say "✓ Task tailwind/source: Removed RubyCMS @source paths from tailwind entry CSS.",
881
+ :green
877
882
  rescue StandardError => e
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
883
+ say "⚠ Task tailwind/source: Could not clean @source lines: #{e.message}. " \
884
+ "Check tailwind/application.css manually.",
885
+ :yellow
897
886
  end
898
887
 
899
- # Tailwind v3 support (tailwind.config.js content array)
900
- def add_ruby_cms_tailwind_content_paths # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
888
+ # Remove RubyCMS content globs from Tailwind v3 config as well.
889
+ def remove_ruby_cms_tailwind_content_paths
901
890
  config_path = Rails.root.join("config/tailwind.config.js")
902
891
  return unless File.exist?(config_path)
903
892
 
904
893
  content = File.read(config_path)
905
- patterns = ruby_cms_tailwind_content_patterns
906
- return if patterns.all? {|p| content.include?(p) }
907
-
908
- inject = "#{patterns.map {|p| " \"#{p}\"," }.join("\n")}\n"
894
+ cleaned = content.gsub(/^\s*["']?[^"'\n]*ruby_cms[^"'\n]*["']?,?\s*$\n?/i, "")
895
+ return if cleaned == content
909
896
 
910
- # Insert inside `content: [` if present; otherwise no-op.
911
- inserted = false
912
- if content.match?(/content:\s*\[/)
913
- gsub_file config_path.to_s, /content:\s*\[\s*\n/ do |match|
914
- inserted = true
915
- "#{match}#{inject}"
916
- end
917
- end
918
-
919
- return unless inserted
920
-
921
- say "✓ Task tailwind/content: Added RubyCMS paths to config/tailwind.config.js.", :green
897
+ File.write(config_path, cleaned)
898
+ say "✓ Task tailwind/content: Removed RubyCMS paths from tailwind.config.js.", :green
922
899
  rescue StandardError => e
923
- say "⚠ Task tailwind/content: Could not update tailwind.config.js: #{e.message}.", :yellow
900
+ say "⚠ Task tailwind/content: Could not clean tailwind.config.js: #{e.message}.", :yellow
924
901
  end
925
902
 
926
- def ruby_cms_tailwind_content_patterns
927
- views = RubyCms::Engine.root.join("app/views").relative_path_from(Rails.root).to_s
928
- components = RubyCms::Engine.root.join("app/components").relative_path_from(Rails.root).to_s
929
- [
930
- "#{views}/**/*.erb",
931
- "#{components}/**/*.rb"
932
- ]
903
+ def remove_legacy_ruby_cms_tailwind_sources(content)
904
+ content
905
+ .gsub(%r{^\s*/\*\s*Include RubyCMS views/components so Tailwind finds utility classes\.\s*\*/\s*$\n?}, "")
906
+ .gsub(/^\s*@source\s+"[^"\n]*ruby_cms[^"\n]*";\s*$\n?/i, "")
933
907
  end
934
-
935
908
  end
936
909
 
937
910
  def run_migrate
@@ -15,7 +15,7 @@
15
15
  <link rel="manifest" href="<%= asset_path("site.webmanifest") %>">
16
16
 
17
17
  <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
18
- <%= stylesheet_link_tag "tailwind", "data-turbo-track": "reload" %>
18
+ <%= stylesheet_link_tag "ruby_cms/admin", "data-turbo-track": "reload" rescue nil %>
19
19
  <%= stylesheet_link_tag "actiontext", "data-turbo-track": "reload" rescue nil %>
20
20
  <%= javascript_importmap_tags "admin" %>
21
21
  </head>
@@ -100,8 +100,7 @@ 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
- # 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")
103
+ app.config.importmap.cache_sweepers << config.root.join("app/javascript")
105
104
  end
106
105
  end
107
106
 
@@ -263,18 +262,12 @@ module RubyCms
263
262
  end
264
263
  end
265
264
 
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.
270
265
  def self.assets_precompile_phase?
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")
275
-
276
266
  command = File.basename($PROGRAM_NAME.to_s)
277
- (command == "rake" || command == "rails") && argv.include?("assets:precompile")
267
+ rake_assets_precompile = command == "rake" && ARGV.include?("assets:precompile")
268
+ rails_assets_precompile = command == "rails" && ARGV.include?("assets:precompile")
269
+
270
+ rake_assets_precompile || rails_assets_precompile
278
271
  end
279
272
  end
280
273
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyCms
4
- VERSION = "0.2.0.3"
4
+ VERSION = "0.2.0.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.3
4
+ version: 0.2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codebyjob