svelte-on-rails 0.0.21 → 0.0.23

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: 4760a8d0ae7d7de9e8bfb08b82e6cc7ff830979ef1297001606ab9a6eb282bff
4
- data.tar.gz: 49ba7cbb917e62092d1997a4d39b1815d43a71546d78c5c5e52845e95a4c2d7e
3
+ metadata.gz: 66e90b317f4d27aa1eefed02488e7e3560054ec1f58f5a75bf8f1f383b9f4345
4
+ data.tar.gz: a5f5309db035430f1fd67bdc2ccf624e585a4bf7a76c454314ea0284e496add5
5
5
  SHA512:
6
- metadata.gz: 4a3774a457cb886ff0854393857aea33b0c067cb814f72a94bad40c7beb4265018544370b1df2e5c6968daf35df9318897dcc666e16e595e8108f1e04c63547a
7
- data.tar.gz: b35eabfabd993155ced5ad68f90f9c8795e9520234312f142bd42c25c98b5fe16ebddec50c230879df72a144c13c31e3ace74a9cbaee7681264f4707e658c613
6
+ metadata.gz: 90cea52cbcb1240f68d5d2185a043405fd487a00ad29a44f8bba83a8b91184dadcb6e4600332555059cea3b63e085c416b25c2355a23059e1dab883e5e568d8a
7
+ data.tar.gz: cb8bad796a27e11b6b10f994758c1d43a1aae388b3d95999015faa3e92626ee8dae99afd562db57e26685c74b4dfd8b43251771e6b42de996e95f25fcf412cde
@@ -43,7 +43,7 @@ module SvelteOnRails
43
43
  # Write the modified content back to the file
44
44
  begin
45
45
  File.write(file_path, lines.map{|l|l.gsub(/\n/, '')}.join("\n"))
46
- puts "Successfully inserted «#{import_statement}» into '#{file_path}'"
46
+ puts "Successfully inserted «#{import_statement}» into '#{file_path}' on line #{last_import_index + 2}."
47
47
  rescue => e
48
48
  raise "Error writing to #{file_path} => «#{e.message}»"
49
49
  end
@@ -1 +1,27 @@
1
- <h1>Hello Svelte</h1>
1
+ <script>
2
+ export let items
3
+ let count = 0;
4
+
5
+ function increment() {
6
+ count += 1;
7
+ }
8
+ </script>
9
+
10
+ <h1>Greetings from svelte</h1>
11
+ <button on:click={increment}>Increment: {count}</button>
12
+
13
+ <ul>
14
+ {#each items as item}
15
+ <li>{item}</li>
16
+ {/each}
17
+ </ul>
18
+
19
+ <style>
20
+ button {
21
+ background-color: darkred;
22
+ color: white;
23
+ padding: 10px;
24
+ border: none;
25
+ cursor: pointer;
26
+ }
27
+ </style>
@@ -1,3 +1,3 @@
1
1
  %h1 Hello
2
2
 
3
- = svelte_component "SvelteOnRailsHelloWorld"
3
+ = svelte_component "SvelteOnRailsHelloWorld", items: ['item-1', 'item-2', 'item-3']
@@ -25,7 +25,9 @@ module SvelteOnRails
25
25
  gu.install_gem('vite_rails')
26
26
 
27
27
  Dir.chdir(Rails.root) do
28
+ puts '++ running «bundle exec vite install» ++'
28
29
  `bundle exec vite install`
30
+ puts '++ vite installer finished ++'
29
31
  end
30
32
 
31
33
  end
@@ -52,22 +54,24 @@ module SvelteOnRails
52
54
 
53
55
  js_i = SvelteOnRails::Installer::Javascript
54
56
  pkg = '@sveltejs/vite-plugin-svelte'
55
- js_i.append_import_statement('vite.config.ts', pkg, "import {svelte} from '#{pkg}'")
56
57
  npm_i = SvelteOnRails::Installer::Npm
57
58
  npm_i.install_or_update_package(pkg)
58
59
 
59
60
  # add plugin
60
61
 
61
- file_content = File.read('vite.config.ts')
62
+ file_path = 'vite.config.ts'
62
63
 
63
- if file_content.match?(/svelte/)
64
- puts "Svelte seams already configured in vite.config.ts, nothing changed here."
64
+ if File.read(file_path).match?(/svelte/)
65
+ puts "Svelte seams already configured in vite.config.ts, skipping here."
65
66
  else
66
67
 
68
+ js_i.append_import_statement('vite.config.ts', pkg, "import {svelte} from '#{pkg}'")
69
+
67
70
  # Regex to match the plugins array and locate RubyPlugin()
68
- plugins_regex = /(plugins:\s*\[\s*)(\s*)RubyPlugin\(\),\s*([^]]*?\])/m
71
+ plugins_regex = /(plugins:\s*\[\s*)(\s*)RubyPlugin\(\),\s*([^\]]*?\])/m
69
72
 
70
73
  # Check if plugins array with RubyPlugin exists
74
+ file_content = File.read(file_path)
71
75
  unless file_content.match?(plugins_regex)
72
76
  puts "Error: No plugins array with RubyPlugin() found in the input."
73
77
  return file_content
@@ -81,7 +85,7 @@ module SvelteOnRails
81
85
  "#{prefix}#{indent}RubyPlugin(),\n#{indent}svelte({}),\n#{indent}#{rest}"
82
86
  end
83
87
 
84
- File.write('vite.config.ts', modified_content)
88
+ File.write(file_path, modified_content)
85
89
  puts "Updated vite.config.ts with svelte() plugin."
86
90
  end
87
91
  end
@@ -17,6 +17,17 @@ namespace :svelte_on_rails do
17
17
  puts '-' * 80
18
18
  puts 'STARTING SVELTE-ON-RAILS INSTALLATION'
19
19
 
20
+
21
+ # vite
22
+
23
+ vite_i = SvelteOnRails::Installer::Vite
24
+ vite_i.install_vite
25
+
26
+ # haml
27
+
28
+ haml_i = SvelteOnRails::Installer::Haml
29
+ haml_i.install_haml_and_convert
30
+
20
31
  # svelte_on_rails
21
32
 
22
33
  utils.write_templates(['config/svelte_on_rails.yml'])
@@ -29,17 +40,6 @@ namespace :svelte_on_rails do
29
40
  init_stat = '../initializers/svelte.js'
30
41
  js_i.append_import_statement(application_js_path, init_stat, "import '#{init_stat}';")
31
42
 
32
-
33
- # haml
34
-
35
- haml_i = SvelteOnRails::Installer::Haml
36
- haml_i.install_haml_and_convert
37
-
38
- # vite
39
-
40
- vite_i = SvelteOnRails::Installer::Vite
41
- vite_i.install_vite
42
-
43
43
  # turbo
44
44
 
45
45
  tr_pkg = '@hotwired/turbo-rails'
@@ -72,10 +72,10 @@ namespace :svelte_on_rails do
72
72
  puts "SvelteOnRails installed successfully!"
73
73
  puts "Restart the server and check if it all works."
74
74
  if hello_world_path
75
- puts "You can now see the Hello World component on: #{hello_world_path}."
75
+ puts "You can now access the Hello World component on: http://localhost:your-port-number#{hello_world_path}."
76
76
  end
77
77
  puts "Happy coding!"
78
- #exit
78
+
79
79
  end
80
80
 
81
81
  desc "Installs SvelteOnRails YAML configuration into your Rails application"
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: 0.0.21
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair