vite_ruby 1.2.5 → 1.2.10

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: 4cf73b3471127a2ca30bb94a9db5eadde2674289194dbe605ae01c3dc9bee817
4
- data.tar.gz: 93312a90a04807cb3f683f9435fddd399ffdfeda7dff31b9316c9977fb1b7a22
3
+ metadata.gz: 434e2c4bccc4557134c3ef317342b499cb57a70e3f441778d6fd94d4c2debf8b
4
+ data.tar.gz: 0456b70d36df278b46ded52dab70c3f098c9b31aa072b9d0cddd96652546e386
5
5
  SHA512:
6
- metadata.gz: 789ff6d9d918b741f1430e802ea7fed4404ae3e216748d26b48f48c6a3d41976197f00a7e2ed3878b88d819fb2b812bef14099f753d884e02c6f0ea8acc5b315
7
- data.tar.gz: 58044eba7336765db7a63bfa871f0c7ede9b28ef8ebf66708eb9c8c669abb7ca24f9855878af55fe02afd3e5d5126e1f49e5ef7e4feeaf8229984f59445c38d1
6
+ metadata.gz: 46d5df8aee43d5c3965bc58a479b76e332ca2f025159a06371b10163ec127d9cf37a5f696165ef06b62ca35f5d9d93cf5df14256b83dba902387b2dfa5931a17
7
+ data.tar.gz: 40900cb76780ddc98239d39b40d1633ec0593b9e7040d9c5ca5a4d99aab91a54a17313ce681b4aae457b1c762809c74eaf87ab88a12b56c5c44525a930239053
data/CHANGELOG.md CHANGED
@@ -1,3 +1,48 @@
1
+ ## [1.2.10](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.9...vite_ruby@1.2.10) (2021-05-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Lock dry-cli to 0.6 since 0.7 has breaking changes (close [#76](https://github.com/ElMassimo/vite_ruby/issues/76)) ([9883458](https://github.com/ElMassimo/vite_ruby/commit/9883458443cb0047cd4cceaf02de2a86066d624e))
7
+
8
+
9
+
10
+ ## [1.2.9](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.8...vite_ruby@1.2.9) (2021-05-04)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * Stream output during installation and don't skip installation of npm packages when no lockfile is detected ([#73](https://github.com/ElMassimo/vite_ruby/issues/73)) ([028a5ba](https://github.com/ElMassimo/vite_ruby/commit/028a5bae359085a36aa942d2ad63c23616a00ffb))
16
+
17
+
18
+
19
+ ## [1.2.8](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.7...vite_ruby@1.2.8) (2021-04-29)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * Don't modify url for minified css when proxying a request ([#71](https://github.com/ElMassimo/vite_ruby/issues/71)) ([d30a577](https://github.com/ElMassimo/vite_ruby/commit/d30a577a8436c4987d7c2e08e7eae68e589eb2a7))
25
+
26
+
27
+
28
+ ## [1.2.7](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.6...vite_ruby@1.2.7) (2021-04-28)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * Support Rails 5.1 by avoiding [incorrectly monkeypatched](https://github.com//github.com/rails/rails/blob/5-1-stable/activesupport/lib/active_support/core_ext/array/prepend_and_append.rb/issues/L2-L3) `Array#append` ([1b59551](https://github.com/ElMassimo/vite_ruby/commit/1b5955170b33a528a2b13d7e7e308e8493d97a91))
34
+
35
+
36
+
37
+ ## [1.2.6](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.5...vite_ruby@1.2.6) (2021-04-26)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * Update installation to use the latest version of the plugin ([#67](https://github.com/ElMassimo/vite_ruby/issues/67)) ([7e10636](https://github.com/ElMassimo/vite_ruby/commit/7e10636f5396f496bd099a03e069cf8572b9585b))
43
+
44
+
45
+
1
46
  ## [1.2.5](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.4...vite_ruby@1.2.5) (2021-04-21)
2
47
 
3
48
 
data/lib/vite_ruby.rb CHANGED
@@ -10,6 +10,7 @@ loader.ignore("#{ __dir__ }/install")
10
10
  loader.ignore("#{ __dir__ }/tasks")
11
11
  loader.ignore("#{ __dir__ }/exe")
12
12
  loader.inflector.inflect('cli' => 'CLI')
13
+ loader.inflector.inflect('io' => 'IO')
13
14
  loader.setup
14
15
 
15
16
  class ViteRuby
@@ -17,8 +18,8 @@ class ViteRuby
17
18
  ENV_PREFIX = 'VITE_RUBY'
18
19
 
19
20
  # Internal: Versions used by default when running `vite install`.
20
- DEFAULT_VITE_VERSION = '^2.0.3'
21
- DEFAULT_PLUGIN_VERSION = '^1.0.13'
21
+ DEFAULT_VITE_VERSION = '^2.2.3'
22
+ DEFAULT_PLUGIN_VERSION = '^2.0.2'
22
23
 
23
24
  # Internal: Ruby Frameworks that have a companion library for Vite Ruby.
24
25
  SUPPORTED_FRAMEWORKS = %w[rails hanami roda padrino sinatra].freeze
@@ -69,7 +69,7 @@ private
69
69
  def build_with_vite(*args)
70
70
  logger.info 'Building with Vite ⚡️'
71
71
 
72
- stdout, stderr, status = ViteRuby.run(['build', *args], capture: true)
72
+ stdout, stderr, status = ViteRuby.run(['build', *args])
73
73
  log_build_result(stdout, stderr.to_s, status)
74
74
 
75
75
  status.success?
@@ -8,6 +8,6 @@ class ViteRuby::CLI::Dev < ViteRuby::CLI::Build
8
8
  option(:force, desc: 'Force Vite to re-bundle dependencies', type: :boolean)
9
9
 
10
10
  def call(**options)
11
- super { |args| ViteRuby.run(args) }
11
+ super { |args| ViteRuby.run(args, exec: true) }
12
12
  end
13
13
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'dry/cli/utils/files'
4
4
  require 'stringio'
5
- require 'open3'
6
5
 
7
6
  class ViteRuby::CLI::Install < Dry::CLI::Command
8
7
  desc 'Performs the initial configuration setup to get started with Vite Ruby.'
@@ -73,11 +72,12 @@ private
73
72
  def install_js_dependencies
74
73
  package_json = root.join('package.json')
75
74
  write(package_json, '{}') unless package_json.exist?
75
+
76
76
  Dir.chdir(root) do
77
77
  deps = "vite@#{ ViteRuby::DEFAULT_VITE_VERSION } vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }"
78
- stdout, stderr, status = Open3.capture3({}, "npx --yes --package @antfu/ni -- ni -D #{ deps }")
79
- stdout, stderr, = Open3.capture3({}, "yarn add -D #{ deps }") unless status.success?
80
- say(stdout, "\n", stderr)
78
+ _, stderr, status = ViteRuby::IO.capture("npx --package @antfu/ni -- ni -D #{ deps }", stdin_data: "\n")
79
+ _, stderr, = ViteRuby::IO.capture("yarn add -D #{ deps }") unless status.success?
80
+ say("Could not install JS dependencies.\n", stderr) unless stderr.to_s.empty?
81
81
  end
82
82
  end
83
83
 
@@ -33,7 +33,7 @@ private
33
33
  uri = env.fetch('REQUEST_URI') { [env['PATH_INFO'], env['QUERY_STRING']].reject { |str| str.to_s.strip.empty? }.join('?') }
34
34
  .sub(HOST_WITH_PORT_REGEX, '/') # Hanami adds the host and port.
35
35
  .sub('.ts.js', '.ts') # Hanami's javascript helper always adds the extension.
36
- .sub(/(\.\w+)\.css$/, '\1') # Rails' stylesheet_link_tag always adds the extension.
36
+ .sub(/(\.(?!min)\w+)\.css$/, '\1') # Rails' stylesheet_link_tag always adds the extension.
37
37
  env['PATH_INFO'], env['QUERY_STRING'] = (env['REQUEST_URI'] = uri).split('?')
38
38
  end
39
39
 
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ # Public: Builds on top of Ruby I/O open3 providing a friendlier experience.
6
+ module ViteRuby::IO
7
+ class << self
8
+ # Internal: A modified version of capture3 that can continuosly print stdout.
9
+ # NOTE: Streaming output provides a better UX when running bin/vite build.
10
+ def capture(*cmd, with_output: $stdout.method(:puts), stdin_data: '', **opts)
11
+ return Open3.capture3(*cmd, **opts) unless with_output
12
+
13
+ Open3.popen3(*cmd, **opts) { |stdin, stdout, stderr, wait_threads|
14
+ stdin << stdin_data
15
+ stdin.close
16
+ out = Thread.new { read_lines(stdout, &with_output) }
17
+ err = Thread.new { stderr.read }
18
+ [out.value, err.value, wait_threads.value]
19
+ }
20
+ end
21
+
22
+ # Internal: Reads and yield every line in the stream. Returns the full content.
23
+ def read_lines(io)
24
+ buffer = +''
25
+ while line = io.gets
26
+ buffer << line
27
+ yield line
28
+ end
29
+ buffer
30
+ end
31
+ end
32
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'open3'
4
-
5
3
  # Public: Executes Vite commands, providing conveniences for debugging.
6
4
  class ViteRuby::Runner
7
5
  def initialize(vite_ruby)
@@ -9,10 +7,13 @@ class ViteRuby::Runner
9
7
  end
10
8
 
11
9
  # Public: Executes Vite with the specified arguments.
12
- def run(argv, capture: false)
10
+ def run(argv, exec: false)
13
11
  Dir.chdir(config.root) {
14
12
  cmd = command_for(argv)
15
- capture ? capture3_with_output(*cmd, chdir: config.root) : Kernel.exec(*cmd)
13
+ return Kernel.exec(*cmd) if exec
14
+
15
+ log_or_noop = ->(line) { logger.info('vite') { line } } unless config.hide_build_console_output
16
+ ViteRuby::IO.capture(*cmd, chdir: config.root, with_output: log_or_noop)
16
17
  }
17
18
  rescue Errno::ENOENT => error
18
19
  raise ViteRuby::MissingExecutableError, error
@@ -28,11 +29,11 @@ private
28
29
  def command_for(args)
29
30
  [config.to_env].tap do |cmd|
30
31
  args = args.clone
31
- cmd.append('node', '--inspect-brk') if args.delete('--inspect')
32
- cmd.append('node', '--trace-deprecation') if args.delete('--trace_deprecation')
33
- cmd.append(vite_executable)
34
- cmd.append(*args)
35
- cmd.append('--mode', config.mode) unless args.include?('--mode') || args.include?('-m')
32
+ cmd.push('node', '--inspect-brk') if args.delete('--inspect')
33
+ cmd.push('node', '--trace-deprecation') if args.delete('--trace_deprecation')
34
+ cmd.push(vite_executable)
35
+ cmd.push(*args)
36
+ cmd.push('--mode', config.mode) unless args.include?('--mode') || args.include?('-m')
36
37
  end
37
38
  end
38
39
 
@@ -41,26 +42,4 @@ private
41
42
  bin_path = config.vite_bin_path
42
43
  File.exist?(bin_path) ? bin_path : "#{ `npm bin`.chomp }/vite"
43
44
  end
44
-
45
- # Internal: A modified version of capture3 that continuosly prints stdout.
46
- # NOTE: This improves the experience of running bin/vite build.
47
- def capture3_with_output(*cmd, **opts)
48
- return Open3.capture3(*cmd, opts) if config.hide_build_console_output
49
-
50
- Open3.popen3(*cmd, opts) { |_stdin, stdout, stderr, wait_threads|
51
- out = Thread.new { read_lines(stdout) { |l| logger.info('vite') { l } } }
52
- err = Thread.new { stderr.read }
53
- [out.value, err.value, wait_threads.value]
54
- }
55
- end
56
-
57
- # Internal: Reads and yield every line in the stream. Returns the full content.
58
- def read_lines(io)
59
- buffer = +''
60
- while line = io.gets
61
- buffer << line
62
- yield line
63
- end
64
- buffer
65
- end
66
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ViteRuby
4
- VERSION = '1.2.5'
4
+ VERSION = '1.2.10'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vite_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Máximo Mussini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-21 00:00:00.000000000 Z
11
+ date: 2021-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: 0.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.6'
26
+ version: 0.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack-proxy
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +225,7 @@ files:
225
225
  - lib/vite_ruby/config.rb
226
226
  - lib/vite_ruby/dev_server_proxy.rb
227
227
  - lib/vite_ruby/error.rb
228
+ - lib/vite_ruby/io.rb
228
229
  - lib/vite_ruby/manifest.rb
229
230
  - lib/vite_ruby/missing_entrypoint_error.rb
230
231
  - lib/vite_ruby/missing_executable_error.rb
@@ -237,8 +238,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
237
238
  licenses:
238
239
  - MIT
239
240
  metadata:
240
- source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.5/vite_ruby
241
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.5/vite_ruby/CHANGELOG.md
241
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.10/vite_ruby
242
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.10/vite_ruby/CHANGELOG.md
242
243
  post_install_message:
243
244
  rdoc_options: []
244
245
  require_paths: