vite_rails 1.0.11 → 2.0.3

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +52 -34
  4. data/lib/tasks/vite.rake +17 -0
  5. data/lib/vite_rails.rb +5 -82
  6. data/lib/vite_rails/config.rb +11 -130
  7. data/lib/vite_rails/engine.rb +7 -11
  8. data/lib/vite_rails/installation.rb +52 -0
  9. data/lib/vite_rails/tag_helpers.rb +61 -0
  10. data/lib/vite_rails/version.rb +2 -2
  11. data/{lib/install/config/vite.json → templates/config/rails-vite.json} +1 -0
  12. data/{lib/install/javascript → templates}/entrypoints/application.js +0 -0
  13. metadata +27 -166
  14. data/CONTRIBUTING.md +0 -33
  15. data/lib/install/bin/vite +0 -17
  16. data/lib/install/binstubs.rb +0 -6
  17. data/lib/install/config/vite.config.ts +0 -11
  18. data/lib/install/template.rb +0 -40
  19. data/lib/tasks/vite/binstubs.rake +0 -12
  20. data/lib/tasks/vite/build.rake +0 -39
  21. data/lib/tasks/vite/clean.rake +0 -23
  22. data/lib/tasks/vite/clobber.rake +0 -20
  23. data/lib/tasks/vite/info.rake +0 -20
  24. data/lib/tasks/vite/install.rake +0 -12
  25. data/lib/tasks/vite/install_dependencies.rake +0 -14
  26. data/lib/tasks/vite/verify_install.rake +0 -23
  27. data/lib/vite_rails/builder.rb +0 -111
  28. data/lib/vite_rails/commands.rb +0 -109
  29. data/lib/vite_rails/dev_server.rb +0 -23
  30. data/lib/vite_rails/dev_server_proxy.rb +0 -57
  31. data/lib/vite_rails/helper.rb +0 -71
  32. data/lib/vite_rails/manifest.rb +0 -140
  33. data/lib/vite_rails/runner.rb +0 -53
  34. data/package.json +0 -19
  35. data/package/default.vite.json +0 -16
  36. data/test/builder_test.rb +0 -77
  37. data/test/commands_test.rb +0 -67
  38. data/test/config_test.rb +0 -133
  39. data/test/dev_server_proxy_test.rb +0 -102
  40. data/test/dev_server_test.rb +0 -9
  41. data/test/engine_rake_tasks_test.rb +0 -81
  42. data/test/helper_test.rb +0 -70
  43. data/test/manifest_test.rb +0 -79
  44. data/test/mode_test.rb +0 -16
  45. data/test/mounted_app/Rakefile +0 -6
  46. data/test/mounted_app/test/dummy/Rakefile +0 -5
  47. data/test/mounted_app/test/dummy/bin/rails +0 -5
  48. data/test/mounted_app/test/dummy/bin/rake +0 -5
  49. data/test/mounted_app/test/dummy/config.ru +0 -7
  50. data/test/mounted_app/test/dummy/config/application.rb +0 -12
  51. data/test/mounted_app/test/dummy/config/environment.rb +0 -5
  52. data/test/mounted_app/test/dummy/config/vite.json +0 -14
  53. data/test/mounted_app/test/dummy/package.json +0 -8
  54. data/test/mounted_app/test/dummy/yarn.lock +0 -208
  55. data/test/rake_tasks_test.rb +0 -60
  56. data/test/runner_test.rb +0 -31
  57. data/test/test_app/Rakefile +0 -5
  58. data/test/test_app/app/frontend/entrypoints/application.js +0 -2
  59. data/test/test_app/bin/vite +0 -17
  60. data/test/test_app/config.ru +0 -7
  61. data/test/test_app/config/application.rb +0 -13
  62. data/test/test_app/config/environment.rb +0 -6
  63. data/test/test_app/config/vite.json +0 -18
  64. data/test/test_app/config/vite_additional_paths.json +0 -5
  65. data/test/test_app/config/vite_public_dir.json +0 -5
  66. data/test/test_app/package.json +0 -13
  67. data/test/test_app/public/vite-production/manifest.json +0 -22
  68. data/test/test_app/some.config.js +0 -0
  69. data/test/test_app/yarn.lock +0 -11
  70. 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
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'config/application'
4
-
5
- Rails.application.load_tasks
@@ -1,2 +0,0 @@
1
- /* eslint no-console:0 */
2
- console.log('Hello World from ViteRails')
@@ -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
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file allows the `Rails.root` to be correctly determined.
4
-
5
- require_relative 'config/environment'
6
-
7
- run Rails.application
@@ -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,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'application'
4
-
5
- Rails.backtrace_cleaner.remove_silencers!
6
- Rails.application.initialize!
@@ -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
- }
@@ -1,5 +0,0 @@
1
- {
2
- "all": {
3
- "watchAdditionalPaths": ["config/*"]
4
- }
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "all": {
3
- "publicDir": "../public"
4
- }
5
- }
@@ -1,13 +0,0 @@
1
- {
2
- "name": "test_app",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "license": "MIT",
6
- "private": true,
7
- "dependencies": {
8
- "left-pad": "^1.2.0"
9
- },
10
- "devDependencies": {
11
- "right-pad": "^1.0.1"
12
- }
13
- }
@@ -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
@@ -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