vite_ruby 3.0.0.beta.1 → 3.0.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/default.vite.json +1 -1
- data/lib/vite_ruby/builder.rb +1 -21
- data/lib/vite_ruby/commands.rb +2 -0
- data/lib/vite_ruby/compatibility_check.rb +49 -0
- data/lib/vite_ruby/config.rb +29 -3
- data/lib/vite_ruby/manifest.rb +18 -8
- data/lib/vite_ruby/version.rb +3 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b5eacc1f40e589613a5804a54aaf8f09a6b4000da7e8bd3ce05ae225fb76dc3
|
4
|
+
data.tar.gz: 6dc5725316ed7aa13b5ca4531ea2ca2fd999c6fbe0d33770a9cbf7d479128b76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c69993fb89ad7cd0d6f6a50d2a3a0bfe828c4be21875eb7c16c9f18cee13a15a7a7055876cb5b382c9db2c9f4f2b25a2e7178089374505bae7865265efb213
|
7
|
+
data.tar.gz: 10f64b31dbd0120e00661a30350668b8a622b79111f575d244bf2f5c55ec0cba28e3269cccec7337244154b434188c290889f88a5874168aab6637f0000cfd28
|
data/default.vite.json
CHANGED
data/lib/vite_ruby/builder.rb
CHANGED
@@ -57,7 +57,7 @@ private
|
|
57
57
|
# changes, and skip Vite builds if no files have changed.
|
58
58
|
def watched_files_digest
|
59
59
|
Dir.chdir File.expand_path(config.root) do
|
60
|
-
files = Dir[*watched_paths].reject { |f| File.directory?(f) }
|
60
|
+
files = Dir[*config.watched_paths].reject { |f| File.directory?(f) }
|
61
61
|
file_ids = files.sort.map { |f| "#{ File.basename(f) }/#{ Digest::SHA1.file(f).hexdigest }" }
|
62
62
|
Digest::SHA1.hexdigest(file_ids.join('/'))
|
63
63
|
end
|
@@ -88,24 +88,4 @@ private
|
|
88
88
|
logger.error '❌ Check that vite and vite-plugin-ruby are in devDependencies and have been installed. ' if stderr.include?('ERR! canceled')
|
89
89
|
end
|
90
90
|
end
|
91
|
-
|
92
|
-
# Internal: Files and directories that should be watched for changes.
|
93
|
-
#
|
94
|
-
# NOTE: You can specify additional ones in vite.json using "watchAdditionalPaths": [...]
|
95
|
-
def watched_paths
|
96
|
-
[
|
97
|
-
*config.watch_additional_paths,
|
98
|
-
"#{ config.source_code_dir }/**/*",
|
99
|
-
'package-lock.json',
|
100
|
-
'package.json',
|
101
|
-
'pnpm-lock.yaml',
|
102
|
-
'postcss.config.js',
|
103
|
-
'tailwind.config.js',
|
104
|
-
'vite.config.js',
|
105
|
-
'vite.config.ts',
|
106
|
-
'windi.config.ts',
|
107
|
-
'yarn.lock',
|
108
|
-
config.config_path,
|
109
|
-
].freeze
|
110
|
-
end
|
111
91
|
end
|
data/lib/vite_ruby/commands.rb
CHANGED
@@ -108,6 +108,8 @@ class ViteRuby::Commands
|
|
108
108
|
packages = `npm ls vite vite-plugin-ruby`
|
109
109
|
packages_msg = packages.include?('vite@') ? "installed packages:\n#{ packages }" : '❌ Check that vite and vite-plugin-ruby have been added as development dependencies and installed.'
|
110
110
|
$stdout.puts packages_msg
|
111
|
+
|
112
|
+
ViteRuby::CompatibilityCheck.verify_plugin_version(config.root)
|
111
113
|
end
|
112
114
|
end
|
113
115
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
# Internal: Verifies that the installed vite-plugin-ruby version is compatible
|
6
|
+
# with the current version of vite_ruby.
|
7
|
+
#
|
8
|
+
# This helps to prevent more subtle runtime errors if there is a mismatch in the
|
9
|
+
# manifest schema.
|
10
|
+
module ViteRuby::CompatibilityCheck
|
11
|
+
class << self
|
12
|
+
# Public: Attempt to verify that the vite-plugin-ruby version is compatible.
|
13
|
+
def verify_plugin_version(root)
|
14
|
+
package = JSON.parse(root.join('package.json').read) rescue {}
|
15
|
+
requirement = package.dig('devDependencies', 'vite-plugin-ruby') ||
|
16
|
+
package.dig('dependencies', 'vite-plugin-ruby')
|
17
|
+
|
18
|
+
raise_unless_satisfied(requirement, ViteRuby::DEFAULT_PLUGIN_VERSION)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Internal: Notifies the user of a possible incompatible plugin.
|
22
|
+
def raise_unless_satisfied(npm_req, ruby_req)
|
23
|
+
unless compatible_plugin?(npm_req, ruby_req)
|
24
|
+
raise ArgumentError, <<~ERROR
|
25
|
+
vite-plugin-ruby@#{ npm_req } might not be compatible with vite_ruby-#{ ViteRuby::VERSION }
|
26
|
+
|
27
|
+
You may disable this check if needed: https://vite-ruby.netlify.app/config/#skipCompatibilityCheck
|
28
|
+
|
29
|
+
You may upgrade both by running:
|
30
|
+
|
31
|
+
bundle exec vite upgrade
|
32
|
+
ERROR
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Internal: Returns true unless the check is performed and does not meet the
|
37
|
+
# requirement.
|
38
|
+
def compatible_plugin?(npm_req, ruby_req)
|
39
|
+
npm_req, ruby_req = [npm_req, ruby_req]
|
40
|
+
.map { |req| Gem::Requirement.new(req.sub('^', '~>')) }
|
41
|
+
|
42
|
+
current_version = npm_req.requirements.first.second
|
43
|
+
|
44
|
+
ruby_req.satisfied_by?(current_version)
|
45
|
+
rescue StandardError
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/vite_ruby/config.rb
CHANGED
@@ -52,6 +52,18 @@ class ViteRuby::Config
|
|
52
52
|
end.merge(ViteRuby.env)
|
53
53
|
end
|
54
54
|
|
55
|
+
# Internal: Files and directories that should be watched for changes.
|
56
|
+
def watched_paths
|
57
|
+
[
|
58
|
+
*(watch_additional_paths + additional_entrypoints).reject { |dir|
|
59
|
+
dir.start_with?('~/') || dir.start_with?(source_code_dir)
|
60
|
+
},
|
61
|
+
"#{ source_code_dir }/**/*",
|
62
|
+
config_path,
|
63
|
+
*DEFAULT_WATCHED_PATHS,
|
64
|
+
].freeze
|
65
|
+
end
|
66
|
+
|
55
67
|
private
|
56
68
|
|
57
69
|
# Internal: Coerces all the configuration values, in case they were passed
|
@@ -61,7 +73,7 @@ private
|
|
61
73
|
config['port'] = config['port'].to_i
|
62
74
|
config['root'] = Pathname.new(config['root'])
|
63
75
|
config['build_cache_dir'] = config['root'].join(config['build_cache_dir'])
|
64
|
-
coerce_booleans(config, 'auto_build', 'hide_build_console_output', 'https')
|
76
|
+
coerce_booleans(config, 'auto_build', 'hide_build_console_output', 'https', 'skip_compatibility_check')
|
65
77
|
end
|
66
78
|
|
67
79
|
# Internal: Coerces configuration options to boolean.
|
@@ -71,6 +83,7 @@ private
|
|
71
83
|
|
72
84
|
def initialize(attrs)
|
73
85
|
@config = attrs.tap { |config| coerce_values(config) }.freeze
|
86
|
+
ViteRuby::CompatibilityCheck.verify_plugin_version(root) unless skip_compatibility_check
|
74
87
|
end
|
75
88
|
|
76
89
|
class << self
|
@@ -143,10 +156,23 @@ private
|
|
143
156
|
DEFAULT_CONFIG = load_json("#{ __dir__ }/../../default.vite.json").freeze
|
144
157
|
|
145
158
|
# Internal: Configuration options that can not be provided as env vars.
|
146
|
-
NOT_CONFIGURABLE_WITH_ENV = %w[
|
159
|
+
NOT_CONFIGURABLE_WITH_ENV = %w[additional_entrypoints watch_additional_paths].freeze
|
147
160
|
|
148
161
|
# Internal: Configuration options that can be provided as env vars.
|
149
|
-
CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root] - NOT_CONFIGURABLE_WITH_ENV).freeze
|
162
|
+
CONFIGURABLE_WITH_ENV = (DEFAULT_CONFIG.keys + %w[mode root skip_compatibility_check] - NOT_CONFIGURABLE_WITH_ENV).freeze
|
163
|
+
|
164
|
+
# Internal: If any of these files is modified the build won't be skipped.
|
165
|
+
DEFAULT_WATCHED_PATHS = %w[
|
166
|
+
package-lock.json
|
167
|
+
package.json
|
168
|
+
pnpm-lock.yaml
|
169
|
+
postcss.config.js
|
170
|
+
tailwind.config.js
|
171
|
+
vite.config.js
|
172
|
+
vite.config.ts
|
173
|
+
windi.config.ts
|
174
|
+
yarn.lock
|
175
|
+
].freeze
|
150
176
|
|
151
177
|
public
|
152
178
|
|
data/lib/vite_ruby/manifest.rb
CHANGED
@@ -85,6 +85,9 @@ protected
|
|
85
85
|
|
86
86
|
private
|
87
87
|
|
88
|
+
# Internal: The prefix used by Vite.js to request files with an absolute path.
|
89
|
+
FS_PREFIX = '/@fs/'
|
90
|
+
|
88
91
|
extend Forwardable
|
89
92
|
|
90
93
|
def_delegators :@vite_ruby, :config, :builder, :dev_server_running?
|
@@ -135,7 +138,9 @@ private
|
|
135
138
|
def resolve_references(manifest)
|
136
139
|
manifest.each_value do |entry|
|
137
140
|
entry['file'] = prefix_vite_asset(entry['file'])
|
138
|
-
|
141
|
+
%w[css assets].each do |key|
|
142
|
+
entry[key] = entry[key].map { |path| prefix_vite_asset(path) } if entry[key]
|
143
|
+
end
|
139
144
|
entry['imports']&.map! { |name| manifest.fetch(name) }
|
140
145
|
end
|
141
146
|
end
|
@@ -143,14 +148,19 @@ private
|
|
143
148
|
# Internal: Resolves the manifest entry name for the specified resource.
|
144
149
|
def resolve_entry_name(name, type: nil)
|
145
150
|
name = with_file_extension(name.to_s, type)
|
146
|
-
name = name[1..-1] if name.start_with?('/')
|
147
151
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
raise ArgumentError, "Asset names can not be relative. Found: #{ name }" if name.start_with?('.')
|
153
|
+
|
154
|
+
# Explicit path, relative to the source_code_dir.
|
155
|
+
name.sub(%r{^~/(.+)$}) { return Regexp.last_match(1) }
|
156
|
+
|
157
|
+
# Explicit path, relative to the project root.
|
158
|
+
name.sub(%r{^/(.+)$}) {
|
159
|
+
return dev_server_running? ? File.join(FS_PREFIX, config.root, Regexp.last_match(1)) : Regexp.last_match(1)
|
160
|
+
}
|
161
|
+
|
162
|
+
# Sugar: Prefix with the entrypoints dir if the path is not nested.
|
163
|
+
name.include?('/') ? name : File.join(config.entrypoints_dir, name)
|
154
164
|
end
|
155
165
|
|
156
166
|
# Internal: Adds a file extension to the file name, unless it already has one.
|
data/lib/vite_ruby/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class ViteRuby
|
4
|
-
VERSION = '3.0.0.beta.
|
4
|
+
VERSION = '3.0.0.beta.2'
|
5
5
|
|
6
6
|
# Internal: Versions used by default when running `vite install`.
|
7
|
-
DEFAULT_VITE_VERSION = '^2.5.0
|
8
|
-
DEFAULT_PLUGIN_VERSION = '^3.0.0-beta.
|
7
|
+
DEFAULT_VITE_VERSION = '^2.5.0'
|
8
|
+
DEFAULT_PLUGIN_VERSION = '^3.0.0-beta.3'
|
9
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: 3.0.0.beta.
|
4
|
+
version: 3.0.0.beta.2
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/vite_ruby/cli/version.rb
|
185
185
|
- lib/vite_ruby/cli/vite.rb
|
186
186
|
- lib/vite_ruby/commands.rb
|
187
|
+
- lib/vite_ruby/compatibility_check.rb
|
187
188
|
- lib/vite_ruby/config.rb
|
188
189
|
- lib/vite_ruby/dev_server_proxy.rb
|
189
190
|
- lib/vite_ruby/error.rb
|
@@ -200,8 +201,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
200
201
|
licenses:
|
201
202
|
- MIT
|
202
203
|
metadata:
|
203
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.0.0.beta.
|
204
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.0.0.beta.
|
204
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.0.0.beta.2/vite_ruby
|
205
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.0.0.beta.2/vite_ruby/CHANGELOG.md
|
205
206
|
post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
|
206
207
|
manually, please run:\n\tbundle exec vite upgrade"
|
207
208
|
rdoc_options: []
|