vite_rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tasks/vite/binstubs.rake +12 -0
- data/lib/tasks/vite/build.rake +33 -0
- data/lib/tasks/vite/clean.rake +25 -0
- data/lib/tasks/vite/clobber.rake +20 -0
- data/lib/tasks/vite/info.rake +21 -0
- data/lib/tasks/vite/install.rake +12 -0
- data/lib/tasks/vite/install_dependencies.rake +20 -0
- data/lib/tasks/vite/verify_install.rake +23 -0
- data/lib/vite_rails/version.rb +1 -1
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89b280f3a27da1896e3036c387874f6f2c5c0033aa3cb9f77cac84fecba57be3
|
4
|
+
data.tar.gz: 70e6f39a6f35af3e7a95cbd92cf7a2b9d2b4c0429335611ebf3cbab60386c775
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b97f37e3822e99622b2a668cd957a27aeb1a00b98efe3e750c90169f4ae8dc2312a4c7460de6b4582a8414a92b704b668c880190314fd1d3632002b3f77c587
|
7
|
+
data.tar.gz: 76cce62bdedfc515e62e1777746a7a39ebe500a0e8afbd5b7c9255372a984a1042747d7e8dc52d4992d03370649c677c7c603cab75d3a6b5c9af2c0c447ef0a9
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
binstubs_template_path = File.expand_path('../../install/binstubs.rb', __dir__).freeze
|
4
|
+
bin_path = ENV['BUNDLE_BIN'] || Rails.root.join('bin')
|
5
|
+
|
6
|
+
namespace :vite do
|
7
|
+
desc 'Installs Vite binstubs in this application'
|
8
|
+
task :binstubs do |task|
|
9
|
+
prefix = task.name.split(/#|vite:binstubs/).first
|
10
|
+
exec "#{ RbConfig.ruby } #{ bin_path }/rails #{ prefix }app:template LOCATION=#{ binstubs_template_path }"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$stdout.sync = true
|
4
|
+
|
5
|
+
def enhance_assets_precompile
|
6
|
+
Rake::Task['assets:precompile'] do |task|
|
7
|
+
prefix = task.name.split(/#|assets:precompile/).first
|
8
|
+
|
9
|
+
Rake::Task["#{ prefix }vite:build"].invoke
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :vite do
|
14
|
+
desc 'Compile JavaScript packs using vite for production with digests'
|
15
|
+
task build: [:'vite:verify_install', :environment] do
|
16
|
+
ViteRails.with_node_env(ENV.fetch('NODE_ENV', 'production')) do
|
17
|
+
ViteRails.ensure_log_goes_to_stdout do
|
18
|
+
ViteRails.build || exit!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Compile packs after we've compiled all other assets during precompilation
|
25
|
+
skip_vite_precompile = %w[no false n f].include?(ENV['VITE_RUBY_PRECOMPILE'])
|
26
|
+
|
27
|
+
unless skip_vite_precompile
|
28
|
+
if Rake::Task.task_defined?('assets:precompile')
|
29
|
+
enhance_assets_precompile
|
30
|
+
else
|
31
|
+
Rake::Task.define_task('assets:precompile' => [:'vite:install_dependencies', :'vite:build'])
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$stdout.sync = true
|
4
|
+
|
5
|
+
namespace :vite do
|
6
|
+
desc 'Remove old compiled vites'
|
7
|
+
task :clean, [:keep, :age] => [:'vite:verify_install', :environment] do |_, args|
|
8
|
+
ViteRails.ensure_log_goes_to_stdout do
|
9
|
+
ViteRails.clean(keep_up_to: Integer(args.keep || 2), age_in_seconds: Integer(args.age || 3600))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
skip_vite_clean = %w[no false n f].include?(ENV['VITE_RUBY_PRECOMPILE'])
|
15
|
+
|
16
|
+
unless skip_vite_clean
|
17
|
+
# Run clean if the assets:clean is run
|
18
|
+
if Rake::Task.task_defined?('assets:clean')
|
19
|
+
Rake::Task['assets:clean'].enhance do
|
20
|
+
Rake::Task['vite:clean'].invoke
|
21
|
+
end
|
22
|
+
else
|
23
|
+
Rake::Task.define_task('assets:clean' => 'vite:clean')
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :vite do
|
4
|
+
desc 'Remove the vite build output directory'
|
5
|
+
task clobber: [:'vite:verify_install', :environment] do
|
6
|
+
ViteRails.clobber
|
7
|
+
$stdout.puts "Removed vite build output directory #{ ViteRails.config.build_output_dir }"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
skip_vite_clobber = %w[no false n f].include?(ENV['VITE_RUBY_PRECOMPILE'])
|
12
|
+
|
13
|
+
unless skip_vite_clobber
|
14
|
+
# Run clobber if the assets:clobber is run
|
15
|
+
if Rake::Task.task_defined?('assets:clobber')
|
16
|
+
Rake::Task['assets:clobber'].enhance do
|
17
|
+
Rake::Task['vite:clobber'].invoke
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :vite do
|
4
|
+
desc "Provide information on ViteRails's environment"
|
5
|
+
task :info do
|
6
|
+
Dir.chdir(Rails.root) do
|
7
|
+
$stdout.puts "Ruby: #{ `ruby --version` }"
|
8
|
+
$stdout.puts "Rails: #{ Rails.version }"
|
9
|
+
$stdout.puts "ViteRails: #{ ViteRails::VERSION }"
|
10
|
+
$stdout.puts "Node: #{ `node --version` }"
|
11
|
+
$stdout.puts "Yarn: #{ `yarn --version` }"
|
12
|
+
|
13
|
+
$stdout.puts "\n"
|
14
|
+
$stdout.puts "vite-plugin-ruby: \n#{ `npm list vite-plugin-ruby version` }"
|
15
|
+
|
16
|
+
$stdout.puts "Is bin/vite present?: #{ File.exist? 'bin/vite' }"
|
17
|
+
$stdout.puts "Is bin/vite-dev-server present?: #{ File.exist? 'bin/vite-dev-server' }"
|
18
|
+
$stdout.puts "Is bin/yarn present?: #{ File.exist? 'bin/yarn' }"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
install_template_path = File.expand_path('../../install/template.rb', __dir__).freeze
|
4
|
+
bin_path = ENV['BUNDLE_BIN'] || Rails.root.join('bin')
|
5
|
+
|
6
|
+
namespace :vite do
|
7
|
+
desc 'Install ViteRails in this application'
|
8
|
+
task :install do |task|
|
9
|
+
prefix = task.name.split(/#|vite:install/).first
|
10
|
+
exec "#{ RbConfig.ruby } #{ bin_path }/rails #{ prefix }app:template LOCATION=#{ install_template_path }"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :vite do
|
4
|
+
desc 'Support for older Rails versions. Install all JavaScript dependencies as specified via Yarn'
|
5
|
+
task :install_dependencies do
|
6
|
+
valid_node_envs = %w[test development production]
|
7
|
+
node_env = ENV.fetch('NODE_ENV') { valid_node_envs.include?(Rails.env) ? Rails.env : 'production' }
|
8
|
+
Dir.chdir(Rails.root) do
|
9
|
+
install_command = if Rails.root.join('yarn.lock').exist?
|
10
|
+
v1 = `yarn --version`.start_with?('1')
|
11
|
+
"yarn install #{ v1 ? '--no-progress --frozen-lockfile' : '--immutable' }"
|
12
|
+
elsif Rails.root.join('pnpm-lock.yaml').exist?
|
13
|
+
'pnpm install'
|
14
|
+
else
|
15
|
+
'npm ci'
|
16
|
+
end
|
17
|
+
system({ 'NODE_ENV' => node_env }, install_command)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :vite do
|
4
|
+
desc 'Verifies if Vite Rails is installed'
|
5
|
+
task :verify_install do
|
6
|
+
unless File.exist?(Rails.root.join('bin/vite'))
|
7
|
+
warn <<~WARN
|
8
|
+
vite binstub not found.
|
9
|
+
Have you run rails vite:install?
|
10
|
+
Make sure the bin directory and bin/vite are not included in .gitignore
|
11
|
+
WARN
|
12
|
+
exit!
|
13
|
+
end
|
14
|
+
unless ViteRails.config.config_path.exist?
|
15
|
+
path = ViteRails.config.config_path.relative_path_from(Pathname.new(pwd)).to_s
|
16
|
+
warn <<~WARN
|
17
|
+
Configuration #{ path } file for vite-plugin-ruby not found.
|
18
|
+
Make sure vite:install has run successfully before running dependent tasks.
|
19
|
+
WARN
|
20
|
+
exit!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/vite_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vite_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Máximo Mussini
|
@@ -121,6 +121,14 @@ files:
|
|
121
121
|
- README.md
|
122
122
|
- lib/install/binstubs.rb
|
123
123
|
- lib/install/template.rb
|
124
|
+
- lib/tasks/vite/binstubs.rake
|
125
|
+
- lib/tasks/vite/build.rake
|
126
|
+
- lib/tasks/vite/clean.rake
|
127
|
+
- lib/tasks/vite/clobber.rake
|
128
|
+
- lib/tasks/vite/info.rake
|
129
|
+
- lib/tasks/vite/install.rake
|
130
|
+
- lib/tasks/vite/install_dependencies.rake
|
131
|
+
- lib/tasks/vite/verify_install.rake
|
124
132
|
- lib/vite_rails.rb
|
125
133
|
- lib/vite_rails/builder.rb
|
126
134
|
- lib/vite_rails/commands.rb
|
@@ -174,8 +182,8 @@ homepage: https://github.com/ElMassimo/vite_rails
|
|
174
182
|
licenses:
|
175
183
|
- MIT
|
176
184
|
metadata:
|
177
|
-
source_code_uri: https://github.com/ElMassimo/vite_rails/tree/v1.0.
|
178
|
-
changelog_uri: https://github.com/ElMassimo/vite_rails/blob/v1.0.
|
185
|
+
source_code_uri: https://github.com/ElMassimo/vite_rails/tree/v1.0.1
|
186
|
+
changelog_uri: https://github.com/ElMassimo/vite_rails/blob/v1.0.1/CHANGELOG.md
|
179
187
|
post_install_message:
|
180
188
|
rdoc_options: []
|
181
189
|
require_paths:
|