suspenders 1.54.1 → 1.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/NEWS.md +6 -0
  4. data/Rakefile +6 -5
  5. data/lib/suspenders/adapters/heroku.rb +16 -16
  6. data/lib/suspenders/app_builder.rb +40 -40
  7. data/lib/suspenders/generators/advisories_generator.rb +1 -1
  8. data/lib/suspenders/generators/analytics_generator.rb +1 -1
  9. data/lib/suspenders/generators/app_generator.rb +25 -25
  10. data/lib/suspenders/generators/base.rb +2 -2
  11. data/lib/suspenders/generators/db_optimizations_generator.rb +2 -2
  12. data/lib/suspenders/generators/factories_generator.rb +1 -1
  13. data/lib/suspenders/generators/jobs_generator.rb +3 -3
  14. data/lib/suspenders/generators/js_driver_generator.rb +1 -1
  15. data/lib/suspenders/generators/lint_generator.rb +5 -0
  16. data/lib/suspenders/generators/preloader_generator.rb +4 -4
  17. data/lib/suspenders/generators/production/compression_generator.rb +1 -1
  18. data/lib/suspenders/generators/production/email_generator.rb +6 -6
  19. data/lib/suspenders/generators/production/manifest_generator.rb +8 -8
  20. data/lib/suspenders/generators/production/single_redirect.rb +1 -1
  21. data/lib/suspenders/generators/production/timeout_generator.rb +2 -2
  22. data/lib/suspenders/generators/profiler_generator.rb +4 -4
  23. data/lib/suspenders/generators/runner_generator.rb +4 -4
  24. data/lib/suspenders/generators/staging/pull_requests_generator.rb +2 -2
  25. data/lib/suspenders/generators/stylelint_generator.rb +2 -1
  26. data/lib/suspenders/generators/stylesheet_base_generator.rb +1 -1
  27. data/lib/suspenders/generators/testing_generator.rb +2 -2
  28. data/lib/suspenders/version.rb +5 -5
  29. data/spec/adapters/heroku_spec.rb +16 -16
  30. data/spec/expand_json_spec.rb +9 -9
  31. data/spec/fakes/bin/heroku +1 -1
  32. data/spec/fakes/bin/hub +1 -1
  33. data/spec/features/cli_help_spec.rb +4 -4
  34. data/spec/features/heroku_spec.rb +3 -3
  35. data/spec/features/lint_spec.rb +26 -0
  36. data/spec/features/new_project_spec.rb +33 -33
  37. data/spec/features/production/compression_spec.rb +2 -2
  38. data/spec/features/production/email_spec.rb +10 -10
  39. data/spec/features/production/manifest_spec.rb +16 -16
  40. data/spec/features/production/single_redirect_spec.rb +2 -2
  41. data/spec/features/profiler_spec.rb +2 -2
  42. data/spec/features/stylelint_spec.rb +7 -7
  43. data/spec/spec_helper.rb +3 -3
  44. data/spec/support/fake_github.rb +3 -3
  45. data/spec/support/fake_heroku.rb +8 -8
  46. data/spec/support/project_files.rb +1 -1
  47. data/spec/support/suspenders.rb +3 -4
  48. data/suspenders.gemspec +20 -20
  49. data/templates/capybara_silence_puma.rb +1 -1
  50. data/templates/errors.rb +3 -3
  51. data/templates/hound.yml +1 -2
  52. data/templates/partials/ci_simplecov.rb +0 -2
  53. data/templates/partials/db_optimizations_configuration.rb +5 -7
  54. data/templates/partials/email_smtp.rb +2 -3
  55. data/templates/partials/pull_requests_config.rb +0 -1
  56. data/templates/partials/runner_setup.rb +1 -2
  57. data/templates/spec_helper.rb +1 -1
  58. data/templates/spring.rb +1 -1
  59. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1c3a5fd298d2c49ceed3d4b3c79d99590aae75259c0f4ec6f06bd6f244336d3
4
- data.tar.gz: c880d208a127a68da87b63a33da39fade1abf8e6c6d6b754806771be68e23e03
3
+ metadata.gz: 5e684d97af6b8cca59865bb7d84045625df2357214bd756f63456435160f49b3
4
+ data.tar.gz: b0ae039bf62ed232460bd9f0eb924ccce92555dda231e8fe051401ae647d65c1
5
5
  SHA512:
6
- metadata.gz: 35d40b50ca80e2248efe6cc0c5ac5b87eff319aa6638e9293bafbb798081a1143b7a2d0e5907261bf68ceece79f482471c0762782a6d4cfebc69b0871fe8ea28
7
- data.tar.gz: d02195af5d9673603233ce092cae10b4a2e2cf49697d8129c808a378d743d008f9046787b53ec050ec9a4450433fb063a7fbc4308fb5c16efc17d3ed73de291a
6
+ metadata.gz: 653fd7de13544c3081459fa32a85814d85925fe087c027aee63477d691b30179cac09b24172da99bfdd3f6260a38812b9acd55cd483e21d3e1fba91a4ef88ec2
7
+ data.tar.gz: 69d4f55ea43380c41e4cee01ace5c15aebcb1840b7ac1310c34299b799fc82bc1673ab0b4deb2c5441289648e493fd0ee2f393a1218fd641d03d3a3406089efb
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  Unreleased
2
2
 
3
+ 1.55.0 (July 15, 2020)
4
+
5
+ * Changed: lint generator to install standard instead of RuboCop
6
+ * Changed: profile generator and timeout generator to write to `.sample.env`
7
+ instead of `.env`
8
+
3
9
  1.54.1 (June 30, 2020)
4
10
 
5
11
  * Fixed: invalid Gemfile entry for bundler-audit
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
- require 'bundler/setup'
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
1
+ require "bundler/setup"
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ require "standard/rake"
4
5
 
5
6
  RSpec::Core::RakeTask.new(:rspec)
6
7
 
7
- desc 'Run the test suite'
8
- task :default => :rspec
8
+ desc "Run the test suite"
9
+ task default: [:rspec, :standard]
@@ -7,8 +7,8 @@ module Suspenders
7
7
 
8
8
  def set_heroku_remotes
9
9
  remotes = <<~SHELL
10
- #{command_to_join_heroku_app('staging')}
11
- #{command_to_join_heroku_app('production')}
10
+ #{command_to_join_heroku_app("staging")}
11
+ #{command_to_join_heroku_app("production")}
12
12
 
13
13
  git config heroku.remote staging
14
14
  SHELL
@@ -29,28 +29,28 @@ module Suspenders
29
29
  end
30
30
 
31
31
  def set_heroku_rails_secrets
32
- %w(staging production).each do |environment|
32
+ %w[staging production].each do |environment|
33
33
  run_toolbelt_command(
34
34
  "config:add SECRET_KEY_BASE=#{generate_secret}",
35
- environment,
35
+ environment
36
36
  )
37
37
  end
38
38
  end
39
39
 
40
40
  def set_heroku_honeybadger_env
41
- %w(staging production).each do |environment|
41
+ %w[staging production].each do |environment|
42
42
  run_toolbelt_command(
43
43
  "config:add HONEYBADGER_ENV=#{environment}",
44
- environment,
44
+ environment
45
45
  )
46
46
  end
47
47
  end
48
48
 
49
49
  def set_heroku_backup_schedule
50
- %w(staging production).each do |environment|
50
+ %w[staging production].each do |environment|
51
51
  run_toolbelt_command(
52
52
  "pg:backups:schedule DATABASE_URL --at '10:00 UTC'",
53
- environment,
53
+ environment
54
54
  )
55
55
  end
56
56
  end
@@ -65,34 +65,34 @@ module Suspenders
65
65
  run_toolbelt_command(
66
66
  "pipelines:create #{heroku_app_name} \
67
67
  -a #{heroku_app_name}-staging --stage staging",
68
- "staging",
68
+ "staging"
69
69
  )
70
70
 
71
71
  run_toolbelt_command(
72
72
  "pipelines:add #{heroku_app_name} \
73
73
  -a #{heroku_app_name}-production --stage production",
74
- "production",
74
+ "production"
75
75
  )
76
76
  end
77
77
 
78
78
  def set_heroku_application_host
79
- %w(staging production).each do |environment|
79
+ %w[staging production].each do |environment|
80
80
  run_toolbelt_command(
81
81
  "config:add APPLICATION_HOST=#{heroku_app_name}-#{environment}.herokuapp.com",
82
- environment,
82
+ environment
83
83
  )
84
84
  end
85
85
  end
86
86
 
87
87
  def set_heroku_buildpacks
88
- %w(staging production).each do |environment|
88
+ %w[staging production].each do |environment|
89
89
  run_toolbelt_command(
90
90
  "buildpacks:add --index 1 heroku/nodejs",
91
- environment,
91
+ environment
92
92
  )
93
93
  run_toolbelt_command(
94
94
  "buildpacks:add --index 2 heroku/ruby",
95
- environment,
95
+ environment
96
96
  )
97
97
  end
98
98
  end
@@ -128,7 +128,7 @@ module Suspenders
128
128
 
129
129
  def run_toolbelt_command(command, environment)
130
130
  app_builder.run(
131
- "heroku #{command} --remote #{environment}",
131
+ "heroku #{command} --remote #{environment}"
132
132
  )
133
133
  end
134
134
  end
@@ -15,11 +15,11 @@ module Suspenders
15
15
  :set_heroku_honeybadger_env,
16
16
  :set_heroku_rails_secrets,
17
17
  :set_heroku_remotes,
18
- :set_heroku_buildpacks,
18
+ :set_heroku_buildpacks
19
19
  )
20
20
 
21
21
  def readme
22
- template 'README.md.erb', 'README.md'
22
+ template "README.md.erb", "README.md"
23
23
  end
24
24
 
25
25
  def gitignore
@@ -33,7 +33,7 @@ module Suspenders
33
33
  def setup_rack_mini_profiler
34
34
  copy_file(
35
35
  "rack_mini_profiler.rb",
36
- "config/initializers/rack_mini_profiler.rb",
36
+ "config/initializers/rack_mini_profiler.rb"
37
37
  )
38
38
  end
39
39
 
@@ -42,15 +42,15 @@ module Suspenders
42
42
  end
43
43
 
44
44
  def raise_on_delivery_errors
45
- replace_in_file 'config/environments/development.rb',
46
- 'raise_delivery_errors = false', 'raise_delivery_errors = true'
45
+ replace_in_file "config/environments/development.rb",
46
+ "raise_delivery_errors = false", "raise_delivery_errors = true"
47
47
  end
48
48
 
49
49
  def set_test_delivery_method
50
50
  inject_into_file(
51
51
  "config/environments/development.rb",
52
52
  "\n config.action_mailer.delivery_method = :file",
53
- after: "config.action_mailer.raise_delivery_errors = true",
53
+ after: "config.action_mailer.raise_delivery_errors = true"
54
54
  )
55
55
  end
56
56
 
@@ -90,7 +90,7 @@ module Suspenders
90
90
 
91
91
  RUBY
92
92
 
93
- inject_into_class 'config/application.rb', 'Application', config
93
+ inject_into_class "config/application.rb", "Application", config
94
94
  end
95
95
 
96
96
  def configure_local_mail
@@ -98,27 +98,27 @@ module Suspenders
98
98
  end
99
99
 
100
100
  def setup_asset_host
101
- replace_in_file 'config/environments/production.rb',
101
+ replace_in_file "config/environments/production.rb",
102
102
  "# config.action_controller.asset_host = 'http://assets.example.com'",
103
103
  'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))'
104
104
 
105
105
  if File.exist?("config/initializers/assets.rb")
106
- replace_in_file 'config/initializers/assets.rb',
106
+ replace_in_file "config/initializers/assets.rb",
107
107
  "config.assets.version = '1.0'",
108
108
  'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
109
109
  end
110
110
 
111
- config = <<-EOD
112
- config.public_file_server.headers = {
113
- "Cache-Control" => "public, max-age=31557600",
114
- }
111
+ config = <<~EOD
112
+ config.public_file_server.headers = {
113
+ "Cache-Control" => "public, max-age=31557600",
114
+ }
115
115
  EOD
116
116
 
117
117
  configure_environment("production", config)
118
118
  end
119
119
 
120
120
  def setup_secret_token
121
- template 'secrets.yml', 'config/secrets.yml', force: true
121
+ template "secrets.yml", "config/secrets.yml", force: true
122
122
  end
123
123
 
124
124
  def disallow_wrapping_parameters
@@ -126,7 +126,7 @@ config.public_file_server.headers = {
126
126
  end
127
127
 
128
128
  def use_postgres_config_template
129
- template 'postgresql_database.yml.erb', 'config/database.yml',
129
+ template "postgresql_database.yml.erb", "config/database.yml",
130
130
  force: true
131
131
  end
132
132
 
@@ -135,9 +135,9 @@ config.public_file_server.headers = {
135
135
  end
136
136
 
137
137
  def replace_gemfile(path)
138
- template 'Gemfile.erb', 'Gemfile', force: true do |content|
138
+ template "Gemfile.erb", "Gemfile", force: true do |content|
139
139
  if path
140
- content.gsub(%r{gem .suspenders.}) { |s| %{#{s}, path: "#{path}"} }
140
+ content.gsub(%r{gem .suspenders.}) { |s| %(#{s}, path: "#{path}") }
141
141
  else
142
142
  content
143
143
  end
@@ -145,7 +145,7 @@ config.public_file_server.headers = {
145
145
  end
146
146
 
147
147
  def ruby_version
148
- create_file '.ruby-version', "#{Suspenders::RUBY_VERSION}\n"
148
+ create_file ".ruby-version", "#{Suspenders::RUBY_VERSION}\n"
149
149
  end
150
150
 
151
151
  def configure_i18n_for_missing_translations
@@ -154,7 +154,7 @@ config.public_file_server.headers = {
154
154
  end
155
155
 
156
156
  def configure_action_mailer_in_specs
157
- copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
157
+ copy_file "action_mailer.rb", "spec/support/action_mailer.rb"
158
158
  end
159
159
 
160
160
  def configure_time_formats
@@ -163,14 +163,14 @@ config.public_file_server.headers = {
163
163
  end
164
164
 
165
165
  def configure_action_mailer
166
- action_mailer_host "development", %{"localhost:3000"}
167
- action_mailer_asset_host "development", %{"http://localhost:3000"}
168
- action_mailer_host "test", %{"www.example.com"}
169
- action_mailer_asset_host "test", %{"http://www.example.com"}
166
+ action_mailer_host "development", %("localhost:3000")
167
+ action_mailer_asset_host "development", %("http://localhost:3000")
168
+ action_mailer_host "test", %("www.example.com")
169
+ action_mailer_asset_host "test", %("http://www.example.com")
170
170
  action_mailer_host "production", %{ENV.fetch("APPLICATION_HOST")}
171
171
  action_mailer_asset_host(
172
172
  "production",
173
- %{ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))},
173
+ %{ENV.fetch("ASSET_HOST", ENV.fetch("APPLICATION_HOST"))}
174
174
  )
175
175
  end
176
176
 
@@ -199,15 +199,15 @@ config.public_file_server.headers = {
199
199
  "environment.rb",
200
200
  "environments/development.rb",
201
201
  "environments/production.rb",
202
- "environments/test.rb",
202
+ "environments/test.rb"
203
203
  ]
204
204
 
205
205
  config_files.each do |config_file|
206
206
  path = File.join(destination_root, "config/#{config_file}")
207
207
 
208
- accepted_content = File.readlines(path).reject do |line|
208
+ accepted_content = File.readlines(path).reject { |line|
209
209
  line =~ /^.*#.*$/ || line =~ /^$\n/
210
- end
210
+ }
211
211
 
212
212
  File.open(path, "w") do |file|
213
213
  accepted_content.each { |line| file.puts line }
@@ -216,23 +216,23 @@ config.public_file_server.headers = {
216
216
  end
217
217
 
218
218
  def remove_routes_comment_lines
219
- replace_in_file 'config/routes.rb',
219
+ replace_in_file "config/routes.rb",
220
220
  /Rails\.application\.routes\.draw do.*end/m,
221
221
  "Rails.application.routes.draw do\nend"
222
222
  end
223
223
 
224
224
  def setup_default_rake_task
225
- append_file 'Rakefile' do
226
- <<-EOS
227
- task(:default).clear
228
- task default: [:spec]
229
-
230
- if defined? RSpec
231
- task(:spec).clear
232
- RSpec::Core::RakeTask.new(:spec) do |t|
233
- t.verbose = false
234
- end
235
- end
225
+ append_file "Rakefile" do
226
+ <<~EOS
227
+ task(:default).clear
228
+ task default: [:spec]
229
+
230
+ if defined? RSpec
231
+ task(:spec).clear
232
+ RSpec::Core::RakeTask.new(:spec) do |t|
233
+ t.verbose = false
234
+ end
235
+ end
236
236
  EOS
237
237
  end
238
238
  end
@@ -240,7 +240,7 @@ end
240
240
  private
241
241
 
242
242
  def raise_on_missing_translations_in(environment)
243
- config = 'config.action_view.raise_on_missing_translations = true'
243
+ config = "config.action_view.raise_on_missing_translations = true"
244
244
 
245
245
  uncomment_lines("config/environments/#{environment}.rb", config)
246
246
  end
@@ -9,7 +9,7 @@ module Suspenders
9
9
 
10
10
  def rake_task
11
11
  copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
12
- append_file "Rakefile", %{\ntask default: "bundle:audit"\n}
12
+ append_file "Rakefile", %(\ntask default: "bundle:audit"\n)
13
13
  end
14
14
  end
15
15
  end
@@ -10,7 +10,7 @@ module Suspenders
10
10
  def render_partial
11
11
  if File.exist?(js_partial)
12
12
  inject_into_file js_partial,
13
- %{\n\n<%= render "analytics" %>},
13
+ %(\n\n<%= render "analytics" %>),
14
14
  after: "<%= yield :javascript %>"
15
15
  end
16
16
  end
@@ -1,39 +1,39 @@
1
- require 'rails/generators'
2
- require 'rails/generators/rails/app/app_generator'
1
+ require "rails/generators"
2
+ require "rails/generators/rails/app/app_generator"
3
3
 
4
4
  module Suspenders
5
5
  class AppGenerator < Rails::Generators::AppGenerator
6
6
  hide!
7
7
 
8
8
  class_option :database, type: :string, aliases: "-d", default: "postgresql",
9
- desc: "Configure for selected database (options: #{DATABASES.join("/")})"
9
+ desc: "Configure for selected database (options: #{DATABASES.join("/")})"
10
10
 
11
11
  class_option :heroku, type: :boolean, aliases: "-H", default: false,
12
- desc: "Create staging and production Heroku apps"
12
+ desc: "Create staging and production Heroku apps"
13
13
 
14
14
  class_option :heroku_flags, type: :string, default: "",
15
- desc: "Set extra Heroku flags"
15
+ desc: "Set extra Heroku flags"
16
16
 
17
17
  class_option :github, type: :string, default: nil,
18
- desc: "Create Github repository and add remote origin pointed to repo"
18
+ desc: "Create Github repository and add remote origin pointed to repo"
19
19
 
20
20
  class_option :version, type: :boolean, aliases: "-v", group: :suspenders,
21
- desc: "Show Suspenders version number and quit"
21
+ desc: "Show Suspenders version number and quit"
22
22
 
23
- class_option :help, type: :boolean, aliases: '-h', group: :suspenders,
24
- desc: "Show this help message and quit"
23
+ class_option :help, type: :boolean, aliases: "-h", group: :suspenders,
24
+ desc: "Show this help message and quit"
25
25
 
26
26
  class_option :path, type: :string, default: nil,
27
- desc: "Path to the gem"
27
+ desc: "Path to the gem"
28
28
 
29
29
  class_option :skip_test, type: :boolean, default: true,
30
- desc: "Skip Test Unit"
30
+ desc: "Skip Test Unit"
31
31
 
32
32
  class_option :skip_system_test,
33
- type: :boolean, default: true, desc: "Skip system test files"
33
+ type: :boolean, default: true, desc: "Skip system test files"
34
34
 
35
35
  class_option :skip_turbolinks,
36
- type: :boolean, default: true, desc: "Skip turbolinks gem"
36
+ type: :boolean, default: true, desc: "Skip turbolinks gem"
37
37
 
38
38
  def finish_template
39
39
  invoke :suspenders_customization
@@ -59,13 +59,13 @@ module Suspenders
59
59
 
60
60
  def customize_gemfile
61
61
  build :replace_gemfile, options[:path]
62
- bundle_command 'install'
62
+ bundle_command "install"
63
63
  end
64
64
 
65
65
  def setup_database
66
- say 'Setting up database'
66
+ say "Setting up database"
67
67
 
68
- if 'postgresql' == options[:database]
68
+ if options[:database] == "postgresql"
69
69
  build :use_postgres_config_template
70
70
  end
71
71
 
@@ -73,7 +73,7 @@ module Suspenders
73
73
  end
74
74
 
75
75
  def setup_development_environment
76
- say 'Setting up the development environment'
76
+ say "Setting up the development environment"
77
77
  build :configure_local_mail
78
78
  build :raise_on_missing_assets_in_test
79
79
  build :raise_on_delivery_errors
@@ -86,17 +86,17 @@ module Suspenders
86
86
  end
87
87
 
88
88
  def setup_production_environment
89
- say 'Setting up the production environment'
89
+ say "Setting up the production environment"
90
90
  build :setup_asset_host
91
91
  end
92
92
 
93
93
  def setup_secret_token
94
- say 'Moving secret token out of version control'
94
+ say "Moving secret token out of version control"
95
95
  build :setup_secret_token
96
96
  end
97
97
 
98
98
  def configure_app
99
- say 'Configuring app'
99
+ say "Configuring app"
100
100
  build :configure_action_mailer
101
101
  build :configure_time_formats
102
102
  build :setup_default_rake_task
@@ -119,13 +119,13 @@ module Suspenders
119
119
 
120
120
  def create_github_repo
121
121
  if !options[:skip_git] && options[:github]
122
- say 'Creating Github repo'
122
+ say "Creating Github repo"
123
123
  build :create_github_repo, options[:github]
124
124
  end
125
125
  end
126
126
 
127
127
  def copy_miscellaneous_files
128
- say 'Copying miscellaneous support files'
128
+ say "Copying miscellaneous support files"
129
129
  build :copy_miscellaneous_files
130
130
  end
131
131
 
@@ -139,6 +139,7 @@ module Suspenders
139
139
 
140
140
  def generate_default
141
141
  run("spring stop")
142
+ generate("suspenders:runner")
142
143
  generate("suspenders:profiler")
143
144
  generate("suspenders:json")
144
145
  generate("suspenders:static")
@@ -156,7 +157,6 @@ module Suspenders
156
157
  generate("suspenders:analytics")
157
158
  generate("suspenders:inline_svg")
158
159
  generate("suspenders:advisories")
159
- generate("suspenders:runner")
160
160
  generate("suspenders:preloader")
161
161
  end
162
162
 
@@ -176,12 +176,12 @@ module Suspenders
176
176
  end
177
177
 
178
178
  def outro
179
- say 'Congratulations! You just pulled our suspenders.'
179
+ say "Congratulations! You just pulled our suspenders."
180
180
  say honeybadger_outro
181
181
  end
182
182
 
183
183
  def self.banner
184
- "suspenders #{arguments.map(&:usage).join(' ')} [options]"
184
+ "suspenders #{arguments.map(&:usage).join(" ")} [options]"
185
185
  end
186
186
 
187
187
  protected