vite_rb 0.0.1.alpha1

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 (127) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +3 -0
  3. data/.dockerignore +22 -0
  4. data/.github/FUNDING.yml +1 -0
  5. data/.github/workflows/build.yml +17 -0
  6. data/.gitignore +71 -0
  7. data/.ruby-version +1 -0
  8. data/.solargraph.yml +16 -0
  9. data/.standard.yml +11 -0
  10. data/CHANGELOG.md +65 -0
  11. data/Gemfile +8 -0
  12. data/LICENSE.txt +21 -0
  13. data/README.md +258 -0
  14. data/Rakefile +39 -0
  15. data/bin/console +15 -0
  16. data/bin/setup +8 -0
  17. data/examples/rails-without-webpack/.gitignore +34 -0
  18. data/examples/rails-without-webpack/.ruby-version +1 -0
  19. data/examples/rails-without-webpack/Gemfile +33 -0
  20. data/examples/rails-without-webpack/README.md +24 -0
  21. data/examples/rails-without-webpack/Rakefile +6 -0
  22. data/examples/rails-without-webpack/app/assets/config/manifest.js +2 -0
  23. data/examples/rails-without-webpack/app/assets/images/.keep +0 -0
  24. data/examples/rails-without-webpack/app/assets/stylesheets/application.css +15 -0
  25. data/examples/rails-without-webpack/app/assets/stylesheets/static_pages.scss +3 -0
  26. data/examples/rails-without-webpack/app/channels/application_cable/channel.rb +4 -0
  27. data/examples/rails-without-webpack/app/channels/application_cable/connection.rb +4 -0
  28. data/examples/rails-without-webpack/app/channels/chat_channel.rb +12 -0
  29. data/examples/rails-without-webpack/app/controllers/application_controller.rb +2 -0
  30. data/examples/rails-without-webpack/app/controllers/concerns/.keep +0 -0
  31. data/examples/rails-without-webpack/app/controllers/static_pages_controller.rb +4 -0
  32. data/examples/rails-without-webpack/app/helpers/application_helper.rb +2 -0
  33. data/examples/rails-without-webpack/app/helpers/static_pages_helper.rb +2 -0
  34. data/examples/rails-without-webpack/app/jobs/application_job.rb +7 -0
  35. data/examples/rails-without-webpack/app/mailers/application_mailer.rb +4 -0
  36. data/examples/rails-without-webpack/app/models/application_record.rb +3 -0
  37. data/examples/rails-without-webpack/app/models/concerns/.keep +0 -0
  38. data/examples/rails-without-webpack/app/snowpacker/assets/fake-asset.png +0 -0
  39. data/examples/rails-without-webpack/app/snowpacker/channels/consumer.js +5 -0
  40. data/examples/rails-without-webpack/app/snowpacker/channels/index.js +2 -0
  41. data/examples/rails-without-webpack/app/snowpacker/entrypoints/application.js +10 -0
  42. data/examples/rails-without-webpack/app/snowpacker/javascript/index.js +1 -0
  43. data/examples/rails-without-webpack/app/snowpacker/stylesheets/index.css +3 -0
  44. data/examples/rails-without-webpack/app/views/layouts/application.html.erb +15 -0
  45. data/examples/rails-without-webpack/app/views/layouts/mailer.html.erb +13 -0
  46. data/examples/rails-without-webpack/app/views/layouts/mailer.text.erb +1 -0
  47. data/examples/rails-without-webpack/app/views/static_pages/index.html.erb +2 -0
  48. data/examples/rails-without-webpack/bin/bundle +114 -0
  49. data/examples/rails-without-webpack/bin/rails +9 -0
  50. data/examples/rails-without-webpack/bin/rake +9 -0
  51. data/examples/rails-without-webpack/bin/setup +36 -0
  52. data/examples/rails-without-webpack/bin/spring +17 -0
  53. data/examples/rails-without-webpack/bin/yarn +9 -0
  54. data/examples/rails-without-webpack/config.ru +5 -0
  55. data/examples/rails-without-webpack/config/application.rb +19 -0
  56. data/examples/rails-without-webpack/config/boot.rb +4 -0
  57. data/examples/rails-without-webpack/config/cable.yml +10 -0
  58. data/examples/rails-without-webpack/config/credentials.yml.enc +1 -0
  59. data/examples/rails-without-webpack/config/database.yml +25 -0
  60. data/examples/rails-without-webpack/config/environment.rb +5 -0
  61. data/examples/rails-without-webpack/config/environments/development.rb +62 -0
  62. data/examples/rails-without-webpack/config/environments/production.rb +112 -0
  63. data/examples/rails-without-webpack/config/environments/test.rb +49 -0
  64. data/examples/rails-without-webpack/config/initializers/application_controller_renderer.rb +8 -0
  65. data/examples/rails-without-webpack/config/initializers/assets.rb +14 -0
  66. data/examples/rails-without-webpack/config/initializers/backtrace_silencers.rb +7 -0
  67. data/examples/rails-without-webpack/config/initializers/content_security_policy.rb +31 -0
  68. data/examples/rails-without-webpack/config/initializers/cookies_serializer.rb +5 -0
  69. data/examples/rails-without-webpack/config/initializers/filter_parameter_logging.rb +4 -0
  70. data/examples/rails-without-webpack/config/initializers/inflections.rb +16 -0
  71. data/examples/rails-without-webpack/config/initializers/mime_types.rb +4 -0
  72. data/examples/rails-without-webpack/config/initializers/snowpacker.rb +41 -0
  73. data/examples/rails-without-webpack/config/initializers/wrap_parameters.rb +14 -0
  74. data/examples/rails-without-webpack/config/locales/en.yml +33 -0
  75. data/examples/rails-without-webpack/config/puma.rb +38 -0
  76. data/examples/rails-without-webpack/config/routes.rb +5 -0
  77. data/examples/rails-without-webpack/config/snowpacker/.browserslistrc +1 -0
  78. data/examples/rails-without-webpack/config/snowpacker/babel.config.js +76 -0
  79. data/examples/rails-without-webpack/config/snowpacker/postcss.config.js +12 -0
  80. data/examples/rails-without-webpack/config/snowpacker/snowpack.config.js +61 -0
  81. data/examples/rails-without-webpack/config/spring.rb +6 -0
  82. data/examples/rails-without-webpack/config/storage.yml +34 -0
  83. data/examples/rails-without-webpack/db/seeds.rb +7 -0
  84. data/examples/rails-without-webpack/lib/assets/.keep +0 -0
  85. data/examples/rails-without-webpack/lib/tasks/.keep +0 -0
  86. data/examples/rails-without-webpack/package.json +20 -0
  87. data/examples/rails-without-webpack/storage/.keep +0 -0
  88. data/examples/rails-without-webpack/test/application_system_test_case.rb +5 -0
  89. data/examples/rails-without-webpack/test/channels/application_cable/connection_test.rb +11 -0
  90. data/examples/rails-without-webpack/test/channels/chat_channel_test.rb +8 -0
  91. data/examples/rails-without-webpack/test/controllers/.keep +0 -0
  92. data/examples/rails-without-webpack/test/controllers/static_pages_controller_test.rb +8 -0
  93. data/examples/rails-without-webpack/test/fixtures/.keep +0 -0
  94. data/examples/rails-without-webpack/test/fixtures/files/.keep +0 -0
  95. data/examples/rails-without-webpack/test/helpers/.keep +0 -0
  96. data/examples/rails-without-webpack/test/integration/.keep +0 -0
  97. data/examples/rails-without-webpack/test/mailers/.keep +0 -0
  98. data/examples/rails-without-webpack/test/models/.keep +0 -0
  99. data/examples/rails-without-webpack/test/system/.keep +0 -0
  100. data/examples/rails-without-webpack/test/test_helper.rb +13 -0
  101. data/examples/rails-without-webpack/vendor/.keep +0 -0
  102. data/examples/rails-without-webpack/yarn.lock +7545 -0
  103. data/lib/tasks/rails.rake +31 -0
  104. data/lib/tasks/ruby.rake +21 -0
  105. data/lib/vite_rb.rb +25 -0
  106. data/lib/vite_rb/configuration.rb +56 -0
  107. data/lib/vite_rb/engine.rb +5 -0
  108. data/lib/vite_rb/env.rb +29 -0
  109. data/lib/vite_rb/generator.rb +81 -0
  110. data/lib/vite_rb/helpers.rb +51 -0
  111. data/lib/vite_rb/manifest.rb +40 -0
  112. data/lib/vite_rb/proxy.rb +35 -0
  113. data/lib/vite_rb/runner.rb +46 -0
  114. data/lib/vite_rb/templates/postcss.config.js +12 -0
  115. data/lib/vite_rb/templates/vite.config.js +71 -0
  116. data/lib/vite_rb/templates/vite.rb.tt +54 -0
  117. data/lib/vite_rb/templates/vite/channels/consumer.js +5 -0
  118. data/lib/vite_rb/templates/vite/channels/index.js +2 -0
  119. data/lib/vite_rb/templates/vite/entrypoints/application.js +10 -0
  120. data/lib/vite_rb/templates/vite/stylesheets/index.css +3 -0
  121. data/lib/vite_rb/utils.rb +55 -0
  122. data/lib/vite_rb/version.rb +5 -0
  123. data/package.json +25 -0
  124. data/package/src/index.js +0 -0
  125. data/vite_rb.gemspec +46 -0
  126. data/yarn.lock +1215 -0
  127. metadata +337 -0
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "vite_rb"
4
+
5
+ begin
6
+ require "bundler/setup"
7
+ rescue LoadError
8
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
9
+ end
10
+
11
+ require "yard"
12
+
13
+ YARD::Rake::YardocTask.new do |t|
14
+ t.files = ["lib/**/*.rb", "README.md"] # optional
15
+ t.options = ["--title Vite #{::ViteRb::VERSION}", "--line-numbers", "--any", "--extra", "--opts"] # optional
16
+ t.stats_options = ["--list-undoc"] # optional
17
+ end
18
+
19
+ require "bundler/gem_tasks"
20
+
21
+ require "rake/testtask"
22
+
23
+ Rake::TestTask.new(:test) do |t|
24
+ t.libs << "test"
25
+ t.test_files = Dir["test/**/*_test.rb"].reject do |path|
26
+ path.include?("rails_test_app") || path.include?("ruby_test_app")
27
+ end
28
+ t.verbose = true
29
+ end
30
+
31
+ Rake::TestTask.new(:"test:unit") do |t|
32
+ t.libs << "test"
33
+ t.test_files = Dir["test/unit/**/*_test.rb"]
34
+ t.verbose = true
35
+ end
36
+
37
+ require "standard/rake"
38
+
39
+ task default: :test
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'vite_rb/rails'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+ /db/*.sqlite3-*
14
+
15
+ # Ignore all logfiles and tempfiles.
16
+ /log/*
17
+ /tmp/*
18
+ !/log/.keep
19
+ !/tmp/.keep
20
+
21
+ # Ignore pidfiles, but keep the directory.
22
+ /tmp/pids/*
23
+ !/tmp/pids/
24
+ !/tmp/pids/.keep
25
+
26
+ # Ignore uploaded files in development.
27
+ /storage/*
28
+ !/storage/.keep
29
+
30
+ /public/assets
31
+ .byebug_history
32
+
33
+ # Ignore master key for decrypting credentials and more.
34
+ /config/master.key
@@ -0,0 +1,33 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby "2.6.3"
5
+
6
+ gem "rails", "~> 6.0.3", ">= 6.0.3.2"
7
+ gem "sqlite3", "~> 1.4"
8
+ gem "puma", "~> 4.1"
9
+ gem "sass-rails", ">= 6"
10
+ # gem 'webpacker', '~> 4.0'
11
+ gem "turbolinks", "~> 5"
12
+ gem "jbuilder", "~> 2.7"
13
+ gem "bootsnap", ">= 1.4.2", require: false
14
+ gem "vite_rb", path: "../../"
15
+
16
+ group :development, :test do
17
+ gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
18
+ end
19
+
20
+ group :development do
21
+ gem "web-console", ">= 3.3.0"
22
+ gem "listen", "~> 3.2"
23
+ gem "spring"
24
+ gem "spring-watcher-listen", "~> 2.0.0"
25
+ end
26
+
27
+ group :test do
28
+ gem "capybara", ">= 2.15"
29
+ gem "selenium-webdriver"
30
+ gem "webdrivers"
31
+ end
32
+
33
+ gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
@@ -0,0 +1,24 @@
1
+ # README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the static_pages controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: https://sass-lang.com/
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,12 @@
1
+ class ChatChannel < ApplicationCable::Channel
2
+ def subscribed
3
+ # stream_from "some_channel"
4
+ end
5
+
6
+ def unsubscribed
7
+ # Any cleanup needed when channel is unsubscribed
8
+ end
9
+
10
+ def speak
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class StaticPagesController < ApplicationController
2
+ def index
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module StaticPagesHelper
2
+ end
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout "mailer"
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,5 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+
4
+ import { createConsumer } from "@rails/actioncable"
5
+ export default createConsumer()
@@ -0,0 +1,2 @@
1
+ import importAll from "import-all.macro"
2
+ importAll.sync("./**/*_channel.js")
@@ -0,0 +1,10 @@
1
+ import "@rails/ujs" // Autostarts
2
+ import Turbolinks from "turbolinks"
3
+ import ActiveStorage from "@rails/activestorage"
4
+ import "../stylesheets/index.css"
5
+ import "../javascript"
6
+
7
+ Turbolinks.start()
8
+ ActiveStorage.start()
9
+
10
+ console.log("Hello from ViteRb")
@@ -0,0 +1 @@
1
+ console.log("Hi from javascript")
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsWithoutWebpack</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= javascript_vite_tag "application" %>
9
+ <%= vite_hmr_tag %>
10
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,2 @@
1
+ <h1>StaticPages#index</h1>
2
+ <p>Find me in app/views/static_pages/index.html.erb</p>
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new {
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling {
91
+ gem "bundler", bundler_requirement
92
+ }
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling {
95
+ require "bundler/version"
96
+ }
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ }
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end