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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a26dc7e8929f42fed07d13c8d38d3390d99d8063c81e5887ac171e52c1d9303
4
- data.tar.gz: defd50858d68d0e22fdd396d6be214af15edb6eb6c5c030c1047c17f1f2ab0e6
3
+ metadata.gz: 22469e4a0a5114411640201194bae46bdb549f365a7bb7064eeb95bfd4ddb24e
4
+ data.tar.gz: 6b85f5dec1cf64f9132fd7cf1267f66d021a00f3058400b1644a7ac8f04bb534
5
5
  SHA512:
6
- metadata.gz: d94c1392eaaa325b56225b618f318d0af156c4696dc806a2ba238796c10c75f128c4a7369475a455d1e6f851edd8ca66a5a10e86ed246a0d15917ba00a198bab
7
- data.tar.gz: 86ddf03428eb1889ea9bcabd463fa761bc5738a724e201197323228ef067cd1d400f85da40d273a69cc06bf7c8016a9bba732ddd36e6c56147d980d14bda74ce
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
- # keeping only vendor lib requires.
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
- .select do |d|
74
- %i[vendor
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)
@@ -1,3 +1,3 @@
1
1
  module ReactManifest
2
- VERSION = "0.2.9".freeze
2
+ VERSION = "0.2.10".freeze
3
3
  end
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.9
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-15 00:00:00.000000000 Z
11
+ date: 2026-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties