fiver 0.0alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.browserslistrc +1 -0
  3. data/.gitignore +57 -0
  4. data/.orchestration.yml +4 -0
  5. data/.rspec +3 -0
  6. data/.rspec_status +18 -0
  7. data/.rubocop.yml +10 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +6 -0
  10. data/Gemfile +36 -0
  11. data/Gemfile.lock +292 -0
  12. data/LICENSE +7 -0
  13. data/LICENSE.txt +21 -0
  14. data/Makefile +27 -0
  15. data/README.md +11 -0
  16. data/Rakefile +8 -0
  17. data/app/assets/config/manifest.js +2 -0
  18. data/app/assets/images/.keep +0 -0
  19. data/app/assets/stylesheets/application.css +15 -0
  20. data/app/channels/application_cable/channel.rb +6 -0
  21. data/app/channels/application_cable/connection.rb +6 -0
  22. data/app/controllers/application_controller.rb +4 -0
  23. data/app/controllers/concerns/.keep +0 -0
  24. data/app/helpers/application_helper.rb +5 -0
  25. data/app/javascript/channels/consumer.js +6 -0
  26. data/app/javascript/channels/index.js +5 -0
  27. data/app/javascript/packs/application.js +17 -0
  28. data/app/javascript/packs/hello_react.jsx +26 -0
  29. data/app/jobs/application_job.rb +9 -0
  30. data/app/mailers/application_mailer.rb +6 -0
  31. data/app/models/application_record.rb +6 -0
  32. data/app/models/concerns/.keep +0 -0
  33. data/app/views/layouts/application.html.erb +15 -0
  34. data/app/views/layouts/mailer.html.erb +13 -0
  35. data/app/views/layouts/mailer.text.erb +1 -0
  36. data/babel.config.js +87 -0
  37. data/bin/bundle +114 -0
  38. data/bin/console +14 -0
  39. data/bin/rails +9 -0
  40. data/bin/rake +9 -0
  41. data/bin/setup +8 -0
  42. data/bin/spring +17 -0
  43. data/bin/webpack +18 -0
  44. data/bin/webpack-dev-server +18 -0
  45. data/bin/yarn +11 -0
  46. data/config.ru +7 -0
  47. data/config/application.rb +18 -0
  48. data/config/boot.rb +6 -0
  49. data/config/cable.yml +10 -0
  50. data/config/credentials.yml.enc +1 -0
  51. data/config/database.yml +25 -0
  52. data/config/environment.rb +7 -0
  53. data/config/environments/development.rb +64 -0
  54. data/config/environments/production.rb +114 -0
  55. data/config/environments/test.rb +52 -0
  56. data/config/initializers/application_controller_renderer.rb +9 -0
  57. data/config/initializers/assets.rb +16 -0
  58. data/config/initializers/backtrace_silencers.rb +8 -0
  59. data/config/initializers/content_security_policy.rb +31 -0
  60. data/config/initializers/cookies_serializer.rb +7 -0
  61. data/config/initializers/filter_parameter_logging.rb +6 -0
  62. data/config/initializers/inflections.rb +17 -0
  63. data/config/initializers/mime_types.rb +5 -0
  64. data/config/initializers/wrap_parameters.rb +16 -0
  65. data/config/locales/en.yml +33 -0
  66. data/config/puma.rb +40 -0
  67. data/config/rabbitmq.yml +8 -0
  68. data/config/routes.rb +5 -0
  69. data/config/spring.rb +8 -0
  70. data/config/storage.yml +34 -0
  71. data/config/unicorn.rb +19 -0
  72. data/config/webpack/development.js +5 -0
  73. data/config/webpack/environment.js +3 -0
  74. data/config/webpack/production.js +5 -0
  75. data/config/webpack/test.js +5 -0
  76. data/config/webpacker.yml +97 -0
  77. data/db/schema.rb +15 -0
  78. data/db/seeds.rb +8 -0
  79. data/fiver.gemspec +26 -0
  80. data/lib/assets/.keep +0 -0
  81. data/lib/fiver.rb +12 -0
  82. data/lib/fiver/version.rb +5 -0
  83. data/lib/tasks/.keep +0 -0
  84. data/log/.keep +0 -0
  85. data/orchestration/Dockerfile +34 -0
  86. data/orchestration/Makefile +511 -0
  87. data/orchestration/docker-compose.development.yml +14 -0
  88. data/orchestration/docker-compose.production.yml +33 -0
  89. data/orchestration/docker-compose.test.yml +14 -0
  90. data/orchestration/entrypoint.sh +17 -0
  91. data/package.json +20 -0
  92. data/postcss.config.js +12 -0
  93. data/public/404.html +67 -0
  94. data/public/422.html +67 -0
  95. data/public/500.html +66 -0
  96. data/public/apple-touch-icon-precomposed.png +0 -0
  97. data/public/apple-touch-icon.png +0 -0
  98. data/public/favicon.ico +0 -0
  99. data/public/robots.txt +1 -0
  100. data/storage/.keep +0 -0
  101. data/tmp/.keep +0 -0
  102. data/tmp/pids/.keep +0 -0
  103. data/vendor/.keep +0 -0
  104. data/yarn.lock +7696 -0
  105. metadata +148 -0
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2021 Robert Farrell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Bob Farrell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,27 @@
1
+ include orchestration/Makefile
2
+ #
3
+ # Example test command
4
+ #
5
+ # This command will call `test-setup` before running your usual test pipeline.
6
+ #
7
+ # `test-setup` starts all containers specified in `docker-compose.test.yml`,
8
+ # waits for them to be ready, and runs DB migrations.
9
+ #
10
+ # In your CI environment, simply run `make test`.
11
+ #
12
+ .PHONY: test
13
+ test: test-setup
14
+ bundle exec rspec
15
+ bundle exec rubocop
16
+ bundle exec strong_versions
17
+ bundle exec brakeman
18
+
19
+ # Start development containers and create/migrate/seed database
20
+ .PHONY: develop
21
+ develop:
22
+ bundle install
23
+ @$(MAKE) start env=test
24
+ @$(MAKE) start env=development
25
+ bundle exec rake db:create
26
+ bundle exec rake db:migrate
27
+ bundle exec rake db:seed
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Fiver
2
+
3
+ Dashboard and management console for [ActiveJob](https://guides.rubyonrails.org/active_job_basics.html)'s [`:advanced_sneakers` adapter](https://github.com/veeqo/advanced-sneakers-activejob) (built on top of [Sneakers](https://github.com/jondot/sneakers)).
4
+
5
+ Run as a standalone application using a pre-built _Docker_ image or mount as a _Rails_ engine inside your application.
6
+
7
+ Your _RabbitMQ_ instance *must* have the [`management` plugin](https://www.rabbitmq.com/management.html) enabled.
8
+
9
+ ## License
10
+
11
+ [MIT License](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative 'config/application'
7
+
8
+ Rails.application.load_tasks
@@ -0,0 +1,2 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
File without changes
@@ -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,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Channel < ActionCable::Channel::Base
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationCable
4
+ class Connection < ActionCable::Connection::Base
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Base helper for all views.
4
+ module ApplicationHelper
5
+ end
@@ -0,0 +1,6 @@
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
+
6
+ export default createConsumer()
@@ -0,0 +1,5 @@
1
+ // Load all the channels within this directory and all subdirectories.
2
+ // Channel files must be named *_channel.js.
3
+
4
+ const channels = require.context('.', true, /_channel\.js$/)
5
+ channels.keys().forEach(channels)
@@ -0,0 +1,17 @@
1
+ // This file is automatically compiled by Webpack, along with any other files
2
+ // present in this directory. You're encouraged to place your actual application logic in
3
+ // a relevant structure within app/javascript and only use these pack files to reference
4
+ // that code so it'll be compiled.
5
+
6
+ require("@rails/ujs").start()
7
+ require("turbolinks").start()
8
+ require("@rails/activestorage").start()
9
+ require("channels")
10
+
11
+
12
+ // Uncomment to copy all static images under ../images to the output folder and reference
13
+ // them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
14
+ // or the `imagePath` JavaScript helper below.
15
+ //
16
+ // const images = require.context('../images', true)
17
+ // const imagePath = (name) => images(name, true)
@@ -0,0 +1,26 @@
1
+ // Run this example by adding <%= javascript_pack_tag 'hello_react' %> to the head of your layout file,
2
+ // like app/views/layouts/application.html.erb. All it does is render <div>Hello React</div> at the bottom
3
+ // of the page.
4
+
5
+ import React from 'react'
6
+ import ReactDOM from 'react-dom'
7
+ import PropTypes from 'prop-types'
8
+
9
+ const Hello = props => (
10
+ <div>Hello {props.name}!</div>
11
+ )
12
+
13
+ Hello.defaultProps = {
14
+ name: 'David'
15
+ }
16
+
17
+ Hello.propTypes = {
18
+ name: PropTypes.string
19
+ }
20
+
21
+ document.addEventListener('DOMContentLoaded', () => {
22
+ ReactDOM.render(
23
+ <Hello name="React" />,
24
+ document.body.appendChild(document.createElement('div')),
25
+ )
26
+ })
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationJob < ActiveJob::Base
4
+ # Automatically retry jobs that encountered a deadlock
5
+ # retry_on ActiveRecord::Deadlocked
6
+
7
+ # Most jobs are safe to ignore if the underlying records are no longer available
8
+ # discard_on ActiveJob::DeserializationError
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Base ActiveRecord model class.
4
+ class ApplicationRecord < ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
File without changes
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Fiver</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
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 @@
1
+ <%= yield %>
data/babel.config.js ADDED
@@ -0,0 +1,87 @@
1
+ module.exports = function(api) {
2
+ var validEnv = ['development', 'test', 'production']
3
+ var currentEnv = api.env()
4
+ var isDevelopmentEnv = api.env('development')
5
+ var isProductionEnv = api.env('production')
6
+ var isTestEnv = api.env('test')
7
+
8
+ if (!validEnv.includes(currentEnv)) {
9
+ throw new Error(
10
+ 'Please specify a valid `NODE_ENV` or ' +
11
+ '`BABEL_ENV` environment variables. Valid values are "development", ' +
12
+ '"test", and "production". Instead, received: ' +
13
+ JSON.stringify(currentEnv) +
14
+ '.'
15
+ )
16
+ }
17
+
18
+ return {
19
+ presets: [
20
+ isTestEnv && [
21
+ '@babel/preset-env',
22
+ {
23
+ targets: {
24
+ node: 'current'
25
+ },
26
+ modules: 'commonjs'
27
+ },
28
+ '@babel/preset-react'
29
+ ],
30
+ (isProductionEnv || isDevelopmentEnv) && [
31
+ '@babel/preset-env',
32
+ {
33
+ forceAllTransforms: true,
34
+ useBuiltIns: 'entry',
35
+ corejs: 3,
36
+ modules: false,
37
+ exclude: ['transform-typeof-symbol']
38
+ }
39
+ ],
40
+ [
41
+ '@babel/preset-react',
42
+ {
43
+ development: isDevelopmentEnv || isTestEnv,
44
+ useBuiltIns: true
45
+ }
46
+ ]
47
+ ].filter(Boolean),
48
+ plugins: [
49
+ 'babel-plugin-macros',
50
+ '@babel/plugin-syntax-dynamic-import',
51
+ isTestEnv && 'babel-plugin-dynamic-import-node',
52
+ '@babel/plugin-transform-destructuring',
53
+ [
54
+ '@babel/plugin-proposal-class-properties',
55
+ {
56
+ loose: true
57
+ }
58
+ ],
59
+ [
60
+ '@babel/plugin-proposal-object-rest-spread',
61
+ {
62
+ useBuiltIns: true
63
+ }
64
+ ],
65
+ [
66
+ '@babel/plugin-transform-runtime',
67
+ {
68
+ helpers: false,
69
+ regenerator: true,
70
+ corejs: false
71
+ }
72
+ ],
73
+ [
74
+ '@babel/plugin-transform-regenerator',
75
+ {
76
+ async: false
77
+ }
78
+ ],
79
+ isProductionEnv && [
80
+ 'babel-plugin-transform-react-remove-prop-types',
81
+ {
82
+ removeImport: true
83
+ }
84
+ ]
85
+ ].filter(Boolean)
86
+ }
87
+ }
data/bin/bundle ADDED
@@ -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 do
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 do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
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
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end