rails_node_module_linker 0.2.0 → 0.2.2

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: a715e5efda2b9c74f8b0148969279ef882137cfbd2099e4c4f8dbab139ad703c
4
- data.tar.gz: ec17edf684bc7ee2e471f46cc09c4c14aa1872de15b5ab2eccc69e1ef0a4f41f
3
+ metadata.gz: 9ea23d68950f392ad9a8716ff600f096219595e48596e83698e342cf3732b7d4
4
+ data.tar.gz: 2a2bd49b2d0abb6e3427bcad27a1f85bf56337567ad9f72ab4719cbbab33c85e
5
5
  SHA512:
6
- metadata.gz: 35db5fd4280b252f45f8e0e2556d2b0fc37667d9430aec7566a7a42e4b80b6f01bef25f191eb32f3dfd69be30f9a17969919b0f3cf253d6f187882c9afca0015
7
- data.tar.gz: a6553ee7db4b1fc3adc47c88936eb2e89ee00a0787b07598c814407a24c9ad578de120cd15a9458634d46782b9b98691e7835618f4b805a654bb38b1c77baa98
6
+ metadata.gz: a0719cb466f01cca5be07cb5b1d5b8c1228206e00bbd3c18f31a676ccf547ddb0d7e6730b86b9596eb6e38ad34ba7b0307a8a14c30173c7bd1d2e8fe36c50a14
7
+ data.tar.gz: 99073a506ccc015bb0755fabcd9ef852099d17094cea8125013d7c387dfbd5e10263b6bcaa0b41f5d90f3fc4c62435cbb35d472684b4b5dc21b8e584368bc584
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.2] - 2026-11-23
4
+
5
+ - Fixes the middleware rewriting the config file when the package is already listed
6
+ - Fixes indentation of list items in the config file when the middleware adds a package
7
+ - Removes the Railtie glob for rake tasks that never matched a file (the Engine loads them)
8
+ - Adds railties and simplecov as development gems, so the specs run on the bundle of the gem
9
+ - Adds specs for the middleware, the link tasks, the Railtie and the Engine initializer
10
+ - Enforces 100% line and branch coverage with SimpleCov
11
+
12
+ ## [0.2.1] - 2025-08-21
13
+
14
+ - Adds force_link setting
15
+ - Fixes linking bug of broken symlink
16
+ - Improves emoji selection in console output
17
+ - Adds ruby Version file
18
+
3
19
  ## [0.2.0] - 2025-05-17
4
20
 
5
21
  - Adds ability to change the `destination_path`
data/README.md CHANGED
@@ -24,6 +24,7 @@ gem install rails_node_module_linker
24
24
  Rails.application.config.to_prepare do
25
25
  RailsNodeModuleLinker.config.symlinked_node_modules_config = 'config/symlinked_node_modules.yml'
26
26
  RailsNodeModuleLinker.config.destination_path = 'public/node_modules'
27
+ RailsNodeModuleLinker.config.force_link = false
27
28
  RailsNodeModuleLinker.config.use_emojis = true
28
29
  end
29
30
  ```
@@ -58,7 +59,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
58
59
 
59
60
  ## Contributing
60
61
 
61
- Bug reports and pull requests are welcome on GitHub [here](https://github.com/anthony0030/rails_node_module_linker). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/anthony0030/rails_node_module_linker/blob/master/CODE_OF_CONDUCT.md).
62
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/anthony0030/rails_node_module_linker). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/anthony0030/rails_node_module_linker/blob/master/CODE_OF_CONDUCT.md).
62
63
 
63
64
  ## License
64
65
 
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RailsNodeModuleLinker::Config
4
- attr_accessor :symlinked_node_modules_config, :destination_path, :use_emojis
4
+ attr_accessor :symlinked_node_modules_config, :destination_path, :force_link, :use_emojis
5
5
 
6
6
  def initialize
7
7
  # * Default configuration values
8
8
  @symlinked_node_modules_config = 'config/symlinked_node_modules.yml'
9
9
  @destination_path = 'public/node_modules'
10
+ @force_link = false
10
11
  @use_emojis = true
11
12
 
12
13
  # TODO: make source folder customizable
@@ -25,11 +25,15 @@ class RailsNodeModuleLinker::Middleware
25
25
  # * Load existing config or initialize a new one
26
26
  config = File.exist?(symlinked_node_modules_config) ? YAML.load_file(symlinked_node_modules_config) : { 'packages' => [] }
27
27
 
28
- # * Add the package if not already listed
29
- config['packages'] = (config['packages'] | [package]).sort
28
+ packages = config['packages'] || []
30
29
 
31
- # * Save the updated config
32
- File.write(symlinked_node_modules_config, config.to_yaml)
30
+ # * Write the config only when the package is new. A relink of a listed package keeps the file unchanged.
31
+ unless packages.include?(package)
32
+ config['packages'] = (packages | [package]).sort
33
+
34
+ # * Psych writes list items at column 0. Indent them by 2 spaces to match common YAML linters.
35
+ File.write(symlinked_node_modules_config, config.to_yaml.gsub(/^- /, ' - '))
36
+ end
33
37
 
34
38
  # * Call the rake task to create the symlink
35
39
  system('bin/rails rails_node_module_linker:link')
@@ -10,10 +10,8 @@ class RailsNodeModuleLinker::Railtie < Rails::Railtie
10
10
  # * Hardcoded toggle for before/after
11
11
  PRECOMPILE_HOOK_POSITION = :before # ? or :after
12
12
 
13
+ # * RailsNodeModuleLinker::Engine loads the tasks in lib/tasks
13
14
  rake_tasks do
14
- path = File.expand_path(__dir__)
15
- Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
16
-
17
15
  Rake::Task.define_task(:environment)
18
16
 
19
17
  case PRECOMPILE_HOOK_POSITION
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsNodeModuleLinker
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.2'
5
5
  end
@@ -53,8 +53,9 @@ namespace :rails_node_module_linker do
53
53
  node_modules_to_link.each do |package|
54
54
  source = Rails.root.join('node_modules', package)
55
55
  destination = node_modules_destination_path.join(package)
56
+ force_link = RailsNodeModuleLinker.config.force_link
56
57
 
57
- unless source.exist?
58
+ if !source.exist? && !force_link && !destination.symlink?
58
59
  log_with_emoji("🚫 Source does not exist: #{source} (skipping)")
59
60
 
60
61
  next
@@ -64,10 +65,11 @@ namespace :rails_node_module_linker do
64
65
  if File.exist?(destination.readlink)
65
66
  log_with_emoji("✅ Already linked: #{destination}")
66
67
  next
67
- else
68
- log_with_emoji("⚠ Broken symlink detected: #{destination} (removing)")
68
+ elsif !force_link
69
+ log_with_emoji("⛓️‍💥 Broken symlink detected: #{destination} (removing)")
69
70
 
70
71
  FileUtils.rm(destination)
72
+ next
71
73
  end
72
74
  elsif destination.exist?
73
75
  log_with_emoji("❌ Destination exists but is not a symlink: #{destination} (skipping)")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_node_module_linker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Veaudry
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - ".rspec"
21
21
  - ".rubocop.yml"
22
+ - ".ruby-version"
22
23
  - ".vscode/settings.json"
23
24
  - CHANGELOG.md
24
25
  - CODE_OF_CONDUCT.md
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
56
  requirements: []
56
- rubygems_version: 3.6.8
57
+ rubygems_version: 4.0.20
57
58
  specification_version: 4
58
59
  summary: Link node modules into the public folder of a Rails app using Propshaft
59
60
  test_files: []