svelte-on-rails 2.0.1 → 2.0.3

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: e16a769e38b976e345c081f5a3ad9547fc3ed2e0ac9fdfeda0e0bba81d0647af
4
- data.tar.gz: 50d9fc3536eeaa32fd44e58d24f50911eb3d9253bc9398d3eefb1116dcad4f6d
3
+ metadata.gz: 433a24cebdd461077d7c4ebd071d0f8ccfaa37bf640c38988c1a3b2e6d41b3f1
4
+ data.tar.gz: 6746df6083f635e08dd27e3e94c3fa9e25dc5c26632ffabb9da65fc39364b259
5
5
  SHA512:
6
- metadata.gz: def95c897b35752847a3d4a4262ac164baa0a99907fa27990c4c1c9da98b2aade7f006d33cbbd6b61d659be16851da158509d0cd27d520613c5cf52c2efb7317
7
- data.tar.gz: 31b782e4fb8823b7ac30eafd1aa11fcf7bad00e6816ccdaaa1fdc2b08b2bd60c5ac7d804a0d3f9a7c5571b0708514ef30bdedcf28a4e50969e433641b31a767e
6
+ metadata.gz: 57ad22eb8057a368e49653eeb1b9f6abce0151b137c2d8f45c59ec702a14471a1da30b9e265bbac5d5f86a0658849fb18cf338515f05d9d9880f0d5897fbf57b
7
+ data.tar.gz: cdca6d74748f650862b5a815e3d7c90d1863b501582128d182578888092c003190b4a1a80893ffcd20e2acd27c6f0ac0b0b06e47efc80541b9e4eeb2cb25e68b
data/README.md CHANGED
@@ -79,6 +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.
83
+ - If node is not included on the PATH you can configure your node path by environment variable `SVELTE_ON_RAILS_NODE_BIN`
84
+ - if `nvm` is installed it gets the path to the node-binary from there.
82
85
 
83
86
  ## Installation from cero ⚙️
84
87
 
@@ -103,6 +103,37 @@ module SvelteOnRails
103
103
  :vite_rails
104
104
  end
105
105
 
106
+ def node_bin_path
107
+ @node_bin_path ||= begin
108
+ n = ENV['SVELTE_ON_RAILS_NODE_BIN'] || 'node'
109
+
110
+ if n == 'node'
111
+
112
+ nvm_installed = false
113
+ nvm_dir = ENV['NVM_DIR'] || File.expand_path('~/.nvm')
114
+ nvm_installed ||= File.exist?("#{nvm_dir}/nvm.sh")
115
+
116
+ 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"
119
+ node_path, status = Open3.capture2("bash -lc '#{command}'")
120
+
121
+ # Only update n if the command succeeded and output is non-empty
122
+ n = node_path.strip if status.success? && !node_path.strip.empty?
123
+ end
124
+ end
125
+
126
+ # Validate node_bin
127
+ 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."
129
+ end
130
+
131
+ n
132
+ 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."
134
+ end
135
+ end
136
+
106
137
  private
107
138
 
108
139
  def load_yaml_config
@@ -6,6 +6,11 @@ module SvelteOnRails
6
6
  def initialize(component_name, base_path: SvelteOnRails::Configuration.instance.components_folder_full)
7
7
 
8
8
  config = SvelteOnRails::Configuration.instance
9
+
10
+ unless system("#{config.node_bin_path} --version > /dev/null 2>&1")
11
+ raise "Node.js not found at '#{config.node_bin_path}'. Please configure SvelteOnRails.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 which default` to find the path."
12
+ end
13
+
9
14
  if !Dir.exist?(config.ssr_dist_folder) || config.watch_changes?
10
15
  SvelteOnRails::Lib::Utils.watch_changes_and_precompile
11
16
  end
@@ -21,10 +26,11 @@ module SvelteOnRails
21
26
  require 'base64'
22
27
  require 'json'
23
28
  utils = SvelteOnRails::Lib::Utils
29
+ cnf = SvelteOnRails::Configuration.instance
24
30
 
25
31
  cmd = [
26
- 'node',
27
- '/Users/christian/projects-gmbh/gems/svelte-on-rails/svelte-on-rails-gem/lib/svelte_on_rails/renderer/render.js',
32
+ cnf.node_bin_path,
33
+ File.join(utils.gem_app_dir, 'renderer', 'render.js'),
28
34
  @component_files[:compiled_file] + '.js',
29
35
  SvelteOnRails::Configuration.instance.rails_root
30
36
  ].join(' ')
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.0.1
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair