svelte-on-rails 2.1.1 → 2.1.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: e31a3a82d534f874208a4bb67c36c2285fa2c793fdeeb98a3380c16fa98cb149
4
- data.tar.gz: 29e19f383e0317c0b588fe4414462c90fe83328f4f3ce46c81ce383b68e1326c
3
+ metadata.gz: 4002f622be27b2cee89f360cb18d02f063f4918208ecf433aeb85eee3e1b8ad3
4
+ data.tar.gz: f91206ad19b1e982f583300036c00ae5061a2096cf6bf20ce4eaea9de2ca989f
5
5
  SHA512:
6
- metadata.gz: fd20e2487507675be708f07f0dc414d09d38b43b1c4ae6fcb28cc5e3719cc4b21fd9586dcd547e49993f98ed940c0f19129fc42717d532ea0a8f95de031bf4e6
7
- data.tar.gz: 7ddf1c74f7c7d16c2ef2ee5fd5f4fecd6e3919c765ebf11008df2dfb460c9cadd948e8d270babfa11677669bea4410a46d862ce6a29b82afdabf5005e38aa283
6
+ metadata.gz: f90f6082c7c97d672ca15c4c8d8c5c0576edb253ca35d02ca5857227365ccf52b1c4947aa28479aefd36351496a427a02976f0395e98ef63076b1d8a609c25c7
7
+ data.tar.gz: afbd7c72cd186de0451e26f0216dcd310d92d277ec5bc7072bb1e61c67fcd483265cf5c598e5edeb99bc3afb392f66873c26aedd43753e2d365459c4223e3c3f
data/README.md CHANGED
@@ -79,8 +79,9 @@ If you have issues, please open one, and contributors are welcome!
79
79
  - turbo (recommended / [how to install turbo on rails](https://github.com/hotwired/turbo-rails?tab=readme-ov-file#installation))
80
80
  - if you use special packages (like pug) that requires commonjs, you may need
81
81
  - npm on latest versions
82
- - node installed.
82
+ - actual node installed.
83
83
  - if `nvm` is installed it gets the path to the node-binary from there.
84
+ - When `.nvmrc` is present on projects root, it is respected
84
85
  - If node is not included on the PATH you can configure your node path by environment variable `SVELTE_ON_RAILS_NODE_BIN`
85
86
 
86
87
  ## Installation from cero ⚙️
@@ -2,7 +2,6 @@ require "svelte_on_rails/configuration"
2
2
  require "svelte_on_rails/view_helpers"
3
3
  require "svelte_on_rails/renderer/renderer"
4
4
  require "svelte_on_rails/lib/utils"
5
- require "svelte_on_rails/lib/initializable"
6
5
  require "svelte_on_rails/railtie" if defined?(Rails)
7
6
 
8
7
  # installer
@@ -108,14 +108,26 @@ module SvelteOnRails
108
108
  n = ENV['SVELTE_ON_RAILS_NODE_BIN'] || 'node'
109
109
 
110
110
  if n == 'node'
111
-
112
111
  nvm_installed = false
113
112
  nvm_dir = ENV['NVM_DIR'] || File.expand_path('~/.nvm')
114
113
  nvm_installed ||= File.exist?("#{nvm_dir}/nvm.sh")
115
114
 
116
115
  if nvm_installed
117
- # Use NVM_DIR if set, otherwise default to ~/.nvm
118
- command = "[ -s \"#{nvm_dir}/nvm.sh\" ] && . \"#{nvm_dir}/nvm.sh\" && nvm which current"
116
+ # Check for .nvmrc in the project root
117
+ project_root = rails_root || Dir.pwd
118
+ nvmrc_path = File.join(project_root, '.nvmrc')
119
+ use_nvmrc = File.exist?(nvmrc_path)
120
+
121
+ if use_nvmrc
122
+ # Read the version from .nvmrc
123
+ node_version = File.read(nvmrc_path).strip
124
+ # Ensure NVM is sourced and use the version from .nvmrc
125
+ command = "[ -s \"#{nvm_dir}/nvm.sh\" ] && . \"#{nvm_dir}/nvm.sh\" && nvm use #{node_version} > /dev/null 2>&1 && nvm which #{node_version}"
126
+ else
127
+ # Fallback to current NVM version
128
+ command = "[ -s \"#{nvm_dir}/nvm.sh\" ] && . \"#{nvm_dir}/nvm.sh\" && nvm which current"
129
+ end
130
+
119
131
  node_path, status = Open3.capture2("bash -lc '#{command}'")
120
132
 
121
133
  # Only update n if the command succeeded and output is non-empty
@@ -125,12 +137,12 @@ module SvelteOnRails
125
137
 
126
138
  # Validate node_bin
127
139
  unless n && !n.empty? && system("#{n} --version > /dev/null 2>&1")
128
- raise "Node.js not found at '#{n || 'unknown'}'. Please configure SVELTE_ON_RAILS_NODE_BIN (e.g., to ~/.nvm/versions/node/vX.Y.Z/bin/node) or ensure 'node' is in the PATH. If using NVM, run `nvm alias default <version>` to set a default version."
140
+ raise "Node.js not found at '#{n || 'unknown'}'. Please configure SVELTE_ON_RAILS_NODE_BIN (e.g., to ~/.nvm/versions/node/vX.Y.Z/bin/node) or ensure 'node' is in the PATH. If using NVM, run `nvm alias default <version>` to set a default version or ensure a valid .nvmrc file is present."
129
141
  end
130
142
 
131
143
  n
132
144
  rescue StandardError => e
133
- raise "Failed to detect Node.js binary: «#{e.message}». Ensure Node.js is installed and accessible, or set SVELTE_ON_RAILS_NODE_BIN."
145
+ raise "Failed to detect Node.js binary: «#{e.message}». Ensure Node.js is installed and accessible, or set SVELTE_ON_RAILS_NODE_BIN. If using .nvmrc, ensure the specified version is installed via NVM."
134
146
  end
135
147
  end
136
148
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svelte-on-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair
@@ -41,7 +41,6 @@ files:
41
41
  - lib/svelte_on_rails/installer/utils.rb
42
42
  - lib/svelte_on_rails/installer/vite.rb
43
43
  - lib/svelte_on_rails/lib/development_utils.rb
44
- - lib/svelte_on_rails/lib/initializable.rb
45
44
  - lib/svelte_on_rails/lib/utils.rb
46
45
  - lib/svelte_on_rails/railtie.rb
47
46
  - lib/svelte_on_rails/renderer/render.js
@@ -1,17 +0,0 @@
1
- module SvelteOnRails
2
-
3
- module Lib
4
- module Initializable
5
- def initialize(filename, base_path: SvelteOnRails::Configuration.instance.components_folder_full)
6
-
7
- fn = (filename.match(/\.svelte$/) ? filename[0..-8] : filename)
8
- @svelte_file = base_path + filename
9
- @svelte_filename = filename
10
- cnf = SvelteOnRails::Configuration.instance
11
- cf = cnf.dist_folder + cnf.components_folder + fn
12
- @compiled_file = cf.to_s
13
-
14
- end
15
- end
16
- end
17
- end