svelte-on-rails 2.1.0 → 2.1.1
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 +33 -37
- 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: e31a3a82d534f874208a4bb67c36c2285fa2c793fdeeb98a3380c16fa98cb149
|
4
|
+
data.tar.gz: 29e19f383e0317c0b588fe4414462c90fe83328f4f3ce46c81ce383b68e1326c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd20e2487507675be708f07f0dc414d09d38b43b1c4ae6fcb28cc5e3719cc4b21fd9586dcd547e49993f98ed940c0f19129fc42717d532ea0a8f95de031bf4e6
|
7
|
+
data.tar.gz: 7ddf1c74f7c7d16c2ef2ee5fd5f4fecd6e3919c765ebf11008df2dfb460c9cadd948e8d270babfa11677669bea4410a46d862ce6a29b82afdabf5005e38aa283
|
@@ -59,59 +59,55 @@ module SvelteOnRails
|
|
59
59
|
def self.precompile(last_mtime = nil)
|
60
60
|
config = SvelteOnRails::Configuration.instance
|
61
61
|
|
62
|
-
|
62
|
+
# run build
|
63
63
|
|
64
|
-
|
64
|
+
cmd = "#{config.rails_root.join('node_modules', '.bin', 'vite')} build --config vite-ssr.config.ts"
|
65
65
|
|
66
|
-
|
66
|
+
stdout, stderr, status = Open3.capture3(cmd)
|
67
67
|
|
68
|
-
|
68
|
+
warnings = stderr.to_s.split("\n")
|
69
|
+
errors_matcher = Regexp.new('(Could not resolve|failed to resolve)')
|
70
|
+
error_lines = warnings.select { |e| e.match(errors_matcher) }
|
71
|
+
have_error = error_lines.present? || status.to_s.match(/exit 1/)
|
69
72
|
|
70
|
-
|
71
|
-
errors_matcher = Regexp.new('(Could not resolve|failed to resolve)')
|
72
|
-
error_lines = warnings.select { |e| e.match(errors_matcher) }
|
73
|
-
have_error = error_lines.present? || status.to_s.match(/exit 1/)
|
73
|
+
# error handling
|
74
74
|
|
75
|
-
|
75
|
+
if stderr.present?
|
76
76
|
|
77
|
-
|
77
|
+
red_background = "\033[97;41m"
|
78
|
+
light_blue_background = "\033[30;106m"
|
79
|
+
clear_colors = "\033[0m"
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
clear_colors = "\033[0m"
|
81
|
+
msg = " +++ #{have_error ? 'ERROR' : 'WARNING'} compiling Svelte components#{have_error ? ' failed' : ''} («#{cmd}») +++ "
|
82
|
+
puts "#{have_error ? red_background : light_blue_background}#{msg}#{clear_colors}"
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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}"
|
84
|
+
warnings.each do |e|
|
85
|
+
if e.match(errors_matcher)
|
86
|
+
red_font = "\033[31m"
|
87
|
+
puts "#{red_background} #{clear_colors}#{red_font} #{e}#{clear_colors}"
|
97
88
|
else
|
98
|
-
puts "#{light_blue_background}
|
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
|
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"
|
89
|
+
puts "#{light_blue_background} #{clear_colors}#{e}"
|
107
90
|
end
|
91
|
+
end
|
108
92
|
|
93
|
+
if have_error
|
94
|
+
puts "#{red_background} +++ End of error message +++ #{clear_colors}"
|
95
|
+
else
|
96
|
+
puts "#{light_blue_background} +++ End of compiling warnings +++ #{clear_colors}"
|
109
97
|
end
|
98
|
+
puts "#{have_error ? red_background : light_blue_background} +++ Run «npm run build:ssr» on the console to see the original error message +++ #{clear_colors}"
|
110
99
|
|
111
|
-
|
100
|
+
if have_error
|
101
|
+
cl_str = if error_lines.present?
|
102
|
+
"#{error_lines.join("\n")}\n\n"
|
103
|
+
end
|
104
|
+
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"
|
105
|
+
end
|
112
106
|
|
113
107
|
end
|
114
108
|
|
109
|
+
puts stdout
|
110
|
+
|
115
111
|
unless Dir.exist?(config.ssr_dist_folder)
|
116
112
|
raise "Could not find dist folder: #{config.ssr_dist_folder}"
|
117
113
|
end
|