react-manifest-rails 0.2.9 → 0.2.10
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/lib/react_manifest/application_migrator.rb +30 -4
- data/lib/react_manifest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 22469e4a0a5114411640201194bae46bdb549f365a7bb7064eeb95bfd4ddb24e
|
|
4
|
+
data.tar.gz: 6b85f5dec1cf64f9132fd7cf1267f66d021a00f3058400b1644a7ac8f04bb534
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9501224f4fe519573393612a126f6bedaeea60ece7a44c6adce4e6c143f90db6ec948075ac228b93e1f7ca944195a5645e621d932ec3d1ce7c4890f208a46a4
|
|
7
|
+
data.tar.gz: e68251a96c1beb886969b2bc479babddd2fedf471d110f861bec99410c3dbbd4a72bf3961bd4088abe887857acdb72f9bd4b84de541c8d108d3f36adcb49c19c
|
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.10] - 2026-04-16
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- `ApplicationMigrator` now removes only `ux`-classified directives and preserves non-UX requires in `application*.js`, preventing accidental removal of root-level assets such as `mini-search`.
|
|
12
|
+
- Re-running migration/setup no longer duplicates the managed header comment block in `application*.js`.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Regression coverage for preserving unknown non-UX requires during migration.
|
|
16
|
+
- Regression coverage for idempotent managed-header behavior on repeated migration runs.
|
|
17
|
+
- Dummy app root-level fixture assets (`axios.min.js`, `mini-search.js`) and corresponding requires in `application.js` / `application_dev.js` to verify setup behavior before release.
|
|
18
|
+
|
|
8
19
|
## [0.2.9] - 2026-04-15
|
|
9
20
|
|
|
10
21
|
### Added
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module ReactManifest
|
|
2
2
|
# Rewrites application*.js files to remove UX/app code requires,
|
|
3
|
-
#
|
|
3
|
+
# while preserving all non-UX directives.
|
|
4
4
|
#
|
|
5
5
|
# Safety:
|
|
6
6
|
# - Creates a .bak backup before any write; aborts if backup fails
|
|
@@ -9,6 +9,12 @@ module ReactManifest
|
|
|
9
9
|
# - Adds a managed-by comment at the top
|
|
10
10
|
class ApplicationMigrator
|
|
11
11
|
MANAGED_COMMENT = <<~JS.freeze
|
|
12
|
+
// Non-UX libraries — loaded on every page.
|
|
13
|
+
// React app code is now served per-controller via react_bundle_tag.
|
|
14
|
+
// Managed by react-manifest-rails — do not add require_tree.
|
|
15
|
+
JS
|
|
16
|
+
|
|
17
|
+
LEGACY_MANAGED_COMMENT = <<~JS.freeze
|
|
12
18
|
// Vendor libraries — loaded on every page.
|
|
13
19
|
// React app code is now served per-controller via react_bundle_tag.
|
|
14
20
|
// Managed by react-manifest-rails — do not add require_tree.
|
|
@@ -70,12 +76,13 @@ module ReactManifest
|
|
|
70
76
|
|
|
71
77
|
def build_new_content(result)
|
|
72
78
|
kept_lines = result.directives
|
|
73
|
-
.
|
|
74
|
-
|
|
75
|
-
passthrough].include?(d.classification)
|
|
79
|
+
.reject do |d|
|
|
80
|
+
d.classification == :ux_code
|
|
76
81
|
end
|
|
77
82
|
.map(&:original_line)
|
|
78
83
|
|
|
84
|
+
strip_managed_header!(kept_lines)
|
|
85
|
+
|
|
79
86
|
# Remove leading blank lines from kept_lines
|
|
80
87
|
kept_lines.shift while kept_lines.first&.strip&.empty?
|
|
81
88
|
|
|
@@ -87,6 +94,25 @@ module ReactManifest
|
|
|
87
94
|
lines.join("\n")
|
|
88
95
|
end
|
|
89
96
|
|
|
97
|
+
def strip_managed_header!(lines)
|
|
98
|
+
managed_variants = [MANAGED_COMMENT, LEGACY_MANAGED_COMMENT].map { |comment| comment.lines.map(&:chomp) }
|
|
99
|
+
|
|
100
|
+
loop do
|
|
101
|
+
matched = managed_variants.any? { |managed_lines| starts_with_lines?(lines, managed_lines) }
|
|
102
|
+
break unless matched
|
|
103
|
+
|
|
104
|
+
header_len = managed_variants.find { |managed_lines| starts_with_lines?(lines, managed_lines) }.length
|
|
105
|
+
lines.shift(header_len)
|
|
106
|
+
lines.shift while lines.first&.strip&.empty?
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def starts_with_lines?(lines, prefix)
|
|
111
|
+
return false if lines.length < prefix.length
|
|
112
|
+
|
|
113
|
+
lines.first(prefix.length) == prefix
|
|
114
|
+
end
|
|
115
|
+
|
|
90
116
|
def print_diff(file, new_content)
|
|
91
117
|
old_lines = File.readlines(file, encoding: "utf-8").map(&:chomp)
|
|
92
118
|
new_lines = new_content.lines.map(&:chomp)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: react-manifest-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oliver Noonan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|