react-manifest-rails 0.2.5 → 0.2.7

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: 91ed3c8b3020fda5a5d811b059fdc654dd22c220878c42e76a42011ee899713e
4
- data.tar.gz: a3ea26760e50e90e85d35a790fac7df24fbbaa38c717e56f071b61dc7003dcfd
3
+ metadata.gz: d9635ab7ddcec793c091f9ba04da6196f6b86b130ede696a7431f85e9b9e43a1
4
+ data.tar.gz: e56d0d2981e699e9113f189e981b9d37e7d0664f2c72cc63c153c03bd1d60558
5
5
  SHA512:
6
- metadata.gz: f6648f2f5dbe48b37a3a96db8a472308be09af4ca652a1b5cb70132ec82d7a6b423451298c5c58721baf566a8b798df33e05a6da7a399036d5b589385bf3ba0a
7
- data.tar.gz: 25ec716c8cb0c806152762e0e70c93468a68b3d07cb68a002180be303be892953ae2f2b4b400343c1607e821b44928a7303f264ec2129366f200230d71e523e2
6
+ metadata.gz: 9142794e512c65c87b23580503fcfb270cfb139ad12a725fc96990052d43ba71c3fc2203a75603a4204078332d629d207e03b8b6e15ec017e416062f8b2288e9
7
+ data.tar.gz: 57406840f71a57bf614bd591bcdefd8a0de16ded215cfa6d181831e5720487aa350ea06fab874acce6b1607c4dcb5f1cd6d4aca79ccda4faf91016a39a75ec92
data/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.7] - 2026-04-15
9
+
10
+ ### Added
11
+ - Generated manifests now live in a dedicated folder (`app/assets/javascripts/ux_manifests` by default) to keep `app/assets/javascripts` tidy.
12
+ - Automatic migration of legacy `ux_*.js` files from `output_dir` root into the manifest folder during generation.
13
+
14
+ ### Changed
15
+ - Added `config.manifest_subdir` (default: `ux_manifests`) for explicit control over generated manifest placement.
16
+ - `react_manifest:clean` now removes auto-generated manifests from both the dedicated manifest folder and legacy root location.
17
+ - README and inline configuration docs updated to explain the clean manifest directory behavior.
18
+
19
+ ## [0.2.6] - 2026-04-15
20
+
21
+ ### Fixed
22
+ - Resolved Railtie boot error caused by calling private class method `missing_manifest_bundles` with an explicit receiver.
23
+ - Development server boot no longer raises `private method missing_manifest_bundles called for ReactManifest::Railtie:Class`.
24
+
8
25
  ## [0.2.5] - 2026-04-15
9
26
 
10
27
  ### Fixed
data/README.md CHANGED
@@ -42,6 +42,7 @@ ReactManifest.configure do |config|
42
42
  config.ux_root = "app/assets/javascripts/ux"
43
43
  config.app_dir = "app"
44
44
  config.output_dir = "app/assets/javascripts"
45
+ config.manifest_subdir = "ux_manifests"
45
46
  config.shared_bundle = "ux_shared"
46
47
  config.always_include = []
47
48
  config.ignore = []
@@ -107,6 +108,8 @@ In development:
107
108
 
108
109
  - `ux_shared.js`: shared files outside `ux/app/`
109
110
  - `ux_<controller>.js`: one bundle per directory under `ux/app/`
111
+ - Generated manifests are written to `app/assets/javascripts/ux_manifests/` by default.
112
+ - Existing legacy `app/assets/javascripts/ux_*.js` files are moved automatically on generation.
110
113
 
111
114
  Example:
112
115
  - `ux/app/users/...` -> `ux_users.js`
@@ -17,6 +17,10 @@ module ReactManifest
17
17
  # Where generated ux_*.js manifests are written (relative to Rails.root)
18
18
  attr_accessor :output_dir
19
19
 
20
+ # Subdirectory under output_dir that holds generated ux_*.js manifests.
21
+ # Keeping generated files out of output_dir root avoids clutter.
22
+ attr_accessor :manifest_subdir
23
+
20
24
  # Bundle name for auto-generated shared bundle (all non-app/ dirs)
21
25
  attr_accessor :shared_bundle
22
26
 
@@ -54,6 +58,7 @@ module ReactManifest
54
58
  @ux_root = "app/assets/javascripts/ux"
55
59
  @app_dir = "app"
56
60
  @output_dir = "app/assets/javascripts"
61
+ @manifest_subdir = "ux_manifests"
57
62
  @shared_bundle = "ux_shared"
58
63
  @always_include = []
59
64
  @ignore = []
@@ -99,5 +104,16 @@ module ReactManifest
99
104
  def abs_output_dir
100
105
  Rails.root.join(output_dir).to_s
101
106
  end
107
+
108
+ def abs_manifest_dir
109
+ subdir = normalized_manifest_subdir
110
+ return abs_output_dir if subdir.empty?
111
+
112
+ File.join(abs_output_dir, subdir)
113
+ end
114
+
115
+ def normalized_manifest_subdir
116
+ manifest_subdir.to_s.gsub(%r{\A/+|/+\z}, "")
117
+ end
102
118
  end
103
119
  end
@@ -48,6 +48,8 @@ module ReactManifest
48
48
  manifests << build_shared(classification.shared_dirs)
49
49
  classification.controller_dirs.each { |ctrl| manifests << build_controller(ctrl) }
50
50
 
51
+ migrate_legacy_manifests!
52
+
51
53
  # Phase 2: write — each write is atomic (tmp + rename).
52
54
  results = manifests.map { |m| write_manifest(m[:filename], m[:content]) }
53
55
 
@@ -96,7 +98,7 @@ module ReactManifest
96
98
  # --------------------------------------------------------------- write
97
99
 
98
100
  def write_manifest(filename, content)
99
- dest = File.join(@config.abs_output_dir, filename)
101
+ dest = File.join(@config.abs_manifest_dir, filename)
100
102
 
101
103
  # Safety: never touch files not bearing our AUTO-GENERATED header
102
104
  # (unless they don't exist yet)
@@ -131,6 +133,31 @@ module ReactManifest
131
133
  { path: dest, status: :written }
132
134
  end
133
135
 
136
+ def migrate_legacy_manifests!
137
+ legacy_dir = @config.abs_output_dir
138
+ manifest_dir = @config.abs_manifest_dir
139
+ return if legacy_dir == manifest_dir
140
+
141
+ legacy_files = Dir.glob(File.join(legacy_dir, "ux_*.js"))
142
+ return if legacy_files.empty?
143
+
144
+ if @config.dry_run?
145
+ legacy_files.each do |legacy|
146
+ target = File.join(manifest_dir, File.basename(legacy))
147
+ $stdout.puts "[ReactManifest] DRY-RUN: would move #{legacy} -> #{target}"
148
+ end
149
+ return
150
+ end
151
+
152
+ FileUtils.mkdir_p(manifest_dir)
153
+ legacy_files.each do |legacy|
154
+ target = File.join(manifest_dir, File.basename(legacy))
155
+ next if File.exist?(target)
156
+
157
+ FileUtils.mv(legacy, target)
158
+ end
159
+ end
160
+
134
161
  # ----------------------------------------------------------- helpers
135
162
 
136
163
  def header_lines
@@ -10,7 +10,8 @@ module ReactManifest
10
10
  next unless Rails.env.development?
11
11
 
12
12
  config = ReactManifest.configuration
13
- missing = self.class.missing_manifest_bundles(config)
13
+ # Private class method: call via send from the initializer instance context.
14
+ missing = self.class.send(:missing_manifest_bundles, config)
14
15
  next if missing.empty?
15
16
 
16
17
  message = "[ReactManifest] Missing manifests on boot: #{missing.join(', ')}. Generating now..."
@@ -34,6 +35,12 @@ module ReactManifest
34
35
  # Expose config as Rails.application.config.react_manifest
35
36
  config.react_manifest = ReactManifest.configuration
36
37
 
38
+ # Keep generated manifests in a dedicated folder while preserving logical
39
+ # asset names (ux_shared, ux_users, etc.) via an explicit Sprockets path.
40
+ initializer "react_manifest.assets_path" do |app|
41
+ app.config.assets.paths << ReactManifest.configuration.abs_manifest_dir if app.config.respond_to?(:assets)
42
+ end
43
+
37
44
  # ----------------------------------------------------------------
38
45
  # Start the file watcher in development
39
46
  # ----------------------------------------------------------------
@@ -77,9 +84,9 @@ module ReactManifest
77
84
  private
78
85
 
79
86
  def missing_manifest_bundles(config)
80
- output_dir = config.abs_output_dir
81
87
  expected_manifest_bundles(config).reject do |bundle_name|
82
- File.exist?(File.join(output_dir, "#{bundle_name}.js"))
88
+ File.exist?(File.join(config.abs_manifest_dir, "#{bundle_name}.js")) ||
89
+ File.exist?(File.join(config.abs_output_dir, "#{bundle_name}.js"))
83
90
  end
84
91
  end
85
92
 
@@ -1,3 +1,3 @@
1
1
  module ReactManifest
2
- VERSION = "0.2.5".freeze
2
+ VERSION = "0.2.7".freeze
3
3
  end
@@ -30,23 +30,25 @@ module ReactManifest
30
30
  # Used by the react_bundle_tag view helper.
31
31
  def resolve_bundles(ctrl_name)
32
32
  config = configuration
33
- output = config.abs_output_dir
34
33
  bundles = []
35
34
 
36
35
  # 1. Shared bundle always first
37
- bundles << config.shared_bundle if bundle_exists?(output, config.shared_bundle)
36
+ shared = resolve_bundle_reference(config, config.shared_bundle)
37
+ bundles << shared if shared
38
38
 
39
39
  # 2. always_include bundles (e.g. ux_main)
40
40
  config.always_include.each do |b|
41
- bundles << b if bundle_exists?(output, b) && !bundles.include?(b)
41
+ resolved = resolve_bundle_reference(config, b)
42
+ bundles << resolved if resolved && !bundles.include?(resolved)
42
43
  end
43
44
 
44
45
  # 3. Controller-specific bundle
45
46
  # Try fully-namespaced first: admin/users → ux_admin_users
46
47
  # Then drop segments: ux_admin
47
48
  controller_candidates(ctrl_name).each do |candidate|
48
- if bundle_exists?(output, candidate) && !bundles.include?(candidate)
49
- bundles << candidate
49
+ resolved = resolve_bundle_reference(config, candidate)
50
+ if resolved && !bundles.include?(resolved)
51
+ bundles << resolved
50
52
  break
51
53
  end
52
54
  end
@@ -56,8 +58,15 @@ module ReactManifest
56
58
 
57
59
  private
58
60
 
59
- def bundle_exists?(output_dir, bundle_name)
60
- File.exist?(File.join(output_dir, "#{bundle_name}.js"))
61
+ def resolve_bundle_reference(config, bundle_name)
62
+ manifest_path = File.join(config.abs_manifest_dir, "#{bundle_name}.js")
63
+ return bundle_name if File.exist?(manifest_path)
64
+
65
+ # Backward compatibility for apps still holding legacy manifests in output_dir root.
66
+ legacy_path = File.join(config.abs_output_dir, "#{bundle_name}.js")
67
+ return bundle_name if File.exist?(legacy_path)
68
+
69
+ nil
61
70
  end
62
71
 
63
72
  def controller_candidates(ctrl_name)
@@ -68,19 +68,21 @@ namespace :react_manifest do
68
68
  desc "Remove all AUTO-GENERATED ux_*.js manifests"
69
69
  task clean: :environment do
70
70
  config = ReactManifest.configuration
71
- output = config.abs_output_dir
71
+ targets = [config.abs_manifest_dir, config.abs_output_dir].uniq
72
72
  removed = 0
73
73
  skipped = 0
74
74
 
75
- Dir.glob(File.join(output, "ux_*.js")).each do |file|
76
- first_line = File.foreach(file).first.to_s
77
- if first_line.include?("AUTO-GENERATED")
78
- File.delete(file)
79
- puts "[ReactManifest] Removed: #{file.sub("#{Rails.root}/", '')}"
80
- removed += 1
81
- else
82
- puts "[ReactManifest] Skipped (not auto-generated): #{file.sub("#{Rails.root}/", '')}"
83
- skipped += 1
75
+ targets.each do |dir|
76
+ Dir.glob(File.join(dir, "ux_*.js")).each do |file|
77
+ first_line = File.foreach(file).first.to_s
78
+ if first_line.include?("AUTO-GENERATED")
79
+ File.delete(file)
80
+ puts "[ReactManifest] Removed: #{file.sub("#{Rails.root}/", '')}"
81
+ removed += 1
82
+ else
83
+ puts "[ReactManifest] Skipped (not auto-generated): #{file.sub("#{Rails.root}/", '')}"
84
+ skipped += 1
85
+ end
84
86
  end
85
87
  end
86
88
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: react-manifest-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Noonan