svelte-on-rails 3.0.6 → 3.1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2851a32bc97ac4fc669189927f2493976a029b21ed724cd90b0f0832e90bb0b4
|
4
|
+
data.tar.gz: fecead1bb111cd3a5e504350c0123d689f08eacc452d6421d159e1e2a0c53685
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 610aa41d2d4a964a216db1459b42eb37fe57d20750777e3c6f811f0e8275df327b04690a3c70405c61729e11055bb5939c578ea28942f96ff143de3639039c38
|
7
|
+
data.tar.gz: 021dbaff2383180c544430c66f02759d05eeacf79c2d800e87201de212722aac3666458dab96d877b2768e5c49f3f543374d38ba641a2098cdaa1b8ae615f137
|
data/README.md
CHANGED
@@ -25,6 +25,8 @@ On every app there are parts where you want it to shine. This is where Svelte co
|
|
25
25
|
- Super fast
|
26
26
|
- **Compared to Stimulus**
|
27
27
|
- No more writing double logic of the initial HTML state
|
28
|
+
- One Logic in one file!
|
29
|
+
- Render logic and script logic is in one file and, maybe, some css too.
|
28
30
|
- Stimulus is great for rails views with some javascript, but, complex parts: You will love svelte.
|
29
31
|
- **Compared to React**
|
30
32
|
- No more shadow dom and all those packages that are supposed to improve performance (e.g. useCallback...)
|
@@ -75,7 +77,10 @@ If you have issues, please open one, and contributors are welcome!
|
|
75
77
|
## Requirements
|
76
78
|
|
77
79
|
- actual node installed on the server
|
78
|
-
- tested on
|
80
|
+
- tested on
|
81
|
+
- ruby 3.2.2 and rails 7.1
|
82
|
+
- ruby 2.7.5 and rails 6.1
|
83
|
+
- vite@6 (v7 not supported, see issues)
|
79
84
|
- vite_rails (the installer will install it by option --full or --vite)
|
80
85
|
- svelte v5 (see: [how to install svelte on rails/vite](https://dev.to/chmich/setup-inertia-and-svelte-on-rails-7-3glk))
|
81
86
|
- turbo (recommended / [how to install turbo on rails](https://github.com/hotwired/turbo-rails?tab=readme-ov-file#installation))
|
@@ -294,6 +299,28 @@ rails svelte_on_rails:add_hello_world
|
|
294
299
|
rails svelte_on_rails:remove_hello_world
|
295
300
|
```
|
296
301
|
|
302
|
+
## Deploy
|
303
|
+
|
304
|
+
For example, by deploying with capistrano, you may add a step like
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
before 'deploy:assets:precompile', 'deploy:npm:install'
|
308
|
+
namespace :deploy do
|
309
|
+
namespace :npm do
|
310
|
+
desc 'Install Node.js dependencies'
|
311
|
+
task :install do
|
312
|
+
on roles(:app) do
|
313
|
+
within release_path do
|
314
|
+
execute :npm, 'install'
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
```
|
321
|
+
|
322
|
+
to `deploy.rb` for making sure the ssr compilation is working.
|
323
|
+
|
297
324
|
## Contributors Guide
|
298
325
|
|
299
326
|
Contributors welcome!
|
@@ -2,19 +2,44 @@ module SvelteOnRails
|
|
2
2
|
module Installer
|
3
3
|
module Npm
|
4
4
|
|
5
|
-
def self.install_or_update_package(package_name, minimal_version: nil, update_to_latest: true, dev_dependency: false
|
5
|
+
def self.install_or_update_package(package_name, minimal_version: nil, major_version: nil, update_to_latest: true, dev_dependency: false)
|
6
6
|
pkg = inspect_package(package_name)
|
7
|
-
|
7
|
+
puts "#{package_name} already installed (#{pkg[:version].join('.')})" if pkg
|
8
|
+
|
9
|
+
to_do = if !pkg
|
10
|
+
true
|
11
|
+
elsif major_version
|
12
|
+
r = pkg[:version].first != major_version
|
13
|
+
if r
|
14
|
+
puts "updating to major version #{major_version}"
|
15
|
+
else
|
16
|
+
puts "nothing to do (major version #{major_version} OK)"
|
17
|
+
end
|
18
|
+
r
|
19
|
+
elsif minimal_version
|
20
|
+
r = pkg[:version].first < minimal_version.first || pkg[:version].second < minimal_version.second
|
21
|
+
puts "updating to minimal version #{minimal_version}" if r
|
22
|
+
r
|
23
|
+
else
|
24
|
+
puts 'nothing to do'
|
25
|
+
false
|
26
|
+
end
|
27
|
+
|
8
28
|
save_dev = (dev_dependency ? ' --save-dev' : '')
|
9
29
|
if to_do
|
10
30
|
|
11
|
-
cmd = if
|
31
|
+
cmd = if major_version
|
32
|
+
"npm install #{package_name}@#{major_version}#{save_dev}"
|
33
|
+
elsif update_to_latest
|
12
34
|
"npm install #{package_name}@latest#{save_dev}"
|
13
35
|
else
|
14
36
|
raise "ERROR: not implemented"
|
15
37
|
end
|
16
38
|
|
17
39
|
stdout, stderr, status = Open3.capture3(cmd)
|
40
|
+
|
41
|
+
puts cmd
|
42
|
+
|
18
43
|
if stderr.present?
|
19
44
|
raise "ERROR #{cmd} => #{stderr}"
|
20
45
|
end
|
@@ -52,7 +77,6 @@ module SvelteOnRails
|
|
52
77
|
end
|
53
78
|
end
|
54
79
|
|
55
|
-
|
56
80
|
def self.inspect_package(package_name)
|
57
81
|
pkg = nil
|
58
82
|
version = nil
|
@@ -75,34 +99,33 @@ module SvelteOnRails
|
|
75
99
|
|
76
100
|
end
|
77
101
|
|
78
|
-
def self.check_version(current_version, minimal_version)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
102
|
+
# def self.check_version(current_version, minimal_version)
|
103
|
+
# if !current_version
|
104
|
+
# return false
|
105
|
+
# elsif !minimal_version.present?
|
106
|
+
# return true
|
107
|
+
# else
|
108
|
+
# compare_version_arrays(current_version, minimal_version)
|
109
|
+
# end
|
110
|
+
# end
|
87
111
|
|
88
112
|
private
|
89
113
|
|
90
|
-
def self.compare_version_arrays(current_version, minimal_version)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
114
|
+
# def self.compare_version_arrays(current_version, minimal_version)
|
115
|
+
# raise "ERROR: current_version must be an array" unless current_version.is_a?(Array)
|
116
|
+
#
|
117
|
+
# current_version.each_with_index do |v, i|
|
118
|
+
# raise "ERROR: current_version entries must be an integer" unless v.is_a?(Integer)
|
119
|
+
#
|
120
|
+
# if minimal_version[i]
|
121
|
+
# raise "ERROR: minimal_version entries must be an integer" unless minimal_version[i].is_a?(Integer)
|
122
|
+
# if v < minimal_version[i]
|
123
|
+
# return false
|
124
|
+
# end
|
125
|
+
# end
|
126
|
+
# end
|
127
|
+
# true
|
128
|
+
# end
|
106
129
|
|
107
130
|
end
|
108
131
|
end
|
@@ -4,7 +4,7 @@ module SvelteOnRails
|
|
4
4
|
|
5
5
|
module Vite
|
6
6
|
|
7
|
-
def self.install_vite
|
7
|
+
def self.install_vite(major_version: nil, minimal_version: nil)
|
8
8
|
iu = SvelteOnRails::Installer::Utils
|
9
9
|
|
10
10
|
puts '-' * 80
|
@@ -44,7 +44,7 @@ module SvelteOnRails
|
|
44
44
|
# check npm package version
|
45
45
|
|
46
46
|
ni = SvelteOnRails::Installer::Npm
|
47
|
-
ni.install_or_update_package('vite',
|
47
|
+
ni.install_or_update_package('vite', major_version: major_version, minimal_version: minimal_version)
|
48
48
|
|
49
49
|
end
|
50
50
|
|