svelte-on-rails 1.0.11 → 1.0.12
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/lib/utils.rb +21 -4
- 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: 89b585de2264458769d479f27bcadc4080a8984b23e916cccd5d07876a30ea24
|
4
|
+
data.tar.gz: 7255f6af6ee943e809b24ba6551730e05dd21b8279555c677f7be2346d47a0f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3557343363ea9f1776a6766eadcb97a3d8e6376ac069b1daa764cd77aa87a2f04614c91f3ed0b9d16a549b4ca7651ad82716d4b2374fc222c6d649d1e1c538c3
|
7
|
+
data.tar.gz: 4f301fb16a422e682e75ca9ebf09a207474346ff973140191d8e92226bc9b284c04eaa3c3662f6745b83637b6db83752c8b5b4dcfa35deaec71eaa0d0ad1d973
|
@@ -62,20 +62,37 @@ module SvelteOnRails
|
|
62
62
|
mtime = (File.exist?(config.ssr_dist_folder.join('last_mtime')) ? File.read(config.ssr_dist_folder.join('last_mtime')).to_f : 0.0)
|
63
63
|
|
64
64
|
Dir.chdir(config.rails_root) do
|
65
|
+
|
66
|
+
# run build
|
67
|
+
|
65
68
|
cmd = "./node_modules/.bin/vite build --config vite-ssr.config.ts"
|
66
69
|
stdout, stderr, status = Open3.capture3(cmd)
|
67
70
|
mtime2 = (File.exist?(config.ssr_dist_folder.join('last_mtime')) ? File.read(config.ssr_dist_folder.join('last_mtime')).to_f : 0.0)
|
68
|
-
|
69
|
-
|
71
|
+
|
72
|
+
# error handling
|
70
73
|
|
71
74
|
if stderr.present?
|
72
|
-
|
75
|
+
|
76
|
+
nothing_done = mtime2 == mtime
|
77
|
+
color = (nothing_done ? "\033[97;41m" : "\033[30;106m")
|
78
|
+
|
79
|
+
msg = " +++ #{nothing_done ? 'ERROR' : 'WARNING'} compiling Svelte components#{nothing_done ? ' failed' : ''} («#{cmd}») +++ "
|
73
80
|
puts "#{color}#{msg}\033[0m"
|
74
81
|
errs = stderr.split("\n")
|
75
|
-
errs.each {|e|puts "#{color} \033[0m #{e}"}
|
82
|
+
errs.each { |e| puts "#{color} \033[0m #{e}" }
|
76
83
|
puts "#{color} +++ End of error message +++ \033[0m"
|
77
84
|
puts "#{color} +++ Run «npm run build:ssr» on the console to see the original error message +++ \033[0m"
|
85
|
+
|
86
|
+
if nothing_done
|
87
|
+
critical_lines = errs.select { |e| e.match(/Could not resolve/i) }
|
88
|
+
cl_str = if critical_lines.present?
|
89
|
+
"#{critical_lines.join("\n")}\n\n"
|
90
|
+
end
|
91
|
+
raise "Svelte components compilation failed\n\n#{cl_str}Full message:\n+++\n#{stderr}+++\n\nYou can run «npm run build:ssr» on the console to see the original error message\n"
|
92
|
+
end
|
93
|
+
|
78
94
|
end
|
95
|
+
|
79
96
|
puts stdout
|
80
97
|
|
81
98
|
end
|