vite_ruby 3.5.0 → 3.7.0
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/CHANGELOG.md +32 -0
- data/default.vite.json +2 -1
- data/lib/tasks/vite.rake +15 -6
- data/lib/vite_ruby/cli/install.rb +22 -10
- data/lib/vite_ruby/cli/upgrade_packages.rb +1 -2
- data/lib/vite_ruby/cli/vite.rb +12 -1
- data/lib/vite_ruby/commands.rb +4 -4
- data/lib/vite_ruby/config.rb +16 -3
- data/lib/vite_ruby/manifest.rb +2 -0
- data/lib/vite_ruby/runner.rb +14 -12
- 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: 99a8b071373aa761774cd95dd665040264cc7646114315edeecc3e355af3ef23
|
|
4
|
+
data.tar.gz: 1276207af761a598b3ea291ead1ccc2ceafb13117adcc150988d4532b8c71ae3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c213bbcc8ed5aeed6c8862f51fa096be5fc8d9cfa3c708c7e50a607869c94d8989cf5484704ec4f155760b7f6e53f3be2ab11526e7b2c9df1849b121bb7d79d4
|
|
7
|
+
data.tar.gz: 2f5d739582f2d1135ee5326cc8ffdd5c773dac791828317a61f7ff32a352d54e77f38d32d3d6b174f6439c98ff27479a786352b740f485c834b4f0e68cb67878
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
# [3.7.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.6.2...vite_ruby@3.7.0) (2024-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add `package_manager` config option, experimental support for bun ([#481](https://github.com/ElMassimo/vite_ruby/issues/481)) ([4426cb1](https://github.com/ElMassimo/vite_ruby/commit/4426cb1007dbb58f4637a4423b1e7d640db96841)), closes [#324](https://github.com/ElMassimo/vite_ruby/issues/324)
|
|
7
|
+
* change default execution to use `npx vite` instead ([#480](https://github.com/ElMassimo/vite_ruby/issues/480)) ([330f61f](https://github.com/ElMassimo/vite_ruby/commit/330f61fedadf1274547a069856125e52002d0065)), closes [#462](https://github.com/ElMassimo/vite_ruby/issues/462)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [3.6.2](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.6.1...vite_ruby@3.6.2) (2024-07-16)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [3.6.1](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.6.0...vite_ruby@3.6.1) (2024-07-16)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* use ESM by default in new installations ([#479](https://github.com/ElMassimo/vite_ruby/issues/479)) ([cc379ca](https://github.com/ElMassimo/vite_ruby/commit/cc379ca613dd4e5863f8556be62ea623b56cfe0c)), closes [#431](https://github.com/ElMassimo/vite_ruby/issues/431)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# [3.6.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.5.0...vite_ruby@3.6.0) (2024-06-07)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* allow skipping dependency install in assets:precompile ([#451](https://github.com/ElMassimo/vite_ruby/issues/451)) ([5a922b2](https://github.com/ElMassimo/vite_ruby/commit/5a922b2071446e3880b17503474a0c7806eab6a7))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
1
33
|
# [3.5.0](https://github.com/ElMassimo/vite_ruby/compare/vite_ruby@3.4.0...vite_ruby@3.5.0) (2023-11-16)
|
|
2
34
|
|
|
3
35
|
|
data/default.vite.json
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"publicOutputDir": "vite",
|
|
8
8
|
"configPath": "config/vite.json",
|
|
9
9
|
"devServerConnectTimeout": 0.01,
|
|
10
|
+
"packageManager": null,
|
|
10
11
|
"publicDir": "public",
|
|
11
12
|
"entrypointsDir": "entrypoints",
|
|
12
13
|
"sourceCodeDir": "app/frontend",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"https": null,
|
|
17
18
|
"port": 3036,
|
|
18
19
|
"hideBuildConsoleOutput": false,
|
|
19
|
-
"viteBinPath":
|
|
20
|
+
"viteBinPath": null,
|
|
20
21
|
"watchAdditionalPaths": [],
|
|
21
22
|
"base": "",
|
|
22
23
|
"ssrBuildEnabled": false,
|
data/lib/tasks/vite.rake
CHANGED
|
@@ -43,10 +43,13 @@ namespace :vite do
|
|
|
43
43
|
desc 'Ensure build dependencies like Vite are installed before bundling'
|
|
44
44
|
task :install_dependencies do
|
|
45
45
|
install_env_args = ENV['VITE_RUBY_SKIP_INSTALL_DEV_DEPENDENCIES'] == 'true' ? {} : { 'NODE_ENV' => 'development' }
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
|
|
47
|
+
install_cmd = case (pkg = ViteRuby.config.package_manager)
|
|
48
|
+
when 'npm' then 'npm ci'
|
|
49
|
+
else "#{ pkg } install --frozen-lockfile"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
system(install_env_args, install_cmd)
|
|
50
53
|
end
|
|
51
54
|
|
|
52
55
|
desc "Provide information on ViteRuby's environment"
|
|
@@ -59,12 +62,18 @@ unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION'] == 'true'
|
|
|
59
62
|
if Rake::Task.task_defined?('assets:precompile')
|
|
60
63
|
Rake::Task['assets:precompile'].enhance do |task|
|
|
61
64
|
prefix = task.name.split(/#|assets:precompile/).first
|
|
62
|
-
|
|
65
|
+
unless ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL'] == 'true'
|
|
66
|
+
Rake::Task["#{ prefix }vite:install_dependencies"].invoke
|
|
67
|
+
end
|
|
63
68
|
Rake::Task["#{ prefix }vite:build_all"].invoke
|
|
64
69
|
end
|
|
65
70
|
else
|
|
66
71
|
desc 'Bundle Vite assets'
|
|
67
|
-
|
|
72
|
+
if ENV['VITE_RUBY_SKIP_ASSETS_PRECOMPILE_INSTALL'] == 'true'
|
|
73
|
+
Rake::Task.define_task('assets:precompile' => 'vite:build_all')
|
|
74
|
+
else
|
|
75
|
+
Rake::Task.define_task('assets:precompile' => ['vite:install_dependencies', 'vite:build_all'])
|
|
76
|
+
end
|
|
68
77
|
end
|
|
69
78
|
|
|
70
79
|
unless Rake::Task.task_defined?('assets:clean')
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'stringio'
|
|
4
|
+
require 'json'
|
|
4
5
|
|
|
5
6
|
class ViteRuby::CLI::Install < Dry::CLI::Command
|
|
6
7
|
desc 'Performs the initial configuration setup to get started with Vite Ruby.'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
option(:package_manager, values: %w[npm pnpm yarn bun], aliases: %w[package-manager with], desc: 'The package manager to use when installing JS dependencies.')
|
|
10
|
+
|
|
11
|
+
def call(package_manager: nil, **)
|
|
12
|
+
ENV['VITE_RUBY_PACKAGE_MANAGER'] ||= package_manager if package_manager
|
|
13
|
+
|
|
9
14
|
$stdout.sync = true
|
|
10
15
|
|
|
11
16
|
say 'Creating binstub'
|
|
@@ -79,9 +84,20 @@ private
|
|
|
79
84
|
# Internal: Installs vite and vite-plugin-ruby at the project level.
|
|
80
85
|
def install_js_dependencies
|
|
81
86
|
package_json = root.join('package.json')
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
unless package_json.exist?
|
|
88
|
+
write package_json, <<~JSON
|
|
89
|
+
{
|
|
90
|
+
"private": true,
|
|
91
|
+
"type": "module"
|
|
92
|
+
}
|
|
93
|
+
JSON
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
if (JSON.parse(package_json.read)['type'] != 'module' rescue nil)
|
|
97
|
+
FileUtils.mv root.join('vite.config.ts'), root.join('vite.config.mts'), force: true, verbose: true
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
install_js_packages js_dependencies.join(' ')
|
|
85
101
|
end
|
|
86
102
|
|
|
87
103
|
# Internal: Adds compilation output dirs to git ignore.
|
|
@@ -115,12 +131,8 @@ private
|
|
|
115
131
|
end
|
|
116
132
|
end
|
|
117
133
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return 'yarn add' if root.join('yarn.lock').exist?
|
|
121
|
-
return 'pnpm install' if root.join('pnpm-lock.yaml').exist?
|
|
122
|
-
|
|
123
|
-
'npm install'
|
|
134
|
+
def install_js_packages(deps)
|
|
135
|
+
run_with_capture("#{ config.package_manager } add -D #{ deps }", stdin_data: "\n")
|
|
124
136
|
end
|
|
125
137
|
|
|
126
138
|
# Internal: Avoid printing warning about missing vite.json, we will create one.
|
data/lib/vite_ruby/cli/vite.rb
CHANGED
|
@@ -5,6 +5,7 @@ class ViteRuby::CLI::Vite < Dry::CLI::Command
|
|
|
5
5
|
|
|
6
6
|
def self.executable_options
|
|
7
7
|
option(:mode, default: self::DEFAULT_ENV, values: %w[development production test], aliases: ['m'], desc: 'The build mode for Vite')
|
|
8
|
+
option(:node_options, desc: 'Node options for the Vite executable', aliases: ['node-options'])
|
|
8
9
|
option(:inspect, desc: 'Run Vite in a debugging session with node --inspect-brk', aliases: ['inspect-brk'], type: :boolean)
|
|
9
10
|
option(:trace_deprecation, desc: 'Run Vite in debugging mode with node --trace-deprecation', aliases: ['trace-deprecation'], type: :boolean)
|
|
10
11
|
end
|
|
@@ -15,10 +16,20 @@ class ViteRuby::CLI::Vite < Dry::CLI::Command
|
|
|
15
16
|
option(:clobber, desc: 'Clear cache and previous builds', type: :boolean, aliases: %w[clean clear])
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
def call(mode:, args: [], clobber: false, **boolean_opts)
|
|
19
|
+
def call(mode:, args: [], clobber: false, node_options: nil, inspect: nil, trace_deprecation: nil, **boolean_opts)
|
|
19
20
|
ViteRuby.env['VITE_RUBY_MODE'] = mode
|
|
20
21
|
ViteRuby.commands.clobber if clobber
|
|
22
|
+
|
|
23
|
+
node_options = [
|
|
24
|
+
node_options,
|
|
25
|
+
('--inspect-brk' if inspect),
|
|
26
|
+
('--trace-deprecation' if trace_deprecation),
|
|
27
|
+
].compact.join(' ')
|
|
28
|
+
|
|
29
|
+
args << %(--node-options="#{ node_options }") unless node_options.empty?
|
|
30
|
+
|
|
21
31
|
boolean_opts.map { |name, value| args << "--#{ name }" if value }
|
|
32
|
+
|
|
22
33
|
yield(args)
|
|
23
34
|
end
|
|
24
35
|
end
|
data/lib/vite_ruby/commands.rb
CHANGED
|
@@ -109,11 +109,11 @@ class ViteRuby::Commands
|
|
|
109
109
|
$stdout.puts "#{ framework }: #{ Gem.loaded_specs[framework]&.version }"
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
$stdout.puts "node: #{ `node --version` }"
|
|
113
|
-
$stdout.puts "npm: #{ `npm --version` }"
|
|
114
|
-
$stdout.puts "yarn: #{ `yarn --version` rescue nil }"
|
|
115
|
-
$stdout.puts "pnpm: #{ `pnpm --version` rescue nil }"
|
|
116
112
|
$stdout.puts "ruby: #{ `ruby --version` }"
|
|
113
|
+
$stdout.puts "node: #{ `node --version` }"
|
|
114
|
+
|
|
115
|
+
pkg = config.package_manager
|
|
116
|
+
$stdout.puts "#{ pkg }: #{ `#{ pkg } --version` rescue nil }"
|
|
117
117
|
|
|
118
118
|
$stdout.puts "\n"
|
|
119
119
|
packages = `npm ls vite vite-plugin-ruby`
|
data/lib/vite_ruby/config.rb
CHANGED
|
@@ -96,10 +96,11 @@ private
|
|
|
96
96
|
def coerce_values(config)
|
|
97
97
|
config['mode'] = config['mode'].to_s
|
|
98
98
|
config['port'] = config['port'].to_i
|
|
99
|
-
config['root'] = Pathname.new(config['root'])
|
|
100
|
-
config['build_cache_dir'] =
|
|
101
|
-
config['ssr_output_dir'] =
|
|
99
|
+
config['root'] = root = Pathname.new(config['root'])
|
|
100
|
+
config['build_cache_dir'] = root.join(config['build_cache_dir'])
|
|
101
|
+
config['ssr_output_dir'] = root.join(config['ssr_output_dir'])
|
|
102
102
|
coerce_booleans(config, 'auto_build', 'hide_build_console_output', 'https', 'skip_compatibility_check', 'skip_proxy')
|
|
103
|
+
config['package_manager'] ||= detect_package_manager(root)
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
# Internal: Coerces configuration options to boolean.
|
|
@@ -107,6 +108,15 @@ private
|
|
|
107
108
|
names.each { |name| config[name] = [true, 'true'].include?(config[name]) }
|
|
108
109
|
end
|
|
109
110
|
|
|
111
|
+
def detect_package_manager(root)
|
|
112
|
+
return 'npm' if root.join('package-lock.json').exist?
|
|
113
|
+
return 'pnpm' if root.join('pnpm-lock.yaml').exist?
|
|
114
|
+
return 'bun' if root.join('bun.lockb').exist?
|
|
115
|
+
return 'yarn' if root.join('yarn.lock').exist?
|
|
116
|
+
|
|
117
|
+
'npm'
|
|
118
|
+
end
|
|
119
|
+
|
|
110
120
|
def initialize(attrs)
|
|
111
121
|
@config = attrs.tap { |config| coerce_values(config) }.freeze
|
|
112
122
|
ViteRuby::CompatibilityCheck.verify_plugin_version(root) unless skip_compatibility_check
|
|
@@ -189,12 +199,15 @@ private
|
|
|
189
199
|
|
|
190
200
|
# Internal: If any of these files is modified the build won't be skipped.
|
|
191
201
|
DEFAULT_WATCHED_PATHS = %w[
|
|
202
|
+
bun.lockb
|
|
192
203
|
package-lock.json
|
|
193
204
|
package.json
|
|
194
205
|
pnpm-lock.yaml
|
|
195
206
|
postcss.config.js
|
|
196
207
|
tailwind.config.js
|
|
197
208
|
vite.config.js
|
|
209
|
+
vite.config.mjs
|
|
210
|
+
vite.config.mts
|
|
198
211
|
vite.config.ts
|
|
199
212
|
windi.config.ts
|
|
200
213
|
yarn.lock
|
data/lib/vite_ruby/manifest.rb
CHANGED
data/lib/vite_ruby/runner.rb
CHANGED
|
@@ -28,24 +28,26 @@ private
|
|
|
28
28
|
# Internal: Returns an Array with the command to run.
|
|
29
29
|
def command_for(args)
|
|
30
30
|
[config.to_env(env)].tap do |cmd|
|
|
31
|
-
|
|
32
|
-
cmd.push(
|
|
33
|
-
cmd.push(
|
|
34
|
-
cmd.push(*vite_executable)
|
|
35
|
-
cmd.push(*args)
|
|
31
|
+
exec_args, vite_args = args.partition { |arg| arg.start_with?('--node-options') }
|
|
32
|
+
cmd.push(*vite_executable(*exec_args))
|
|
33
|
+
cmd.push(*vite_args)
|
|
36
34
|
cmd.push('--mode', config.mode) unless args.include?('--mode') || args.include?('-m')
|
|
37
35
|
end
|
|
38
36
|
end
|
|
39
37
|
|
|
40
38
|
# Internal: Resolves to an executable for Vite.
|
|
41
|
-
def vite_executable
|
|
39
|
+
def vite_executable(*exec_args)
|
|
42
40
|
bin_path = config.vite_bin_path
|
|
43
|
-
return [bin_path] if File.exist?(bin_path)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
return [bin_path] if bin_path && File.exist?(bin_path)
|
|
42
|
+
|
|
43
|
+
x = case config.package_manager
|
|
44
|
+
when 'npm' then %w[npx]
|
|
45
|
+
when 'pnpm' then %w[pnpm exec]
|
|
46
|
+
when 'bun' then %w[bun x]
|
|
47
|
+
when 'yarn' then %w[yarn]
|
|
48
|
+
else raise ArgumentError, "Unknown package manager #{ config.package_manager.inspect }"
|
|
49
49
|
end
|
|
50
|
+
|
|
51
|
+
[*x, *exec_args, 'vite']
|
|
50
52
|
end
|
|
51
53
|
end
|
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: 3.
|
|
4
|
+
version: 3.7.0
|
|
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:
|
|
11
|
+
date: 2024-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dry-cli
|
|
@@ -208,8 +208,8 @@ homepage: https://github.com/ElMassimo/vite_ruby
|
|
|
208
208
|
licenses:
|
|
209
209
|
- MIT
|
|
210
210
|
metadata:
|
|
211
|
-
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.
|
|
212
|
-
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.
|
|
211
|
+
source_code_uri: https://github.com/ElMassimo/vite_ruby/tree/vite_ruby@3.7.0/vite_ruby
|
|
212
|
+
changelog_uri: https://github.com/ElMassimo/vite_ruby/blob/vite_ruby@3.7.0/vite_ruby/CHANGELOG.md
|
|
213
213
|
post_install_message: "Thanks for installing Vite Ruby!\n\nIf you upgraded the gem
|
|
214
214
|
manually, please run:\n\tbundle exec vite upgrade"
|
|
215
215
|
rdoc_options: []
|