svelte-on-rails 2.1.1 → 3.0.0

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: 76409374bf0d050e3692e15b2d3ea63581284880ae8f20bd53be6835303efe4a
4
+ data.tar.gz: 3eebb55f473cd0e34296d5b353110f3f73b137295826386399635ebbfc1b6e20
5
5
  SHA512:
6
- metadata.gz: fd20e2487507675be708f07f0dc414d09d38b43b1c4ae6fcb28cc5e3719cc4b21fd9586dcd547e49993f98ed940c0f19129fc42717d532ea0a8f95de031bf4e6
7
- data.tar.gz: 7ddf1c74f7c7d16c2ef2ee5fd5f4fecd6e3919c765ebf11008df2dfb460c9cadd948e8d270babfa11677669bea4410a46d862ce6a29b82afdabf5005e38aa283
6
+ metadata.gz: bbcbf7474805e40713ed91e2ec26096b0395d7d2eabd299be3f62a7e1a809d01b176f09ef5a95c5d6fe92667174b3727ea223256fed4f46937c57d3b538220f0
7
+ data.tar.gz: 32378518bfc0de290d393771ca0eb66fc206bd5acf75b4673b45f7b72116d55396c1aa1807b47ab5a4e534abfec9ec5ac2b20c59cfd3bd42779c892781747f36
data/README.md CHANGED
@@ -1,17 +1,18 @@
1
1
  <div style="text-align: center;">
2
2
  <img src="./Svelte_Logo.svg.png" alt="Svelte Logo" height="120">
3
+ <img src="./vite-logo.svg" alt="Svelte Logo" height="120">
3
4
  </div>
4
5
 
5
6
  ---
6
7
 
7
- Do you want to combine DHH's [vision](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision)
8
- with modern front-end requirements?
8
+ Combining [DHH's vision](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision)
9
+ with modern front-end requirements:
9
10
 
10
11
  Svelte.
11
12
 
12
13
  Vite.
13
14
 
14
- Nothing else.
15
+ Hotwired.
15
16
 
16
17
  # Why Svelte?
17
18
 
@@ -64,9 +65,10 @@ performance optimized.
64
65
  Thanks to [shakacode](https://github.com/shakacode/react_on_rails)
65
66
  and [ElMassimo](https://github.com/ElMassimo) for inspiring and helping me with their gems.
66
67
 
67
- **STATUS** This gem is in early development but ready to use for curious developers.
68
- It has a nearly 100% test coverage, all tests pass and, since 2025-05-15 it is successfully
69
- implemented on my first customers app.
68
+ **STATUS:** This gem is in the early stages of development, but is ready for use.
69
+ It has nearly 100% test coverage and all tests pass. Since 15 May 2025, it has been successfully
70
+ implemented on my first customer's app: an ERP system with fat Svelte components that are crucial for the workflow.
71
+ of this company.
70
72
 
71
73
  If you have issues, please open one, and contributors are welcome!
72
74
 
@@ -79,8 +81,9 @@ If you have issues, please open one, and contributors are welcome!
79
81
  - turbo (recommended / [how to install turbo on rails](https://github.com/hotwired/turbo-rails?tab=readme-ov-file#installation))
80
82
  - if you use special packages (like pug) that requires commonjs, you may need
81
83
  - npm on latest versions
82
- - node installed.
84
+ - actual node installed.
83
85
  - if `nvm` is installed it gets the path to the node-binary from there.
86
+ - When `.nvmrc` is present on projects root, it is respected
84
87
  - If node is not included on the PATH you can configure your node path by environment variable `SVELTE_ON_RAILS_NODE_BIN`
85
88
 
86
89
  ## 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: 3.0.0
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