bulldozer 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/CONTRIBUTING.md +59 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/NEWS.md +638 -0
- data/README.md +225 -0
- data/RELEASING.md +18 -0
- data/Rakefile +8 -0
- data/USAGE +13 -0
- data/bin/bulldozer +23 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +13 -0
- data/bulldozer.gemspec +35 -0
- data/docker-compose.yml +8 -0
- data/dockerfile +11 -0
- data/lib/bulldozer.rb +24 -0
- data/lib/bulldozer/actions.rb +85 -0
- data/lib/bulldozer/adapters/heroku.rb +123 -0
- data/lib/bulldozer/app_builder.rb +321 -0
- data/lib/bulldozer/generators/analytics_generator.rb +24 -0
- data/lib/bulldozer/generators/app_generator.rb +231 -0
- data/lib/bulldozer/generators/base.rb +20 -0
- data/lib/bulldozer/generators/ci_generator.rb +22 -0
- data/lib/bulldozer/generators/db_optimizations_generator.rb +30 -0
- data/lib/bulldozer/generators/factories_generator.rb +22 -0
- data/lib/bulldozer/generators/forms_generator.rb +18 -0
- data/lib/bulldozer/generators/jobs_generator.rb +38 -0
- data/lib/bulldozer/generators/js_driver_generator.rb +15 -0
- data/lib/bulldozer/generators/json_generator.rb +10 -0
- data/lib/bulldozer/generators/lint_generator.rb +9 -0
- data/lib/bulldozer/generators/production/deployment_generator.rb +27 -0
- data/lib/bulldozer/generators/production/email_generator.rb +37 -0
- data/lib/bulldozer/generators/production/force_tls_generator.rb +11 -0
- data/lib/bulldozer/generators/production/manifest_generator.rb +24 -0
- data/lib/bulldozer/generators/production/timeout_generator.rb +21 -0
- data/lib/bulldozer/generators/staging/pull_requests_generator.rb +33 -0
- data/lib/bulldozer/generators/static_generator.rb +10 -0
- data/lib/bulldozer/generators/stylesheet_base_generator.rb +31 -0
- data/lib/bulldozer/generators/testing_generator.rb +55 -0
- data/lib/bulldozer/generators/views_generator.rb +30 -0
- data/lib/bulldozer/version.rb +8 -0
- data/spec/adapters/heroku_spec.rb +72 -0
- data/spec/fakes/bin/heroku +5 -0
- data/spec/fakes/bin/hub +5 -0
- data/spec/features/api_spec.rb +18 -0
- data/spec/features/cli_help_spec.rb +36 -0
- data/spec/features/github_spec.rb +16 -0
- data/spec/features/heroku_spec.rb +71 -0
- data/spec/features/json_spec.rb +15 -0
- data/spec/features/new_project_spec.rb +341 -0
- data/spec/features/production/deployment_spec.rb +22 -0
- data/spec/features/production/email_spec.rb +47 -0
- data/spec/features/production/manifest_spec.rb +35 -0
- data/spec/features/staging/pull_requests_spec.rb +22 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/be_executable_matcher.rb +7 -0
- data/spec/support/bulldozer.rb +182 -0
- data/spec/support/contain_json_matcher.rb +24 -0
- data/spec/support/exist_as_a_file_matcher.rb +7 -0
- data/spec/support/fake_github.rb +21 -0
- data/spec/support/fake_heroku.rb +53 -0
- data/spec/support/generators.rb +5 -0
- data/spec/support/match_contents_matcher.rb +6 -0
- data/spec/support/project_files.rb +13 -0
- data/templates/Gemfile.erb +51 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +28 -0
- data/templates/_analytics.html.erb +8 -0
- data/templates/_css_overrides.html.erb +7 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +3 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/active_job.rb +13 -0
- data/templates/application.scss +8 -0
- data/templates/bin_deploy +12 -0
- data/templates/bin_setup +28 -0
- data/templates/bin_setup_review_app.erb +22 -0
- data/templates/browserslist +3 -0
- data/templates/bulldozer_gitignore +18 -0
- data/templates/bulldozer_layout.html.erb.erb +21 -0
- data/templates/bundler_audit.rake +4 -0
- data/templates/chromedriver.rb +17 -0
- data/templates/circle.yml.erb +6 -0
- data/templates/config_locales_en.yml.erb +19 -0
- data/templates/dev.rake +12 -0
- data/templates/dotfiles/.ctags +2 -0
- data/templates/dotfiles/.env +13 -0
- data/templates/email.rb +3 -0
- data/templates/errors.rb +34 -0
- data/templates/factories.rb +2 -0
- data/templates/factory_bot_rspec.rb +5 -0
- data/templates/flashes_helper.rb +5 -0
- data/templates/hound.yml +14 -0
- data/templates/i18n.rb +3 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/postgresql_database.yml.erb +19 -0
- data/templates/puma.rb +28 -0
- data/templates/rack_mini_profiler.rb +5 -0
- data/templates/rails_helper.rb +22 -0
- data/templates/secrets.yml +8 -0
- data/templates/shoulda_matchers_config_rspec.rb +6 -0
- data/templates/smtp.rb +9 -0
- data/templates/spec_helper.rb +28 -0
- 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,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,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"
|
data/templates/bin_setup
ADDED
@@ -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,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,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
|
data/templates/dev.rake
ADDED
@@ -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,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
|
data/templates/email.rb
ADDED
data/templates/errors.rb
ADDED
@@ -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
|
data/templates/hound.yml
ADDED
@@ -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 @@
|
|
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,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!
|