rails_audit 1.0.0 → 1.0.4

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 (143) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +20 -165
  3. data/README.md +17 -5
  4. data/app/controllers/auditor/admin/approvals_controller.rb +44 -0
  5. data/app/controllers/auditor/admin/audits_controller.rb +11 -0
  6. data/app/controllers/auditor/admin/base_controller.rb +4 -0
  7. data/app/controllers/auditor/admin/verifications_controller.rb +61 -0
  8. data/app/controllers/auditor/admin/verifiers_controller.rb +69 -0
  9. data/app/controllers/auditor/controller/application.rb +32 -0
  10. data/app/models/auditor/approval.rb +5 -0
  11. data/app/models/auditor/audit.rb +5 -0
  12. data/app/models/auditor/ext/audited.rb +58 -0
  13. data/app/models/auditor/ext/verifiable.rb +10 -0
  14. data/app/models/auditor/ext/verified.rb +25 -0
  15. data/app/models/auditor/model/approval.rb +59 -0
  16. data/app/models/auditor/model/approving.rb +65 -0
  17. data/app/models/auditor/model/audit.rb +25 -0
  18. data/app/models/auditor/model/verification.rb +32 -0
  19. data/app/models/auditor/model/verifier.rb +20 -0
  20. data/app/models/auditor/verification.rb +5 -0
  21. data/app/models/auditor/verifier.rb +5 -0
  22. data/app/models/auditor.rb +11 -0
  23. data/app/views/auditor/_approvals.html.erb +14 -0
  24. data/app/views/auditor/_checks.html.erb +16 -0
  25. data/app/views/auditor/admin/approvals/_filter.html.erb +7 -0
  26. data/app/views/auditor/admin/approvals/_form.html.erb +6 -0
  27. data/app/views/auditor/admin/approvals/_index.html.erb +10 -0
  28. data/app/views/auditor/admin/approvals/_show_table.html.erb +28 -0
  29. data/app/views/auditor/admin/approvals/_table.html.erb +28 -0
  30. data/app/views/auditor/admin/approvals/index.js.erb +3 -0
  31. data/app/views/auditor/admin/audits/_button.html.erb +0 -0
  32. data/app/views/auditor/admin/audits/_index_tbody.html.erb +38 -0
  33. data/app/views/auditor/admin/audits/_index_thead.html.erb +4 -0
  34. data/app/views/auditor/admin/audits/index.html.erb +7 -0
  35. data/app/views/auditor/admin/verifications/_edit_form.html.erb +7 -0
  36. data/app/views/auditor/admin/verifications/_filter_form.html.erb +5 -0
  37. data/app/views/auditor/admin/verifications/_index_tbody.html.erb +4 -0
  38. data/app/views/auditor/admin/verifications/_index_thead.html.erb +5 -0
  39. data/app/views/auditor/admin/verifications/_new_form.html.erb +7 -0
  40. data/app/views/auditor/admin/verifications/_show_table.html.erb +16 -0
  41. data/app/views/auditor/admin/verifiers/_edit_form.html.erb +3 -0
  42. data/app/views/auditor/admin/verifiers/_filter_form.html.erb +9 -0
  43. data/app/views/auditor/admin/verifiers/_form.html.erb +5 -0
  44. data/app/views/auditor/admin/verifiers/_index_tbody.html.erb +3 -0
  45. data/app/views/auditor/admin/verifiers/_index_thead.html.erb +4 -0
  46. data/app/views/auditor/admin/verifiers/_member_field.html.erb +1 -0
  47. data/app/views/auditor/admin/verifiers/_new_form.html.erb +3 -0
  48. data/app/views/auditor/admin/verifiers/_show_table.html.erb +24 -0
  49. data/app/views/auditor/admin/verifiers/members.turbo_stream.erb +3 -0
  50. data/config/locales/en.yml +12 -0
  51. data/config/locales/zh.controller.yml +13 -0
  52. data/config/locales/zh.enum.yml +7 -0
  53. data/config/locales/zh.yml +21 -0
  54. data/config/routes.rb +22 -2
  55. data/lib/rails_audit/config.rb +14 -0
  56. data/lib/rails_audit/engine.rb +15 -6
  57. data/lib/rails_audit.rb +3 -2
  58. data/test/controllers/audit/admin/approvals_controller_test.rb +36 -0
  59. data/test/dummy/Gemfile +54 -0
  60. data/test/dummy/Gemfile.lock +382 -0
  61. data/test/dummy/README.md +8 -1
  62. data/test/dummy/app/assets/images/default_avatar.jpg +0 -0
  63. data/test/dummy/app/assets/images/logo.png +0 -0
  64. data/test/dummy/app/assets/javascripts/admin/application.js +1 -0
  65. data/test/dummy/app/assets/javascripts/application.js +11 -2
  66. data/test/dummy/app/assets/javascripts/phone.js +5 -0
  67. data/test/dummy/app/assets/stylesheets/css.scss +4 -0
  68. data/test/dummy/app/controllers/active_storage/base_controller.rb +19 -0
  69. data/test/dummy/app/controllers/admin_controller.rb +3 -0
  70. data/test/dummy/app/controllers/application_controller.rb +10 -1
  71. data/test/dummy/app/controllers/home_controller.rb +0 -5
  72. data/test/dummy/app/controllers/me_controller.rb +4 -0
  73. data/test/dummy/app/controllers/my_controller.rb +4 -0
  74. data/test/dummy/app/models/auth/user.rb +7 -0
  75. data/test/dummy/app/views/home/index.css +3 -0
  76. data/test/dummy/app/views/home/index.html.erb +0 -0
  77. data/test/dummy/app/views/layouts/_right_menu.html.erb +0 -20
  78. data/test/dummy/bin/bundle +1 -1
  79. data/test/dummy/bin/setup +1 -1
  80. data/test/dummy/bin/vite +19 -0
  81. data/test/dummy/bin/yarn +11 -0
  82. data/test/dummy/config/application.rb +12 -5
  83. data/test/dummy/config/boot.rb +8 -4
  84. data/test/dummy/config/credentials/development.key +1 -0
  85. data/test/dummy/config/credentials/test.key +1 -0
  86. data/test/dummy/config/credentials.yml.enc +1 -0
  87. data/test/dummy/config/database.yml +16 -0
  88. data/test/dummy/config/environment.rb +0 -2
  89. data/test/dummy/config/environments/development.rb +19 -32
  90. data/test/dummy/config/environments/production.rb +1 -13
  91. data/test/dummy/config/environments/test.rb +5 -0
  92. data/test/dummy/config/initializers/mime_types.rb +0 -4
  93. data/test/dummy/config/initializers/new_framework_defaults.rb +0 -4
  94. data/test/dummy/config/locales/en.yml +1 -22
  95. data/test/dummy/config/master.key +1 -0
  96. data/test/dummy/config/puma.rb +28 -41
  97. data/test/dummy/config/routes.rb +9 -2
  98. data/test/dummy/config/storage.yml +11 -0
  99. data/test/dummy/config/vite/base.js +5 -0
  100. data/test/dummy/config/vite/development.js +12 -0
  101. data/test/dummy/config/vite/production.js +6 -0
  102. data/test/dummy/config.ru +2 -0
  103. data/test/dummy/lib/deploy.rb +115 -0
  104. data/test/dummy/package.json +23 -2
  105. data/test/dummy/postcss.config.js +11 -0
  106. data/test/dummy/yarn.lock +2140 -4
  107. data/test/factories/approvals.rb +7 -0
  108. data/test/factories/infos.rb +8 -0
  109. data/test/{the_audit_test.rb → rails_audit_test.rb} +3 -1
  110. data/test/test_helper.rb +9 -16
  111. metadata +151 -97
  112. data/app/controllers/admin/audits_controller.rb +0 -12
  113. data/app/models/rails_audit/audit.rb +0 -14
  114. data/app/models/rails_audit/concerns/auditable.rb +0 -59
  115. data/app/models/rails_audit/history.rb +0 -36
  116. data/app/models/rails_audit/major_record.rb +0 -14
  117. data/app/models/rails_audit/minor_record.rb +0 -15
  118. data/app/views/admin/audits/_index.html.erb +0 -9
  119. data/app/views/admin/audits/_table.html.erb +0 -61
  120. data/app/views/admin/audits/index.html.erb +0 -3
  121. data/app/views/admin/audits/index.js.erb +0 -8
  122. data/db/migrate/20170314035239_create_audits.rb +0 -20
  123. data/lib/rails_audit/controller_helper.rb +0 -39
  124. data/lib/rails_audit/version.rb +0 -3
  125. data/lib/tasks/the_history_tasks.rake +0 -4
  126. data/test/dummy/app/assets/config/manifest.js +0 -3
  127. data/test/dummy/app/assets/javascripts/cable.js +0 -13
  128. data/test/dummy/app/assets/stylesheets/application.css +0 -5
  129. data/test/dummy/app/controllers/admin/base_controller.rb +0 -7
  130. data/test/dummy/app/controllers/my/base_controller.rb +0 -7
  131. data/test/dummy/app/models/application_record.rb +0 -3
  132. data/test/dummy/app/models/user.rb +0 -3
  133. data/test/dummy/app/views/layouts/_navbar.html.erb +0 -18
  134. data/test/dummy/app/views/layouts/application.html.erb +0 -19
  135. data/test/dummy/app/views/layouts/mailer.html.erb +0 -13
  136. data/test/dummy/app/views/layouts/mailer.text.erb +0 -1
  137. data/test/dummy/bin/update +0 -29
  138. data/test/dummy/config/database.yml.mysql +0 -14
  139. data/test/dummy/config/database.yml.sqlite3 +0 -12
  140. data/test/dummy/config/initializers/assets.rb +0 -6
  141. data/test/dummy/config/secrets.yml +0 -22
  142. data/test/dummy/db/migrate/20180525090830_create_active_storage_tables.active_storage.rb +0 -26
  143. data/test/dummy/log/development.log +0 -2
@@ -1,13 +1,20 @@
1
1
  require_relative 'boot'
2
-
3
- require 'rails/all'
4
-
2
+ require 'rails_com/all'
5
3
  Bundler.require(*Rails.groups)
6
4
 
7
5
  module Dummy
8
6
  class Application < Rails::Application
7
+ config.load_defaults Rails::VERSION::STRING.to_f
9
8
 
9
+ config.time_zone = 'Beijing'
10
+ config.i18n.default_locale = :zh
10
11
 
11
-
12
+ config.hosts += [
13
+ '.one.work',
14
+ '.work.design'
15
+ ]
12
16
  end
13
- end
17
+ end
18
+
19
+ ENV['EDITOR'] = 'code --wait'
20
+ SETTING = Rails.application.credentials
@@ -1,5 +1,9 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
1
+ engine_path = File.expand_path('../../../Gemfile', __dir__)
2
+ if File.exist? engine_path
3
+ ENV['BUNDLE_GEMFILE'] ||= engine_path
4
+ $:.unshift File.expand_path('../../../lib', __dir__)
5
+ else
6
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
7
+ end
3
8
 
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
9
+ require 'bundler/setup'
@@ -0,0 +1 @@
1
+ ff68435ed592040b43a4c366b25cab2c
@@ -0,0 +1 @@
1
+ 1ea3054fbe191c8d99769422e565b79a
@@ -0,0 +1 @@
1
+ MimMLkFHCBq1zcnnkv2zngu4tS+Gtep7hx1J8qFTCqFvN4H31Pd2UqdRlXpHLGL+4qKEhNJOQunMTACW+qIzvZPoJ9MTjLM1ZLabVbkHYgRYhkOX4vZ2hj7Z+YUWWe/OHKzjfsPLAMVkeoqn4BTi+mmf6rdX3NHryamuJIa+w9drlkevWgV0iUlUtJZu9F8QsHTOHT1U+MpCkssMRwvjbumB8Jp9GLatQbZGFVeXsdk4ZXmnWCIFkOWIPBxOBLiTs+blWqDajnhLU9CN9byqNpmDim6i0/2HCAIjeBF0t1TzPye9Ni2xsUNPC83HXmhk6nqw+swFiAIplgvLH5Hpziw5W+V9mQ9h4NOSw9HypZiQannZBEysB+VOhw==--l6w0Rkun7l6DUA45--mARmDw0cZ9J82/uugsKu0w==
@@ -0,0 +1,16 @@
1
+ default: &default
2
+ adapter: <%= ENV['DATABASE_ADAPTER'] || 'postgresql' %>
3
+ pool: 5
4
+ timeout: 5000
5
+
6
+ development:
7
+ <<: *default
8
+ url: <%= ENV['DATABASE_URL'] || Rails.application.credentials.postgres[:dev] %>
9
+
10
+ test:
11
+ <<: *default
12
+ url: <%= ENV['DATABASE_URL'] || Rails.application.credentials.postgres[:test] %>
13
+
14
+ production:
15
+ <<: *default
16
+ url: <%= ENV['DATABASE_URL'] || Rails.application.credentials.postgres[:pro] %>
@@ -1,5 +1,3 @@
1
- # Load the Rails application.
2
1
  require_relative 'application'
3
2
 
4
- # Initialize the Rails application.
5
3
  Rails.application.initialize!
@@ -1,54 +1,41 @@
1
1
  Rails.application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
2
 
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
3
  config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
4
  config.eager_load = false
11
-
12
- # Show full error reports.
13
5
  config.consider_all_requests_local = true
14
6
 
15
- # Enable/disable caching. By default caching is disabled.
7
+ #config.file_watcher = ActiveSupport::EventedFileUpdateChecker
8
+
9
+ config.hosts += [
10
+ '.lvh.me'
11
+ ]
12
+
16
13
  if Rails.root.join('tmp/caching-dev.txt').exist?
17
14
  config.action_controller.perform_caching = true
18
-
19
- config.cache_store = :memory_store
15
+ config.action_controller.enable_fragment_cache_logging = true
16
+ config.cache_store = :file_store, 'tmp/cache/store'
20
17
  config.public_file_server.headers = {
21
- 'Cache-Control' => 'public, max-age=172800'
18
+ 'Cache-Control' => "public, max-age=#{2.days.to_i}"
22
19
  }
23
20
  else
24
21
  config.action_controller.perform_caching = false
25
-
26
22
  config.cache_store = :null_store
27
23
  end
28
24
 
29
- # Don't care if the mailer can't send.
30
- config.action_mailer.raise_delivery_errors = false
25
+ config.action_mailbox.ingress = :mailgun
31
26
 
27
+ config.action_mailer.raise_delivery_errors = false
32
28
  config.action_mailer.perform_caching = false
33
29
 
34
- # Print deprecation notices to the Rails logger.
35
- config.active_support.deprecation = :log
36
-
37
- # Raise an error on page load if there are pending migrations.
38
30
  config.active_record.migration_error = :page_load
39
31
 
40
- # Debug mode disables concatenation and preprocessing of assets.
41
- # This option may cause significant delays in view rendering with a large
42
- # number of complex assets.
43
- config.assets.debug = true
44
-
45
- # Suppress logger output for asset requests.
46
- config.assets.quiet = true
32
+ config.active_storage.service = :local
47
33
 
48
- # Raises error for missing translations
49
- # config.action_view.raise_on_missing_translations = true
50
-
51
- # Use an evented file watcher to asynchronously detect changes in source code,
52
- # routes, locales, etc. This feature depends on the listen gem.
53
- # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
34
+ config.active_support.deprecation = :log
54
35
  end
36
+
37
+ Rails.application.routes.default_url_options = {
38
+ protocol: 'http',
39
+ host: 'lvh.me',
40
+ port: 3000
41
+ }
@@ -16,19 +16,7 @@ Rails.application.configure do
16
16
 
17
17
  # Disable serving static files from the `/public` folder by default since
18
18
  # Apache or NGINX already handles this.
19
- config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
20
-
21
- # Compress JavaScripts and CSS.
22
- config.assets.js_compressor = :uglifier
23
- # config.assets.css_compressor = :sass
24
-
25
- # Do not fallback to assets pipeline if a precompiled asset is missed.
26
- config.assets.compile = false
27
-
28
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
29
-
30
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
31
- # config.action_controller.asset_host = 'http://assets.example.com'
19
+ config.public_file_server.enabled = ENV.fetch('RAILS_SERVE_STATIC_FILES') { true }
32
20
 
33
21
  # Specifies the header that your server uses for sending files.
34
22
  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
@@ -37,6 +37,11 @@ Rails.application.configure do
37
37
  # Print deprecation notices to the stderr.
38
38
  config.active_support.deprecation = :stderr
39
39
 
40
+ config.active_storage.service = :local_test
41
+
40
42
  # Raises error for missing translations
41
43
  # config.action_view.raise_on_missing_translations = true
42
44
  end
45
+ Rails.application.routes.default_url_options = {
46
+ host: 'localhost:3000'
47
+ }
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
@@ -12,7 +12,3 @@ Rails.application.config.active_record.belongs_to_required_by_default = true
12
12
 
13
13
  # Configure SSL options to enable HSTS with subdomains. Previous versions had false.
14
14
  Rails.application.config.ssl_options = { hsts: { subdomains: true } }
15
-
16
- if defined?(FactoryBot)
17
- FactoryBot.definition_file_paths << RailsLog::Engine.root.join('test/factories')
18
- end
@@ -1,23 +1,2 @@
1
- # Files in the config/locales directory are used for internationalization
2
- # and are automatically loaded by Rails. If you want to use locales other
3
- # than English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t 'hello'
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t('hello') %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # To learn more, please read the Rails Internationalization guide
20
- # available at http://guides.rubyonrails.org/i18n.html.
21
-
22
1
  en:
23
- hello: "Hello world"
2
+ site_name: Rails App
@@ -0,0 +1 @@
1
+ e02c7f0fe029fdfaa1e2ecf15306cf56
@@ -1,47 +1,34 @@
1
- # Puma can serve each request in a thread from an internal thread pool.
2
- # The `threads` method setting takes two numbers a minimum and maximum.
3
- # Any libraries that use thread pools should be configured to match
4
- # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
- # and maximum, this matches the default thread size of Active Record.
6
- #
7
- threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
8
- threads threads_count, threads_count
1
+ max_threads_count = ENV.fetch('RAILS_MAX_THREADS') { 1 }
2
+ min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
3
+ dir = @config.options[:app].root.to_s
9
4
 
10
- # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
11
- #
12
- port ENV.fetch("PORT") { 3000 }
5
+ #workers 1
6
+ threads min_threads_count, max_threads_count
7
+ worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
8
+ port ENV.fetch('PORT') { 3000 }
9
+ environment ENV.fetch('RAILS_ENV') { 'development' }
10
+ pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
13
11
 
14
- # Specifies the `environment` that Puma will run in.
15
- #
16
- environment ENV.fetch("RAILS_ENV") { "development" }
12
+ #state_path "#{File.expand_path('tmp/sockets/puma.state', dir)}"
13
+ #prune_bundler true
14
+ #early_hints true
15
+ #bind "unix://#{File.expand_path('tmp/sockets/puma.sock', dir)}"
16
+ state_path 'tmp/sockets/puma.state'
17
+ activate_control_app "unix://#{File.expand_path('tmp/sockets/pumactl.sock', dir)}"
17
18
 
18
- # Specifies the number of `workers` to boot in clustered mode.
19
- # Workers are forked webserver processes. If using threads and workers together
20
- # the concurrency of the application would be max `threads` * `workers`.
21
- # Workers do not work on JRuby or Windows (both of which do not support
22
- # processes).
23
- #
24
- # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
19
+ before_fork do
20
+ ActiveRecord::Base.connection_pool.disconnect!
21
+ end
22
+ on_worker_boot do
23
+ ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
24
+ end
25
25
 
26
- # Use the `preload_app!` method when specifying a `workers` number.
27
- # This directive tells Puma to first boot the application and load code
28
- # before forking the application. This takes advantage of Copy On Write
29
- # process behavior so workers use less memory. If you use this option
30
- # you need to make sure to reconnect any threads in the `on_worker_boot`
31
- # block.
32
- #
33
- # preload_app!
26
+ on_restart do
27
+ puts "\n-----> On restart"
28
+ puts "env: #{@options[:environment]}"
29
+ puts "pidfile: #{@options[:pidfile]}"
30
+ puts "binds: #{@options[:binds]}"
31
+ puts "control_url: #{@options[:control_url]}"
32
+ end
34
33
 
35
- # The code in the `on_worker_boot` will be called if you are using
36
- # clustered mode by specifying a number of `workers`. After each worker
37
- # process is booted this block will be run, if you are using `preload_app!`
38
- # option you will want to use this block to reconnect to any threads
39
- # or connections that may have been created at application boot, Ruby
40
- # cannot share connections between processes.
41
- #
42
- # on_worker_boot do
43
- # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
44
- # end
45
-
46
- # Allow puma to be restarted by `rails restart` command.
47
34
  plugin :tmp_restart
@@ -1,7 +1,14 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
-
4
3
  root to: 'home#index'
5
-
4
+ namespace :board, defaults: { namespace: 'board' } do
5
+ root 'home#index'
6
+ end
7
+ namespace :panel, defaults: { namespace: 'panel' } do
8
+ root 'home#index'
9
+ end
10
+ namespace :my, defaults: { namespace: 'my' } do
11
+ root 'home#index'
12
+ end
6
13
 
7
14
  end
@@ -0,0 +1,11 @@
1
+ acme:
2
+ service: Disc
3
+ root: <%= Rails.root.join('acme') %>
4
+
5
+ local_test:
6
+ service: Disk
7
+ root: <%= Rails.root.join('tmp/storage_test') %>
8
+
9
+ local:
10
+ service: Disk
11
+ root: <%= Rails.root.join('tmp/storage') %>
@@ -0,0 +1,5 @@
1
+ const { viteConfig } = require('vite_rails')
2
+
3
+ module.exports = {
4
+ ...viteConfig
5
+ }
@@ -0,0 +1,12 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development'
2
+ process.env.RAILS_ENV = process.env.NODE_ENV
3
+
4
+ const viteConfig = require('./base')
5
+
6
+ module.exports = {
7
+ define: {
8
+ 'process.env': {},
9
+ __dirname: {}
10
+ },
11
+ ...viteConfig
12
+ }
@@ -0,0 +1,6 @@
1
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
2
+ process.env.RAILS_ENV = process.env.NODE_ENV
3
+
4
+ const viteConfig = require('./base')
5
+
6
+ module.exports = viteConfig
data/test/dummy/config.ru CHANGED
@@ -3,3 +3,5 @@
3
3
  require_relative 'config/environment'
4
4
 
5
5
  run Rails.application
6
+
7
+ Rails.application.load_server
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+ require 'optparse'
5
+ require 'pathname'
6
+ require 'logger'
7
+
8
+ module Deploy
9
+ MOVED_DIRS = [
10
+ 'log',
11
+ 'tmp',
12
+ 'storage',
13
+ 'node_modules'
14
+ ]
15
+ SHARED_DIRS = [
16
+ 'public/packs',
17
+ 'vendor/bundle'
18
+ ].freeze
19
+ SHARED_FILES = [
20
+ 'config/database.yml',
21
+ 'config/credentials/staging.key',
22
+ 'config/credentials/production.key'
23
+ ].freeze
24
+ INIT_DIRS = [
25
+ 'tmp/sockets',
26
+ 'tmp/pids',
27
+ 'config/credentials'
28
+ ].freeze
29
+ extend self
30
+
31
+ def restart
32
+ exec_cmd('bundle exec pumactl restart')
33
+ end
34
+
35
+ def github_hmac(data)
36
+ OpenSSL::HMAC.hexdigest('sha1', RailsCom.config.github_hmac_key, data)
37
+ end
38
+
39
+ def init(root = Pathname.pwd)
40
+ dirs = []
41
+ shared = root.join('../shared')
42
+ dirs += MOVED_DIRS.map { |dir| shared.join(dir) }
43
+ dirs += SHARED_DIRS.map { |dir| shared.join(dir) }
44
+ dirs += INIT_DIRS.map { |dir| shared.join(dir) }
45
+ FileUtils.mkdir_p dirs
46
+
47
+ SHARED_FILES.map do |path|
48
+ `touch #{shared.join(path)}`
49
+ end
50
+ ln_shared_paths(root)
51
+ end
52
+
53
+ def ln_shared_paths(root = Pathname.pwd)
54
+ cmds = []
55
+ cmds << 'bundle config set --local deployment true'
56
+ cmds << 'bundle config set --local path vendor/bundle'
57
+ cmds << 'bundle config set --local without development test'
58
+ cmds += MOVED_DIRS.map do |path|
59
+ "rm -rf #{root.join(path)}"
60
+ end
61
+ cmds += (MOVED_DIRS + SHARED_DIRS).map do |path|
62
+ "ln -Tsfv #{root.join('../shared', path)} #{root.join(path)}"
63
+ end
64
+ cmds += SHARED_FILES.map do |path|
65
+ "ln -Tsfv #{root.join('../shared', path)} #{root.join(path)}"
66
+ end
67
+ cmds.each do |cmd|
68
+ exec_cmd(cmd)
69
+ end
70
+ end
71
+
72
+ def exec_cmds(env, added_cmds: [], **options)
73
+ cmds = []
74
+ cmds << 'git pull'
75
+ cmds << 'bundle install'
76
+ cmds << "RAILS_ENV=#{env} bundle exec rake db:migrate"
77
+ cmds << 'bundle exec pumactl restart'
78
+ cmds += Array(added_cmds)
79
+ cmds.each do |cmd|
80
+ exec_cmd(cmd)
81
+ end
82
+ end
83
+
84
+ def exec_cmd(cmd)
85
+ Open3.popen2e(cmd) do |_, output, thread|
86
+ logger.debug "=====> #{cmd} (PID: #{thread.pid})"
87
+ output.each_line do |line|
88
+ logger.debug line
89
+ end
90
+ end
91
+ end
92
+
93
+ def logger
94
+ if defined? Rails
95
+ Rails.logger
96
+ else
97
+ Logger.new $stdout
98
+ end
99
+ end
100
+
101
+ end
102
+
103
+ options = { env: 'production' }
104
+ OptionParser.new do |opts|
105
+ opts.on('-e ENV') do |v|
106
+ options[:env] = v
107
+ end
108
+ opts.on('-C') do |v|
109
+ puts "--------->#{v}"
110
+ end
111
+ end.parse!
112
+
113
+ if $0 == __FILE__
114
+ Deploy.exec_cmds(options[:env], added_cmds: 'systemctl --user restart sidekiq_dummy')
115
+ end
@@ -1,6 +1,27 @@
1
1
  {
2
+ "name": "dummy",
3
+ "private": true,
2
4
  "dependencies": {
3
- "jquery": "^3.3.1",
4
- "yigexiangfa_ui": "https://github.com/yigexiangfa/yigexiangfa.github.io.git"
5
+ "@fortawesome/fontawesome-free": "^5.14.0",
6
+ "@rails/actioncable": "^6.1.4",
7
+ "@rails/activestorage": "^6.1.4",
8
+ "bulma": "^0.9.2",
9
+ "choices.js": "^9.0.1",
10
+ "core-js": "^3.6.5",
11
+ "cssnano": "^4.1.10",
12
+ "moment": "^2.27.0",
13
+ "sortablejs": "^1.10.2",
14
+ "stickybits": "^3.7.7",
15
+ "vite_rails": "^0.0.2",
16
+ "vue": "^3.1.5",
17
+ "weui": "^2.4.4",
18
+ "weui.js": "^1.2.2"
19
+ },
20
+ "devDependencies": {
21
+ "@vitejs/plugin-vue": "^1.4.0",
22
+ "@vue/compiler-sfc": "^3.1.5",
23
+ "postcss-import": "^14.0.2",
24
+ "postcss-preset-env": "^6.7.0",
25
+ "sass": "^1.30.0"
5
26
  }
6
27
  }
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ plugins: [
3
+ require('postcss-import'),
4
+ require('postcss-preset-env')({
5
+ autoprefixer: {
6
+ flexbox: 'no-2009'
7
+ },
8
+ stage: 3
9
+ })
10
+ ]
11
+ }