bulldozer 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +12 -0
  5. data/CONTRIBUTING.md +59 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +638 -0
  9. data/README.md +225 -0
  10. data/RELEASING.md +18 -0
  11. data/Rakefile +8 -0
  12. data/USAGE +13 -0
  13. data/bin/bulldozer +23 -0
  14. data/bin/rake +16 -0
  15. data/bin/rspec +16 -0
  16. data/bin/setup +13 -0
  17. data/bulldozer.gemspec +35 -0
  18. data/docker-compose.yml +8 -0
  19. data/dockerfile +11 -0
  20. data/lib/bulldozer.rb +24 -0
  21. data/lib/bulldozer/actions.rb +85 -0
  22. data/lib/bulldozer/adapters/heroku.rb +123 -0
  23. data/lib/bulldozer/app_builder.rb +321 -0
  24. data/lib/bulldozer/generators/analytics_generator.rb +24 -0
  25. data/lib/bulldozer/generators/app_generator.rb +231 -0
  26. data/lib/bulldozer/generators/base.rb +20 -0
  27. data/lib/bulldozer/generators/ci_generator.rb +22 -0
  28. data/lib/bulldozer/generators/db_optimizations_generator.rb +30 -0
  29. data/lib/bulldozer/generators/factories_generator.rb +22 -0
  30. data/lib/bulldozer/generators/forms_generator.rb +18 -0
  31. data/lib/bulldozer/generators/jobs_generator.rb +38 -0
  32. data/lib/bulldozer/generators/js_driver_generator.rb +15 -0
  33. data/lib/bulldozer/generators/json_generator.rb +10 -0
  34. data/lib/bulldozer/generators/lint_generator.rb +9 -0
  35. data/lib/bulldozer/generators/production/deployment_generator.rb +27 -0
  36. data/lib/bulldozer/generators/production/email_generator.rb +37 -0
  37. data/lib/bulldozer/generators/production/force_tls_generator.rb +11 -0
  38. data/lib/bulldozer/generators/production/manifest_generator.rb +24 -0
  39. data/lib/bulldozer/generators/production/timeout_generator.rb +21 -0
  40. data/lib/bulldozer/generators/staging/pull_requests_generator.rb +33 -0
  41. data/lib/bulldozer/generators/static_generator.rb +10 -0
  42. data/lib/bulldozer/generators/stylesheet_base_generator.rb +31 -0
  43. data/lib/bulldozer/generators/testing_generator.rb +55 -0
  44. data/lib/bulldozer/generators/views_generator.rb +30 -0
  45. data/lib/bulldozer/version.rb +8 -0
  46. data/spec/adapters/heroku_spec.rb +72 -0
  47. data/spec/fakes/bin/heroku +5 -0
  48. data/spec/fakes/bin/hub +5 -0
  49. data/spec/features/api_spec.rb +18 -0
  50. data/spec/features/cli_help_spec.rb +36 -0
  51. data/spec/features/github_spec.rb +16 -0
  52. data/spec/features/heroku_spec.rb +71 -0
  53. data/spec/features/json_spec.rb +15 -0
  54. data/spec/features/new_project_spec.rb +341 -0
  55. data/spec/features/production/deployment_spec.rb +22 -0
  56. data/spec/features/production/email_spec.rb +47 -0
  57. data/spec/features/production/manifest_spec.rb +35 -0
  58. data/spec/features/staging/pull_requests_spec.rb +22 -0
  59. data/spec/spec_helper.rb +21 -0
  60. data/spec/support/be_executable_matcher.rb +7 -0
  61. data/spec/support/bulldozer.rb +182 -0
  62. data/spec/support/contain_json_matcher.rb +24 -0
  63. data/spec/support/exist_as_a_file_matcher.rb +7 -0
  64. data/spec/support/fake_github.rb +21 -0
  65. data/spec/support/fake_heroku.rb +53 -0
  66. data/spec/support/generators.rb +5 -0
  67. data/spec/support/match_contents_matcher.rb +6 -0
  68. data/spec/support/project_files.rb +13 -0
  69. data/templates/Gemfile.erb +51 -0
  70. data/templates/Procfile +2 -0
  71. data/templates/README.md.erb +28 -0
  72. data/templates/_analytics.html.erb +8 -0
  73. data/templates/_css_overrides.html.erb +7 -0
  74. data/templates/_flashes.html.erb +7 -0
  75. data/templates/_javascript.html.erb +3 -0
  76. data/templates/action_mailer.rb +5 -0
  77. data/templates/active_job.rb +13 -0
  78. data/templates/application.scss +8 -0
  79. data/templates/bin_deploy +12 -0
  80. data/templates/bin_setup +28 -0
  81. data/templates/bin_setup_review_app.erb +22 -0
  82. data/templates/browserslist +3 -0
  83. data/templates/bulldozer_gitignore +18 -0
  84. data/templates/bulldozer_layout.html.erb.erb +21 -0
  85. data/templates/bundler_audit.rake +4 -0
  86. data/templates/chromedriver.rb +17 -0
  87. data/templates/circle.yml.erb +6 -0
  88. data/templates/config_locales_en.yml.erb +19 -0
  89. data/templates/dev.rake +12 -0
  90. data/templates/dotfiles/.ctags +2 -0
  91. data/templates/dotfiles/.env +13 -0
  92. data/templates/email.rb +3 -0
  93. data/templates/errors.rb +34 -0
  94. data/templates/factories.rb +2 -0
  95. data/templates/factory_bot_rspec.rb +5 -0
  96. data/templates/flashes_helper.rb +5 -0
  97. data/templates/hound.yml +14 -0
  98. data/templates/i18n.rb +3 -0
  99. data/templates/json_encoding.rb +1 -0
  100. data/templates/postgresql_database.yml.erb +19 -0
  101. data/templates/puma.rb +28 -0
  102. data/templates/rack_mini_profiler.rb +5 -0
  103. data/templates/rails_helper.rb +22 -0
  104. data/templates/secrets.yml +8 -0
  105. data/templates/shoulda_matchers_config_rspec.rb +6 -0
  106. data/templates/smtp.rb +9 -0
  107. data/templates/spec_helper.rb +28 -0
  108. metadata +197 -0
@@ -0,0 +1,8 @@
1
+ <% if ENV["SEGMENT_KEY"] %>
2
+ <script type="text/javascript">
3
+ !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
4
+ analytics.load("<%= ENV["SEGMENT_KEY"] %>");
5
+ analytics.page();
6
+ }}();
7
+ </script>
8
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if Rails.env.test? %>
2
+ <style type="text/css">
3
+ * {
4
+ transition-property: none !important;
5
+ }
6
+ </style>
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <% if flash.any? %>
2
+ <div class="flashes">
3
+ <% user_facing_flashes.each do |key, value| -%>
4
+ <div class="flash-<%= key %>"><%= value %></div>
5
+ <% end -%>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= javascript_include_tag :application %>
2
+
3
+ <%= yield :javascript %>
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do
3
+ ActionMailer::Base.deliveries.clear
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ require "active_job/logging"
2
+
3
+ ActiveSupport::Notifications.unsubscribe("enqueue.active_job")
4
+
5
+ module ActiveJob
6
+ module Logging
7
+ class EnqueueLogSubscriber < LogSubscriber
8
+ define_method :enqueue, instance_method(:enqueue)
9
+ end
10
+ end
11
+ end
12
+
13
+ ActiveJob::Logging::EnqueueLogSubscriber.attach_to(:active_job)
@@ -0,0 +1,8 @@
1
+ @charset "utf-8";
2
+
3
+ @import "normalize.css/normalize";
4
+
5
+ @import "bourbon";
6
+ @import "neat";
7
+
8
+ @import "base/base";
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ # Run this script to deploy the app to Heroku.
4
+
5
+ set -e
6
+
7
+ branch="$(git symbolic-ref HEAD --short)"
8
+ target="${1:-staging}"
9
+
10
+ git push "$target" "$branch:master"
11
+ heroku run rails db:migrate --exit-code --remote "$target"
12
+ heroku restart --remote "$target"
@@ -0,0 +1,28 @@
1
+ #!/bin/sh
2
+
3
+ # Set up Rails app. Run this script immediately after cloning the codebase.
4
+ # https://github.com/SeasonedSoftware/guides/tree/master/protocol
5
+
6
+ # Exit if any subcommand fails
7
+ set -e
8
+
9
+ # Set up Ruby dependencies via Bundler
10
+ gem install bundler --conservative
11
+ bundle check || bundle install
12
+
13
+ # Install JavaScript dependencies
14
+ bin/yarn
15
+
16
+ # Set up database and add any development seed data
17
+ bin/rails dev:prime
18
+
19
+ if [ ! -d .git/safe ] && echo $PATH | grep .git/safe > /dev/null; then
20
+ echo "-----------------------------------------------------------------------"
21
+ echo
22
+ echo "-> When you trust this repo, remember to run: mkdir -p .git/safe"
23
+ echo
24
+ fi
25
+
26
+ # Only if this isn't CI
27
+ # if [ -z "$CI" ]; then
28
+ # fi
@@ -0,0 +1,22 @@
1
+ #!/bin/sh
2
+
3
+ # Run this script to set up a review app's database and worker dyno
4
+
5
+ set -e
6
+
7
+ if [ -z "$1" ]; then
8
+ printf "You must provide a review app (same as the pull request) id.\n"
9
+ exit 64
10
+ fi
11
+
12
+ PARENT_APP_NAME=<%= app_name.dasherize %>-staging
13
+ APP_NAME=<%= app_name.dasherize %>-staging-pr-$1
14
+
15
+ heroku pg:backups:capture --app $PARENT_APP_NAME
16
+
17
+ URL=`heroku pg:backups public-url --app $PARENT_APP_NAME`
18
+
19
+ heroku pg:backups restore $URL DATABASE_URL --confirm $APP_NAME --app $APP_NAME
20
+ heroku run rails db:migrate --exit-code --app $APP_NAME
21
+ heroku ps:scale worker=1 --app $APP_NAME
22
+ heroku restart --app $APP_NAME
@@ -0,0 +1,3 @@
1
+ Last 2 versions
2
+ Explorer >= 11
3
+ Android >= 4.4
@@ -0,0 +1,18 @@
1
+ !.keep
2
+ *.DS_Store
3
+ *.swo
4
+ *.swp
5
+ .byebug_history
6
+ /.bundle
7
+ /.env.local
8
+ /coverage/*
9
+ /db/*.sqlite3
10
+ /db/*.sqlite3-journal
11
+ /log/*
12
+ /node_modules
13
+ /public/assets
14
+ /public/packs
15
+ /public/system
16
+ /tags
17
+ /tmp/*
18
+ /yarn-error.log
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="<%= I18n.locale %>">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
6
+ <%%#
7
+ Configure default and controller-, and view-specific titles in
8
+ config/locales/en.yml. For more see:
9
+ https://github.com/calebthompson/title#usage
10
+ %>
11
+ <title><%%= title %></title>
12
+ <%%= stylesheet_link_tag :application, media: "all" %>
13
+ <%%= csrf_meta_tags %>
14
+ </head>
15
+ <body>
16
+ <%%= render "flashes" -%>
17
+ <%%= yield %>
18
+ <%%= render "javascript" %>
19
+ <%%= render "css_overrides" %>
20
+ </body>
21
+ </html>
@@ -0,0 +1,4 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "bundler/audit/task"
3
+ Bundler::Audit::Task.new
4
+ end
@@ -0,0 +1,17 @@
1
+ require "selenium/webdriver"
2
+
3
+ Capybara.register_driver :chrome do |app|
4
+ Capybara::Selenium::Driver.new(app, browser: :chrome)
5
+ end
6
+
7
+ Capybara.register_driver :headless_chrome do |app|
8
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
9
+ chromeOptions: { args: %w(headless disable-gpu) },
10
+ )
11
+
12
+ Capybara::Selenium::Driver.new app,
13
+ browser: :chrome,
14
+ desired_capabilities: capabilities
15
+ end
16
+
17
+ Capybara.javascript_driver = :headless_chrome
@@ -0,0 +1,6 @@
1
+ database:
2
+ override:
3
+ - RAILS_ENV=development bin/setup
4
+ test:
5
+ override:
6
+ - COVERAGE=true bin/rake
@@ -0,0 +1,19 @@
1
+ en:
2
+ date:
3
+ formats:
4
+ default:
5
+ "%m/%d/%Y"
6
+ with_weekday:
7
+ "%a %m/%d/%y"
8
+
9
+ time:
10
+ formats:
11
+ default:
12
+ "%a, %b %-d, %Y at %r"
13
+ date:
14
+ "%b %-d, %Y"
15
+ short:
16
+ "%B %d"
17
+
18
+ titles:
19
+ application: <%= app_name.humanize %>
@@ -0,0 +1,12 @@
1
+ if Rails.env.development? || Rails.env.test?
2
+ require "factory_bot"
3
+
4
+ namespace :dev do
5
+ desc "Sample data for local development environment"
6
+ task prime: "db:setup" do
7
+ include FactoryBot::Syntax::Methods
8
+
9
+ # create(:user, email: "user@example.com", password: "password")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ --recurse=yes
2
+ --exclude=vendor
@@ -0,0 +1,13 @@
1
+ # https://github.com/ddollar/forego
2
+ ASSET_HOST=localhost:3000
3
+ APPLICATION_HOST=localhost:3000
4
+ PORT=3000
5
+ RACK_ENV=development
6
+ RACK_MINI_PROFILER=0
7
+ SECRET_KEY_BASE=development_secret
8
+ EXECJS_RUNTIME=Node
9
+ SMTP_ADDRESS=smtp.example.com
10
+ SMTP_DOMAIN=example.com
11
+ SMTP_PASSWORD=password
12
+ SMTP_USERNAME=username
13
+ WEB_CONCURRENCY=1
@@ -0,0 +1,3 @@
1
+ if ENV["EMAIL_RECIPIENTS"].present?
2
+ Mail.register_interceptor RecipientInterceptor.new(ENV["EMAIL_RECIPIENTS"])
3
+ end
@@ -0,0 +1,34 @@
1
+ require "net/http"
2
+ require "net/smtp"
3
+
4
+ # Example:
5
+ # begin
6
+ # some http call
7
+ # rescue *HTTP_ERRORS => error
8
+ # notify_hoptoad error
9
+ # end
10
+
11
+ HTTP_ERRORS = [
12
+ EOFError,
13
+ Errno::ECONNRESET,
14
+ Errno::EINVAL,
15
+ Net::HTTPBadResponse,
16
+ Net::HTTPHeaderSyntaxError,
17
+ Net::ProtocolError,
18
+ Timeout::Error,
19
+ ]
20
+
21
+ SMTP_SERVER_ERRORS = [
22
+ IOError,
23
+ Net::SMTPAuthenticationError,
24
+ Net::SMTPServerBusy,
25
+ Net::SMTPUnknownError,
26
+ Timeout::Error,
27
+ ]
28
+
29
+ SMTP_CLIENT_ERRORS = [
30
+ Net::SMTPFatalError,
31
+ Net::SMTPSyntaxError,
32
+ ]
33
+
34
+ SMTP_ERRORS = SMTP_SERVER_ERRORS + SMTP_CLIENT_ERRORS
@@ -0,0 +1,2 @@
1
+ FactoryBot.define do
2
+ end
@@ -0,0 +1,5 @@
1
+ FactoryBot.use_parent_strategy = true
2
+
3
+ RSpec.configure do |config|
4
+ config.include FactoryBot::Syntax::Methods
5
+ end
@@ -0,0 +1,5 @@
1
+ module FlashesHelper
2
+ def user_facing_flashes
3
+ flash.to_hash.slice("alert", "error", "notice", "success")
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ # See https://houndci.com/configuration for help.
2
+ haml:
3
+ # config_file: .haml-style.yml
4
+ enabled: true
5
+ javascript:
6
+ # config_file: .javascript-style.json
7
+ enabled: true
8
+ # ignore_file: .javascript_ignore
9
+ ruby:
10
+ # config_file: .ruby-style.yml
11
+ enabled: true
12
+ scss:
13
+ # config_file: .scss-style.yml
14
+ enabled: true
data/templates/i18n.rb ADDED
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include ActionView::Helpers::TranslationHelper
3
+ end
@@ -0,0 +1 @@
1
+ ActiveSupport::JSON::Encoding.time_precision = 0
@@ -0,0 +1,19 @@
1
+ development: &default
2
+ adapter: postgresql
3
+ database: <%= app_name %>_development
4
+ encoding: utf8
5
+ min_messages: warning
6
+ pool: <%%= Integer(ENV.fetch("DB_POOL", 5)) %>
7
+ reaping_frequency: <%%= Integer(ENV.fetch("DB_REAPING_FREQUENCY", 10)) %>
8
+ timeout: 5000
9
+
10
+ test:
11
+ <<: *default
12
+ database: <%= app_name %>_test
13
+
14
+ production: &deploy
15
+ encoding: utf8
16
+ min_messages: warning
17
+ pool: <%%= [Integer(ENV.fetch("MAX_THREADS", 5)), Integer(ENV.fetch("DB_POOL", 5))].max %>
18
+ timeout: 5000
19
+ url: <%%= ENV.fetch("DATABASE_URL", "") %>
data/templates/puma.rb ADDED
@@ -0,0 +1,28 @@
1
+ # https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server
2
+
3
+ # The environment variable WEB_CONCURRENCY may be set to a default value based
4
+ # on dyno size. To manually configure this value use heroku config:set
5
+ # WEB_CONCURRENCY.
6
+ #
7
+ # Increasing the number of workers will increase the amount of resting memory
8
+ # your dynos use. Increasing the number of threads will increase the amount of
9
+ # potential bloat added to your dynos when they are responding to heavy
10
+ # requests.
11
+ #
12
+ # Starting with a low number of workers and threads provides adequate
13
+ # performance for most applications, even under load, while maintaining a low
14
+ # risk of overusing memory.
15
+ workers Integer(ENV.fetch("WEB_CONCURRENCY", 2))
16
+ threads_count = Integer(ENV.fetch("MAX_THREADS", 2))
17
+ threads(threads_count, threads_count)
18
+
19
+ preload_app!
20
+
21
+ rackup DefaultRackup
22
+ environment ENV.fetch("RACK_ENV", "development")
23
+
24
+ on_worker_boot do
25
+ # Worker specific setup for Rails 4.1+
26
+ # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
27
+ ActiveRecord::Base.establish_connection
28
+ end
@@ -0,0 +1,5 @@
1
+ if ENV["RACK_MINI_PROFILER"].to_i > 0
2
+ require "rack-mini-profiler"
3
+
4
+ Rack::MiniProfilerRails.initialize!(Rails.application)
5
+ end
@@ -0,0 +1,22 @@
1
+ ENV["RACK_ENV"] = "test"
2
+
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ abort("DATABASE_URL environment variable is set") if ENV["DATABASE_URL"]
5
+
6
+ require "rspec/rails"
7
+
8
+ Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |file| require file }
9
+
10
+ module Features
11
+ # Extend this module in spec/support/features/*.rb
12
+ include Formulaic::Dsl
13
+ end
14
+
15
+ RSpec.configure do |config|
16
+ config.include Features, type: :feature
17
+ config.infer_base_class_for_anonymous_controllers = false
18
+ config.infer_spec_type_from_file_location!
19
+ config.use_transactional_fixtures = true
20
+ end
21
+
22
+ ActiveRecord::Migration.maintain_test_schema!
@@ -0,0 +1,8 @@
1
+ shared:
2
+ secret_key_base: <%%= ENV["SECRET_KEY_BASE"] %>
3
+
4
+ development:
5
+
6
+ test:
7
+
8
+ production: