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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fae4c4bf2119aa220d24e012f464136310c2409da41c1c13efd28dfc66c6221
4
- data.tar.gz: 931d743b51f07cb28581c93f347499cca8ca4fdf31d6a8c0ac078c90f4446e11
3
+ metadata.gz: e31a3a82d534f874208a4bb67c36c2285fa2c793fdeeb98a3380c16fa98cb149
4
+ data.tar.gz: 29e19f383e0317c0b588fe4414462c90fe83328f4f3ce46c81ce383b68e1326c
5
5
  SHA512:
6
- metadata.gz: 0cfc39709d7a9e4936aacba08b80d8f159146c8a58a08fe4d760bd75b311339608514fc480bf240044f872255cc3dd081fa5c6c8f5e5b787255613b70c70267f
7
- data.tar.gz: 5b9931cd49aa1115078f8406a85e3b6c28fe3645b9414ed42ace6bc3ac561c74936b04b355ad5e68d9701c55fd3fb219bb73915e5bab819415235a73c512f8c0
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
- Dir.chdir(config.rails_root) do
62
+ # run build
63
63
 
64
- # run build
64
+ cmd = "#{config.rails_root.join('node_modules', '.bin', 'vite')} build --config vite-ssr.config.ts"
65
65
 
66
- cmd = "./node_modules/.bin/vite build --config vite-ssr.config.ts"
66
+ stdout, stderr, status = Open3.capture3(cmd)
67
67
 
68
- stdout, stderr, status = Open3.capture3(cmd)
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
- warnings = stderr.to_s.split("\n")
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
- # error handling
75
+ if stderr.present?
76
76
 
77
- if stderr.present?
77
+ red_background = "\033[97;41m"
78
+ light_blue_background = "\033[30;106m"
79
+ clear_colors = "\033[0m"
78
80
 
79
- red_background = "\033[97;41m"
80
- light_blue_background = "\033[30;106m"
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
- 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}"
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} +++ 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
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
- puts stdout
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
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: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Sedlmair