svelte-on-rails 1.0.13 → 1.0.14
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 +34 -18
- 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: bff57a06d326d5d82c6723869221aa21a47cb5d26e13c2d12100962610240b94
|
4
|
+
data.tar.gz: 589902ba14fd77b3c094a92ce2396a0edb0d5bfb8e81f23bf2250953f9d89da2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35ee591f318848ca0918280f4c633f36896f530a443f97ff6e02444877e6b9b677aeb0a139503a8296f3f47fbb528dc5b60cb277721237d68c5100e1b048267d
|
7
|
+
data.tar.gz: c119240c35a8a0c74d9606a7cc651f37bb8c107fa9e96d18d8b20ce2b68018fa630d6f3749bd0ecb594834fc5cdf742fc4e1d2c1bfc0095e18d4074b38c9b105
|
@@ -59,35 +59,50 @@ module SvelteOnRails
|
|
59
59
|
def self.precompile(last_mtime = nil)
|
60
60
|
config = SvelteOnRails::Configuration.instance
|
61
61
|
|
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
|
-
|
64
62
|
Dir.chdir(config.rails_root) do
|
65
63
|
|
66
64
|
# run build
|
67
65
|
|
68
66
|
cmd = "./node_modules/.bin/vite build --config vite-ssr.config.ts"
|
67
|
+
|
69
68
|
stdout, stderr, status = Open3.capture3(cmd)
|
70
|
-
|
69
|
+
|
70
|
+
warnings = stderr.to_s.split("\n")
|
71
|
+
errors_matcher = Regexp.new('(Could not resolve)')
|
72
|
+
error_lines = warnings.select { |e| e.match(errors_matcher) }
|
73
|
+
have_error = error_lines.present? || status.to_s.match(/exit 1/)
|
71
74
|
|
72
75
|
# error handling
|
73
76
|
|
74
77
|
if stderr.present?
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
79
|
+
red_background = "\033[97;41m"
|
80
|
+
light_blue_background = "\033[30;106m"
|
81
|
+
clear_colors = "\033[0m"
|
82
|
+
|
83
|
+
msg = " +++ #{have_error ? 'ERROR' : 'WARNING'} compiling Svelte components#{have_error ? ' failed' : ''} («#{cmd}») +++ "
|
84
|
+
puts "#{have_error ? red_background : light_blue_background}#{msg}#{clear_colors}"
|
85
|
+
|
86
|
+
warnings.each do |e|
|
87
|
+
if e.match(errors_matcher)
|
88
|
+
red_font = "\033[31m"
|
89
|
+
puts "#{red_background} #{clear_colors}#{red_font} #{e}#{clear_colors}"
|
90
|
+
else
|
91
|
+
puts "#{light_blue_background} #{clear_colors}#{e}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
if have_error
|
96
|
+
puts "#{red_background} +++ End of error message +++ #{clear_colors}"
|
97
|
+
else
|
98
|
+
puts "#{light_blue_background} +++ End of compiling warnings +++ #{clear_colors}"
|
99
|
+
end
|
100
|
+
puts "#{have_error ? red_background : light_blue_background} +++ Run «npm run build:ssr» on the console to see the original error message +++ #{clear_colors}"
|
101
|
+
|
102
|
+
if have_error
|
103
|
+
cl_str = if error_lines.present?
|
104
|
+
"#{error_lines.join("\n")}\n\n"
|
105
|
+
end
|
91
106
|
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
107
|
end
|
93
108
|
|
@@ -104,6 +119,7 @@ module SvelteOnRails
|
|
104
119
|
mtime_path = config.ssr_dist_folder.join('last_mtime')
|
105
120
|
File.write(mtime_path, last_mtime.to_s)
|
106
121
|
end
|
122
|
+
|
107
123
|
end
|
108
124
|
|
109
125
|
end
|