react-manifest-rails 0.2.6 → 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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +3 -0
- data/lib/react_manifest/configuration.rb +16 -0
- data/lib/react_manifest/generator.rb +28 -1
- data/lib/react_manifest/railtie.rb +8 -2
- data/lib/react_manifest/version.rb +1 -1
- data/lib/react_manifest.rb +16 -7
- data/tasks/react_manifest.rake +12 -10
- 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: d9635ab7ddcec793c091f9ba04da6196f6b86b130ede696a7431f85e9b9e43a1
|
|
4
|
+
data.tar.gz: e56d0d2981e699e9113f189e981b9d37e7d0664f2c72cc63c153c03bd1d60558
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9142794e512c65c87b23580503fcfb270cfb139ad12a725fc96990052d43ba71c3fc2203a75603a4204078332d629d207e03b8b6e15ec017e416062f8b2288e9
|
|
7
|
+
data.tar.gz: 57406840f71a57bf614bd591bcdefd8a0de16ded215cfa6d181831e5720487aa350ea06fab874acce6b1607c4dcb5f1cd6d4aca79ccda4faf91016a39a75ec92
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ 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
|
+
|
|
8
19
|
## [0.2.6] - 2026-04-15
|
|
9
20
|
|
|
10
21
|
### 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.
|
|
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
|
|
@@ -35,6 +35,12 @@ module ReactManifest
|
|
|
35
35
|
# Expose config as Rails.application.config.react_manifest
|
|
36
36
|
config.react_manifest = ReactManifest.configuration
|
|
37
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
|
+
|
|
38
44
|
# ----------------------------------------------------------------
|
|
39
45
|
# Start the file watcher in development
|
|
40
46
|
# ----------------------------------------------------------------
|
|
@@ -78,9 +84,9 @@ module ReactManifest
|
|
|
78
84
|
private
|
|
79
85
|
|
|
80
86
|
def missing_manifest_bundles(config)
|
|
81
|
-
output_dir = config.abs_output_dir
|
|
82
87
|
expected_manifest_bundles(config).reject do |bundle_name|
|
|
83
|
-
File.exist?(File.join(
|
|
88
|
+
File.exist?(File.join(config.abs_manifest_dir, "#{bundle_name}.js")) ||
|
|
89
|
+
File.exist?(File.join(config.abs_output_dir, "#{bundle_name}.js"))
|
|
84
90
|
end
|
|
85
91
|
end
|
|
86
92
|
|
data/lib/react_manifest.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
|
60
|
-
File.
|
|
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)
|
data/tasks/react_manifest.rake
CHANGED
|
@@ -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
|
-
|
|
71
|
+
targets = [config.abs_manifest_dir, config.abs_output_dir].uniq
|
|
72
72
|
removed = 0
|
|
73
73
|
skipped = 0
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|