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
@@ -17,8 +17,8 @@ module Suspenders
17
17
  File.join(
18
18
  default_source_root,
19
19
  "descriptions",
20
- "#{subclass.generator_name}.md",
21
- ),
20
+ "#{subclass.generator_name}.md"
21
+ )
22
22
  )
23
23
 
24
24
  subclass.desc File.read(description_file)
@@ -3,7 +3,7 @@ require_relative "base"
3
3
  module Suspenders
4
4
  class DbOptimizationsGenerator < Generators::Base
5
5
  def add_bullet
6
- gem "bullet", group: %i(development test)
6
+ gem "bullet", group: %i[development test]
7
7
  Bundler.with_unbundled_env { run "bundle install" }
8
8
  end
9
9
 
@@ -11,7 +11,7 @@ module Suspenders
11
11
  inject_template_into_file(
12
12
  "config/environments/development.rb",
13
13
  "partials/db_optimizations_configuration.rb",
14
- after: /config.action_mailer.raise_delivery_errors = .*/,
14
+ after: /config.action_mailer.raise_delivery_errors = .*/
15
15
  )
16
16
  end
17
17
  end
@@ -3,7 +3,7 @@ require_relative "base"
3
3
  module Suspenders
4
4
  class FactoriesGenerator < Generators::Base
5
5
  def add_factory_bot
6
- gem "factory_bot_rails", group: %i(development test)
6
+ gem "factory_bot_rails", group: %i[development test]
7
7
  Bundler.with_unbundled_env { run "bundle install" }
8
8
  end
9
9
 
@@ -14,13 +14,13 @@ module Suspenders
14
14
  def initialize_active_job
15
15
  copy_file(
16
16
  "active_job.rb",
17
- "config/initializers/active_job.rb",
17
+ "config/initializers/active_job.rb"
18
18
  )
19
19
  end
20
20
 
21
21
  def configure_active_job
22
22
  configure_application_file(
23
- "config.active_job.queue_adapter = :delayed_job",
23
+ "config.active_job.queue_adapter = :delayed_job"
24
24
  )
25
25
  configure_environment "test", "config.active_job.queue_adapter = :inline"
26
26
  end
@@ -31,7 +31,7 @@ module Suspenders
31
31
  inject_into_file(
32
32
  "config/application.rb",
33
33
  "\n #{config}",
34
- before: "\n end",
34
+ before: "\n end"
35
35
  )
36
36
  end
37
37
  end
@@ -11,7 +11,7 @@ module Suspenders
11
11
  copy_file "chromedriver.rb", "spec/support/chromedriver.rb"
12
12
  copy_file(
13
13
  "capybara_silence_puma.rb",
14
- "spec/support/capybara_silence_puma.rb",
14
+ "spec/support/capybara_silence_puma.rb"
15
15
  )
16
16
  end
17
17
  end
@@ -5,5 +5,10 @@ module Suspenders
5
5
  def set_up_hound
6
6
  copy_file "hound.yml", ".hound.yml"
7
7
  end
8
+
9
+ def set_up_standard
10
+ gem "standard", group: :development
11
+ prepend_to_file("Rakefile", 'require "standard/rake"')
12
+ end
8
13
  end
9
14
  end
@@ -54,7 +54,7 @@ module Suspenders
54
54
  :always_gsub_file,
55
55
  @config_file,
56
56
  "config.cache_classes = true",
57
- "config.cache_classes = false",
57
+ "config.cache_classes = false"
58
58
  )
59
59
  end
60
60
 
@@ -63,7 +63,7 @@ module Suspenders
63
63
  :always_gsub_file,
64
64
  @config_file,
65
65
  "config.cache_classes = false",
66
- "config.cache_classes = true",
66
+ "config.cache_classes = true"
67
67
  )
68
68
  end
69
69
  end
@@ -71,10 +71,10 @@ module Suspenders
71
71
  protected
72
72
 
73
73
  def always_run(command, with: nil, verbose: true, env: nil, capture: nil,
74
- abort_on_failure: nil)
74
+ abort_on_failure: nil)
75
75
  destination = relative_to_original_destination_root(
76
76
  destination_root,
77
- false,
77
+ false
78
78
  )
79
79
  desc = "#{command} from #{destination.inspect}"
80
80
 
@@ -6,7 +6,7 @@ module Suspenders
6
6
  def add_rack_deflater
7
7
  configure_environment(
8
8
  :production,
9
- %{config.middleware.use Rack::Deflater},
9
+ %(config.middleware.use Rack::Deflater)
10
10
  )
11
11
  end
12
12
  end
@@ -14,7 +14,7 @@ module Suspenders
14
14
  inject_template_into_file(
15
15
  "config/environments/production.rb",
16
16
  "partials/email_smtp.rb",
17
- after: "config.action_mailer.perform_caching = false",
17
+ after: "config.action_mailer.perform_caching = false"
18
18
  )
19
19
  end
20
20
 
@@ -22,11 +22,11 @@ module Suspenders
22
22
  expand_json(
23
23
  "app.json",
24
24
  env: {
25
- SMTP_ADDRESS: { required: true },
26
- SMTP_DOMAIN: { required: true },
27
- SMTP_PASSWORD: { required: true },
28
- SMTP_USERNAME: { required: true },
29
- },
25
+ SMTP_ADDRESS: {required: true},
26
+ SMTP_DOMAIN: {required: true},
27
+ SMTP_PASSWORD: {required: true},
28
+ SMTP_USERNAME: {required: true}
29
+ }
30
30
  )
31
31
  end
32
32
  end
@@ -9,15 +9,15 @@ module Suspenders
9
9
  name: app_name.dasherize,
10
10
  scripts: {},
11
11
  env: {
12
- APPLICATION_HOST: { required: true },
13
- AUTO_MIGRATE_DB: { value: true },
14
- EMAIL_RECIPIENTS: { required: true },
15
- HEROKU_APP_NAME: { required: true },
16
- HEROKU_PARENT_APP_NAME: { required: true },
17
- RACK_ENV: { required: true },
18
- SECRET_KEY_BASE: { generator: "secret" },
12
+ APPLICATION_HOST: {required: true},
13
+ AUTO_MIGRATE_DB: {value: true},
14
+ EMAIL_RECIPIENTS: {required: true},
15
+ HEROKU_APP_NAME: {required: true},
16
+ HEROKU_PARENT_APP_NAME: {required: true},
17
+ RACK_ENV: {required: true},
18
+ SECRET_KEY_BASE: {generator: "secret"}
19
19
  },
20
- addons: ["heroku-postgresql"],
20
+ addons: ["heroku-postgresql"]
21
21
  )
22
22
  end
23
23
  end
@@ -7,7 +7,7 @@ module Suspenders
7
7
  inject_into_file(
8
8
  "config/environments/production.rb",
9
9
  %{\n config.middleware.use Rack::CanonicalHost, ENV.fetch("APPLICATION_HOST")},
10
- before: "\nend",
10
+ before: "\nend"
11
11
  )
12
12
  end
13
13
  end
@@ -9,13 +9,13 @@ module Suspenders
9
9
  end
10
10
 
11
11
  def configure_rack_timeout
12
- append_file ".env", rack_timeout_config
12
+ append_file ".sample.env", rack_timeout_config
13
13
  end
14
14
 
15
15
  private
16
16
 
17
17
  def rack_timeout_config
18
- %{RACK_TIMEOUT_SERVICE_TIMEOUT=10}
18
+ %(RACK_TIMEOUT_SERVICE_TIMEOUT=10)
19
19
  end
20
20
  end
21
21
  end
@@ -3,12 +3,12 @@ require_relative "base"
3
3
  module Suspenders
4
4
  class ProfilerGenerator < Generators::Base
5
5
  def augment_default_env
6
- append_to_file ".env", "RACK_MINI_PROFILER=0\n"
6
+ append_to_file ".sample.env", "RACK_MINI_PROFILER=0\n"
7
7
  rescue Errno::ENOENT
8
- create_file ".env", "RACK_MINI_PROFILER=0\n"
8
+ create_file ".sample.env", "RACK_MINI_PROFILER=0\n"
9
9
  rescue Thor::Error => e
10
10
  if e.message.match?(/does not appear to exist/)
11
- create_file ".env", "RACK_MINI_PROFILER=0\n"
11
+ create_file ".sample.env", "RACK_MINI_PROFILER=0\n"
12
12
  else
13
13
  raise
14
14
  end
@@ -24,7 +24,7 @@ module Suspenders
24
24
  "rack_mini_profiler.rb",
25
25
  "config/initializers/rack_mini_profiler.rb",
26
26
  force: false,
27
- skip: true,
27
+ skip: true
28
28
  )
29
29
  end
30
30
 
@@ -15,18 +15,18 @@ module Suspenders
15
15
  inject_template_into_file(
16
16
  "bin/setup",
17
17
  "partials/runner_setup.rb",
18
- before: %{ puts "\\n== Preparing database =="},
18
+ before: %( puts "\\n== Preparing database ==")
19
19
  )
20
20
  elsif bin_setup_mentions_ci?
21
21
  inject_into_file(
22
22
  "bin/setup",
23
- %{ cp -i .sample.env .env\n},
24
- after: %{if [ -z "$CI" ]; then\n},
23
+ %( cp -i .sample.env .env\n),
24
+ after: %(if [ -z "$CI" ]; then\n)
25
25
  )
26
26
  else
27
27
  append_to_file(
28
28
  "bin/setup",
29
- %{\nif [ -z "$CI" ]; then\n cp -i .sample.env .env\nfi},
29
+ %(\nif [ -z "$CI" ]; then\n cp -i .sample.env .env\nfi)
30
30
  )
31
31
  end
32
32
  end
@@ -7,7 +7,7 @@ module Suspenders
7
7
  inject_template_into_file(
8
8
  "config/environments/production.rb",
9
9
  "partials/pull_requests_config.rb",
10
- after: "Rails.application.configure do\n",
10
+ after: "Rails.application.configure do\n"
11
11
  )
12
12
  end
13
13
 
@@ -15,7 +15,7 @@ module Suspenders
15
15
  template(
16
16
  "bin_setup_review_app.erb",
17
17
  "bin/setup_review_app",
18
- force: true,
18
+ force: true
19
19
  )
20
20
 
21
21
  run "chmod a+x bin/setup_review_app"
@@ -26,7 +26,8 @@ module Suspenders
26
26
  @base.invoke @generator
27
27
  end
28
28
 
29
- def revoke!; end
29
+ def revoke!
30
+ end
30
31
  end
31
32
 
32
33
  class ToggleComments
@@ -15,7 +15,7 @@ module Suspenders
15
15
  copy_file(
16
16
  "application.scss",
17
17
  "app/assets/stylesheets/application.scss",
18
- force: true,
18
+ force: true
19
19
  )
20
20
  end
21
21
 
@@ -4,7 +4,7 @@ module Suspenders
4
4
  class TestingGenerator < Generators::Base
5
5
  def add_testing_gems
6
6
  gem "spring-commands-rspec", group: :development
7
- gem "rspec-rails", "~> 3.6", group: %i(development test)
7
+ gem "rspec-rails", "~> 3.6", group: %i[development test]
8
8
  gem "shoulda-matchers", group: :test
9
9
 
10
10
  Bundler.with_unbundled_env { run "bundle install" }
@@ -24,7 +24,7 @@ module Suspenders
24
24
  def provide_shoulda_matchers_config
25
25
  copy_file(
26
26
  "shoulda_matchers_config_rspec.rb",
27
- "spec/support/shoulda_matchers.rb",
27
+ "spec/support/shoulda_matchers.rb"
28
28
  )
29
29
  end
30
30
 
@@ -1,8 +1,8 @@
1
1
  module Suspenders
2
2
  RAILS_VERSION = "~> 6.0.0".freeze
3
- RUBY_VERSION = IO.
4
- read("#{File.dirname(__FILE__)}/../../.ruby-version").
5
- strip.
6
- freeze
7
- VERSION = "1.54.1".freeze
3
+ RUBY_VERSION = IO
4
+ .read("#{File.dirname(__FILE__)}/../../.ruby-version")
5
+ .strip
6
+ .freeze
7
+ VERSION = "1.55.0".freeze
8
8
  end
@@ -10,10 +10,10 @@ module Suspenders
10
10
 
11
11
  Heroku.new(app_builder).set_heroku_remotes
12
12
 
13
- expect(app_builder).to have_received(:append_file).
14
- with(setup_file, /heroku apps:info --app #{app_name.dasherize}-production/)
15
- expect(app_builder).to have_received(:append_file).
16
- with(setup_file, /heroku apps:info --app #{app_name.dasherize}-staging/)
13
+ expect(app_builder).to have_received(:append_file)
14
+ .with(setup_file, /heroku apps:info --app #{app_name.dasherize}-production/)
15
+ expect(app_builder).to have_received(:append_file)
16
+ .with(setup_file, /heroku apps:info --app #{app_name.dasherize}-staging/)
17
17
  end
18
18
 
19
19
  it "sets the heroku rails secrets" do
@@ -23,10 +23,10 @@ module Suspenders
23
23
  Heroku.new(app_builder).set_heroku_rails_secrets
24
24
 
25
25
  expect(app_builder).to(
26
- have_configured_var("staging", "SECRET_KEY_BASE"),
26
+ have_configured_var("staging", "SECRET_KEY_BASE")
27
27
  )
28
28
  expect(app_builder).to(
29
- have_configured_var("production", "SECRET_KEY_BASE"),
29
+ have_configured_var("production", "SECRET_KEY_BASE")
30
30
  )
31
31
  end
32
32
 
@@ -47,11 +47,11 @@ module Suspenders
47
47
  Heroku.new(app_builder).set_heroku_application_host
48
48
 
49
49
  expect(app_builder).to(
50
- have_configured_var("staging", "APPLICATION_HOST"),
50
+ have_configured_var("staging", "APPLICATION_HOST")
51
51
  )
52
52
 
53
53
  expect(app_builder).to(
54
- have_configured_var("production", "APPLICATION_HOST"),
54
+ have_configured_var("production", "APPLICATION_HOST")
55
55
  )
56
56
  end
57
57
 
@@ -61,16 +61,16 @@ module Suspenders
61
61
 
62
62
  Heroku.new(app_builder).set_heroku_buildpacks
63
63
 
64
- %w(staging production).each do |remote|
64
+ %w[staging production].each do |remote|
65
65
  expect(app_builder).to(
66
66
  have_configured_buildpack(
67
- remote_name: remote, index: 1, packname: "heroku/nodejs",
68
- ),
67
+ remote_name: remote, index: 1, packname: "heroku/nodejs"
68
+ )
69
69
  )
70
70
  expect(app_builder).to(
71
71
  have_configured_buildpack(
72
- remote_name: remote, index: 2, packname: "heroku/ruby",
73
- ),
72
+ remote_name: remote, index: 2, packname: "heroku/ruby"
73
+ )
74
74
  )
75
75
  end
76
76
  end
@@ -80,8 +80,8 @@ module Suspenders
80
80
  end
81
81
 
82
82
  def have_backup_schedule(remote_name)
83
- have_received(:run).
84
- with(/pg:backups:schedule DATABASE_URL --at '10:00 UTC' --remote #{remote_name}/)
83
+ have_received(:run)
84
+ .with(/pg:backups:schedule DATABASE_URL --at '10:00 UTC' --remote #{remote_name}/)
85
85
  end
86
86
 
87
87
  def have_configured_var(remote_name, var)
@@ -90,7 +90,7 @@ module Suspenders
90
90
 
91
91
  def have_configured_buildpack(remote_name:, index:, packname:)
92
92
  have_received(:run).with(
93
- /buildpacks:add --index #{index} #{packname} --remote #{remote_name}/,
93
+ /buildpacks:add --index #{index} #{packname} --remote #{remote_name}/
94
94
  )
95
95
  end
96
96
  end
@@ -16,8 +16,8 @@ RSpec.describe Suspenders::Actions::ExpandJson do
16
16
  destination_root,
17
17
  destination_file_name,
18
18
  env: {
19
- SMTP_ADDRESS: { required: true },
20
- },
19
+ SMTP_ADDRESS: {required: true}
20
+ }
21
21
  ).invoke!
22
22
  end
23
23
 
@@ -26,8 +26,8 @@ RSpec.describe Suspenders::Actions::ExpandJson do
26
26
  destination_root,
27
27
  destination_file_name,
28
28
  env: {
29
- HEROKU_APP_NAME: { required: true },
30
- },
29
+ HEROKU_APP_NAME: {required: true}
30
+ }
31
31
  ).invoke!
32
32
 
33
33
  expected = <<~JSON
@@ -53,9 +53,9 @@ RSpec.describe Suspenders::Actions::ExpandJson do
53
53
  destination_root,
54
54
  destination_file_name,
55
55
  env: {
56
- foo: { required: true },
57
- bar: { required: true },
58
- },
56
+ foo: {required: true},
57
+ bar: {required: true}
58
+ }
59
59
  ).invoke!
60
60
  end
61
61
 
@@ -64,8 +64,8 @@ RSpec.describe Suspenders::Actions::ExpandJson do
64
64
  destination_root,
65
65
  destination_file_name,
66
66
  env: {
67
- foo: { required: true },
68
- },
67
+ foo: {required: true}
68
+ }
69
69
  ).revoke!
70
70
 
71
71
  expected = <<~JSON