vite_ruby 1.2.12 → 1.2.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/lib/vite_ruby.rb +38 -33
- data/lib/vite_ruby/builder.rb +2 -2
- data/lib/vite_ruby/cli/install.rb +11 -3
- data/lib/vite_ruby/dev_server_proxy.rb +1 -1
- data/lib/vite_ruby/missing_executable_error.rb +1 -1
- data/lib/vite_ruby/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f702f993fc5df33d479953322735001bfb90e05854e8818f968739a957c61671
|
4
|
+
data.tar.gz: c6b6a5df4d3c589cc83d62d1356d1a8a13389911a8e18d90c4b1baae8cab27cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff157c02f679fff7590cf7b9786f91ca9e2db5698d13e8cd472a3bed51178bc61c8355753206770d7098303fd48b204600d69e1f230321cfe32e26c4c3b759b5
|
7
|
+
data.tar.gz: 953ddd4dfdcc310831dd1bbbbd92b0603df85b3301f9b376a1fd2e3c56bbfa00ead841a647368e1cc34a3d0e13985967cd51c23064323d629624d57dcaffbbf2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
## <small>1.2.17 (2021-07-12)</small>
|
2
|
+
|
3
|
+
* fix: Proxy CSS Modules requests to Vite.js with the correct extension (close #98) ([8976872](https://github.com/ElMassimo/vite_ruby/commit/8976872)), closes [#98](https://github.com/ElMassimo/vite_ruby/issues/98)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## <small>1.2.16 (2021-07-07)</small>
|
8
|
+
|
9
|
+
* feat: Enable usage in engines by using `run` from the current instance ([023a61d](https://github.com/ElMassimo/vite_ruby/commit/023a61d))
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## [1.2.15](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.14...vite_ruby@1.2.15) (2021-07-01)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [1.2.14](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.13...vite_ruby@1.2.14) (2021-07-01)
|
18
|
+
|
19
|
+
|
20
|
+
### Features
|
21
|
+
|
22
|
+
* Add support for Jekyll installer ([7b942ec](https://github.com/ElMassimo/vite_ruby/commit/7b942ec745eb28092d684056b02df675ad6ececa))
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
## [1.2.13](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.12...vite_ruby@1.2.13) (2021-06-30)
|
27
|
+
|
28
|
+
|
29
|
+
### Features
|
30
|
+
|
31
|
+
* Improve the error message when npm packages are missing ([9159557](https://github.com/ElMassimo/vite_ruby/commit/9159557e5152547554cfe519fae8dbefe26686fb))
|
32
|
+
|
33
|
+
|
34
|
+
|
1
35
|
## [1.2.12](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@1.2.11...vite_ruby@1.2.12) (2021-06-08)
|
2
36
|
|
3
37
|
|
data/lib/vite_ruby.rb
CHANGED
@@ -18,28 +18,28 @@ class ViteRuby
|
|
18
18
|
ENV_PREFIX = 'VITE_RUBY'
|
19
19
|
|
20
20
|
# Internal: Versions used by default when running `vite install`.
|
21
|
-
DEFAULT_VITE_VERSION = '^2.
|
22
|
-
DEFAULT_PLUGIN_VERSION = '^2.0.
|
23
|
-
|
24
|
-
# Internal:
|
25
|
-
|
21
|
+
DEFAULT_VITE_VERSION = '^2.3.8'
|
22
|
+
DEFAULT_PLUGIN_VERSION = '^2.0.4'
|
23
|
+
|
24
|
+
# Internal: Companion libraries for Vite Ruby, and their target framework.
|
25
|
+
COMPANION_LIBRARIES = {
|
26
|
+
'vite_rails' => 'rails',
|
27
|
+
'vite_hanami' => 'hanami',
|
28
|
+
'vite_roda' => 'roda',
|
29
|
+
'vite_padrino' => 'padrino',
|
30
|
+
'vite_sinatra' => 'sinatra',
|
31
|
+
'jekyll-vite' => 'jekyll',
|
32
|
+
'vite_rails_legacy' => 'rails',
|
33
|
+
}
|
26
34
|
|
27
35
|
class << self
|
28
36
|
extend Forwardable
|
29
37
|
|
30
|
-
def_delegators :instance, :config, :commands, :run_proxy?
|
38
|
+
def_delegators :instance, :config, :commands, :env, :run, :run_proxy?
|
31
39
|
def_delegators :config, :mode
|
32
40
|
|
33
41
|
def instance
|
34
|
-
@instance ||=
|
35
|
-
end
|
36
|
-
|
37
|
-
# Public: Additional environment variables to pass to Vite.
|
38
|
-
#
|
39
|
-
# Example:
|
40
|
-
# ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
|
41
|
-
def env
|
42
|
-
@env ||= load_env_variables
|
42
|
+
@instance ||= new
|
43
43
|
end
|
44
44
|
|
45
45
|
# Internal: Refreshes the manifest.
|
@@ -52,28 +52,16 @@ class ViteRuby
|
|
52
52
|
load File.expand_path('tasks/vite.rake', __dir__)
|
53
53
|
end
|
54
54
|
|
55
|
-
# Internal:
|
56
|
-
def
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
# Internal: Refreshes the config after setting the env vars.
|
61
|
-
def reload_with(env_vars)
|
62
|
-
env.update(env_vars)
|
63
|
-
@instance = nil
|
64
|
-
config
|
65
|
-
end
|
66
|
-
|
67
|
-
# Internal: Allows to obtain any env variables for configuration options.
|
68
|
-
def load_env_variables
|
69
|
-
ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
55
|
+
# Internal: Creates a new instance with the specified options.
|
56
|
+
def reload_with(**config_options)
|
57
|
+
@instance = new(**config_options)
|
70
58
|
end
|
71
59
|
|
72
60
|
# Internal: Detects if the application has installed a framework-specific
|
73
61
|
# variant of Vite Ruby.
|
74
62
|
def framework_libraries
|
75
|
-
|
76
|
-
if library =
|
63
|
+
COMPANION_LIBRARIES.map { |name, framework|
|
64
|
+
if library = Gem.loaded_specs[name]
|
77
65
|
[framework, library]
|
78
66
|
end
|
79
67
|
}.compact
|
@@ -82,6 +70,10 @@ class ViteRuby
|
|
82
70
|
|
83
71
|
attr_writer :logger
|
84
72
|
|
73
|
+
def initialize(**config_options)
|
74
|
+
@config_options = config_options
|
75
|
+
end
|
76
|
+
|
85
77
|
def logger
|
86
78
|
@logger ||= Logger.new($stdout)
|
87
79
|
end
|
@@ -99,6 +91,14 @@ class ViteRuby
|
|
99
91
|
@running_at = false
|
100
92
|
end
|
101
93
|
|
94
|
+
# Public: Additional environment variables to pass to Vite.
|
95
|
+
#
|
96
|
+
# Example:
|
97
|
+
# ViteRuby.env['VITE_RUBY_CONFIG_PATH'] = 'config/alternate_vite.json'
|
98
|
+
def env
|
99
|
+
@env ||= ENV.select { |key, _| key.start_with?(ENV_PREFIX) }
|
100
|
+
end
|
101
|
+
|
102
102
|
# Public: The proxy for assets should only run in development mode.
|
103
103
|
def run_proxy?
|
104
104
|
config.mode == 'development'
|
@@ -107,6 +107,11 @@ class ViteRuby
|
|
107
107
|
false
|
108
108
|
end
|
109
109
|
|
110
|
+
# Internal: Executes the vite binary.
|
111
|
+
def run(argv, **options)
|
112
|
+
(@runner ||= ViteRuby::Runner.new(self)).run(argv, **options)
|
113
|
+
end
|
114
|
+
|
110
115
|
# Public: Keeps track of watched files and triggers builds as needed.
|
111
116
|
def builder
|
112
117
|
@builder ||= ViteRuby::Builder.new(self)
|
@@ -119,7 +124,7 @@ class ViteRuby
|
|
119
124
|
|
120
125
|
# Public: Current instance configuration for Vite.
|
121
126
|
def config
|
122
|
-
@config ||= ViteRuby::Config.resolve_config
|
127
|
+
@config ||= ViteRuby::Config.resolve_config(**@config_options)
|
123
128
|
end
|
124
129
|
|
125
130
|
# Public: Enables looking up assets managed by Vite using name and type.
|
data/lib/vite_ruby/builder.rb
CHANGED
@@ -33,7 +33,7 @@ private
|
|
33
33
|
|
34
34
|
extend Forwardable
|
35
35
|
|
36
|
-
def_delegators :@vite_ruby, :config, :logger
|
36
|
+
def_delegators :@vite_ruby, :config, :logger, :run
|
37
37
|
|
38
38
|
# Internal: Reads metadata recorded on the last build, if it exists.
|
39
39
|
def last_build_attrs
|
@@ -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 =
|
72
|
+
stdout, stderr, status = run(['build', *args])
|
73
73
|
log_build_result(stdout, stderr.to_s, status)
|
74
74
|
|
75
75
|
status.success?
|
@@ -28,6 +28,14 @@ class ViteRuby::CLI::Install < Dry::CLI::Command
|
|
28
28
|
|
29
29
|
protected
|
30
30
|
|
31
|
+
# Internal: The JS packages that should be added to the app.
|
32
|
+
def js_dependencies
|
33
|
+
[
|
34
|
+
"vite@#{ ViteRuby::DEFAULT_VITE_VERSION }",
|
35
|
+
"vite-plugin-ruby@#{ ViteRuby::DEFAULT_PLUGIN_VERSION }",
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
31
39
|
# Internal: Setup for a plain Rack application.
|
32
40
|
def setup_app_files
|
33
41
|
copy_template 'config/vite.json', to: config.config_path
|
@@ -64,7 +72,7 @@ private
|
|
64
72
|
def create_configuration_files
|
65
73
|
copy_template 'config/vite.config.ts', to: root.join('vite.config.ts')
|
66
74
|
setup_app_files
|
67
|
-
ViteRuby.reload_with(
|
75
|
+
ViteRuby.reload_with(config_path: config.config_path)
|
68
76
|
end
|
69
77
|
|
70
78
|
# Internal: Installs vite and vite-plugin-ruby at the project level.
|
@@ -73,7 +81,7 @@ private
|
|
73
81
|
write(package_json, '{}') unless package_json.exist?
|
74
82
|
|
75
83
|
Dir.chdir(root) do
|
76
|
-
deps =
|
84
|
+
deps = js_dependencies.join(' ')
|
77
85
|
_, stderr, status = ViteRuby::IO.capture("npx --package @antfu/ni -- ni -D #{ deps }", stdin_data: "\n")
|
78
86
|
_, stderr, = ViteRuby::IO.capture("yarn add -D #{ deps }") unless status.success?
|
79
87
|
say("Could not install JS dependencies.\n", stderr) unless stderr.to_s.empty?
|
@@ -117,5 +125,5 @@ end
|
|
117
125
|
|
118
126
|
# NOTE: This allows framework-specific variants to extend the installation.
|
119
127
|
ViteRuby.framework_libraries.each do |_framework, library|
|
120
|
-
require "#{ library.name }/installation"
|
128
|
+
require "#{ library.name.tr('-', '/') }/installation"
|
121
129
|
end
|
@@ -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(/(\.(?!min)\w+)\.css$/, '\1') # Rails' stylesheet_link_tag always adds the extension.
|
36
|
+
.sub(/(\.(?!min|module)\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
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
class ViteRuby::MissingExecutableError < ViteRuby::Error
|
5
5
|
def initialize(error = nil)
|
6
6
|
super <<~MSG
|
7
|
-
❌ The vite binary is not available. Have you installed
|
7
|
+
❌ The vite binary is not available. Have you installed the npm packages?
|
8
8
|
|
9
9
|
:troubleshooting:
|
10
10
|
#{ error }
|
data/lib/vite_ruby/version.rb
CHANGED
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.
|
4
|
+
version: 1.2.17
|
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-
|
11
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -198,8 +198,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
198
198
|
licenses:
|
199
199
|
- MIT
|
200
200
|
metadata:
|
201
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.
|
202
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.
|
201
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@1.2.17/vite_ruby
|
202
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@1.2.17/vite_ruby/CHANGELOG.md
|
203
203
|
post_install_message:
|
204
204
|
rdoc_options: []
|
205
205
|
require_paths:
|