vite_ruby 2.0.0.beta.2 → 2.0.0.beta.6
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/vite_ruby.rb +2 -4
- data/lib/vite_ruby/cli.rb +3 -1
- data/lib/vite_ruby/cli/install.rb +5 -0
- data/lib/vite_ruby/cli/upgrade.rb +25 -0
- data/lib/vite_ruby/cli/upgrade_packages.rb +14 -0
- data/lib/vite_ruby/config.rb +6 -1
- data/lib/vite_ruby/dev_server_proxy.rb +4 -5
- data/lib/vite_ruby/version.rb +5 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0058a6fc7f925f10e97f390c028abbbecc2c4c9cc5e27f214cbcba826c42fe69'
|
4
|
+
data.tar.gz: ebc2076502683d817f99c284fc2f6ec7adfa75dfd41f8f623a72e221cd56da5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 728652c1e4f0884bde8a1823f9a70ffdf12ce509fdb8f7ae898133d8f9084cbcc1a0204da38212c8281f02e4e77f0ec8a481c85ce7e3f74be189965d34fbe791
|
7
|
+
data.tar.gz: 6ed6080dcb36974a061d974188ede76c700b27e97a63ec5b357225acbd04dc5f555a13bc45f4790c73d9daba20c104181583f3a650a0fd7da6dc544c4b680b10
|
data/lib/vite_ruby.rb
CHANGED
@@ -13,14 +13,12 @@ loader.inflector.inflect('cli' => 'CLI')
|
|
13
13
|
loader.inflector.inflect('io' => 'IO')
|
14
14
|
loader.setup
|
15
15
|
|
16
|
+
require 'vite_ruby/version'
|
17
|
+
|
16
18
|
class ViteRuby
|
17
19
|
# Internal: Prefix used for environment variables that modify the configuration.
|
18
20
|
ENV_PREFIX = 'VITE_RUBY'
|
19
21
|
|
20
|
-
# Internal: Versions used by default when running `vite install`.
|
21
|
-
DEFAULT_VITE_VERSION = '^2.5.0-beta.2'
|
22
|
-
DEFAULT_PLUGIN_VERSION = '^3.0.0-beta.1'
|
23
|
-
|
24
22
|
# Internal: Companion libraries for Vite Ruby, and their target framework.
|
25
23
|
COMPANION_LIBRARIES = {
|
26
24
|
'vite_rails' => 'rails',
|
data/lib/vite_ruby/cli.rb
CHANGED
@@ -10,6 +10,8 @@ class ViteRuby::CLI
|
|
10
10
|
register 'build', Build, aliases: ['b']
|
11
11
|
register 'clobber', Clobber, aliases: %w[clean clear]
|
12
12
|
register 'dev', Dev, aliases: %w[d serve]
|
13
|
-
register 'install', Install
|
13
|
+
register 'install', Install
|
14
14
|
register 'version', Version, aliases: ['v', '-v', '--version', 'info']
|
15
|
+
register 'upgrade', Upgrade, aliases: ['update']
|
16
|
+
register 'upgrade_packages', UpgradePackages, aliases: ['update_packages']
|
15
17
|
end
|
@@ -113,6 +113,11 @@ private
|
|
113
113
|
$stdout.puts(*args)
|
114
114
|
end
|
115
115
|
|
116
|
+
def run_with_capture(*args, **options)
|
117
|
+
_, stderr, status = ViteRuby::IO.capture(*args, **options)
|
118
|
+
say(err) unless status.success? || stderr.to_s.empty?
|
119
|
+
end
|
120
|
+
|
116
121
|
# Internal: Avoid printing warning about missing vite.json, we will create one.
|
117
122
|
def silent_warnings
|
118
123
|
old_stderr = $stderr
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ViteRuby::CLI::Upgrade < ViteRuby::CLI::Install
|
4
|
+
desc 'Updates Vite Ruby related gems and npm packages.'
|
5
|
+
|
6
|
+
def call(**)
|
7
|
+
upgrade_ruby_gems
|
8
|
+
upgrade_npm_packages
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def upgrade_ruby_gems
|
14
|
+
say 'Updating gems'
|
15
|
+
|
16
|
+
libraries = ViteRuby.framework_libraries.map { |_f, library| library.name }
|
17
|
+
|
18
|
+
run_with_capture("bundle update #{ libraries.join(' ') }")
|
19
|
+
end
|
20
|
+
|
21
|
+
# NOTE: Spawn a new process so that it uses the updated vite_ruby.
|
22
|
+
def upgrade_npm_packages
|
23
|
+
Kernel.exec('bundle exec vite upgrade_packages')
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ViteRuby::CLI::UpgradePackages < ViteRuby::CLI::Install
|
4
|
+
desc 'Upgrades the npm packages to the recommended versions.'
|
5
|
+
|
6
|
+
def call(**)
|
7
|
+
say 'Upgrading npm packages'
|
8
|
+
|
9
|
+
Dir.chdir(root) do
|
10
|
+
deps = js_dependencies.join(' ')
|
11
|
+
run_with_capture("npx --package @antfu/ni -- ni -D #{ deps }")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/vite_ruby/config.rb
CHANGED
@@ -30,7 +30,7 @@ class ViteRuby::Config
|
|
30
30
|
|
31
31
|
# Public: The directory where the entries are located.
|
32
32
|
def resolved_entrypoints_dir
|
33
|
-
|
33
|
+
vite_root_dir.join(entrypoints_dir)
|
34
34
|
end
|
35
35
|
|
36
36
|
# Internal: The directory where Vite stores its processing cache.
|
@@ -38,6 +38,11 @@ class ViteRuby::Config
|
|
38
38
|
root.join('node_modules/.vite')
|
39
39
|
end
|
40
40
|
|
41
|
+
# Public: The directory that Vite uses as root.
|
42
|
+
def vite_root_dir
|
43
|
+
root.join(source_code_dir)
|
44
|
+
end
|
45
|
+
|
41
46
|
# Public: Sets additional environment variables for vite-plugin-ruby.
|
42
47
|
def to_env
|
43
48
|
CONFIGURABLE_WITH_ENV.each_with_object({}) do |option, env|
|
@@ -52,13 +52,12 @@ private
|
|
52
52
|
path = env['PATH_INFO']
|
53
53
|
return true if path.start_with?(vite_asset_url_prefix) # Vite asset
|
54
54
|
return true if path.start_with?(VITE_DEPENDENCY_PREFIX) # Packages and imports
|
55
|
-
return true if
|
55
|
+
return true if file_in_vite_root?(path) # Fallback if Vite can serve the file
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
config.resolved_entrypoints_dir.join(path.start_with?('/') ? path[1..-1] : path).file?
|
58
|
+
def file_in_vite_root?(path)
|
59
|
+
path.include?('.') && # Check for extension, avoid filesystem if possible.
|
60
|
+
config.vite_root_dir.join(path.start_with?('/') ? path[1..-1] : path).file?
|
62
61
|
end
|
63
62
|
|
64
63
|
def vite_asset_url_prefix
|
data/lib/vite_ruby/version.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ViteRuby
|
4
|
-
VERSION = '2.0.0.beta.
|
4
|
+
VERSION = '2.0.0.beta.6'
|
5
|
+
|
6
|
+
# Internal: Versions used by default when running `vite install`.
|
7
|
+
DEFAULT_VITE_VERSION = '^2.5.0-beta.2'
|
8
|
+
DEFAULT_PLUGIN_VERSION = '^3.0.0-beta.2'
|
5
9
|
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: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.6
|
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-08-
|
11
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -179,6 +179,8 @@ files:
|
|
179
179
|
- lib/vite_ruby/cli/dev.rb
|
180
180
|
- lib/vite_ruby/cli/file_utils.rb
|
181
181
|
- lib/vite_ruby/cli/install.rb
|
182
|
+
- lib/vite_ruby/cli/upgrade.rb
|
183
|
+
- lib/vite_ruby/cli/upgrade_packages.rb
|
182
184
|
- lib/vite_ruby/cli/version.rb
|
183
185
|
- lib/vite_ruby/cli/vite.rb
|
184
186
|
- lib/vite_ruby/commands.rb
|
@@ -198,9 +200,10 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
198
200
|
licenses:
|
199
201
|
- MIT
|
200
202
|
metadata:
|
201
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@2.0.0.beta.
|
202
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@2.0.0.beta.
|
203
|
-
post_install_message:
|
203
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@2.0.0.beta.6/vite_ruby
|
204
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@2.0.0.beta.6/vite_ruby/CHANGELOG.md
|
205
|
+
post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
|
206
|
+
manually, please run:\n\tbundle exec vite upgrade"
|
204
207
|
rdoc_options: []
|
205
208
|
require_paths:
|
206
209
|
- lib
|