svelte-on-rails 0.0.22 → 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: b9171b9d426450c01ff922c667fff82f135416693c935b2cd131d5ee2326e854
4
- data.tar.gz: 96daa72a3460ace56b5e5e6382f678ba354b1693b95a87113639ed4cb3c2afe3
3
+ metadata.gz: 66e90b317f4d27aa1eefed02488e7e3560054ec1f58f5a75bf8f1f383b9f4345
4
+ data.tar.gz: a5f5309db035430f1fd67bdc2ccf624e585a4bf7a76c454314ea0284e496add5
5
5
  SHA512:
6
- metadata.gz: 52a206e75f0fe55f8121a05ae103701fefdd02e9ab6a4c5874179aa5b0ea2429fdb9c7d88d191c5c444fe0259990571ca1f5315ee017387d02d1e14271741d2c
7
- data.tar.gz: d9370b582b86edd05470e54d6f6c78a993412f67ec2dd454e11cb282e96ebc97c379ba0e94f644157edb13c946e2d4bf238667895402f92c2644b48822eb43c1
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']
@@ -54,22 +54,24 @@ module SvelteOnRails
54
54
 
55
55
  js_i = SvelteOnRails::Installer::Javascript
56
56
  pkg = '@sveltejs/vite-plugin-svelte'
57
- js_i.append_import_statement('vite.config.ts', pkg, "import {svelte} from '#{pkg}'")
58
57
  npm_i = SvelteOnRails::Installer::Npm
59
58
  npm_i.install_or_update_package(pkg)
60
59
 
61
60
  # add plugin
62
61
 
63
- file_content = File.read('vite.config.ts')
62
+ file_path = 'vite.config.ts'
64
63
 
65
- if file_content.match?(/svelte/)
66
- 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."
67
66
  else
68
67
 
68
+ js_i.append_import_statement('vite.config.ts', pkg, "import {svelte} from '#{pkg}'")
69
+
69
70
  # Regex to match the plugins array and locate RubyPlugin()
70
- plugins_regex = /(plugins:\s*\[\s*)(\s*)RubyPlugin\(\),\s*([^]]*?\])/m
71
+ plugins_regex = /(plugins:\s*\[\s*)(\s*)RubyPlugin\(\),\s*([^\]]*?\])/m
71
72
 
72
73
  # Check if plugins array with RubyPlugin exists
74
+ file_content = File.read(file_path)
73
75
  unless file_content.match?(plugins_regex)
74
76
  puts "Error: No plugins array with RubyPlugin() found in the input."
75
77
  return file_content
@@ -83,7 +85,7 @@ module SvelteOnRails
83
85
  "#{prefix}#{indent}RubyPlugin(),\n#{indent}svelte({}),\n#{indent}#{rest}"
84
86
  end
85
87
 
86
- File.write('vite.config.ts', modified_content)
88
+ File.write(file_path, modified_content)
87
89
  puts "Updated vite.config.ts with svelte() plugin."
88
90
  end
89
91
  end
@@ -18,16 +18,16 @@ namespace :svelte_on_rails do
18
18
  puts 'STARTING SVELTE-ON-RAILS INSTALLATION'
19
19
 
20
20
 
21
- # haml
22
-
23
- haml_i = SvelteOnRails::Installer::Haml
24
- haml_i.install_haml_and_convert
25
-
26
21
  # vite
27
22
 
28
23
  vite_i = SvelteOnRails::Installer::Vite
29
24
  vite_i.install_vite
30
25
 
26
+ # haml
27
+
28
+ haml_i = SvelteOnRails::Installer::Haml
29
+ haml_i.install_haml_and_convert
30
+
31
31
  # svelte_on_rails
32
32
 
33
33
  utils.write_templates(['config/svelte_on_rails.yml'])
@@ -75,7 +75,7 @@ namespace :svelte_on_rails do
75
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.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair