welaika-suspenders 2.33 → 2.34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +4 -2
  4. data/CHANGELOG_WELAIKA.md +15 -0
  5. data/NEWS.md +8 -0
  6. data/README.md +12 -16
  7. data/docs/heroku_deploy.md +22 -0
  8. data/lib/suspenders.rb +2 -0
  9. data/lib/suspenders/actions.rb +2 -2
  10. data/lib/suspenders/app_builder.rb +19 -11
  11. data/lib/suspenders/generators/app_generator.rb +9 -8
  12. data/lib/suspenders/generators/factories_generator.rb +1 -1
  13. data/lib/suspenders/generators/inline_svg_generator.rb +14 -0
  14. data/lib/suspenders/generators/jobs_generator.rb +53 -0
  15. data/lib/suspenders/generators/production/email_generator.rb +1 -1
  16. data/lib/suspenders/generators/production/error_reporting_generator.rb +6 -6
  17. data/lib/suspenders/generators/production/manifest_generator.rb +2 -1
  18. data/lib/suspenders/generators/production/timeout_generator.rb +1 -0
  19. data/lib/suspenders/generators/staging/pull_requests_generator.rb +3 -3
  20. data/lib/suspenders/generators/stylelint_generator.rb +11 -8
  21. data/lib/suspenders/version.rb +2 -2
  22. data/spec/expand_json_spec.rb +89 -0
  23. data/spec/features/inline_svg_spec.rb +10 -0
  24. data/spec/features/new_project_spec.rb +7 -28
  25. data/spec/features/production/email_spec.rb +1 -1
  26. data/spec/features/production/manifest_spec.rb +2 -0
  27. data/suspenders.gemspec +5 -0
  28. data/templates/Dockerfile.gitlab.erb +1 -1
  29. data/templates/Gemfile.erb +3 -2
  30. data/templates/Procfile +0 -1
  31. data/templates/README.md.erb +12 -6
  32. data/templates/bin_auto_migrate +5 -0
  33. data/templates/bin_deploy +0 -2
  34. data/templates/bin_setup_review_app.erb +0 -1
  35. data/templates/config_sidekiq.yml +14 -0
  36. data/templates/dotfiles/.env +0 -1
  37. data/templates/email.rb +2 -2
  38. data/templates/factory_bot_rspec.rb +1 -1
  39. data/templates/gitlab-ci.yml.erb +50 -50
  40. data/templates/inline_svg.rb +3 -0
  41. data/templates/rack_mini_profiler.rb +2 -2
  42. data/templates/rubocop.yml +11 -1
  43. data/templates/smtp.rb +7 -7
  44. data/templates/spec_support_sidekiq.rb +4 -0
  45. metadata +32 -6
  46. data/templates/browserslist +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1feb33dee0a5957e4e4f475da9afc775414ba866f162781bc160dec04fcdd9f4
4
- data.tar.gz: 6b6f4bd1656d5cb86bf9ffbc4d2131ecc69b1dc64bca69199b4e385f3df3e9df
3
+ metadata.gz: fca0442cb0adbdb8f07149baafe1841af1d44aa4c9028260ed332ffc6dac4c70
4
+ data.tar.gz: 402be3ceb068fdf2a08344050de8b5516f95cd45c63efab9bbda3c93785548d9
5
5
  SHA512:
6
- metadata.gz: fe96258397d31d095e8db2b2259117d1a6fb78eebe4b27e39047408b4628ed910b91815cab7087f5bbd9dfa16214b722c72a56399f15f7acc3cf2fdf8ccbb1d9
7
- data.tar.gz: 4a01c8d4b248329326ef71e2bde68eb4c5d67672e3a7be437b8e72a6ada4fb2a015730ca27f673faee473030bb70b8881e0bf61639406b4aba9d4cc50a895ada
6
+ metadata.gz: ca5b9dff76fe3ecca545cd9c7ae09984b65df11895cb31fba42d7439fed0221e509596cbabcda45ecd0d3eecc11f62b16cd9e968313dbfd5434be513b44f6218
7
+ data.tar.gz: 79104448a207fd73e1a4ee60ae3261d787f9cc91dff76e847bf130a405cc0b7df2f3321b4f6d8bea1609b15c42ffd5ccebc787a9bd488a0d5abfaa8064c39837
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.6.5
data/.travis.yml CHANGED
@@ -1,12 +1,14 @@
1
1
  language: ruby
2
- rvm: 2.6.3
2
+ rvm: 2.6.5
3
3
  cache: bundler
4
4
  sudo: false
5
5
  before_install:
6
6
  - git config --global user.name 'Travis CI'
7
7
  - git config --global user.email 'travis-ci@example.com'
8
8
  - gem update --system
9
- - gem install bundler -v '< 2'
9
+ - gem install bundler
10
10
  install: bundle install
11
11
  notifications:
12
12
  email: false
13
+ services:
14
+ - postgresql
data/CHANGELOG_WELAIKA.md CHANGED
@@ -1,3 +1,18 @@
1
+ 2.34 (October 19th, 2019)
2
+ * Change: gitlab ci steps from prepare -> quality -> test to prepare -> test -> quality. We already run some quality checks with overcommit
3
+ * Change: use :login instead of :plain as smtp authentication system
4
+ * Change: use PostgreSQL 11
5
+ * Change: edited rubocop rules
6
+ * Documentation: update readme about suspenders
7
+ * Feature: add sidekiq
8
+ * Change: install foreman if it does not exist
9
+ * Change: update rubocop rules
10
+ * Fix: stick to style-lint 10 for now, because some plugins does not work with 11
11
+ * Change: use bundler 2 by default
12
+ * Feature: add inline_svg gem (from upstream)
13
+ * Change: use a new way to migrate database on heroku (from upstream)
14
+
15
+
1
16
  2.33 (July 23th, 2019)
2
17
  * Feature: allow to deploy to heroku with push --force-with-lease (useful for staging)
3
18
  * Fix: make new Chrome versions (really) headless
data/NEWS.md CHANGED
@@ -1,3 +1,11 @@
1
+ 1.53.0 (August 23, 2019)
2
+ * Upgraded: Rails 6.0.
3
+ * New generator: `suspenders:inline_svg` for setting up the inline_svg gem.
4
+ * Changed: silence Puma's startup messages in JS specs.
5
+ * Changed: improve chromedriver configuration.
6
+ * Added: documentation for deploying to Heroku.
7
+ * Fixed: indentation in production config file.
8
+
1
9
  1.52.0 (June 7, 2019)
2
10
  * Changed: Setup system tests instead of feature specs
3
11
  * Upgraded: Rails 5.2.3
data/README.md CHANGED
@@ -3,15 +3,21 @@
3
3
  This is a [suspenders](https://github.com/thoughtbot/suspenders) fork in use at [weLaika](http://dev.welaika.com).
4
4
  Big thanks to [thoughtbot](http://thoughtbot.com/community) for providing such a great starting point.
5
5
 
6
+ ** Warning! **
7
+
8
+ welaika-suspenders version 2 will install rails 5.
9
+ welaika-suspenders version 3 will install rails 6.
10
+
11
+ You may want to use version 2 if you need to use solidus 2.9.x
12
+
6
13
  ## Installation
7
14
 
8
- First ensure you have PostgreSQL, npm, yarn and chromedriver
15
+ First ensure you have PostgreSQL (use the same version specified in `Suspenders::POSTGRES_VERSION`), npm and yarn.
9
16
 
10
- $ brew install postgresql@10
17
+ $ brew install postgresql
11
18
  $ brew install node
12
19
  $ npm install npm@latest -g # To update npm if you have already installed it
13
20
  $ brew install yarn
14
- $ brew casks install chromedriver
15
21
 
16
22
  then install the suspenders gem:
17
23
 
@@ -23,7 +29,7 @@ If you want to use heroku, please install the [heroku toolbelt](https://toolbelt
23
29
 
24
30
  Then run:
25
31
 
26
- welaika-suspenders projectname
32
+ welaika-suspenders projectname --heroku=true
27
33
 
28
34
  This will create a Rails app in `projectname` using the latest version of Rails.
29
35
 
@@ -40,19 +46,9 @@ See all possible Heroku flags:
40
46
  This will create a rails app in `projectname`. This script creates a
41
47
  new git repository. It is not meant to be used against an existing repo.
42
48
 
43
- cd projectname && bin/setup
44
-
45
- If you want to add an empty bare repository as origin, run
49
+ Run the bin/setup script
46
50
 
47
- git remote add origin git@github.com:welaika/projectname.git
48
-
49
- ## Sentry && Heroku
50
-
51
- After deploying for the first time on Heroku, please run
52
-
53
- `heroku labs:enable runtime-dyno-metadata`
54
-
55
- for Sentry's release detection to work correctly.
51
+ cd projectname && bin/setup
56
52
 
57
53
  ## Version number
58
54
 
@@ -0,0 +1,22 @@
1
+ # Deploying to Heroku
2
+
3
+ ## Setup
4
+
5
+ Deploying to Heroku requires two additional steps:
6
+
7
+ 1. Manually add buildpacks `node.js` and `ruby` (in that order) to your Heroku
8
+ app. This is necessary because build order is important and Heroku's
9
+ auto-detection will add them in the wrong order.
10
+
11
+ 2. Set the following environment variables:
12
+
13
+ - `ASSET_HOST`: `siteURL.herokuapp.com`
14
+ - `APPLICATION_HOST`: `siteURL.herokuapp.com`
15
+ - `SMTP_ADDRESS`: `smtp.example.com`
16
+ - `SMTP_DOMAIN`: `example.com`
17
+ - `SMTP_USERNAME`: `username`
18
+ - `SMTP_PASSWORD`: `password`
19
+
20
+ ## Execution
21
+
22
+ - Use the `./bin/deploy` convention for deploying to Heroku
data/lib/suspenders.rb CHANGED
@@ -15,6 +15,8 @@ require "suspenders/generators/decorator_generator"
15
15
  require "suspenders/generators/faker_generator"
16
16
  require "suspenders/generators/security_generator"
17
17
  require "suspenders/generators/import_dump_generator"
18
+ require "suspenders/generators/jobs_generator"
19
+ require "suspenders/generators/inline_svg_generator"
18
20
  require "suspenders/generators/production/force_tls_generator"
19
21
  require "suspenders/generators/production/email_generator"
20
22
  require "suspenders/generators/production/timeout_generator"
@@ -39,7 +39,7 @@ module Suspenders
39
39
  end
40
40
 
41
41
  def invoke!
42
- write_out { |existing_json| existing_json.merge(data) }
42
+ write_out { |existing_json| existing_json.deep_merge(data) }
43
43
  end
44
44
 
45
45
  def revoke!
@@ -60,7 +60,7 @@ module Suspenders
60
60
  end
61
61
 
62
62
  def existing_json
63
- JSON.parse(IO.read(destination_file))
63
+ JSON.parse(IO.read(destination_file), symbolize_names: true)
64
64
  rescue Errno::ENOENT
65
65
  {}
66
66
  end
@@ -100,7 +100,7 @@ module Suspenders
100
100
 
101
101
  def enable_rack_canonical_host
102
102
  config = <<-RUBY
103
- config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")
103
+ config.middleware.use Rack::CanonicalHost, ENV.fetch('APPLICATION_HOST')
104
104
  RUBY
105
105
 
106
106
  configure_environment "production", config
@@ -113,7 +113,7 @@ module Suspenders
113
113
  def setup_asset_host
114
114
  replace_in_file 'config/environments/production.rb',
115
115
  "# config.action_controller.asset_host = 'http://assets.example.com'",
116
- 'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
116
+ "config.action_controller.asset_host = ENV.fetch('ASSET_HOST', ENV.fetch('APPLICATION_HOST'))"
117
117
 
118
118
  if File.exist?("config/initializers/assets.rb")
119
119
  replace_in_file 'config/initializers/assets.rb',
@@ -123,7 +123,7 @@ module Suspenders
123
123
 
124
124
  config = <<-EOD
125
125
  config.public_file_server.headers = {
126
- "Cache-Control" => "public, max-age=31557600",
126
+ 'Cache-Control' => 'public, max-age=31557600',
127
127
  }
128
128
  EOD
129
129
 
@@ -175,7 +175,7 @@ config.public_file_server.headers = {
175
175
  template "config_locales_it.yml.erb", "config/locales/it.yml"
176
176
 
177
177
  config = <<-RUBY
178
- config.i18n.available_locales = [:en, :it]
178
+ config.i18n.available_locales = %i[en it]
179
179
  config.i18n.default_locale = :it
180
180
  config.time_zone = 'Rome'
181
181
  RUBY
@@ -188,10 +188,10 @@ config.public_file_server.headers = {
188
188
  action_mailer_asset_host "development", %{"http://localhost:3000"}
189
189
  action_mailer_host "test", %{"www.example.com"}
190
190
  action_mailer_asset_host "test", %{"http://www.example.com"}
191
- action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")}
191
+ action_mailer_host "production", %{ENV.fetch('APPLICATION_HOST')}
192
192
  action_mailer_asset_host(
193
193
  "production",
194
- %{ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))},
194
+ %{ENV.fetch('ASSET_HOST', ENV.fetch('APPLICATION_HOST'))},
195
195
  )
196
196
  end
197
197
 
@@ -200,7 +200,9 @@ config.public_file_server.headers = {
200
200
  end
201
201
 
202
202
  def set_up_forego
203
+ # NOTE: we want to use ruby foreman!
203
204
  copy_file "Procfile", "Procfile"
205
+ Bundler.with_clean_env { run "gem install foreman" }
204
206
  end
205
207
 
206
208
  def setup_default_directories
@@ -236,8 +238,16 @@ config.public_file_server.headers = {
236
238
  create_production_heroku_app(flags)
237
239
  end
238
240
 
241
+ def configure_automatic_deployment
242
+ append_file "Procfile", "release: bin/auto_migrate"
243
+ end
244
+
245
+ def setup_bundler_audit
246
+ copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
247
+ append_file "Rakefile", %{\ntask default: "bundle:audit"\n}
248
+ end
249
+
239
250
  def copy_miscellaneous_files
240
- copy_file "browserslist", "browserslist"
241
251
  copy_file "errors.rb", "config/initializers/errors.rb"
242
252
  copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
243
253
  end
@@ -279,10 +289,8 @@ config.public_file_server.headers = {
279
289
  end
280
290
  end
281
291
 
282
- def remove_routes_comment_lines
283
- replace_in_file 'config/routes.rb',
284
- /Rails\.application\.routes\.draw do.*end/m,
285
- "Rails.application.routes.draw do\nend"
292
+ def run_rubocop_autocorrect
293
+ Bundler.with_clean_env { run "bundle exec rubocop -a" }
286
294
  end
287
295
 
288
296
  def setup_rakefile
@@ -55,8 +55,6 @@ module Suspenders
55
55
  invoke :create_heroku_apps
56
56
  invoke :generate_deployment_default
57
57
  invoke :remove_config_comment_lines
58
- invoke :remove_routes_comment_lines
59
- invoke :outro
60
58
  end
61
59
 
62
60
  def customize_gemfile
@@ -149,10 +147,6 @@ module Suspenders
149
147
  build :remove_config_comment_lines
150
148
  end
151
149
 
152
- def remove_routes_comment_lines
153
- build :remove_routes_comment_lines
154
- end
155
-
156
150
  def generate_default
157
151
  generate("suspenders:json")
158
152
  generate("suspenders:static")
@@ -164,11 +158,12 @@ module Suspenders
164
158
  generate("suspenders:factories")
165
159
  generate("suspenders:lint")
166
160
  generate("suspenders:stylelint")
167
- generate("suspenders:views")
168
161
  generate("suspenders:decorator")
169
162
  generate("suspenders:faker")
170
163
  generate("suspenders:security")
171
164
  generate("suspenders:import_dump")
165
+ generate("suspenders:jobs")
166
+ generate("suspenders:inline_svg")
172
167
  end
173
168
 
174
169
  def generate_deployment_default
@@ -181,7 +176,13 @@ module Suspenders
181
176
  generate("suspenders:production:manifest")
182
177
  end
183
178
 
184
- def outro
179
+ def generate_views
180
+ generate("suspenders:views")
181
+ end
182
+
183
+ def generate_outro
184
+ build :run_rubocop_autocorrect
185
+
185
186
  say "Congratulations! You just pulled our suspenders."
186
187
  say "Read README.md!"
187
188
  end
@@ -4,7 +4,7 @@ module Suspenders
4
4
  class FactoriesGenerator < Generators::Base
5
5
  def add_factory_bot
6
6
  gem "factory_bot_rails", group: %i(development test)
7
- gem "database_cleaner", group: %i(development test)
7
+ gem "database_cleaner", group: %i(development test), require: false
8
8
  Bundler.with_clean_env { run "bundle install" }
9
9
  end
10
10
 
@@ -0,0 +1,14 @@
1
+ require_relative "base"
2
+
3
+ module Suspenders
4
+ class InlineSvgGenerator < Generators::Base
5
+ def add_inline_svg
6
+ gem "inline_svg"
7
+ Bundler.with_clean_env { run "bundle install" }
8
+ end
9
+
10
+ def configure_inline_svg
11
+ copy_file "inline_svg.rb", "config/initializers/inline_svg.rb"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,53 @@
1
+ require_relative "base"
2
+
3
+ module Suspenders
4
+ class JobsGenerator < Generators::Base
5
+ def add_jobs_gem
6
+ gem "sidekiq"
7
+ Bundler.with_clean_env { run "bundle install" }
8
+ end
9
+
10
+ def configure_foreman
11
+ append_to_file(
12
+ 'Procfile',
13
+ 'worker: bundle exec sidekiq -C config/sidekiq.yml'
14
+ )
15
+ end
16
+
17
+ def configure_sidekiq
18
+ copy_file(
19
+ "config_sidekiq.yml",
20
+ "config/sidekiq.yml"
21
+ )
22
+ end
23
+
24
+ def configure_sidekiq_web
25
+ inject_into_file(
26
+ "config/routes.rb",
27
+ "require 'sidekiq/web'\n\n",
28
+ before: "Rails.application.routes.draw do\n"
29
+ )
30
+ inject_into_file(
31
+ "config/routes.rb",
32
+ " mount Sidekiq::Web => '/sidekiq'\n",
33
+ after: "Rails.application.routes.draw do\n"
34
+ )
35
+ warn "Sidekiq web is public! Read https://github.com/mperham/sidekiq/wiki/Monitoring to learn how to add authentication"
36
+ end
37
+
38
+ def configure_sidekiq_test
39
+ copy_file(
40
+ "spec_support_sidekiq.rb",
41
+ "spec/support/sidekiq.rb"
42
+ )
43
+ end
44
+
45
+ def configure_active_job
46
+ inject_into_file(
47
+ "config/application.rb",
48
+ "\n config.active_job.queue_adapter = :sidekiq",
49
+ before: "\n end",
50
+ )
51
+ end
52
+ end
53
+ end
@@ -7,7 +7,7 @@ module Suspenders
7
7
  copy_file "smtp.rb", "config/smtp.rb"
8
8
 
9
9
  prepend_file "config/environments/production.rb",
10
- %{require Rails.root.join("config/smtp")\n}
10
+ %{require Rails.root.join('config', 'smtp')\n}
11
11
  end
12
12
 
13
13
  def use_smtp
@@ -35,14 +35,14 @@ module Suspenders
35
35
 
36
36
  def context_configuration
37
37
  <<-RUBY
38
- before_action :set_raven_context
38
+ before_action :set_raven_context
39
39
 
40
- private
40
+ private
41
41
 
42
- def set_raven_context
43
- Raven.user_context(id: session[:current_user_id])
44
- Raven.extra_context(params: params.to_unsafe_h, url: request.url)
45
- end
42
+ def set_raven_context
43
+ Raven.user_context(id: session[:current_user_id])
44
+ Raven.extra_context(params: params.to_unsafe_h, url: request.url)
45
+ end
46
46
  RUBY
47
47
  end
48
48
  end
@@ -10,13 +10,14 @@ module Suspenders
10
10
  scripts: {},
11
11
  env: {
12
12
  APPLICATION_HOST: { required: true },
13
+ AUTO_MIGRATE_DB: { value: "true" },
13
14
  EMAIL_RECIPIENTS: { required: true },
14
15
  HEROKU_APP_NAME: { required: true },
15
16
  HEROKU_PARENT_APP_NAME: { required: true },
16
17
  RACK_ENV: { required: true },
17
18
  SECRET_KEY_BASE: { generator: "secret" },
18
19
  },
19
- addons: ["heroku-postgresql"],
20
+ addons: ["heroku-postgresql", "heroku-redis"],
20
21
  )
21
22
  end
22
23
  end
@@ -5,6 +5,7 @@ module Suspenders
5
5
  class TimeoutGenerator < Generators::Base
6
6
  def add_gem
7
7
  gem "rack-timeout", group: :production
8
+ Bundler.with_clean_env { run "bundle install" }
8
9
  end
9
10
 
10
11
  def configure_rack_timeout