svelte-on-rails 0.0.31 → 0.0.32
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 +4 -4
- data/README.md +47 -20
- data/lib/generators/svelte_on_rails/install/install_generator.rb +135 -0
- data/lib/svelte-on-rails.rb +24 -0
- data/lib/svelte_on_rails/compiler/compiler.rb +5 -5
- data/lib/svelte_on_rails/configuration.rb +10 -6
- data/lib/svelte_on_rails/installer/hello_world.rb +3 -3
- data/lib/svelte_on_rails/installer/utils.rb +29 -11
- data/lib/tasks/svelte_on_rails_tasks.rake +41 -99
- metadata +4 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b437bee130ee620c17fd1874e37032e316f02e14bb6c90863534c9c3131776e3
|
4
|
+
data.tar.gz: bbfe5547994bfbd95b7e886c998aa233eb7c850114449bf0e34659e0c3bf2652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52bb2bd60cf155cab50966649643c675c4584367b8a7de2c6179bd0355e48952a05f10e6a5c67d5bd4f151d303bbea69b26937c36d10dff28e6364c434f7ba9d
|
7
|
+
data.tar.gz: ab731d288b0b4e91c7d4df6f8935505e5c3e38799909112d5f3cc380924fa20e2f31787744c453111c7946b061d0499e7e0dee74411568f406aa475ee1005319
|
data/README.md
CHANGED
@@ -45,21 +45,40 @@ If you want to start from a new rails app, follow theese tutorials
|
|
45
45
|
rails new my-test-app --skip-javascript
|
46
46
|
```
|
47
47
|
|
48
|
-
within the app
|
48
|
+
within the app add the gem
|
49
49
|
|
50
50
|
```bash
|
51
51
|
bundle add svelte-on-rails
|
52
52
|
```
|
53
53
|
|
54
|
-
and run the
|
54
|
+
and run the installer
|
55
55
|
|
56
56
|
```bash
|
57
|
-
rails svelte_on_rails:
|
57
|
+
rails g svelte_on_rails:install --full
|
58
58
|
```
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
The `--full` contains:
|
61
|
+
|
62
|
+
- `--vite`
|
63
|
+
- adds vite_rails gem and running the installer
|
64
|
+
- `--haml`
|
65
|
+
- adds the gem and converts existing views
|
66
|
+
- `svelte_on_rails`
|
67
|
+
- This is not a option, this is always done: Adds a config file and installs `@csedl/svelte-on-rails` by npm
|
68
|
+
- `--turbo`
|
69
|
+
- installs `@hotwired/turbo-rails` and adds import statement to application.js
|
70
|
+
- `--svelte`
|
71
|
+
- adds or updates `svelte`
|
72
|
+
- `--hello-world`
|
73
|
+
- adds a hello world component
|
74
|
+
|
75
|
+
You can also use the options you want instead of using `--full`
|
76
|
+
|
77
|
+
The installer is written carefully: It does not overwrite a file without asking.
|
78
|
+
It tells you all what he is doing.
|
79
|
+
|
80
|
+
At the end, you just have to (re-) start your server
|
81
|
+
and you will see a Svelte component.
|
63
82
|
|
64
83
|
## Minimal Installation
|
65
84
|
|
@@ -68,19 +87,11 @@ within the app folder
|
|
68
87
|
```bash
|
69
88
|
bundle add svelte-on-rails
|
70
89
|
```
|
71
|
-
```bash
|
72
|
-
rails svelte_on_rails:install
|
73
|
-
```
|
74
|
-
|
75
|
-
This will create a little config file, installs the npm package,
|
76
|
-
creates a initializer file and adds the import statement on `appplication.js` entrypoint file
|
77
90
|
|
78
|
-
|
79
|
-
|
80
|
-
There is also a minimal installer:
|
91
|
+
Run the installer
|
81
92
|
|
82
93
|
```bash
|
83
|
-
rails svelte_on_rails:install
|
94
|
+
rails g svelte_on_rails:install
|
84
95
|
```
|
85
96
|
|
86
97
|
that does:
|
@@ -237,10 +248,26 @@ The folder `spec/installer_tests` is for testing the installer: This folder, mai
|
|
237
248
|
before test. Tests there are starting by `rails new` followed
|
238
249
|
by running the installer.
|
239
250
|
|
240
|
-
NOTE: Theese tests
|
241
|
-
|
242
|
-
|
243
|
-
|
251
|
+
NOTE: Theese tests are running within your current ruby environment. If you want
|
252
|
+
to test if a installer with a specific ruby version is running you must switch
|
253
|
+
this by your development environment. And theese tests are killing all puma processes
|
254
|
+
before and after run.
|
255
|
+
|
256
|
+
Development helpers:
|
257
|
+
|
258
|
+
```bash
|
259
|
+
rake svelte_on_rails:create_test_app
|
260
|
+
```
|
261
|
+
|
262
|
+
This creates a new rails app within `spec/installer_tests` and runs the installer with `--full`.
|
263
|
+
On the last line it shows you the path to the test app.
|
264
|
+
Now you can cd into this folder and run `rails s`.
|
265
|
+
|
266
|
+
```bash
|
267
|
+
rake svelte_on_rails:replace_test_app_hello_world
|
268
|
+
```
|
269
|
+
|
270
|
+
Overwrites the hello world files within this test app from template.
|
244
271
|
|
245
272
|
## Licence
|
246
273
|
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
|
3
|
+
module SvelteOnRails
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
class_option :full, type: :boolean, default: false, desc: "Run full installation with additional setup"
|
8
|
+
class_option :vite, type: :boolean, default: false, desc: "Use Vite"
|
9
|
+
class_option :haml, type: :boolean, default: false, desc: "Use Haml"
|
10
|
+
class_option :turbo, type: :boolean, default: false, desc: "Use @hotwired/turbo-rails"
|
11
|
+
class_option :svelte, type: :boolean, default: false, desc: "Install Svelte"
|
12
|
+
class_option :hello_world, type: :boolean, default: false, desc: "Create Hello World component"
|
13
|
+
|
14
|
+
require 'svelte_on_rails/installer/utils'
|
15
|
+
require 'svelte_on_rails/installer/haml'
|
16
|
+
require_relative '../../../../spec/test_helpers'
|
17
|
+
|
18
|
+
def initialize(*args)
|
19
|
+
super
|
20
|
+
validate_raw_options!(args)
|
21
|
+
puts '-' * 80
|
22
|
+
puts 'STARTING SVELTE-ON-RAILS INSTALLATION'
|
23
|
+
end
|
24
|
+
|
25
|
+
def vite
|
26
|
+
return unless options[:full] || options[:vite]
|
27
|
+
vite_i = SvelteOnRails::Installer::Vite
|
28
|
+
vite_i.install_vite
|
29
|
+
end
|
30
|
+
|
31
|
+
def haml
|
32
|
+
return unless options[:full] || options[:haml]
|
33
|
+
haml_i = SvelteOnRails::Installer::Haml
|
34
|
+
haml_i.install_haml_and_convert
|
35
|
+
end
|
36
|
+
|
37
|
+
def svelte_on_rails
|
38
|
+
utils = SvelteOnRails::Installer::Utils
|
39
|
+
npm_i = SvelteOnRails::Installer::Npm
|
40
|
+
utils.write_templates(['config/svelte_on_rails.yml'])
|
41
|
+
npm_i.install_or_update_package('@csedl/svelte-on-rails')
|
42
|
+
# insert_initializer
|
43
|
+
uts = SvelteOnRails::Installer::Utils
|
44
|
+
uts.write_templates(['app/frontend/initializers/svelte.js'])
|
45
|
+
# add import statements
|
46
|
+
js_i = SvelteOnRails::Installer::Javascript
|
47
|
+
init_stat = '../initializers/svelte.js'
|
48
|
+
js_i.append_import_statement(application_js_path, init_stat, "import '#{init_stat}';")
|
49
|
+
end
|
50
|
+
|
51
|
+
def turbo
|
52
|
+
return unless options[:full] || options[:turbo]
|
53
|
+
|
54
|
+
puts '-' * 80
|
55
|
+
npm_i = SvelteOnRails::Installer::Npm
|
56
|
+
tr_pkg = '@hotwired/turbo-rails'
|
57
|
+
npm_i.install_or_update_package(tr_pkg)
|
58
|
+
js_i = SvelteOnRails::Installer::Javascript
|
59
|
+
js_i.append_import_statement(application_js_path, tr_pkg, "import '#{tr_pkg}';")
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def svelte
|
64
|
+
return unless options[:svelte] || options[:full]
|
65
|
+
|
66
|
+
puts '-' * 80
|
67
|
+
svelte_i = SvelteOnRails::Installer::Svelte
|
68
|
+
svelte_i.install_svelte
|
69
|
+
end
|
70
|
+
|
71
|
+
def hello_world
|
72
|
+
return unless options[:hello_world] || options[:full]
|
73
|
+
|
74
|
+
puts '-' * 80
|
75
|
+
|
76
|
+
hw_i = SvelteOnRails::Installer::HelloWorld
|
77
|
+
@hello_world_path = hw_i.install_hello_world(HELLO_WORLD_FILES)
|
78
|
+
end
|
79
|
+
|
80
|
+
def finish
|
81
|
+
puts '-' * 80
|
82
|
+
puts 'FINISHED SVELTE INSTALLATION'
|
83
|
+
puts '-' * 80
|
84
|
+
|
85
|
+
puts "SvelteOnRails installed successfully!"
|
86
|
+
puts "Restart the server and check if it all works."
|
87
|
+
if @hello_world_path
|
88
|
+
puts "You can now access the Hello World component on: http://localhost:your-port-number#{@hello_world_path}."
|
89
|
+
end
|
90
|
+
puts "Happy coding!"
|
91
|
+
end
|
92
|
+
|
93
|
+
HELLO_WORLD_FILES = %w[
|
94
|
+
app/controllers/svelte_on_rails_hello_world_controller.rb
|
95
|
+
app/views/svelte_on_rails_hello_world/index.haml
|
96
|
+
app/frontend/javascript/components/SvelteOnRailsHelloWorld.svelte
|
97
|
+
app/frontend/javascript/components/Pug.svelte
|
98
|
+
app/frontend/javascript/components/sub/NestedComponent.svelte
|
99
|
+
app/frontend/javascript/nestedJavascript.js
|
100
|
+
app/frontend/javascript/nestedJavascriptToggled.js
|
101
|
+
app/frontend/javascript/components/sub/NestedComponent.svelte
|
102
|
+
app/frontend/images/svg.svg
|
103
|
+
app/frontend/images/check-circle-green.png
|
104
|
+
]
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def toggle_hello_world_files
|
109
|
+
%w[
|
110
|
+
app/frontend/images/svg.svg
|
111
|
+
app/frontend/images/atom.svg
|
112
|
+
app/frontend/javascript/nestedJavascript.js
|
113
|
+
app/frontend/javascript/nestedJavascriptToggled.js
|
114
|
+
]
|
115
|
+
end
|
116
|
+
|
117
|
+
def validate_raw_options!(args)
|
118
|
+
# Get option names from class_options, excluding inherited Thor/Rails options
|
119
|
+
valid_options = self.class.class_options.keys.map { |opt| "--#{opt.to_s.tr('_', '-')}" }
|
120
|
+
rails_internal_options = %w[--skip-namespace --skip-collision-check --pretend --quiet --force]
|
121
|
+
options_array = args.find { |arg| arg.is_a?(Array) && arg.any? { |a| a.start_with?('--') } } || []
|
122
|
+
passed_options = options_array.select { |arg| arg.start_with?('--') }
|
123
|
+
unknown_options = passed_options - valid_options - rails_internal_options
|
124
|
+
unless unknown_options.empty?
|
125
|
+
valid_display = valid_options.map { |opt| opt.gsub(/^--/, '') }.join(', ')
|
126
|
+
raise Thor::Error, "Unknown options: #{unknown_options.join(', ')}. Valid options are: #{valid_display}\nNothing done."
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def application_js_path
|
131
|
+
Rails.root.join("app", "frontend", "entrypoints", "application.js")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/lib/svelte-on-rails.rb
CHANGED
@@ -16,6 +16,8 @@ require 'svelte_on_rails/installer/npm'
|
|
16
16
|
require 'svelte_on_rails/installer/javascript'
|
17
17
|
require 'svelte_on_rails/installer/hello_world'
|
18
18
|
|
19
|
+
require 'generators/svelte_on_rails/install/install_generator'
|
20
|
+
|
19
21
|
module SvelteOnRails
|
20
22
|
class << self
|
21
23
|
def configuration
|
@@ -23,4 +25,26 @@ module SvelteOnRails
|
|
23
25
|
end
|
24
26
|
|
25
27
|
end
|
28
|
+
|
29
|
+
def self.run_install_task
|
30
|
+
# Ensure Rake tasks are loaded
|
31
|
+
Rake::Task.define_task(:environment) # Define a dummy environment task (if needed)
|
32
|
+
load File.expand_path('../rakefile', __FILE__) # Load the gem's Rakefile
|
33
|
+
|
34
|
+
# Invoke the task
|
35
|
+
Rake::Task['svelte_on_rails:create_test_app'].invoke
|
36
|
+
rescue StandardError => e
|
37
|
+
puts "Error running create_test_app task: #{e.message}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.run_replace_hello_world_task
|
41
|
+
# Ensure Rake tasks are loaded
|
42
|
+
Rake::Task.define_task(:environment) # Define a dummy environment task (if needed)
|
43
|
+
load File.expand_path('../rakefile', __FILE__) # Load the gem's Rakefile
|
44
|
+
|
45
|
+
# Invoke the task
|
46
|
+
Rake::Task['svelte_on_rails:replace_test_app_hello_world'].invoke
|
47
|
+
rescue StandardError => e
|
48
|
+
puts "Error running replace_test_app_hello_world task: #{e.message}"
|
49
|
+
end
|
26
50
|
end
|
@@ -101,17 +101,17 @@ module SvelteOnRails
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def self.reset_and_compile_all
|
104
|
-
|
104
|
+
reset_dist
|
105
105
|
cnf = SvelteOnRails::Configuration.instance
|
106
106
|
frontend_folder = cnf.frontend_folder_full
|
107
|
-
|
108
|
-
|
107
|
+
files = Dir.glob(cnf.frontend_folder_full.join('**/*.svelte'))
|
108
|
+
files.each_with_index do |file, ind|
|
109
109
|
comp_name = file.to_s[(cnf.frontend_folder_full.to_s.length + 1)..-1]
|
110
110
|
|
111
|
-
n = SvelteOnRails::
|
111
|
+
n = SvelteOnRails::Compiler.new(comp_name, base_path: frontend_folder)
|
112
112
|
n.compile
|
113
113
|
|
114
|
-
puts "compiled #{ind + 1}/#{
|
114
|
+
puts "compiled #{ind + 1}/#{files.length}: #{comp_name}"
|
115
115
|
|
116
116
|
end
|
117
117
|
end
|
@@ -29,8 +29,8 @@ module SvelteOnRails
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def rails_root
|
33
|
-
Rails.root
|
32
|
+
def rails_root(root_url = nil)
|
33
|
+
root_url || Rails.root
|
34
34
|
end
|
35
35
|
|
36
36
|
def frontend_folder
|
@@ -58,8 +58,8 @@ module SvelteOnRails
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def dist_folder
|
62
|
-
rails_root.join('public', 'svelteDist')
|
61
|
+
def dist_folder(app_root = nil)
|
62
|
+
rails_root(app_root).join('public', 'svelteDist')
|
63
63
|
end
|
64
64
|
|
65
65
|
def system_type
|
@@ -69,8 +69,12 @@ module SvelteOnRails
|
|
69
69
|
private
|
70
70
|
|
71
71
|
def load_yaml_config
|
72
|
-
|
73
|
-
|
72
|
+
begin
|
73
|
+
config_path = Rails.root.join("config", "svelte_on_rails.yml")
|
74
|
+
return unless File.exist?(config_path)
|
75
|
+
rescue
|
76
|
+
return
|
77
|
+
end
|
74
78
|
|
75
79
|
config_data = YAML.load_file(config_path)
|
76
80
|
|
@@ -2,20 +2,20 @@ module SvelteOnRails
|
|
2
2
|
module Installer
|
3
3
|
module HelloWorld
|
4
4
|
|
5
|
-
def self.install_hello_world(files)
|
5
|
+
def self.install_hello_world(files, force: false, app_root: nil)
|
6
6
|
|
7
7
|
utils_i = SvelteOnRails::Installer::Utils
|
8
8
|
|
9
9
|
# write templates
|
10
10
|
|
11
11
|
|
12
|
-
utils_i.write_templates(files)
|
12
|
+
utils_i.write_templates(files, ask_for_overwrite: !force, app_root: app_root)
|
13
13
|
|
14
14
|
|
15
15
|
# route
|
16
16
|
|
17
17
|
route = 'svelte_on_rails_hello_world#index'
|
18
|
-
rr = utils_i.which_root_route
|
18
|
+
rr = utils_i.which_root_route(app_root)
|
19
19
|
root_url = "/"
|
20
20
|
url = root_url + route.sub('#', '/')
|
21
21
|
|
@@ -171,10 +171,11 @@ module SvelteOnRails
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
174
|
-
def self.write_templates(template_paths, ask_for_overwrite: true)
|
174
|
+
def self.write_templates(template_paths, ask_for_overwrite: true, app_root: nil)
|
175
175
|
|
176
|
-
|
177
|
-
|
176
|
+
a_root = app_root_path(app_root)
|
177
|
+
|
178
|
+
existing = template_paths.select { |p| File.exist?(a_root.join(p)) }
|
178
179
|
|
179
180
|
if existing.present? && ask_for_overwrite
|
180
181
|
begin
|
@@ -185,16 +186,20 @@ module SvelteOnRails
|
|
185
186
|
puts "Skipping write #{'template'.pluralize(template_paths.length)}."
|
186
187
|
return
|
187
188
|
end
|
188
|
-
verb = 'Overwrote'
|
189
189
|
end
|
190
190
|
|
191
191
|
template_paths.each do |p|
|
192
192
|
source_path = File.expand_path('rails_template', __dir__) + '/' + p
|
193
|
-
|
194
|
-
|
193
|
+
|
194
|
+
dest_path = a_root.join(p)
|
195
|
+
v = (File.exist?(dest_path) ? 'replaced' : 'created')
|
196
|
+
|
197
|
+
FileUtils.mkdir_p(File.dirname(a_root.join(p)))
|
198
|
+
FileUtils.cp(source_path, a_root.join(p))
|
199
|
+
|
200
|
+
puts "#{v}: #{p}"
|
195
201
|
end
|
196
202
|
|
197
|
-
puts "#{verb} #{'file'.pluralize(template_paths.length)}:\n#{template_paths.join("\n")}"
|
198
203
|
end
|
199
204
|
|
200
205
|
def self.ask_yn(question)
|
@@ -205,11 +210,11 @@ module SvelteOnRails
|
|
205
210
|
continue == 'y'
|
206
211
|
end
|
207
212
|
|
208
|
-
def self.which_root_route
|
213
|
+
def self.which_root_route(app_root = nil)
|
209
214
|
|
210
215
|
# Check if the root route is active (uncommented) or commented out
|
211
216
|
|
212
|
-
routes = File.read(
|
217
|
+
routes = File.read(app_root_path(app_root).join('config', 'routes.rb'))
|
213
218
|
m = routes.match(/^\s*root\s+['"]([^'"]+)['"]/m)
|
214
219
|
if m
|
215
220
|
m.to_s.match(/^\s*root\s*['"]([^'"]*)['"]/)[1]
|
@@ -311,18 +316,31 @@ module SvelteOnRails
|
|
311
316
|
if found_lines.present? && utils.ask_yn("Remove lines\n • #{found_lines.join("\n • ")}\n from #{file_path}?")
|
312
317
|
# Write the modified content back to the file
|
313
318
|
begin
|
314
|
-
File.write(file_path, modified_content.map{|l|l.gsub(/\n/, '')}.join("\n"))
|
319
|
+
File.write(file_path, modified_content.map { |l| l.gsub(/\n/, '') }.join("\n"))
|
315
320
|
puts "Successfully removed #{found_lines.length} #{'line'.pluralize(found_lines.length)}."
|
316
321
|
rescue => e
|
317
322
|
raise "Error writing to #{file_path} => «#{e.message}»"
|
318
323
|
end
|
319
324
|
else
|
320
325
|
|
321
|
-
|
322
326
|
end
|
323
327
|
|
324
328
|
end
|
325
329
|
|
330
|
+
def self.app_root_path(app_root = nil)
|
331
|
+
if app_root
|
332
|
+
raise "ERROR: app_root must be class Pathname" unless app_root.is_a?(Pathname)
|
333
|
+
app_root
|
334
|
+
else
|
335
|
+
begin
|
336
|
+
Dir.exist?(Rails.root.join('app'))
|
337
|
+
Rails.root
|
338
|
+
rescue => e
|
339
|
+
raise "ERROR: Could not find Rails.root => #{e}"
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
326
344
|
end
|
327
345
|
end
|
328
346
|
end
|
@@ -1,107 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if defined?(Rails)
|
2
|
+
Rake::Task["assets:precompile"].enhance do
|
3
|
+
puts '-'*80
|
4
|
+
SvelteOnRails::Compiler.reset_and_compile_all
|
5
|
+
puts "Svelte on Rails: Reset dist and compile-all executed"
|
6
|
+
puts '-'*80
|
7
|
+
end
|
4
8
|
end
|
5
9
|
|
6
|
-
require 'svelte_on_rails/installer/utils'
|
7
|
-
require 'svelte_on_rails/installer/haml'
|
8
|
-
utils = SvelteOnRails::Installer::Utils
|
9
|
-
npm_i = SvelteOnRails::Installer::Npm
|
10
|
-
application_js_path = Rails.root.join("app", "frontend", "entrypoints", "application.js")
|
11
|
-
toggle_hello_world_files = %w[
|
12
|
-
app/frontend/images/svg.svg
|
13
|
-
app/frontend/images/atom.svg
|
14
|
-
app/frontend/javascript/nestedJavascript.js
|
15
|
-
app/frontend/javascript/nestedJavascriptToggled.js
|
16
|
-
]
|
17
|
-
hello_world_files = %w[
|
18
|
-
app/controllers/svelte_on_rails_hello_world_controller.rb
|
19
|
-
app/views/svelte_on_rails_hello_world/index.haml
|
20
|
-
app/frontend/javascript/components/SvelteOnRailsHelloWorld.svelte
|
21
|
-
app/frontend/javascript/components/Pug.svelte
|
22
|
-
app/frontend/javascript/components/sub/NestedComponent.svelte
|
23
|
-
app/frontend/javascript/nestedJavascript.js
|
24
|
-
app/frontend/javascript/nestedJavascriptToggled.js
|
25
|
-
app/frontend/javascript/components/sub/NestedComponent.svelte
|
26
|
-
app/frontend/images/svg.svg
|
27
|
-
app/frontend/images/check-circle-green.png
|
28
|
-
]
|
29
|
-
|
30
|
-
namespace :svelte_on_rails do
|
31
|
-
|
32
|
-
desc "Installs SvelteOnRails for usage together with vite_rails, haml and @hotwired/turbo-rails"
|
33
|
-
task :install_haml_vite => :environment do
|
34
|
-
|
35
|
-
puts '-' * 80
|
36
|
-
puts 'STARTING SVELTE-ON-RAILS INSTALLATION'
|
37
|
-
|
38
|
-
# vite
|
39
|
-
|
40
|
-
vite_i = SvelteOnRails::Installer::Vite
|
41
|
-
vite_i.install_vite
|
42
|
-
|
43
|
-
# haml
|
44
|
-
|
45
|
-
haml_i = SvelteOnRails::Installer::Haml
|
46
|
-
haml_i.install_haml_and_convert
|
47
10
|
|
48
|
-
|
11
|
+
require_relative '../../spec/test_helpers'
|
12
|
+
require_relative '../../lib/svelte_on_rails/installer/hello_world'
|
13
|
+
require_relative '../../lib/generators/svelte_on_rails/install/install_generator'
|
49
14
|
|
50
|
-
utils.write_templates(['config/svelte_on_rails.yml'])
|
51
|
-
npm_i.install_or_update_package('@csedl/svelte-on-rails')
|
52
|
-
# insert_initializer
|
53
|
-
uts = SvelteOnRails::Installer::Utils
|
54
|
-
uts.write_templates(['app/frontend/initializers/svelte.js'])
|
55
|
-
# add import statements
|
56
|
-
js_i = SvelteOnRails::Installer::Javascript
|
57
|
-
init_stat = '../initializers/svelte.js'
|
58
|
-
js_i.append_import_statement(application_js_path, init_stat, "import '#{init_stat}';")
|
59
15
|
|
60
|
-
# turbo
|
61
16
|
|
62
|
-
|
63
|
-
|
64
|
-
npm_i.install_or_update_package(tr_pkg)
|
65
|
-
|
66
|
-
js_i = SvelteOnRails::Installer::Javascript
|
67
|
-
js_i.append_import_statement(application_js_path, tr_pkg, "import '#{tr_pkg}';")
|
68
|
-
|
69
|
-
# svelte
|
70
|
-
|
71
|
-
svelte_i = SvelteOnRails::Installer::Svelte
|
72
|
-
svelte_i.install_svelte
|
73
|
-
|
74
|
-
# Hello World
|
75
|
-
|
76
|
-
puts '-' * 80
|
77
|
-
|
78
|
-
hw_i = SvelteOnRails::Installer::HelloWorld
|
79
|
-
hello_world_path = hw_i.install_hello_world(hello_world_files)
|
80
|
-
|
81
|
-
# finish
|
82
|
-
|
83
|
-
puts '-' * 80
|
84
|
-
puts 'FINISHED SVELTE INSTALLATION'
|
85
|
-
puts '-' * 80
|
86
|
-
|
87
|
-
puts "SvelteOnRails installed successfully!"
|
88
|
-
puts "Restart the server and check if it all works."
|
89
|
-
if hello_world_path
|
90
|
-
puts "You can now access the Hello World component on: http://localhost:your-port-number#{hello_world_path}."
|
91
|
-
end
|
92
|
-
puts "Happy coding!"
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
desc "Installs SvelteOnRails YAML configuration into your Rails application"
|
97
|
-
task :install do
|
98
|
-
|
99
|
-
# svelte_on_rails
|
100
|
-
|
101
|
-
utils.write_templates(['config/svelte_on_rails.yml'])
|
102
|
-
npm_i.install_or_update_package('@csedl/svelte-on-rails')
|
103
|
-
|
104
|
-
end
|
17
|
+
namespace :svelte_on_rails do
|
105
18
|
|
106
19
|
desc "Removes the Hello World component"
|
107
20
|
task :remove_hello_world do
|
@@ -156,7 +69,36 @@ namespace :svelte_on_rails do
|
|
156
69
|
|
157
70
|
desc "Compile all Svelte components"
|
158
71
|
task :reset_and_compile_all do
|
159
|
-
SvelteOnRails::RenderServerSide.reset_and_compile_all
|
72
|
+
#SvelteOnRails::RenderServerSide.reset_and_compile_all
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Build test app within spec/installer_tests"
|
76
|
+
task :create_test_app do
|
77
|
+
TestHelpers.cleanup_rails_app
|
78
|
+
TestHelpers.create_rails_app
|
79
|
+
TestHelpers.gem_setup("rails g svelte_on_rails:install --full")
|
80
|
+
puts '-'*80
|
81
|
+
puts "Built test app successfully!"
|
82
|
+
puts "You can now run the server by:"
|
83
|
+
puts "$ cd #{TestHelpers.installer_test_app_path} && rails s"
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Build test app within spec/installer_tests"
|
87
|
+
task :replace_test_app_hello_world do
|
88
|
+
#require_relative '../../lib/svelte_on_rails/lib/utils'
|
89
|
+
require_relative '../../spec/test_helpers'
|
90
|
+
th = TestHelpers
|
91
|
+
puts '-'*80
|
92
|
+
hw_i = SvelteOnRails::Installer::HelloWorld
|
93
|
+
#utils = SvelteOnRails::Lib::Utils
|
94
|
+
@hello_world_path = hw_i.install_hello_world(
|
95
|
+
SvelteOnRails::Generators::InstallGenerator::HELLO_WORLD_FILES,
|
96
|
+
app_root: th.installer_test_app_path,
|
97
|
+
force: true,
|
98
|
+
)
|
99
|
+
|
100
|
+
puts '-'*80
|
101
|
+
puts "replaced Hello World component with new one"
|
160
102
|
end
|
161
103
|
|
162
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svelte-on-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Sedlmair
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: railties
|
@@ -24,13 +23,13 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '6.0'
|
27
|
-
description:
|
28
26
|
email: christian@sedlmair.ch
|
29
27
|
executables: []
|
30
28
|
extensions: []
|
31
29
|
extra_rdoc_files: []
|
32
30
|
files:
|
33
31
|
- README.md
|
32
|
+
- lib/generators/svelte_on_rails/install/install_generator.rb
|
34
33
|
- lib/svelte-on-rails.rb
|
35
34
|
- lib/svelte_on_rails/compiler/compile.js
|
36
35
|
- lib/svelte_on_rails/compiler/compiler.rb
|
@@ -72,7 +71,6 @@ metadata:
|
|
72
71
|
source_code_uri: https://gitlab.com/sedl/svelte-on-rails
|
73
72
|
changelog_uri: https://gitlab.com/sedl/svelte-on-rails
|
74
73
|
post_install: ruby -r svelte_on_rails/install -e 'SvelteOnRails::Install.run'
|
75
|
-
post_install_message:
|
76
74
|
rdoc_options: []
|
77
75
|
require_paths:
|
78
76
|
- lib
|
@@ -87,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
85
|
- !ruby/object:Gem::Version
|
88
86
|
version: '0'
|
89
87
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
88
|
+
rubygems_version: 3.6.7
|
92
89
|
specification_version: 4
|
93
90
|
summary: Seamlessly integrate Svelte Components into Rails views.
|
94
91
|
test_files: []
|