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,231 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
module Bulldozer
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
hide!
|
7
|
+
|
8
|
+
class_option :database, type: :string, aliases: "-d", default: "postgresql",
|
9
|
+
desc: "Configure for selected database (options: #{DATABASES.join("/")})"
|
10
|
+
|
11
|
+
class_option :heroku, type: :boolean, aliases: "-H", default: false,
|
12
|
+
desc: "Create staging and production Heroku apps"
|
13
|
+
|
14
|
+
class_option :heroku_flags, type: :string, default: "",
|
15
|
+
desc: "Set extra Heroku flags"
|
16
|
+
|
17
|
+
class_option :github, type: :string, default: nil,
|
18
|
+
desc: "Create Github repository and add remote origin pointed to repo"
|
19
|
+
|
20
|
+
class_option :version, type: :boolean, aliases: "-v", group: :bulldozer,
|
21
|
+
desc: "Show Bulldozer version number and quit"
|
22
|
+
|
23
|
+
class_option :help, type: :boolean, aliases: '-h', group: :bulldozer,
|
24
|
+
desc: "Show this help message and quit"
|
25
|
+
|
26
|
+
class_option :path, type: :string, default: nil,
|
27
|
+
desc: "Path to the gem"
|
28
|
+
|
29
|
+
class_option :skip_test, type: :boolean, default: true,
|
30
|
+
desc: "Skip Test Unit"
|
31
|
+
|
32
|
+
class_option :skip_system_test,
|
33
|
+
type: :boolean, default: true, desc: "Skip system test files"
|
34
|
+
|
35
|
+
class_option :skip_turbolinks,
|
36
|
+
type: :boolean, default: true, desc: "Skip turbolinks gem"
|
37
|
+
|
38
|
+
def finish_template
|
39
|
+
invoke :bulldozer_customization
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def bulldozer_customization
|
44
|
+
invoke :customize_gemfile
|
45
|
+
invoke :setup_development_environment
|
46
|
+
invoke :setup_production_environment
|
47
|
+
invoke :setup_secret_token
|
48
|
+
invoke :configure_app
|
49
|
+
invoke :copy_miscellaneous_files
|
50
|
+
invoke :customize_error_pages
|
51
|
+
invoke :setup_dotfiles
|
52
|
+
invoke :setup_database
|
53
|
+
invoke :create_github_repo
|
54
|
+
invoke :setup_bundler_audit
|
55
|
+
invoke :setup_spring
|
56
|
+
invoke :generate_default
|
57
|
+
invoke :setup_default_directories
|
58
|
+
invoke :create_heroku_apps
|
59
|
+
invoke :generate_deployment_default
|
60
|
+
invoke :remove_config_comment_lines
|
61
|
+
invoke :remove_routes_comment_lines
|
62
|
+
invoke :outro
|
63
|
+
end
|
64
|
+
|
65
|
+
def customize_gemfile
|
66
|
+
build :replace_gemfile, options[:path]
|
67
|
+
bundle_command 'install'
|
68
|
+
end
|
69
|
+
|
70
|
+
def setup_database
|
71
|
+
say 'Setting up database'
|
72
|
+
|
73
|
+
if 'postgresql' == options[:database]
|
74
|
+
build :use_postgres_config_template
|
75
|
+
end
|
76
|
+
|
77
|
+
build :create_database
|
78
|
+
end
|
79
|
+
|
80
|
+
def setup_development_environment
|
81
|
+
say 'Setting up the development environment'
|
82
|
+
build :configure_local_mail
|
83
|
+
build :raise_on_missing_assets_in_test
|
84
|
+
build :raise_on_delivery_errors
|
85
|
+
build :set_test_delivery_method
|
86
|
+
build :raise_on_unpermitted_parameters
|
87
|
+
build :provide_setup_script
|
88
|
+
build :configure_generators
|
89
|
+
build :configure_i18n_for_missing_translations
|
90
|
+
build :configure_quiet_assets
|
91
|
+
end
|
92
|
+
|
93
|
+
def setup_production_environment
|
94
|
+
say 'Setting up the production environment'
|
95
|
+
build :enable_rack_canonical_host
|
96
|
+
build :enable_rack_deflater
|
97
|
+
build :setup_asset_host
|
98
|
+
end
|
99
|
+
|
100
|
+
def setup_secret_token
|
101
|
+
say 'Moving secret token out of version control'
|
102
|
+
build :setup_secret_token
|
103
|
+
end
|
104
|
+
|
105
|
+
def configure_app
|
106
|
+
say 'Configuring app'
|
107
|
+
build :configure_action_mailer
|
108
|
+
build :configure_time_formats
|
109
|
+
build :setup_default_rake_task
|
110
|
+
build :replace_default_puma_configuration
|
111
|
+
build :set_up_forego
|
112
|
+
build :setup_rack_mini_profiler
|
113
|
+
end
|
114
|
+
|
115
|
+
def create_heroku_apps
|
116
|
+
if options[:heroku]
|
117
|
+
say "Creating Heroku apps"
|
118
|
+
build :create_heroku_apps, options[:heroku_flags]
|
119
|
+
build :set_heroku_remotes
|
120
|
+
build :set_heroku_rails_secrets
|
121
|
+
build :set_heroku_application_host
|
122
|
+
build :set_heroku_honeybadger_env
|
123
|
+
build :set_heroku_backup_schedule
|
124
|
+
build :create_heroku_pipeline
|
125
|
+
build :configure_automatic_deployment
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def create_github_repo
|
130
|
+
if !options[:skip_git] && options[:github]
|
131
|
+
say 'Creating Github repo'
|
132
|
+
build :create_github_repo, options[:github]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def setup_dotfiles
|
137
|
+
build :copy_dotfiles
|
138
|
+
end
|
139
|
+
|
140
|
+
def setup_default_directories
|
141
|
+
build :setup_default_directories
|
142
|
+
end
|
143
|
+
|
144
|
+
def setup_bundler_audit
|
145
|
+
say "Setting up bundler-audit"
|
146
|
+
build :setup_bundler_audit
|
147
|
+
end
|
148
|
+
|
149
|
+
def setup_spring
|
150
|
+
say "Springifying binstubs"
|
151
|
+
build :setup_spring
|
152
|
+
end
|
153
|
+
|
154
|
+
def copy_miscellaneous_files
|
155
|
+
say 'Copying miscellaneous support files'
|
156
|
+
build :copy_miscellaneous_files
|
157
|
+
end
|
158
|
+
|
159
|
+
def customize_error_pages
|
160
|
+
say 'Customizing the 500/404/422 pages'
|
161
|
+
build :customize_error_pages
|
162
|
+
end
|
163
|
+
|
164
|
+
def remove_config_comment_lines
|
165
|
+
build :remove_config_comment_lines
|
166
|
+
end
|
167
|
+
|
168
|
+
def remove_routes_comment_lines
|
169
|
+
build :remove_routes_comment_lines
|
170
|
+
end
|
171
|
+
|
172
|
+
def generate_default
|
173
|
+
run("spring stop")
|
174
|
+
generate("bulldozer:json")
|
175
|
+
generate("bulldozer:static")
|
176
|
+
generate("bulldozer:stylesheet_base")
|
177
|
+
generate("bulldozer:testing")
|
178
|
+
generate("bulldozer:ci")
|
179
|
+
generate("bulldozer:js_driver")
|
180
|
+
unless options[:api]
|
181
|
+
generate("bulldozer:forms")
|
182
|
+
end
|
183
|
+
generate("bulldozer:db_optimizations")
|
184
|
+
generate("bulldozer:factories")
|
185
|
+
generate("bulldozer:lint")
|
186
|
+
generate("bulldozer:jobs")
|
187
|
+
generate("bulldozer:analytics")
|
188
|
+
generate("bulldozer:views")
|
189
|
+
end
|
190
|
+
|
191
|
+
def generate_deployment_default
|
192
|
+
generate("bulldozer:staging:pull_requests")
|
193
|
+
generate("bulldozer:production:force_tls")
|
194
|
+
generate("bulldozer:production:email")
|
195
|
+
generate("bulldozer:production:timeout")
|
196
|
+
generate("bulldozer:production:deployment")
|
197
|
+
generate("bulldozer:production:manifest")
|
198
|
+
end
|
199
|
+
|
200
|
+
def outro
|
201
|
+
say 'Congratulations! You just pulled our bulldozer.'
|
202
|
+
say honeybadger_outro
|
203
|
+
end
|
204
|
+
|
205
|
+
def self.banner
|
206
|
+
"bulldozer #{arguments.map(&:usage).join(' ')} [options]"
|
207
|
+
end
|
208
|
+
|
209
|
+
protected
|
210
|
+
|
211
|
+
def get_builder_class
|
212
|
+
Bulldozer::AppBuilder
|
213
|
+
end
|
214
|
+
|
215
|
+
def using_active_record?
|
216
|
+
!options[:skip_active_record]
|
217
|
+
end
|
218
|
+
|
219
|
+
private
|
220
|
+
|
221
|
+
def honeybadger_outro
|
222
|
+
"Run 'bundle exec honeybadger heroku install' with your API key#{honeybadger_message_suffix}."
|
223
|
+
end
|
224
|
+
|
225
|
+
def honeybadger_message_suffix
|
226
|
+
if options[:heroku]
|
227
|
+
" unless you're using the Heroku Honeybadger add-on"
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require_relative "../actions"
|
3
|
+
|
4
|
+
module Bulldozer
|
5
|
+
module Generators
|
6
|
+
class Base < Rails::Generators::Base
|
7
|
+
include Bulldozer::Actions
|
8
|
+
|
9
|
+
def self.default_source_root
|
10
|
+
File.expand_path(File.join("..", "..", "..", "templates"), __dir__)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def app_name
|
16
|
+
Rails.app_class.parent_name.demodulize.underscore.dasherize
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
class CiGenerator < Generators::Base
|
5
|
+
def simplecov_test_integration
|
6
|
+
inject_into_file "spec/spec_helper.rb", before: 'SimpleCov.start "rails"' do
|
7
|
+
<<-RUBY
|
8
|
+
|
9
|
+
if ENV["CIRCLE_ARTIFACTS"]
|
10
|
+
dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
|
11
|
+
SimpleCov.coverage_dir(dir)
|
12
|
+
end
|
13
|
+
|
14
|
+
RUBY
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def configure_ci
|
19
|
+
template "circle.yml.erb", "circle.yml"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
class DbOptimizationsGenerator < Generators::Base
|
5
|
+
def add_bullet
|
6
|
+
gem "bullet", group: %i(development test)
|
7
|
+
Bundler.with_clean_env { run "bundle install" }
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure_bullet
|
11
|
+
inject_into_file(
|
12
|
+
"config/environments/development.rb",
|
13
|
+
configuration,
|
14
|
+
after: "config.action_mailer.raise_delivery_errors = true\n",
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def configuration
|
21
|
+
<<-RUBY
|
22
|
+
config.after_initialize do
|
23
|
+
Bullet.enable = true
|
24
|
+
Bullet.bullet_logger = true
|
25
|
+
Bullet.rails_logger = true
|
26
|
+
end
|
27
|
+
RUBY
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
class FactoriesGenerator < Generators::Base
|
5
|
+
def add_factory_bot
|
6
|
+
gem "factory_bot_rails", group: %i(development test)
|
7
|
+
Bundler.with_clean_env { run "bundle install" }
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_up_factory_bot_for_rspec
|
11
|
+
copy_file "factory_bot_rspec.rb", "spec/support/factory_bot.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_empty_factories_file
|
15
|
+
copy_file "factories.rb", "spec/factories.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def provide_dev_prime_task
|
19
|
+
copy_file "dev.rake", "lib/tasks/dev.rake"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
class FormsGenerator < Generators::Base
|
5
|
+
def add_simple_form
|
6
|
+
gem "simple_form"
|
7
|
+
Bundler.with_clean_env { run "bundle install" }
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure_simple_form
|
11
|
+
create_file "config/initializers/simple_form.rb" do
|
12
|
+
"SimpleForm.setup {|config|}"
|
13
|
+
end
|
14
|
+
|
15
|
+
generate "simple_form:install", "--force"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
class JobsGenerator < Generators::Base
|
5
|
+
def add_jobs_gem
|
6
|
+
gem "delayed_job_active_record"
|
7
|
+
Bundler.with_clean_env { run "bundle install" }
|
8
|
+
end
|
9
|
+
|
10
|
+
def configure_background_jobs_for_rspec
|
11
|
+
generate "delayed_job:active_record"
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize_active_job
|
15
|
+
copy_file(
|
16
|
+
"active_job.rb",
|
17
|
+
"config/initializers/active_job.rb",
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure_active_job
|
22
|
+
configure_application_file(
|
23
|
+
"config.active_job.queue_adapter = :delayed_job",
|
24
|
+
)
|
25
|
+
configure_environment "test", "config.active_job.queue_adapter = :inline"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def configure_application_file(config)
|
31
|
+
inject_into_file(
|
32
|
+
"config/application.rb",
|
33
|
+
"\n #{config}",
|
34
|
+
before: "\n end",
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative "base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
class JsDriverGenerator < Generators::Base
|
5
|
+
def add_gems
|
6
|
+
gem "capybara-selenium", group: :test
|
7
|
+
gem "chromedriver-helper", group: :test
|
8
|
+
Bundler.with_clean_env { run "bundle install" }
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure_chromedriver
|
12
|
+
copy_file "chromedriver.rb", "spec/support/chromedriver.rb"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "../base"
|
2
|
+
|
3
|
+
module Bulldozer
|
4
|
+
module Production
|
5
|
+
class DeploymentGenerator < Generators::Base
|
6
|
+
def copy_script
|
7
|
+
copy_file "bin_deploy", "bin/deploy"
|
8
|
+
chmod "bin/deploy", 0o755
|
9
|
+
end
|
10
|
+
|
11
|
+
def inform_user
|
12
|
+
instructions = <<~MARKDOWN
|
13
|
+
|
14
|
+
## Deploying
|
15
|
+
|
16
|
+
If you have previously run the `./bin/setup` script,
|
17
|
+
you can deploy to staging and production with:
|
18
|
+
|
19
|
+
% ./bin/deploy staging
|
20
|
+
% ./bin/deploy production
|
21
|
+
MARKDOWN
|
22
|
+
|
23
|
+
append_file "README.md", instructions
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|