vite_rails 1.0.11 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/README.md +52 -34
- data/lib/tasks/vite.rake +17 -0
- data/lib/vite_rails.rb +5 -82
- data/lib/vite_rails/config.rb +11 -130
- data/lib/vite_rails/engine.rb +7 -11
- data/lib/vite_rails/installation.rb +52 -0
- data/lib/vite_rails/tag_helpers.rb +61 -0
- data/lib/vite_rails/version.rb +2 -2
- data/{lib/install/config/vite.json → templates/config/rails-vite.json} +1 -0
- data/{lib/install/javascript → templates}/entrypoints/application.js +0 -0
- metadata +27 -166
- data/CONTRIBUTING.md +0 -33
- data/lib/install/bin/vite +0 -17
- data/lib/install/binstubs.rb +0 -6
- data/lib/install/config/vite.config.ts +0 -11
- data/lib/install/template.rb +0 -40
- data/lib/tasks/vite/binstubs.rake +0 -12
- data/lib/tasks/vite/build.rake +0 -39
- data/lib/tasks/vite/clean.rake +0 -23
- data/lib/tasks/vite/clobber.rake +0 -20
- data/lib/tasks/vite/info.rake +0 -20
- data/lib/tasks/vite/install.rake +0 -12
- data/lib/tasks/vite/install_dependencies.rake +0 -14
- data/lib/tasks/vite/verify_install.rake +0 -23
- data/lib/vite_rails/builder.rb +0 -111
- data/lib/vite_rails/commands.rb +0 -109
- data/lib/vite_rails/dev_server.rb +0 -23
- data/lib/vite_rails/dev_server_proxy.rb +0 -57
- data/lib/vite_rails/helper.rb +0 -71
- data/lib/vite_rails/manifest.rb +0 -140
- data/lib/vite_rails/runner.rb +0 -53
- data/package.json +0 -19
- data/package/default.vite.json +0 -16
- data/test/builder_test.rb +0 -77
- data/test/commands_test.rb +0 -67
- data/test/config_test.rb +0 -133
- data/test/dev_server_proxy_test.rb +0 -102
- data/test/dev_server_test.rb +0 -9
- data/test/engine_rake_tasks_test.rb +0 -81
- data/test/helper_test.rb +0 -70
- data/test/manifest_test.rb +0 -79
- data/test/mode_test.rb +0 -16
- data/test/mounted_app/Rakefile +0 -6
- data/test/mounted_app/test/dummy/Rakefile +0 -5
- data/test/mounted_app/test/dummy/bin/rails +0 -5
- data/test/mounted_app/test/dummy/bin/rake +0 -5
- data/test/mounted_app/test/dummy/config.ru +0 -7
- data/test/mounted_app/test/dummy/config/application.rb +0 -12
- data/test/mounted_app/test/dummy/config/environment.rb +0 -5
- data/test/mounted_app/test/dummy/config/vite.json +0 -14
- data/test/mounted_app/test/dummy/package.json +0 -8
- data/test/mounted_app/test/dummy/yarn.lock +0 -208
- data/test/rake_tasks_test.rb +0 -60
- data/test/runner_test.rb +0 -31
- data/test/test_app/Rakefile +0 -5
- data/test/test_app/app/frontend/entrypoints/application.js +0 -2
- data/test/test_app/bin/vite +0 -17
- data/test/test_app/config.ru +0 -7
- data/test/test_app/config/application.rb +0 -13
- data/test/test_app/config/environment.rb +0 -6
- data/test/test_app/config/vite.json +0 -18
- data/test/test_app/config/vite_additional_paths.json +0 -5
- data/test/test_app/config/vite_public_dir.json +0 -5
- data/test/test_app/package.json +0 -13
- data/test/test_app/public/vite-production/manifest.json +0 -22
- data/test/test_app/some.config.js +0 -0
- data/test/test_app/yarn.lock +0 -11
- data/test/test_helper.rb +0 -68
data/test/runner_test.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class RunnerTest < ViteRails::Test
|
6
|
-
def test_dev_server_command
|
7
|
-
assert_run_command(flags: ['--mode', 'production'])
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_dev_server_command_via_yarn
|
11
|
-
assert_run_command(flags: ['--mode', 'production'], use_yarn: true)
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_dev_server_command_with_argument
|
15
|
-
assert_run_command('--quiet', flags: ['--mode', 'production'])
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_build_command
|
19
|
-
assert_run_command('build', flags: ['--mode', 'production'])
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_build_command_via_yarn
|
23
|
-
assert_run_command('build', flags: ['--mode', 'production'], use_yarn: true)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_build_command_with_argument
|
27
|
-
with_rails_env('development') do
|
28
|
-
assert_run_command('build', '--emptyOutDir', flags: ['--mode', 'development'])
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/test/test_app/Rakefile
DELETED
data/test/test_app/bin/vite
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] || 'development'
|
5
|
-
ENV['NODE_ENV'] ||= ENV['RAILS_ENV'] == 'development' ? 'development' : 'production'
|
6
|
-
|
7
|
-
require 'pathname'
|
8
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', Pathname.new(__FILE__).realpath)
|
9
|
-
|
10
|
-
require 'bundler/setup'
|
11
|
-
|
12
|
-
require 'vite_rails'
|
13
|
-
|
14
|
-
APP_ROOT = File.expand_path('..', __dir__)
|
15
|
-
Dir.chdir(APP_ROOT) do
|
16
|
-
ViteRails.run(ARGV)
|
17
|
-
end
|
data/test/test_app/config.ru
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'action_controller/railtie'
|
4
|
-
require 'action_view/railtie'
|
5
|
-
require 'vite_rails'
|
6
|
-
|
7
|
-
module TestApp
|
8
|
-
class Application < ::Rails::Application
|
9
|
-
config.secret_key_base = 'abcdef'
|
10
|
-
config.eager_load = true
|
11
|
-
config.active_support.test_order = :sorted
|
12
|
-
end
|
13
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"development": {
|
3
|
-
"autoBuild": true,
|
4
|
-
"port": "3535",
|
5
|
-
"https": true,
|
6
|
-
"publicOutputDir": "vite-development"
|
7
|
-
},
|
8
|
-
"test": {
|
9
|
-
"autoBuild": true,
|
10
|
-
"publicOutputDir": "vite-test"
|
11
|
-
},
|
12
|
-
"production": {
|
13
|
-
"publicOutputDir": "vite-production"
|
14
|
-
},
|
15
|
-
"staging": {
|
16
|
-
"publicOutputDir": "vite-staging"
|
17
|
-
}
|
18
|
-
}
|
data/test/test_app/package.json
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"application.js": {
|
3
|
-
"file": "assets/application.a0ba047e.js",
|
4
|
-
"imports": [
|
5
|
-
"assets/example_import.8e1fddc0.js"
|
6
|
-
]
|
7
|
-
},
|
8
|
-
"example_import.js": {
|
9
|
-
"file": "assets/example_import.8e1fddc0.js",
|
10
|
-
"imports": []
|
11
|
-
},
|
12
|
-
"colored.js": {
|
13
|
-
"file": "assets/colored.1173bfe0.js",
|
14
|
-
"imports": []
|
15
|
-
},
|
16
|
-
"application.css": {
|
17
|
-
"file": "assets/application.cccfef34.css"
|
18
|
-
},
|
19
|
-
"colored.css": {
|
20
|
-
"file": "assets/colored.84277fd6.css"
|
21
|
-
}
|
22
|
-
}
|
File without changes
|
data/test/test_app/yarn.lock
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
2
|
-
# yarn lockfile v1
|
3
|
-
|
4
|
-
|
5
|
-
left-pad@^1.2.0:
|
6
|
-
version "1.2.0"
|
7
|
-
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
|
8
|
-
|
9
|
-
right-pad@^1.0.1:
|
10
|
-
version "1.0.1"
|
11
|
-
resolved "https://registry.yarnpkg.com/right-pad/-/right-pad-1.0.1.tgz#8ca08c2cbb5b55e74dafa96bf7fd1a27d568c8d0"
|
data/test/test_helper.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'simplecov'
|
4
|
-
SimpleCov.start {
|
5
|
-
add_filter '/test/'
|
6
|
-
}
|
7
|
-
|
8
|
-
require 'minitest/autorun'
|
9
|
-
require 'rails'
|
10
|
-
require 'rails/test_help'
|
11
|
-
require 'pry-byebug'
|
12
|
-
|
13
|
-
require_relative 'test_app/config/environment'
|
14
|
-
|
15
|
-
Rails.env = 'production'
|
16
|
-
|
17
|
-
ViteRails.instance = ViteRails.new
|
18
|
-
|
19
|
-
module ViteRailsTestHelpers
|
20
|
-
def refresh_config(env_variables = ViteRails.load_env_variables)
|
21
|
-
ViteRails.env = env_variables
|
22
|
-
(ViteRails.instance = ViteRails.new).config
|
23
|
-
end
|
24
|
-
|
25
|
-
def with_rails_env(env)
|
26
|
-
original = Rails.env
|
27
|
-
Rails.env = ActiveSupport::StringInquirer.new(env)
|
28
|
-
yield(refresh_config)
|
29
|
-
ensure
|
30
|
-
Rails.env = ActiveSupport::StringInquirer.new(original)
|
31
|
-
refresh_config
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_app_path
|
35
|
-
File.expand_path('test_app', __dir__)
|
36
|
-
end
|
37
|
-
|
38
|
-
def with_dev_server_running(&block)
|
39
|
-
ViteRails.instance.stub(:dev_server_running?, true, &block)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class ViteRails::Test < Minitest::Test
|
44
|
-
include ViteRailsTestHelpers
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def assert_run_command(*argv, use_yarn: false, flags: [])
|
49
|
-
command = use_yarn ? %w[yarn vite] : ["#{ test_app_path }/node_modules/.bin/vite"]
|
50
|
-
cwd = Dir.pwd
|
51
|
-
Dir.chdir(test_app_path)
|
52
|
-
|
53
|
-
klass = ViteRails::Runner
|
54
|
-
instance = klass.new(argv)
|
55
|
-
mock = Minitest::Mock.new
|
56
|
-
mock.expect(:call, nil, [ViteRails.config.to_env, *command, *argv, *flags])
|
57
|
-
|
58
|
-
klass.stub(:new, instance) do
|
59
|
-
instance.stub(:executable_exists?, !use_yarn) do
|
60
|
-
Kernel.stub(:exec, mock) { ViteRails.run(argv) }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
mock.verify
|
65
|
-
ensure
|
66
|
-
Dir.chdir(cwd)
|
67
|
-
end
|
68
|
-
end
|