welaika-suspenders 2.29.0.alpha.2 → 2.29.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/suspenders.rb +1 -2
- data/lib/suspenders/adapters/heroku.rb +29 -6
- data/lib/suspenders/app_builder.rb +4 -6
- data/lib/suspenders/generators/app_generator.rb +8 -13
- data/lib/suspenders/generators/ci_generator.rb +5 -10
- data/lib/suspenders/generators/production/error_reporting_generator.rb +57 -0
- data/lib/suspenders/generators/security_generator.rb +4 -1
- data/lib/suspenders/generators/testing_generator.rb +1 -7
- data/lib/suspenders/version.rb +2 -1
- data/spec/adapters/heroku_spec.rb +2 -2
- data/spec/features/cli_help_spec.rb +1 -1
- data/spec/features/heroku_spec.rb +2 -19
- data/spec/features/new_project_spec.rb +4 -34
- data/spec/spec_helper.rb +2 -0
- data/spec/support/suspenders.rb +4 -6
- data/templates/Gemfile.erb +0 -1
- data/templates/README.md.erb +1 -7
- data/templates/_css_overrides.html.slim +4 -3
- data/templates/_javascript.html.slim +0 -5
- data/templates/application.sass +1 -1
- data/templates/bin_setup +16 -28
- data/templates/chromedriver.rb +25 -5
- data/templates/database.gitlab.yml +8 -0
- data/templates/factory_bot.rake +2 -2
- data/templates/gitlab-ci.yml.erb +114 -0
- data/templates/overcommit.yml +1 -1
- data/templates/rails_helper.rb +1 -1
- data/templates/rakefile_template.rb +3 -1
- data/templates/rubocop.yml +0 -4
- data/templates/sentry.rb +1 -1
- data/todo.txt +15 -0
- data/todo_suspenders.md +1 -0
- metadata +7 -5
- data/lib/suspenders/generators/error_reporting_generator.rb +0 -55
- data/lib/suspenders/generators/forms_generator.rb +0 -18
- data/templates/capybara_helpers.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6543a7a9ee1ede8d0c5899ff21f196adb6beddd61d6d4a1bb2dbb2bf77a71714
|
4
|
+
data.tar.gz: 836eec798f86aa54690d957cf5cadfbda9bee96554ace32e060e192c216dbcda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b35628cbffa9f3c50bd139663239e8b7153800bcedc33669b4c30e2b8802ca6462e68fa0a328222dfad0a6d29f5854fcd3918445f4d8a6acbf1bbd0cc2026c85
|
7
|
+
data.tar.gz: a74e0583ffe8d76c1f55679f8ac7d0cf13b177117366c4e0a4c76c1e7400772817d672b3983c0ebfeeca5c02d8b6cfc2c6b414222fa89eb2923b6612a354c11a
|
data/README.md
CHANGED
@@ -5,12 +5,13 @@ Big thanks to [thoughtbot](http://thoughtbot.com/community) for providing such a
|
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
|
-
First ensure you have PostgreSQL, npm and
|
8
|
+
First ensure you have PostgreSQL, npm, yarn and chromedriver
|
9
9
|
|
10
10
|
$ brew install postgresql
|
11
11
|
$ brew install node
|
12
12
|
$ npm install npm@latest -g # To update npm if you have already installed it
|
13
13
|
$ brew install yarn
|
14
|
+
$ brew casks install chromedriver
|
14
15
|
|
15
16
|
then install the suspenders gem:
|
16
17
|
|
@@ -30,7 +31,7 @@ You can optionally specify alternate Heroku flags:
|
|
30
31
|
|
31
32
|
welaika-suspenders projectname \
|
32
33
|
--heroku true \
|
33
|
-
--heroku-flags "--region eu --addons heroku-postgresql,sendgrid,logentries,scheduler
|
34
|
+
--heroku-flags "--region eu --addons heroku-postgresql,sendgrid,logentries,scheduler"
|
34
35
|
|
35
36
|
See all possible Heroku flags:
|
36
37
|
|
data/lib/suspenders.rb
CHANGED
@@ -2,7 +2,6 @@ require "suspenders/version"
|
|
2
2
|
require "suspenders/generators/app_generator"
|
3
3
|
require "suspenders/generators/static_generator"
|
4
4
|
require "suspenders/generators/stylesheet_base_generator"
|
5
|
-
require "suspenders/generators/forms_generator"
|
6
5
|
require "suspenders/generators/ci_generator"
|
7
6
|
require "suspenders/generators/db_optimizations_generator"
|
8
7
|
require "suspenders/generators/factories_generator"
|
@@ -11,12 +10,12 @@ require "suspenders/generators/views_generator"
|
|
11
10
|
require "suspenders/generators/js_driver_generator"
|
12
11
|
require "suspenders/generators/testing_generator"
|
13
12
|
require "suspenders/generators/decorator_generator"
|
14
|
-
require "suspenders/generators/error_reporting_generator"
|
15
13
|
require "suspenders/generators/faker_generator"
|
16
14
|
require "suspenders/generators/security_generator"
|
17
15
|
require "suspenders/generators/production/force_tls_generator"
|
18
16
|
require "suspenders/generators/production/email_generator"
|
19
17
|
require "suspenders/generators/production/timeout_generator"
|
18
|
+
require "suspenders/generators/production/error_reporting_generator"
|
20
19
|
require "suspenders/actions"
|
21
20
|
require "suspenders/adapters/heroku"
|
22
21
|
require "suspenders/app_builder"
|
@@ -7,9 +7,11 @@ module Suspenders
|
|
7
7
|
|
8
8
|
def set_heroku_remotes
|
9
9
|
remotes = <<~SHELL
|
10
|
+
echo "\n== Adding Heroku remotes =="
|
10
11
|
#{command_to_join_heroku_app('staging')}
|
11
12
|
#{command_to_join_heroku_app('production')}
|
12
13
|
|
14
|
+
echo "\n== Setting default heroku remote to 'staging' =="
|
13
15
|
git config heroku.remote staging
|
14
16
|
SHELL
|
15
17
|
|
@@ -37,10 +39,10 @@ module Suspenders
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
|
-
def
|
42
|
+
def set_heroku_error_reporting_env
|
41
43
|
%w(staging production).each do |environment|
|
42
44
|
run_toolbelt_command(
|
43
|
-
"config:add
|
45
|
+
"config:add SENTRY_ENV=#{environment}",
|
44
46
|
environment,
|
45
47
|
)
|
46
48
|
end
|
@@ -97,6 +99,28 @@ module Suspenders
|
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
102
|
+
def set_heroku_metadata_for_sentry
|
103
|
+
%w(staging production).each do |environment|
|
104
|
+
run_toolbelt_command(
|
105
|
+
"labs:enable runtime-dyno-metadata",
|
106
|
+
environment
|
107
|
+
)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def set_buildpacks
|
112
|
+
%w(staging production).each do |environment|
|
113
|
+
run_toolbelt_command(
|
114
|
+
"buildpacks:add --index 1 heroku/nodejs",
|
115
|
+
environment
|
116
|
+
)
|
117
|
+
run_toolbelt_command(
|
118
|
+
"buildpacks:add --index 2 heroku/ruby",
|
119
|
+
environment
|
120
|
+
)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
100
124
|
private
|
101
125
|
|
102
126
|
attr_reader :app_builder
|
@@ -105,11 +129,10 @@ module Suspenders
|
|
105
129
|
heroku_app_name = heroku_app_name_for(environment)
|
106
130
|
<<~SHELL
|
107
131
|
|
108
|
-
if heroku
|
109
|
-
git remote add #{environment} git@heroku.com:#{heroku_app_name}.git || true
|
110
|
-
printf 'You are a collaborator on the "#{heroku_app_name}" Heroku app\n'
|
132
|
+
if heroku apps | grep #{heroku_app_name} > /dev/null 2>&1; then
|
133
|
+
git remote add -f #{environment} git@heroku.com:#{heroku_app_name}.git || true
|
111
134
|
else
|
112
|
-
|
135
|
+
echo "** Ask for access to the '#{heroku_app_name}' Heroku app and run this script again **"
|
113
136
|
fi
|
114
137
|
SHELL
|
115
138
|
end
|
@@ -14,9 +14,11 @@ module Suspenders
|
|
14
14
|
:create_staging_heroku_app,
|
15
15
|
:set_heroku_application_host,
|
16
16
|
:set_heroku_backup_schedule,
|
17
|
-
:
|
17
|
+
:set_heroku_error_reporting_env,
|
18
18
|
:set_heroku_rails_secrets,
|
19
19
|
:set_heroku_remotes,
|
20
|
+
:set_heroku_metadata_for_sentry,
|
21
|
+
:set_buildpacks,
|
20
22
|
)
|
21
23
|
|
22
24
|
def readme
|
@@ -155,7 +157,7 @@ config.public_file_server.headers = {
|
|
155
157
|
def replace_gemfile(path)
|
156
158
|
template 'Gemfile.erb', 'Gemfile', force: true do |content|
|
157
159
|
if path
|
158
|
-
content.gsub(%r{gem
|
160
|
+
content.gsub(%r{gem ['"]welaika-suspenders['"].*}) { |s| %{#{s}, path: "#{path}"} }
|
159
161
|
else
|
160
162
|
content
|
161
163
|
end
|
@@ -259,10 +261,6 @@ you can deploy to staging and production with:
|
|
259
261
|
run "chmod a+x bin/deploy"
|
260
262
|
end
|
261
263
|
|
262
|
-
def setup_spring
|
263
|
-
bundle_command "exec spring binstub --all"
|
264
|
-
end
|
265
|
-
|
266
264
|
def copy_miscellaneous_files
|
267
265
|
copy_file "browserslist", "browserslist"
|
268
266
|
copy_file "errors.rb", "config/initializers/errors.rb"
|
@@ -32,6 +32,9 @@ module Suspenders
|
|
32
32
|
class_option :skip_turbolinks,
|
33
33
|
type: :boolean, default: true, desc: "Skip turbolinks gem"
|
34
34
|
|
35
|
+
class_option :skip_spring, type: :boolean, default: true,
|
36
|
+
desc: "Don't install Spring application preloader"
|
37
|
+
|
35
38
|
def finish_template
|
36
39
|
invoke :suspenders_customization
|
37
40
|
super
|
@@ -49,7 +52,6 @@ module Suspenders
|
|
49
52
|
invoke :remove_routes_comment_lines
|
50
53
|
invoke :setup_dotfiles
|
51
54
|
invoke :setup_database
|
52
|
-
invoke :setup_spring
|
53
55
|
invoke :generate_default
|
54
56
|
invoke :setup_default_directories
|
55
57
|
invoke :create_local_heroku_setup
|
@@ -126,8 +128,10 @@ module Suspenders
|
|
126
128
|
build :set_heroku_remotes
|
127
129
|
build :set_heroku_rails_secrets
|
128
130
|
build :set_heroku_application_host
|
129
|
-
build :
|
131
|
+
build :set_heroku_error_reporting_env
|
130
132
|
build :set_heroku_backup_schedule
|
133
|
+
build :set_heroku_metadata_for_sentry
|
134
|
+
build :set_buildpacks
|
131
135
|
build :create_heroku_pipeline
|
132
136
|
build :configure_automatic_deployment
|
133
137
|
end
|
@@ -141,11 +145,6 @@ module Suspenders
|
|
141
145
|
build :setup_default_directories
|
142
146
|
end
|
143
147
|
|
144
|
-
def setup_spring
|
145
|
-
say "Springifying binstubs"
|
146
|
-
build :setup_spring
|
147
|
-
end
|
148
|
-
|
149
148
|
def copy_miscellaneous_files
|
150
149
|
say 'Copying miscellaneous support files'
|
151
150
|
build :copy_miscellaneous_files
|
@@ -165,15 +164,11 @@ module Suspenders
|
|
165
164
|
end
|
166
165
|
|
167
166
|
def generate_default
|
168
|
-
run("spring stop")
|
169
167
|
generate("suspenders:static")
|
170
168
|
generate("suspenders:stylesheet_base")
|
171
169
|
generate("suspenders:testing")
|
172
170
|
generate("suspenders:ci")
|
173
171
|
generate("suspenders:js_driver")
|
174
|
-
unless options[:api]
|
175
|
-
generate("suspenders:forms")
|
176
|
-
end
|
177
172
|
generate("suspenders:db_optimizations")
|
178
173
|
generate("suspenders:factories")
|
179
174
|
generate("suspenders:lint")
|
@@ -181,13 +176,13 @@ module Suspenders
|
|
181
176
|
generate("suspenders:decorator")
|
182
177
|
generate("suspenders:faker")
|
183
178
|
generate("suspenders:security")
|
184
|
-
generate("suspenders:error_reporting")
|
185
179
|
end
|
186
180
|
|
187
181
|
def generate_production_default
|
188
182
|
generate("suspenders:production:force_tls")
|
189
183
|
generate("suspenders:production:email")
|
190
184
|
generate("suspenders:production:timeout")
|
185
|
+
generate("suspenders:production:error_reporting")
|
191
186
|
end
|
192
187
|
|
193
188
|
def outro
|
@@ -196,7 +191,7 @@ module Suspenders
|
|
196
191
|
end
|
197
192
|
|
198
193
|
def self.banner
|
199
|
-
"suspenders #{arguments.map(&:usage).join(' ')} [options]"
|
194
|
+
"welaika-suspenders #{arguments.map(&:usage).join(' ')} [options]"
|
200
195
|
end
|
201
196
|
|
202
197
|
protected
|
@@ -6,17 +6,12 @@ module Suspenders
|
|
6
6
|
File.join("..", "..", "..", "templates"),
|
7
7
|
File.dirname(__FILE__))
|
8
8
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if ENV["CIRCLE_ARTIFACTS"]
|
14
|
-
dir = File.join(ENV["CIRCLE_ARTIFACTS"], "coverage")
|
15
|
-
SimpleCov.coverage_dir(dir)
|
16
|
-
end
|
9
|
+
def setup_gitlab_ci
|
10
|
+
template 'gitlab-ci.yml.erb', '.gitlab-ci.yml'
|
11
|
+
end
|
17
12
|
|
18
|
-
|
19
|
-
|
13
|
+
def copy_database_yml_for_gitlab
|
14
|
+
copy_file 'database.gitlab.yml', 'config/database.gitlab.yml'
|
20
15
|
end
|
21
16
|
end
|
22
17
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "rails/generators"
|
2
|
+
require_relative "../../actions"
|
3
|
+
|
4
|
+
module Suspenders
|
5
|
+
module Production
|
6
|
+
class ErrorReportingGenerator < Rails::Generators::Base
|
7
|
+
include Suspenders::Actions
|
8
|
+
|
9
|
+
source_root File.expand_path(
|
10
|
+
File.join("..", "..", "..", "..", "templates"),
|
11
|
+
File.dirname(__FILE__),
|
12
|
+
)
|
13
|
+
|
14
|
+
def add_sentry
|
15
|
+
gem "sentry-raven"
|
16
|
+
Bundler.with_clean_env { run "bundle install" }
|
17
|
+
end
|
18
|
+
|
19
|
+
def set_up_sentry
|
20
|
+
copy_file "sentry.rb", "config/initializers/sentry.rb"
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure_sentry_context
|
24
|
+
inject_into_class(
|
25
|
+
"app/controllers/application_controller.rb",
|
26
|
+
'ApplicationController',
|
27
|
+
context_configuration
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def env_vars
|
32
|
+
expand_json(
|
33
|
+
"app.json",
|
34
|
+
env: {
|
35
|
+
SENTRY_DSN: { required: true },
|
36
|
+
SENTRY_ENV: { required: true }
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def context_configuration
|
44
|
+
<<-RUBY
|
45
|
+
before_action :set_raven_context
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def set_raven_context
|
50
|
+
Raven.user_context(id: session[:current_user_id])
|
51
|
+
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
|
52
|
+
end
|
53
|
+
RUBY
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -8,7 +8,6 @@ module Suspenders
|
|
8
8
|
)
|
9
9
|
|
10
10
|
def add_testing_gems
|
11
|
-
gem "spring-commands-rspec", group: :development
|
12
11
|
gem "rspec-rails", "~> 3.8", group: %i(development test)
|
13
12
|
gem "shoulda-matchers", group: :test
|
14
13
|
|
@@ -34,8 +33,7 @@ module Suspenders
|
|
34
33
|
end
|
35
34
|
|
36
35
|
def configure_spec_support_features
|
37
|
-
empty_directory_with_keep_file "spec/
|
38
|
-
empty_directory_with_keep_file "spec/support/features"
|
36
|
+
empty_directory_with_keep_file "spec/system"
|
39
37
|
end
|
40
38
|
|
41
39
|
def configure_i18n_for_test_environment
|
@@ -54,10 +52,6 @@ module Suspenders
|
|
54
52
|
copy_file 'queries_helper_rspec.rb', 'spec/support/queries_helper.rb'
|
55
53
|
end
|
56
54
|
|
57
|
-
def add_capybara_helper
|
58
|
-
copy_file 'capybara_helpers.rb', 'spec/support/capybara_helpers.rb'
|
59
|
-
end
|
60
|
-
|
61
55
|
private
|
62
56
|
|
63
57
|
def empty_directory_with_keep_file(destination)
|
data/lib/suspenders/version.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
module Suspenders
|
2
2
|
RAILS_VERSION = "~> 5.2.0".freeze
|
3
|
+
POSTGRES_VERSION = "10.4".freeze # Used in CI
|
3
4
|
RUBY_VERSION = IO.
|
4
5
|
read("#{File.dirname(__FILE__)}/../../.ruby-version").
|
5
6
|
strip.
|
6
7
|
freeze
|
7
|
-
VERSION = "2.29.0.alpha.
|
8
|
+
VERSION = "2.29.0.alpha.3".freeze
|
8
9
|
end
|
@@ -11,9 +11,9 @@ module Suspenders
|
|
11
11
|
Heroku.new(app_builder).set_heroku_remotes
|
12
12
|
|
13
13
|
expect(app_builder).to have_received(:append_file).
|
14
|
-
with(setup_file, /
|
14
|
+
with(setup_file, /git remote add -f production #{app_name.dasherize}-production/)
|
15
15
|
expect(app_builder).to have_received(:append_file).
|
16
|
-
with(setup_file, /
|
16
|
+
with(setup_file, /git remote add -f staging #{app_name.dasherize}-staging/)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "sets the heroku rails secrets" do
|
@@ -13,14 +13,10 @@ RSpec.describe "Heroku" do
|
|
13
13
|
|
14
14
|
expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
|
15
15
|
expect(FakeHeroku).to have_created_app_for("production", "--region eu")
|
16
|
-
expect(FakeHeroku).to have_configured_vars("staging", "SECRET_KEY_BASE")
|
17
|
-
expect(FakeHeroku).to have_configured_vars(
|
18
|
-
"production",
|
19
|
-
"SECRET_KEY_BASE",
|
20
|
-
)
|
21
16
|
%w(staging production).each do |env|
|
22
17
|
expect(FakeHeroku).to have_configured_vars(env, "APPLICATION_HOST")
|
23
|
-
expect(FakeHeroku).to have_configured_vars(env, "
|
18
|
+
expect(FakeHeroku).to have_configured_vars(env, "SENTRY_DSN")
|
19
|
+
expect(FakeHeroku).to have_configured_vars(env, "SECRET_KEY_BASE")
|
24
20
|
end
|
25
21
|
expect(FakeHeroku).to have_setup_pipeline_for(app_name)
|
26
22
|
|
@@ -39,19 +35,6 @@ RSpec.describe "Heroku" do
|
|
39
35
|
end
|
40
36
|
end
|
41
37
|
|
42
|
-
context "--heroku with region flag" do
|
43
|
-
before(:all) do
|
44
|
-
clean_up
|
45
|
-
run_suspenders(%{--heroku=true --heroku-flags="--region eu"})
|
46
|
-
setup_app_dependencies
|
47
|
-
end
|
48
|
-
|
49
|
-
it "suspends a project with extra Heroku flags" do
|
50
|
-
expect(FakeHeroku).to have_created_app_for("staging", "--region eu")
|
51
|
-
expect(FakeHeroku).to have_created_app_for("production", "--region eu")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
38
|
def clean_up
|
56
39
|
drop_dummy_database
|
57
40
|
remove_project_directory
|
@@ -11,13 +11,13 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
11
11
|
it "uses custom Gemfile" do
|
12
12
|
gemfile_file = IO.read("#{project_path}/Gemfile")
|
13
13
|
expect(gemfile_file).to match(
|
14
|
-
/^ruby
|
14
|
+
/^ruby '#{Suspenders::RUBY_VERSION}'$/,
|
15
15
|
)
|
16
16
|
expect(gemfile_file).to match(
|
17
|
-
/^gem
|
17
|
+
/^gem 'autoprefixer-rails'$/,
|
18
18
|
)
|
19
19
|
expect(gemfile_file).to match(
|
20
|
-
/^gem
|
20
|
+
/^gem 'rails', '#{Suspenders::RAILS_VERSION}'$/,
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
@@ -29,14 +29,6 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
it "includes the bundle:audit task" do
|
33
|
-
Dir.chdir(project_path) do
|
34
|
-
Bundler.with_clean_env do
|
35
|
-
expect(`rails -T`).to include("rails bundle:audit")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
32
|
it "creates .ruby-version from Suspenders .ruby-version" do
|
41
33
|
ruby_version_file = IO.read("#{project_path}/.ruby-version")
|
42
34
|
|
@@ -82,14 +74,10 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
82
74
|
expect(File).to exist("#{project_path}/spec/support/i18n.rb")
|
83
75
|
end
|
84
76
|
|
85
|
-
it "adds rspec helper for fixtures" do
|
86
|
-
expect(File).to exist("#{project_path}/spec/support/fixtures_helper.rb")
|
87
|
-
end
|
88
|
-
|
89
77
|
it "ensures Gemfile contains `rack-mini-profiler`" do
|
90
78
|
gemfile = IO.read("#{project_path}/Gemfile")
|
91
79
|
|
92
|
-
expect(gemfile).to include %{gem
|
80
|
+
expect(gemfile).to include %{gem 'rack-mini-profiler', require: false}
|
93
81
|
end
|
94
82
|
|
95
83
|
it "ensures .sample.env defaults to RACK_MINI_PROFILER=0" do
|
@@ -98,11 +86,6 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
98
86
|
expect(env).to include "RACK_MINI_PROFILER=0"
|
99
87
|
end
|
100
88
|
|
101
|
-
it "initializes ActiveJob to avoid memory bloat" do
|
102
|
-
expect(File).
|
103
|
-
to exist("#{project_path}/config/initializers/active_job.rb")
|
104
|
-
end
|
105
|
-
|
106
89
|
it "creates a rack-mini-profiler initializer" do
|
107
90
|
expect(File).
|
108
91
|
to exist("#{project_path}/config/initializers/rack_mini_profiler.rb")
|
@@ -160,10 +143,6 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
160
143
|
expect(locales_it_file).to match(/application: #{app_name.humanize}/)
|
161
144
|
end
|
162
145
|
|
163
|
-
it "configs simple_form" do
|
164
|
-
expect(File).to exist("#{project_path}/config/initializers/simple_form.rb")
|
165
|
-
end
|
166
|
-
|
167
146
|
it "configs :letter_opener as email delivery method for development" do
|
168
147
|
dev_env_file = IO.read("#{project_path}/config/environments/development.rb")
|
169
148
|
expect(dev_env_file).
|
@@ -208,15 +187,6 @@ RSpec.describe "Suspend a new project with default configuration" do
|
|
208
187
|
)
|
209
188
|
end
|
210
189
|
|
211
|
-
it "adds spring to binstubs" do
|
212
|
-
expect(File).to exist("#{project_path}/bin/spring")
|
213
|
-
|
214
|
-
bin_stubs = %w(rake rails rspec)
|
215
|
-
bin_stubs.each do |bin_stub|
|
216
|
-
expect(IO.read("#{project_path}/bin/#{bin_stub}")).to match(/spring/)
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
190
|
it "adds rspec's helper files" do
|
221
191
|
expect(File).to exist("#{project_path}/spec/spec_helper.rb")
|
222
192
|
expect(File).to exist("#{project_path}/spec/rails_helper.rb")
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/suspenders.rb
CHANGED
@@ -21,7 +21,7 @@ module SuspendersTestHelpers
|
|
21
21
|
Dir.chdir(APP_NAME) do
|
22
22
|
with_env("HOME", tmp_path) do
|
23
23
|
debug `git add .`
|
24
|
-
debug `git commit -m 'Initial commit'`
|
24
|
+
debug `OVERCOMMIT_DISABLE=1 git commit -m 'Initial commit'`
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -41,17 +41,17 @@ module SuspendersTestHelpers
|
|
41
41
|
add_fakes_to_path
|
42
42
|
|
43
43
|
with_revision_for_honeybadger do
|
44
|
-
debug `#{system_rails_bin} new #{APP_NAME}`
|
44
|
+
debug `#{system_rails_bin} new #{APP_NAME} --skip-spring`
|
45
45
|
end
|
46
46
|
|
47
47
|
Dir.chdir(APP_NAME) do
|
48
48
|
File.open("Gemfile", "a") do |file|
|
49
|
-
file.puts %{gem "suspenders", path: #{root_path.inspect}}
|
49
|
+
file.puts %{gem "welaika-suspenders", path: #{root_path.inspect}}
|
50
50
|
end
|
51
51
|
|
52
52
|
with_env("HOME", tmp_path) do
|
53
53
|
debug `git add .`
|
54
|
-
debug `git commit -m 'Initial commit'`
|
54
|
+
debug `OVERCOMMIT_DISABLE=1 git commit -m 'Initial commit'`
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -60,7 +60,6 @@ module SuspendersTestHelpers
|
|
60
60
|
def generate(generator)
|
61
61
|
run_in_project do
|
62
62
|
with_revision_for_honeybadger do
|
63
|
-
debug `bin/spring stop`
|
64
63
|
debug `#{project_rails_bin} generate #{generator}`
|
65
64
|
end
|
66
65
|
end
|
@@ -69,7 +68,6 @@ module SuspendersTestHelpers
|
|
69
68
|
def destroy(generator)
|
70
69
|
run_in_project do
|
71
70
|
with_revision_for_honeybadger do
|
72
|
-
`bin/spring stop`
|
73
71
|
`#{project_rails_bin} destroy #{generator}`
|
74
72
|
end
|
75
73
|
end
|
data/templates/Gemfile.erb
CHANGED
data/templates/README.md.erb
CHANGED
@@ -16,12 +16,6 @@ To install Postgres:
|
|
16
16
|
|
17
17
|
$ brew install postgresql
|
18
18
|
|
19
|
-
To install MySQL:
|
20
|
-
|
21
|
-
$ brew tap homebrew/versions
|
22
|
-
$ brew install mysql55
|
23
|
-
$ brew link --force mysql55
|
24
|
-
|
25
19
|
To install Node:
|
26
20
|
|
27
21
|
$ brew install node
|
@@ -36,7 +30,7 @@ To install Yarn:
|
|
36
30
|
|
37
31
|
To install Chromedriver (for integration test):
|
38
32
|
|
39
|
-
$ brew install chromedriver
|
33
|
+
$ brew cask install chromedriver
|
40
34
|
|
41
35
|
To install ImageMagick:
|
42
36
|
|
data/templates/application.sass
CHANGED
data/templates/bin_setup
CHANGED
@@ -1,34 +1,22 @@
|
|
1
|
-
#!/
|
2
|
-
require 'fileutils'
|
3
|
-
include FileUtils
|
1
|
+
#!/bin/sh
|
4
2
|
|
5
|
-
|
3
|
+
# Set up Rails app. Run this script immediately after cloning the codebase.
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
end
|
5
|
+
# Exit if any subcommand fails
|
6
|
+
set -e
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
echo '== Installing dependencies =='
|
9
|
+
gem install bundler --conservative
|
10
|
+
bundle check || bundle install
|
11
|
+
bin/yarn
|
15
12
|
|
16
|
-
|
13
|
+
echo "\n== Copying sample files =="
|
14
|
+
if [ ! -f .env.local ]; then
|
15
|
+
cp .env .env.local
|
16
|
+
fi
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
cp '.env', '.env.local'
|
21
|
-
end
|
18
|
+
echo "\n== Preparing database and seeds =="
|
19
|
+
bin/rails dev:prime
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
puts "\n== Removing old logs and tempfiles =="
|
27
|
-
system! 'bin/rails log:clear tmp:clear'
|
28
|
-
|
29
|
-
puts "\n== Restarting application server =="
|
30
|
-
system! 'bin/rails restart'
|
31
|
-
|
32
|
-
puts "\n== Activating overcommit =="
|
33
|
-
system! 'bin/overcommit --install'
|
34
|
-
end
|
21
|
+
echo "\n== Activating overcommit =="
|
22
|
+
bin/overcommit --install
|
data/templates/chromedriver.rb
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'selenium/webdriver'
|
4
4
|
|
5
|
-
Capybara.
|
6
|
-
Capybara::Selenium::Driver.new(app, browser: :chrome)
|
7
|
-
end
|
5
|
+
Capybara.server = :puma, { Silent: true }
|
8
6
|
|
9
7
|
Capybara.register_driver :headless_chrome do |app|
|
10
8
|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
@@ -18,5 +16,27 @@ Capybara.register_driver :headless_chrome do |app|
|
|
18
16
|
)
|
19
17
|
end
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.before(:each, type: :system) do
|
21
|
+
if ENV['SELENIUM_REMOTE_URL'].present?
|
22
|
+
# Make the test app listen to outside requests, for the remote Selenium instance.
|
23
|
+
Capybara.server_host = '0.0.0.0'
|
24
|
+
|
25
|
+
# Specify the driver
|
26
|
+
driven_by :selenium, using: :chrome, screen_size: [1400, 2000],
|
27
|
+
options: { url: ENV['SELENIUM_REMOTE_URL'] }
|
28
|
+
|
29
|
+
# Get the rails application IP
|
30
|
+
rails_ip = Socket.ip_address_list.find(&:ipv4_private?).ip_address
|
31
|
+
|
32
|
+
# Set the rails application Port (choose what you want)
|
33
|
+
Capybara.server_port = 3001
|
34
|
+
|
35
|
+
# Use the IP instead of localhost so Capybara knows where to direct Selenium
|
36
|
+
host! "http://#{rails_ip}:#{Capybara.server_port}"
|
37
|
+
else
|
38
|
+
# Otherwise, use the local machine's chromedriver
|
39
|
+
driven_by :headless_chrome
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/templates/factory_bot.rake
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'database_cleaner'
|
4
|
-
|
5
3
|
namespace :factory_bot do
|
6
4
|
desc 'Verify that all FactoryBot factories are valid'
|
7
5
|
task lint: :environment do
|
8
6
|
if Rails.env.test?
|
7
|
+
require 'database_cleaner'
|
8
|
+
|
9
9
|
sh 'bundle exec rails db:migrate'
|
10
10
|
DatabaseCleaner.clean_with :truncation
|
11
11
|
DatabaseCleaner.strategy = :transaction
|
@@ -0,0 +1,114 @@
|
|
1
|
+
image: ruby:<%= Suspenders::RUBY_VERSION %>
|
2
|
+
|
3
|
+
variables:
|
4
|
+
GET_SOURCES_ATTEMPTS: 3
|
5
|
+
ARTIFACT_DOWNLOAD_ATTEMPTS: 3
|
6
|
+
RESTORE_CACHE_ATTEMPTS: 3
|
7
|
+
POSTGRES_DB: rails_app_test
|
8
|
+
POSTGRES_USER: root
|
9
|
+
POSTGRES_PASSWORD: ''
|
10
|
+
SELENIUM_REMOTE_URL: "http://selenium__standalone-chrome:4444/wd/hub/"
|
11
|
+
|
12
|
+
.services: &rails-services
|
13
|
+
- postgres:<%= Suspenders::POSTGRES_VERSION %>
|
14
|
+
- selenium/standalone-chrome:latest
|
15
|
+
|
16
|
+
.cache: &gems-cache-settings
|
17
|
+
key: "gems-$CI_COMMIT_REF_SLUG"
|
18
|
+
paths:
|
19
|
+
- vendor/bundle
|
20
|
+
|
21
|
+
stages:
|
22
|
+
- setup
|
23
|
+
- quality
|
24
|
+
- test
|
25
|
+
|
26
|
+
prepare:
|
27
|
+
stage: setup
|
28
|
+
cache:
|
29
|
+
<<: *gems-cache-settings
|
30
|
+
script:
|
31
|
+
- bundle install --retry 3 --deployment --jobs $(nproc)
|
32
|
+
|
33
|
+
quality:rubocop:
|
34
|
+
stage: quality
|
35
|
+
cache:
|
36
|
+
<<: *gems-cache-settings
|
37
|
+
policy: pull
|
38
|
+
script:
|
39
|
+
- bundle check --path vendor/bundle
|
40
|
+
- bundle exec rubocop
|
41
|
+
|
42
|
+
quality:slim_lint:
|
43
|
+
stage: quality
|
44
|
+
cache:
|
45
|
+
<<: *gems-cache-settings
|
46
|
+
policy: pull
|
47
|
+
script:
|
48
|
+
- bundle check --path vendor/bundle
|
49
|
+
- bundle exec slim-lint app/views/
|
50
|
+
|
51
|
+
quality:bundler-audit:
|
52
|
+
stage: quality
|
53
|
+
cache:
|
54
|
+
<<: *gems-cache-settings
|
55
|
+
policy: pull
|
56
|
+
script:
|
57
|
+
- bundle check --path vendor/bundle
|
58
|
+
- bundle exec bundle-audit check --update
|
59
|
+
|
60
|
+
quality:brakeman:
|
61
|
+
stage: quality
|
62
|
+
cache:
|
63
|
+
<<: *gems-cache-settings
|
64
|
+
policy: pull
|
65
|
+
script:
|
66
|
+
- bundle check --path vendor/bundle
|
67
|
+
- bundle exec brakeman -z --skip-files vendor/bundle
|
68
|
+
|
69
|
+
quality:rubycritic:
|
70
|
+
stage: quality
|
71
|
+
cache:
|
72
|
+
<<: *gems-cache-settings
|
73
|
+
policy: pull
|
74
|
+
script:
|
75
|
+
- bundle check --path vendor/bundle
|
76
|
+
- bundle exec rubycritic app/ config/ lib/ --no-browser --minimum-score 94 --format console
|
77
|
+
|
78
|
+
test:rspec:
|
79
|
+
stage: test
|
80
|
+
services: *rails-services
|
81
|
+
cache:
|
82
|
+
<<: *gems-cache-settings
|
83
|
+
policy: pull
|
84
|
+
script:
|
85
|
+
# Install node
|
86
|
+
- curl -sL https://deb.nodesource.com/setup_10.x | bash -
|
87
|
+
- apt-get update -qq && apt-get install -qq nodejs
|
88
|
+
|
89
|
+
# Install yarn
|
90
|
+
- curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
91
|
+
- echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
|
92
|
+
- apt-get update -qq && apt-get install -qq yarn
|
93
|
+
|
94
|
+
# Verify node and yarn versions
|
95
|
+
- node --version
|
96
|
+
- yarn --version
|
97
|
+
|
98
|
+
# Setup environment
|
99
|
+
- cp -f config/database.gitlab.yml config/database.yml
|
100
|
+
- bundle check --path vendor/bundle
|
101
|
+
- bin/yarn
|
102
|
+
- bundle exec rails db:setup RAILS_ENV=test
|
103
|
+
|
104
|
+
# Run tests
|
105
|
+
- bundle exec rspec spec/
|
106
|
+
coverage: '/\(\d+.\d+\%\) covered/'
|
107
|
+
artifacts:
|
108
|
+
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
109
|
+
when: always
|
110
|
+
expire_in: 5 days
|
111
|
+
paths:
|
112
|
+
- coverage/
|
113
|
+
- tmp/screenshots/
|
114
|
+
- tmp/capybara/
|
data/templates/overcommit.yml
CHANGED
data/templates/rails_helper.rb
CHANGED
@@ -4,10 +4,10 @@ ENV['RACK_ENV'] = 'test'
|
|
4
4
|
|
5
5
|
require File.expand_path('../config/environment', __dir__)
|
6
6
|
|
7
|
-
|
8
7
|
abort('DATABASE_URL environment variable is set') if ENV['DATABASE_URL']
|
9
8
|
|
10
9
|
require 'rspec/rails'
|
10
|
+
require 'capybara/rails'
|
11
11
|
|
12
12
|
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |file| require file }
|
13
13
|
|
@@ -11,10 +11,12 @@ task(:default).clear
|
|
11
11
|
desc 'Run linters, quality, security and tests'
|
12
12
|
task :default do
|
13
13
|
sh 'bundle exec rubocop'
|
14
|
+
sh 'bundle exec slim-lint app/views/'
|
14
15
|
sh 'bundle exec rubycritic app/ config/ lib/ --no-browser --minimum-score 94 --format console'
|
15
16
|
sh 'bundle exec bundle-audit check --update'
|
16
17
|
sh 'bundle exec brakeman -z'
|
17
|
-
sh 'bundle exec rails db:
|
18
|
+
sh 'bundle exec rails db:setup RAILS_ENV=test'
|
19
|
+
sh 'bundle exec rails db:migrate RAILS_ENV=test' # runs any pending migrations
|
18
20
|
sh 'bundle exec rake factory_bot:lint RAILS_ENV=test'
|
19
21
|
sh 'bundle exec rspec spec/'
|
20
22
|
end
|
data/templates/rubocop.yml
CHANGED
data/templates/sentry.rb
CHANGED
@@ -4,5 +4,5 @@ Raven.configure do |config|
|
|
4
4
|
config.dsn = ENV.fetch('SENTRY_DSN')
|
5
5
|
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
|
6
6
|
config.environments = %w[ staging production ]
|
7
|
-
config.current_environment = ENV.fetch('
|
7
|
+
config.current_environment = ENV.fetch('SENTRY_ENV', Rails.env)
|
8
8
|
end
|
data/todo.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# TODO
|
2
|
+
configurare gitlab ci
|
3
|
+
|
4
|
+
# DONE
|
5
|
+
controllare che :sass e :coffee nei file slim funzionino in produzione
|
6
|
+
rake file con rubocop, brakeman, bla bla
|
7
|
+
controllare se ci sono altri linters da mettere
|
8
|
+
aggiungere sentry
|
9
|
+
aggiornare rspec
|
10
|
+
configurare rubocop
|
11
|
+
configurare overcommit
|
12
|
+
aggiungere jquery ad application.js oppure rimuoverlo del tutto!
|
13
|
+
|
14
|
+
# SKIPPED
|
15
|
+
aggiungere sidekiq, oppure rimuovere delayed_job:w
|
data/todo_suspenders.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* aggiornare rspec-rails
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: welaika-suspenders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.29.0.alpha.
|
4
|
+
version: 2.29.0.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoughtbot
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-08-
|
12
|
+
date: 2018-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -75,13 +75,12 @@ files:
|
|
75
75
|
- lib/suspenders/generators/ci_generator.rb
|
76
76
|
- lib/suspenders/generators/db_optimizations_generator.rb
|
77
77
|
- lib/suspenders/generators/decorator_generator.rb
|
78
|
-
- lib/suspenders/generators/error_reporting_generator.rb
|
79
78
|
- lib/suspenders/generators/factories_generator.rb
|
80
79
|
- lib/suspenders/generators/faker_generator.rb
|
81
|
-
- lib/suspenders/generators/forms_generator.rb
|
82
80
|
- lib/suspenders/generators/js_driver_generator.rb
|
83
81
|
- lib/suspenders/generators/lint_generator.rb
|
84
82
|
- lib/suspenders/generators/production/email_generator.rb
|
83
|
+
- lib/suspenders/generators/production/error_reporting_generator.rb
|
85
84
|
- lib/suspenders/generators/production/force_tls_generator.rb
|
86
85
|
- lib/suspenders/generators/production/timeout_generator.rb
|
87
86
|
- lib/suspenders/generators/security_generator.rb
|
@@ -118,9 +117,9 @@ files:
|
|
118
117
|
- templates/bin_setup
|
119
118
|
- templates/bin_setup_review_app.erb
|
120
119
|
- templates/browserslist
|
121
|
-
- templates/capybara_helpers.rb
|
122
120
|
- templates/chromedriver.rb
|
123
121
|
- templates/config_locales_it.yml.erb
|
122
|
+
- templates/database.gitlab.yml
|
124
123
|
- templates/dev.rake
|
125
124
|
- templates/dotfiles/.ctags
|
126
125
|
- templates/dotfiles/.env
|
@@ -130,6 +129,7 @@ files:
|
|
130
129
|
- templates/factory_bot_rspec.rb
|
131
130
|
- templates/faker_rspec.rb
|
132
131
|
- templates/flashes_helper.rb
|
132
|
+
- templates/gitlab-ci.yml.erb
|
133
133
|
- templates/i18n.rb
|
134
134
|
- templates/json_encoding.rb
|
135
135
|
- templates/overcommit.yml
|
@@ -151,6 +151,8 @@ files:
|
|
151
151
|
- templates/spec_helper.rb
|
152
152
|
- templates/suspenders_gitignore
|
153
153
|
- templates/suspenders_layout.html.slim
|
154
|
+
- todo.txt
|
155
|
+
- todo_suspenders.md
|
154
156
|
homepage: http://github.com/welaika/welaika-suspenders
|
155
157
|
licenses:
|
156
158
|
- MIT
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
require_relative "../actions"
|
3
|
-
|
4
|
-
module Suspenders
|
5
|
-
class ErrorReportingGenerator < Rails::Generators::Base
|
6
|
-
include Suspenders::Actions
|
7
|
-
|
8
|
-
source_root File.expand_path(
|
9
|
-
File.join("..", "..", "..", "templates"),
|
10
|
-
File.dirname(__FILE__),
|
11
|
-
)
|
12
|
-
|
13
|
-
def add_sentry
|
14
|
-
gem "sentry-raven"
|
15
|
-
Bundler.with_clean_env { run "bundle install" }
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_up_sentry
|
19
|
-
copy_file "sentry.rb", "config/initializers/sentry.rb"
|
20
|
-
end
|
21
|
-
|
22
|
-
def configure_sentry_context
|
23
|
-
inject_into_class(
|
24
|
-
"app/controllers/application_controller.rb",
|
25
|
-
'ApplicationController',
|
26
|
-
context_configuration
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
def env_vars
|
31
|
-
expand_json(
|
32
|
-
"app.json",
|
33
|
-
env: {
|
34
|
-
SENTRY_DSN: { required: true },
|
35
|
-
SENTRY_CURRENT_ENV: { required: true }
|
36
|
-
}
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def context_configuration
|
43
|
-
<<-RUBY
|
44
|
-
before_action :set_raven_context
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def set_raven_context
|
49
|
-
Raven.user_context(id: session[:current_user_id])
|
50
|
-
Raven.extra_context(params: params.to_unsafe_h, url: request.url)
|
51
|
-
end
|
52
|
-
RUBY
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
|
3
|
-
module Suspenders
|
4
|
-
class FormsGenerator < Rails::Generators::Base
|
5
|
-
def add_simple_form
|
6
|
-
gem "simple_form"
|
7
|
-
Bundler.with_clean_env { run "bundle install" }
|
8
|
-
end
|
9
|
-
|
10
|
-
def configure_simple_form
|
11
|
-
create_file "config/initializers/simple_form.rb" do
|
12
|
-
"SimpleForm.setup {|config|}"
|
13
|
-
end
|
14
|
-
|
15
|
-
generate "simple_form:install", "--force"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|