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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2bddaae521fc71ed3c7975612b8b9109830fd25210eda2d30c00c6150265dca
4
- data.tar.gz: 7adeb7e7181508d704ff98087f5b601a596159d1205cb0ffb08e98f5fca81272
3
+ metadata.gz: bff57a06d326d5d82c6723869221aa21a47cb5d26e13c2d12100962610240b94
4
+ data.tar.gz: 589902ba14fd77b3c094a92ce2396a0edb0d5bfb8e81f23bf2250953f9d89da2
5
5
  SHA512:
6
- metadata.gz: 77f1fd03901c9c73c8893c471b464db9e2e4fd212b9a36dad9a78f15b34f155865155b4796af3409e32b741dd4693a9756c369bcfb32caf05b1a1abdfa6e1af5
7
- data.tar.gz: 7be8fd8640a3d7431dd6e8274a3bc3f3a9eca0c9c9e30f46d42f4eb00735f13a8e8421e8b0e6142c17ac0a0aab9bc9df5cc0914b17add50677498575401ac20b
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
- mtime2 = (File.exist?(config.ssr_dist_folder.join('last_mtime')) ? File.read(config.ssr_dist_folder.join('last_mtime')).to_f : 0.0)
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
- 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}») +++ "
80
- puts "#{color}#{msg}\033[0m"
81
- errs = stderr.split("\n")
82
- errs.each { |e| puts "#{color} \033[0m #{e}" }
83
- puts "#{color} +++ End of error message +++ \033[0m"
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
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
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: 1.0.13
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair