vite_ruby 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e208284305c3370dd47dac35ef06af231c8ddd55b13b8870b7f32179e4c350c4
4
- data.tar.gz: 1390d37229bf7d4139b0df3ce08d7e7b64877e2ad7ec041b7d49722545caa652
3
+ metadata.gz: 4d76db7c0a459f6a410ce71f7bb44e50eeaff89f7a071ad6beddab4b9ea272f6
4
+ data.tar.gz: 5d77215308acacbe91f286665d74bf406205bd3e3a31b30f07022c56a719c51a
5
5
  SHA512:
6
- metadata.gz: b99b7aaf20cb938245f5f83f61d5aace6ffc40519f139b51b9fa9ecd86c14b9098cfafb0b966e08048d64cb62848ff25b4ee086990b44469a44ec739c61712ba
7
- data.tar.gz: cf4db82501767990f54d994a0c8fce16404a9d5156ef956990a1b3fb403ddd8a71a8e220f629c03c6d188400cc40176be650a2985dde6d2c677838fa25a87fee
6
+ metadata.gz: 0f9ceb9ded8010c698349d4cc17d1671544033e4e83d12d6d5b0c134aba0d06182836fa0d5b320c31eaf4111b8acb1c4edeb20e59b9444a28b7c61f3663e50ff
7
+ data.tar.gz: 0a8858be21aa01da1e29f0fbff8a01702eb1b6f56a3aefca06786ff631eb3ecc311154ce6543c684ceae2b35300eac3b4ea694d89a8fbdbde3576342fdd26783
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.2.9](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.8...vite_ruby@1.2.9) (2021-05-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 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))
7
+
8
+
9
+
1
10
  ## [1.2.8](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.7...vite_ruby@1.2.8) (2021-04-29)
2
11
 
3
12
 
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
@@ -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
 
@@ -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
@@ -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.8'
4
+ VERSION = '1.2.9'
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.8
4
+ version: 1.2.9
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-29 00:00:00.000000000 Z
11
+ date: 2021-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -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.8/vite_ruby
241
- changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.8/vite_ruby/CHANGELOG.md
241
+ source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.9/vite_ruby
242
+ changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.9/vite_ruby/CHANGELOG.md
242
243
  post_install_message:
243
244
  rdoc_options: []
244
245
  require_paths: