hosentrager 1.39.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/CONTRIBUTING.md +51 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +21 -0
  8. data/NEWS.md +496 -0
  9. data/README.md +233 -0
  10. data/RELEASING.md +19 -0
  11. data/Rakefile +8 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +13 -0
  15. data/bin/suspenders +23 -0
  16. data/lib/suspenders.rb +5 -0
  17. data/lib/suspenders/actions.rb +33 -0
  18. data/lib/suspenders/adapters/heroku.rb +135 -0
  19. data/lib/suspenders/app_builder.rb +522 -0
  20. data/lib/suspenders/generators/app_generator.rb +265 -0
  21. data/lib/suspenders/version.rb +5 -0
  22. data/spec/adapters/heroku_spec.rb +67 -0
  23. data/spec/fakes/bin/heroku +5 -0
  24. data/spec/fakes/bin/hub +5 -0
  25. data/spec/features/github_spec.rb +16 -0
  26. data/spec/features/heroku_spec.rb +103 -0
  27. data/spec/features/new_project_spec.rb +245 -0
  28. data/spec/spec_helper.rb +20 -0
  29. data/spec/support/fake_github.rb +21 -0
  30. data/spec/support/fake_heroku.rb +53 -0
  31. data/spec/support/suspenders.rb +68 -0
  32. data/suspenders.gemspec +35 -0
  33. data/templates/.bowerrc +3 -0
  34. data/templates/Gemfile.erb +63 -0
  35. data/templates/Procfile +2 -0
  36. data/templates/README.md.erb +28 -0
  37. data/templates/_analytics.html.erb +7 -0
  38. data/templates/_css_overrides.html.erb +7 -0
  39. data/templates/_flashes.html.erb +7 -0
  40. data/templates/_javascript.html.erb +12 -0
  41. data/templates/action_mailer.rb +5 -0
  42. data/templates/app.json.erb +42 -0
  43. data/templates/application.scss +9 -0
  44. data/templates/bin_deploy +12 -0
  45. data/templates/bin_setup +21 -0
  46. data/templates/bin_setup_review_app.erb +19 -0
  47. data/templates/browserslist +3 -0
  48. data/templates/bundler_audit.rake +12 -0
  49. data/templates/capybara_webkit.rb +5 -0
  50. data/templates/circle.yml.erb +6 -0
  51. data/templates/config_locales_en.yml.erb +19 -0
  52. data/templates/database_cleaner_rspec.rb +21 -0
  53. data/templates/dev.rake +12 -0
  54. data/templates/disable_xml_params.rb +1 -0
  55. data/templates/dotfiles/.ctags +2 -0
  56. data/templates/dotfiles/.env +13 -0
  57. data/templates/errors.rb +34 -0
  58. data/templates/factories.rb +2 -0
  59. data/templates/factory_girl_rspec.rb +3 -0
  60. data/templates/flashes_helper.rb +5 -0
  61. data/templates/hound.yml +14 -0
  62. data/templates/i18n.rb +3 -0
  63. data/templates/json_encoding.rb +1 -0
  64. data/templates/newrelic.yml.erb +34 -0
  65. data/templates/postgresql_database.yml.erb +21 -0
  66. data/templates/puma.rb +28 -0
  67. data/templates/rack_mini_profiler.rb +5 -0
  68. data/templates/rails_helper.rb +22 -0
  69. data/templates/secrets.yml +14 -0
  70. data/templates/shoulda_matchers_config_rspec.rb +6 -0
  71. data/templates/smtp.rb +13 -0
  72. data/templates/spec_helper.rb +29 -0
  73. data/templates/suspenders_gitignore +13 -0
  74. data/templates/suspenders_layout.html.erb.erb +22 -0
  75. metadata +190 -0
@@ -0,0 +1,265 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/rails/app/app_generator'
3
+
4
+ module Suspenders
5
+ class AppGenerator < Rails::Generators::AppGenerator
6
+ class_option :database, type: :string, aliases: "-d", default: "postgresql",
7
+ desc: "Configure for selected database (options: #{DATABASES.join("/")})"
8
+
9
+ class_option :heroku, type: :boolean, aliases: "-H", default: false,
10
+ desc: "Create staging and production Heroku apps"
11
+
12
+ class_option :heroku_flags, type: :string, default: "",
13
+ desc: "Set extra Heroku flags"
14
+
15
+ class_option :github, type: :string, aliases: "-G", default: nil,
16
+ desc: "Create Github repository and add remote origin pointed to repo"
17
+
18
+ class_option :skip_test_unit, type: :boolean, aliases: "-T", default: true,
19
+ desc: "Skip Test::Unit files"
20
+
21
+ class_option :skip_turbolinks, type: :boolean, default: true,
22
+ desc: "Skip turbolinks gem"
23
+
24
+ class_option :skip_bundle, type: :boolean, aliases: "-B", default: true,
25
+ desc: "Don't run bundle install"
26
+
27
+ def finish_template
28
+ invoke :suspenders_customization
29
+ super
30
+ end
31
+
32
+ def suspenders_customization
33
+ invoke :customize_gemfile
34
+ invoke :setup_development_environment
35
+ invoke :setup_test_environment
36
+ invoke :setup_production_environment
37
+ invoke :setup_secret_token
38
+ invoke :create_suspenders_views
39
+ invoke :configure_app
40
+ invoke :setup_stylesheets
41
+ invoke :install_bitters
42
+ invoke :install_refills
43
+ invoke :copy_miscellaneous_files
44
+ invoke :customize_error_pages
45
+ invoke :remove_config_comment_lines
46
+ invoke :remove_routes_comment_lines
47
+ invoke :setup_dotfiles
48
+ invoke :setup_git
49
+ invoke :setup_database
50
+ invoke :create_heroku_apps
51
+ invoke :create_github_repo
52
+ invoke :setup_segment
53
+ invoke :setup_bundler_audit
54
+ invoke :setup_spring
55
+ invoke :outro
56
+ end
57
+
58
+ def customize_gemfile
59
+ build :set_ruby_to_version_being_used
60
+
61
+ if options[:heroku]
62
+ build :set_up_heroku_specific_gems
63
+ end
64
+
65
+ bundle_command 'install'
66
+ build :configure_simple_form
67
+ end
68
+
69
+ def setup_database
70
+ say 'Setting up database'
71
+
72
+ if 'postgresql' == options[:database]
73
+ build :use_postgres_config_template
74
+ end
75
+
76
+ build :create_database
77
+ end
78
+
79
+ def setup_development_environment
80
+ say 'Setting up the development environment'
81
+ build :raise_on_missing_assets_in_test
82
+ build :raise_on_delivery_errors
83
+ build :set_test_delivery_method
84
+ build :add_bullet_gem_configuration
85
+ build :raise_on_unpermitted_parameters
86
+ build :provide_setup_script
87
+ build :provide_dev_prime_task
88
+ build :configure_generators
89
+ build :configure_i18n_for_missing_translations
90
+ build :configure_quiet_assets
91
+ build :add_bower_dir_to_assets_paths
92
+ end
93
+
94
+ def setup_test_environment
95
+ say 'Setting up the test environment'
96
+ build :set_up_factory_girl_for_rspec
97
+ build :generate_factories_file
98
+ build :set_up_hound
99
+ build :generate_rspec
100
+ build :configure_rspec
101
+ build :configure_background_jobs_for_rspec
102
+ build :enable_database_cleaner
103
+ build :provide_shoulda_matchers_config
104
+ build :configure_spec_support_features
105
+ build :configure_ci
106
+ build :configure_i18n_for_test_environment
107
+ build :configure_action_mailer_in_specs
108
+ build :configure_capybara_webkit
109
+ end
110
+
111
+ def setup_production_environment
112
+ say 'Setting up the production environment'
113
+ build :configure_newrelic
114
+ build :configure_smtp
115
+ build :configure_rack_timeout
116
+ build :enable_rack_canonical_host
117
+ build :enable_rack_deflater
118
+ build :setup_asset_host
119
+ end
120
+
121
+ def setup_secret_token
122
+ say 'Moving secret token out of version control'
123
+ build :setup_secret_token
124
+ end
125
+
126
+ def create_suspenders_views
127
+ say 'Creating suspenders views'
128
+ build :create_partials_directory
129
+ build :create_shared_flashes
130
+ build :create_shared_javascripts
131
+ build :create_shared_css_overrides
132
+ build :create_application_layout
133
+ end
134
+
135
+ def configure_app
136
+ say 'Configuring app'
137
+ build :configure_action_mailer
138
+ build :configure_active_job
139
+ build :configure_time_formats
140
+ build :disable_xml_params
141
+ build :setup_default_rake_task
142
+ build :configure_puma
143
+ build :set_up_forego
144
+ build :setup_rack_mini_profiler
145
+ end
146
+
147
+ def setup_stylesheets
148
+ say 'Set up stylesheets'
149
+ build :setup_stylesheets
150
+ end
151
+
152
+ def install_bitters
153
+ say 'Install Bitters'
154
+ build :install_bitters
155
+ end
156
+
157
+ def install_refills
158
+ say "Install Refills"
159
+ build :install_refills
160
+ end
161
+
162
+ def setup_git
163
+ if !options[:skip_git]
164
+ say "Initializing git"
165
+ invoke :setup_default_directories
166
+ invoke :init_git
167
+ end
168
+ end
169
+
170
+ def create_heroku_apps
171
+ if options[:heroku]
172
+ say "Creating Heroku apps"
173
+ build :create_heroku_apps, options[:heroku_flags]
174
+ build :provide_review_apps_setup_script
175
+ build :set_heroku_serve_static_files
176
+ build :set_heroku_remotes
177
+ build :set_heroku_rails_secrets
178
+ build :set_heroku_application_host
179
+ build :create_heroku_pipelines_config_file
180
+ build :create_heroku_pipeline
181
+ build :provide_deploy_script
182
+ build :configure_automatic_deployment
183
+ end
184
+ end
185
+
186
+ def create_github_repo
187
+ if !options[:skip_git] && options[:github]
188
+ say 'Creating Github repo'
189
+ build :create_github_repo, options[:github]
190
+ end
191
+ end
192
+
193
+ def setup_segment
194
+ say 'Setting up Segment'
195
+ build :setup_segment
196
+ end
197
+
198
+ def setup_dotfiles
199
+ build :copy_dotfiles
200
+ end
201
+
202
+ def setup_default_directories
203
+ build :setup_default_directories
204
+ end
205
+
206
+ def setup_bundler_audit
207
+ say "Setting up bundler-audit"
208
+ build :setup_bundler_audit
209
+ end
210
+
211
+ def setup_spring
212
+ say "Springifying binstubs"
213
+ build :setup_spring
214
+ end
215
+
216
+ def init_git
217
+ build :init_git
218
+ end
219
+
220
+ def copy_miscellaneous_files
221
+ say 'Copying miscellaneous support files'
222
+ build :copy_miscellaneous_files
223
+ end
224
+
225
+ def customize_error_pages
226
+ say 'Customizing the 500/404/422 pages'
227
+ build :customize_error_pages
228
+ end
229
+
230
+ def remove_config_comment_lines
231
+ build :remove_config_comment_lines
232
+ end
233
+
234
+ def remove_routes_comment_lines
235
+ build :remove_routes_comment_lines
236
+ end
237
+
238
+ def outro
239
+ say 'Congratulations! You just pulled our suspenders.'
240
+ say honeybadger_outro
241
+ end
242
+
243
+ protected
244
+
245
+ def get_builder_class
246
+ Suspenders::AppBuilder
247
+ end
248
+
249
+ def using_active_record?
250
+ !options[:skip_active_record]
251
+ end
252
+
253
+ private
254
+
255
+ def honeybadger_outro
256
+ "Run 'bundle exec honeybadger heroku install' with your API key#{honeybadger_message_suffix}."
257
+ end
258
+
259
+ def honeybadger_message_suffix
260
+ if options[:heroku]
261
+ " unless you're using the Heroku Honeybadger add-on"
262
+ end
263
+ end
264
+ end
265
+ end
@@ -0,0 +1,5 @@
1
+ module Suspenders
2
+ RAILS_VERSION = "~> 4.2.0"
3
+ RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
+ VERSION = "1.39.1"
5
+ end
@@ -0,0 +1,67 @@
1
+ require "spec_helper"
2
+
3
+ module Suspenders
4
+ module Adapters
5
+ RSpec.describe Heroku do
6
+ it "sets the heroku remotes" do
7
+ setup_file = "bin/setup"
8
+ app_builder = double(app_name: app_name)
9
+ allow(app_builder).to receive(:append_file)
10
+
11
+ Heroku.new(app_builder).set_heroku_remotes
12
+
13
+ expect(app_builder).to have_received(:append_file).
14
+ with(setup_file, /heroku join --app #{app_name.dasherize}-production/)
15
+ expect(app_builder).to have_received(:append_file).
16
+ with(setup_file, /heroku join --app #{app_name.dasherize}-staging/)
17
+ end
18
+
19
+ it "sets up the heroku specific gems" do
20
+ app_builder = double(app_name: app_name)
21
+ allow(app_builder).to receive(:inject_into_file)
22
+
23
+ Heroku.new(app_builder).set_up_heroku_specific_gems
24
+
25
+ expect(app_builder).to have_received(:inject_into_file).
26
+ with("Gemfile", /rails_stdout_logging/, anything)
27
+ end
28
+
29
+ it "sets the heroku rails secrets" do
30
+ app_builder = double(app_name: app_name)
31
+ allow(app_builder).to receive(:run)
32
+
33
+ Heroku.new(app_builder).set_heroku_rails_secrets
34
+
35
+ expect(app_builder).to(
36
+ have_configured_var("staging", "SECRET_KEY_BASE"),
37
+ )
38
+ expect(app_builder).to(
39
+ have_configured_var("production", "SECRET_KEY_BASE"),
40
+ )
41
+ end
42
+
43
+ it "sets the application host" do
44
+ app_builder = double(app_name: app_name)
45
+ allow(app_builder).to receive(:run)
46
+
47
+ Heroku.new(app_builder).set_heroku_application_host
48
+
49
+ expect(app_builder).to(
50
+ have_configured_var("staging", "APPLICATION_HOST"),
51
+ )
52
+
53
+ expect(app_builder).to(
54
+ have_configured_var("production", "APPLICATION_HOST"),
55
+ )
56
+ end
57
+
58
+ def app_name
59
+ SuspendersTestHelpers::APP_NAME
60
+ end
61
+
62
+ def have_configured_var(remote_name, var)
63
+ have_received(:run).with(/config:add #{var}=.+ --remote #{remote_name}/)
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_heroku'), File.dirname(__FILE__))
4
+
5
+ FakeHeroku.new(ARGV).run!
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join('..', '..', 'support', 'fake_github'), File.dirname(__FILE__))
4
+
5
+ FakeGithub.new(ARGV).run!
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "GitHub" do
4
+ before do
5
+ drop_dummy_database
6
+ remove_project_directory
7
+ end
8
+
9
+ it "suspends a project with --github option" do
10
+ repo_name = 'test'
11
+ run_suspenders("--github=#{repo_name}")
12
+ setup_app_dependencies
13
+
14
+ expect(FakeGithub).to have_created_repo(repo_name)
15
+ end
16
+ end
@@ -0,0 +1,103 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Heroku" do
4
+ context "--heroku" do
5
+ before(:all) do
6
+ clean_up
7
+ run_suspenders("--heroku=true")
8
+ setup_app_dependencies
9
+ end
10
+
11
+ it "suspends a project for Heroku" do
12
+ app_name = SuspendersTestHelpers::APP_NAME.dasherize
13
+
14
+ expect(FakeHeroku).to(
15
+ have_gem_included(project_path, "rails_stdout_logging"),
16
+ )
17
+ expect(FakeHeroku).to have_created_app_for("staging")
18
+ expect(FakeHeroku).to have_created_app_for("production")
19
+ expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
20
+ expect(FakeHeroku).to have_configured_vars(
21
+ "production",
22
+ "SECRET_KEY_BASE",
23
+ )
24
+ expect(FakeHeroku).to have_configured_vars(
25
+ "staging",
26
+ "APPLICATION_HOST",
27
+ )
28
+ expect(FakeHeroku).to have_configured_vars(
29
+ "production",
30
+ "APPLICATION_HOST",
31
+ )
32
+ expect(FakeHeroku).to have_setup_pipeline_for(app_name)
33
+
34
+ bin_setup_path = "#{project_path}/bin/setup"
35
+ bin_setup = IO.read(bin_setup_path)
36
+
37
+ expect(bin_setup).to include("heroku join --app #{app_name}-production")
38
+ expect(bin_setup).to include("heroku join --app #{app_name}-staging")
39
+ expect(bin_setup).to include("git config heroku.remote staging")
40
+ expect(File.stat(bin_setup_path)).to be_executable
41
+
42
+ bin_setup_path = "#{project_path}/bin/setup_review_app"
43
+ bin_setup = IO.read(bin_setup_path)
44
+
45
+ expect(bin_setup).to include("heroku run rake db:migrate --exit-code --app #{app_name}-staging-pr-$1")
46
+ expect(bin_setup).to include("heroku ps:scale worker=1 --app #{app_name}-staging-pr-$1")
47
+ expect(bin_setup).to include("heroku restart --app #{app_name}-staging-pr-$1")
48
+ expect(File.stat(bin_setup_path)).to be_executable
49
+
50
+ bin_deploy_path = "#{project_path}/bin/deploy"
51
+ bin_deploy = IO.read(bin_deploy_path)
52
+
53
+ expect(bin_deploy).to include("heroku run rake db:migrate --exit-code")
54
+ expect(File.stat(bin_deploy_path)).to be_executable
55
+
56
+ readme = IO.read("#{project_path}/README.md")
57
+
58
+ expect(readme).to include("./bin/deploy staging")
59
+ expect(readme).to include("./bin/deploy production")
60
+
61
+ circle_yml_path = "#{project_path}/circle.yml"
62
+ circle_yml = IO.read(circle_yml_path)
63
+
64
+ expect(circle_yml).to include <<-YML.strip_heredoc
65
+ deployment:
66
+ staging:
67
+ branch: master
68
+ commands:
69
+ - bin/deploy staging
70
+ YML
71
+ end
72
+
73
+ it "adds app.json file" do
74
+ expect(File).to exist("#{project_path}/app.json")
75
+ end
76
+
77
+ it "includes application name in app.json file" do
78
+ app_json_file = IO.read("#{project_path}/app.json")
79
+ app_name = SuspendersTestHelpers::APP_NAME.dasherize
80
+
81
+ expect(app_json_file).to match(/"name":"#{app_name}"/)
82
+ end
83
+ end
84
+
85
+ context "--heroku with region flag" do
86
+ before(:all) do
87
+ clean_up
88
+ run_suspenders(%{--heroku=true --heroku-flags="--region eu"})
89
+ setup_app_dependencies
90
+ end
91
+
92
+ it "suspends a project with extra Heroku flags" do
93
+ expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
94
+ expect(FakeHeroku).to have_created_app_for("production", "--region eu")
95
+ end
96
+ end
97
+
98
+ def clean_up
99
+ drop_dummy_database
100
+ remove_project_directory
101
+ FakeHeroku.clear!
102
+ end
103
+ end