suspenders 1.54.1 → 1.55.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/NEWS.md +6 -0
- data/Rakefile +6 -5
- data/lib/suspenders/adapters/heroku.rb +16 -16
- data/lib/suspenders/app_builder.rb +40 -40
- data/lib/suspenders/generators/advisories_generator.rb +1 -1
- data/lib/suspenders/generators/analytics_generator.rb +1 -1
- data/lib/suspenders/generators/app_generator.rb +25 -25
- data/lib/suspenders/generators/base.rb +2 -2
- data/lib/suspenders/generators/db_optimizations_generator.rb +2 -2
- data/lib/suspenders/generators/factories_generator.rb +1 -1
- data/lib/suspenders/generators/jobs_generator.rb +3 -3
- data/lib/suspenders/generators/js_driver_generator.rb +1 -1
- data/lib/suspenders/generators/lint_generator.rb +5 -0
- data/lib/suspenders/generators/preloader_generator.rb +4 -4
- data/lib/suspenders/generators/production/compression_generator.rb +1 -1
- data/lib/suspenders/generators/production/email_generator.rb +6 -6
- data/lib/suspenders/generators/production/manifest_generator.rb +8 -8
- data/lib/suspenders/generators/production/single_redirect.rb +1 -1
- data/lib/suspenders/generators/production/timeout_generator.rb +2 -2
- data/lib/suspenders/generators/profiler_generator.rb +4 -4
- data/lib/suspenders/generators/runner_generator.rb +4 -4
- data/lib/suspenders/generators/staging/pull_requests_generator.rb +2 -2
- data/lib/suspenders/generators/stylelint_generator.rb +2 -1
- data/lib/suspenders/generators/stylesheet_base_generator.rb +1 -1
- data/lib/suspenders/generators/testing_generator.rb +2 -2
- data/lib/suspenders/version.rb +5 -5
- data/spec/adapters/heroku_spec.rb +16 -16
- data/spec/expand_json_spec.rb +9 -9
- data/spec/fakes/bin/heroku +1 -1
- data/spec/fakes/bin/hub +1 -1
- data/spec/features/cli_help_spec.rb +4 -4
- data/spec/features/heroku_spec.rb +3 -3
- data/spec/features/lint_spec.rb +26 -0
- data/spec/features/new_project_spec.rb +33 -33
- data/spec/features/production/compression_spec.rb +2 -2
- data/spec/features/production/email_spec.rb +10 -10
- data/spec/features/production/manifest_spec.rb +16 -16
- data/spec/features/production/single_redirect_spec.rb +2 -2
- data/spec/features/profiler_spec.rb +2 -2
- data/spec/features/stylelint_spec.rb +7 -7
- data/spec/spec_helper.rb +3 -3
- data/spec/support/fake_github.rb +3 -3
- data/spec/support/fake_heroku.rb +8 -8
- data/spec/support/project_files.rb +1 -1
- data/spec/support/suspenders.rb +3 -4
- data/suspenders.gemspec +20 -20
- data/templates/capybara_silence_puma.rb +1 -1
- data/templates/errors.rb +3 -3
- data/templates/hound.yml +1 -2
- data/templates/partials/ci_simplecov.rb +0 -2
- data/templates/partials/db_optimizations_configuration.rb +5 -7
- data/templates/partials/email_smtp.rb +2 -3
- data/templates/partials/pull_requests_config.rb +0 -1
- data/templates/partials/runner_setup.rb +1 -2
- data/templates/spec_helper.rb +1 -1
- data/templates/spring.rb +1 -1
- metadata +18 -2
@@ -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
|
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
|
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
|
@@ -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
|
-
|
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
|
|
@@ -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: {
|
26
|
-
SMTP_DOMAIN: {
|
27
|
-
SMTP_PASSWORD: {
|
28
|
-
SMTP_USERNAME: {
|
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: {
|
13
|
-
AUTO_MIGRATE_DB: {
|
14
|
-
EMAIL_RECIPIENTS: {
|
15
|
-
HEROKU_APP_NAME: {
|
16
|
-
HEROKU_PARENT_APP_NAME: {
|
17
|
-
RACK_ENV: {
|
18
|
-
SECRET_KEY_BASE: {
|
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
|
@@ -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
|
-
%
|
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: %
|
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
|
-
%
|
24
|
-
after: %
|
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
|
-
%
|
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"
|
@@ -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
|
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
|
|
data/lib/suspenders/version.rb
CHANGED
@@ -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.
|
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
|
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
|
data/spec/expand_json_spec.rb
CHANGED
@@ -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: {
|
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: {
|
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: {
|
57
|
-
bar: {
|
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: {
|
68
|
-
}
|
67
|
+
foo: {required: true}
|
68
|
+
}
|
69
69
|
).revoke!
|
70
70
|
|
71
71
|
expected = <<~JSON
|