svelte-on-rails 0.0.22 → 0.0.24
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/lib/svelte_on_rails/installer/javascript.rb +1 -1
- data/lib/svelte_on_rails/installer/rails_template/app/frontend/javascript/components/SvelteOnRailsHelloWorld.svelte +39 -1
- data/lib/svelte_on_rails/installer/rails_template/app/views/svelte_on_rails_hello_world/index.haml +2 -2
- data/lib/svelte_on_rails/installer/vite.rb +8 -6
- data/lib/tasks/svelte_on_rails_tasks.rake +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97f95713831cb35b5ba7ff76b63f320be3a5f7ef682844c65523728f78455c90
|
4
|
+
data.tar.gz: 9501a5d850b4d5451dbc98055fbf4c21fd2b617dfdc2cc971c26cf02cbe6738e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc4a71238b2d358d38f616081ed56d1143f8745729d7fc80dfc4b1ceba85f70b0be542c760fdbc16095833eb88dfc7485ce22c73a76f940254de97e3c3af463c
|
7
|
+
data.tar.gz: 16870d9e12978fc0e111b2fa380b09bb65b7d824f34b1a7e715d60b4e32414a7f07de824b92c6d0d5be3ef1888f492235d1a3dc231ba46dfae265bf1242ab741
|
@@ -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,39 @@
|
|
1
|
-
<
|
1
|
+
<script>
|
2
|
+
export let items
|
3
|
+
let count = 0;
|
4
|
+
|
5
|
+
function increment() {
|
6
|
+
count += 1;
|
7
|
+
}
|
8
|
+
</script>
|
9
|
+
|
10
|
+
<span class="svelte-component-wrapper">
|
11
|
+
<h1>Greetings from svelte!</h1>
|
12
|
+
<button on:click={increment}>Increment: {count}</button>
|
13
|
+
|
14
|
+
<ul>
|
15
|
+
{#each items as item}
|
16
|
+
<li>{item}</li>
|
17
|
+
{/each}
|
18
|
+
</ul>
|
19
|
+
</span>
|
20
|
+
|
21
|
+
<style>
|
22
|
+
button {
|
23
|
+
background-color: darkred;
|
24
|
+
color: white;
|
25
|
+
padding: 10px;
|
26
|
+
border: none;
|
27
|
+
cursor: pointer;
|
28
|
+
}
|
29
|
+
.svelte-component-wrapper {
|
30
|
+
border: 1px solid black;
|
31
|
+
padding: 10px;
|
32
|
+
margin: 10px;
|
33
|
+
background-color: #efefef;
|
34
|
+
display: inline-block;
|
35
|
+
box-shadow: 2px 3px 16px -1px rgba(0,0,0,0.75);
|
36
|
+
-webkit-box-shadow: 2px 3px 16px -1px rgba(0,0,0,0.75);
|
37
|
+
-moz-box-shadow: 2px 3px 16px -1px rgba(0,0,0,0.75);
|
38
|
+
}
|
39
|
+
</style>
|
data/lib/svelte_on_rails/installer/rails_template/app/views/svelte_on_rails_hello_world/index.haml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
%
|
1
|
+
%p Example view
|
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
|
-
|
62
|
+
file_path = 'vite.config.ts'
|
64
63
|
|
65
|
-
if
|
66
|
-
puts "Svelte seams already configured in vite.config.ts,
|
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*([
|
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(
|
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
|
-
|
78
|
+
|
79
79
|
end
|
80
80
|
|
81
81
|
desc "Installs SvelteOnRails YAML configuration into your Rails application"
|