welaika-suspenders 2.29.0.alpha.1 → 2.29.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2bc8b6b54027c607ac3d40740602bb464a24c69baebdccbf0274b6bcf52b541
4
- data.tar.gz: c6145805c840fd18b6e4b40e63332de24bc626f6f0de7b8f7fc83b816f2b7e5a
3
+ metadata.gz: 99c15d50a9c274c2685a1a9807bd5dd3c68e23308e4f9367da74d1ca7270aef1
4
+ data.tar.gz: 28b04a2011baaa632eb1ab8889bf413a42aede7b102e2b167760aea3fd808c31
5
5
  SHA512:
6
- metadata.gz: 9d92f5e43680df4e9dca8a24618153f3d98cd5ee5de61504b0b8a0fddc796a33b25b90a9189d501150ace679d85343de2a566bcc97e66092cead0ebc9545b55c
7
- data.tar.gz: 90adc4777638db3f20b4caac5ca84a7fadb5a7acf3662f041a396d9a304fca49483c871e65b86f62fb9841393b42620336e63c12548fcc62b6df8c1f3f913f9e
6
+ metadata.gz: 113ae2339f91f79d66f7cee8fba15e2f11f78cbad5fd0db05ae75e8dec9c2b1342da198c2f4118dde86256a2266a2557f39ae885ce28fb57819d612d95327e27
7
+ data.tar.gz: 3c9fad55bfb2c5826956a20de2b1a4255df2b0ab4a7f44defe47d39be6b7f37e55f11ae6a256f26001362455cb4557c82dd32b2bcf7e9e2ba1fe377312cd8ac4
@@ -313,25 +313,11 @@ you can deploy to staging and production with:
313
313
  "Rails.application.routes.draw do\nend"
314
314
  end
315
315
 
316
- def setup_default_rake_task
317
- append_file 'Rakefile' do
318
- <<-EOS
319
- task(:default).clear
320
-
321
- if defined? RSpec
322
- task(:spec).clear
323
- RSpec::Core::RakeTask.new(:spec) do |t|
324
- t.verbose = false
325
- end
326
- end
327
-
328
- task default: :rubocop
329
- task default: :slim_lint
330
- task default: 'brakeman:check'
331
- task default: 'bundle:audit'
332
- task default: :spec
333
- EOS
334
- end
316
+ def setup_rakefile
317
+ # NOTE: we named our file `rakefile_template` and not
318
+ # `Rakefile` because otherwise `copy_file` would copy the
319
+ # rails `Rakefile` into the project folder.
320
+ copy_file 'rakefile_template.rb', 'Rakefile', force: true
335
321
  end
336
322
 
337
323
  private
@@ -104,17 +104,19 @@ module Suspenders
104
104
  build :configure_action_mailer
105
105
  build :configure_locales_and_time_zone
106
106
  build :configure_time_formats
107
- build :setup_default_rake_task
107
+ build :setup_rakefile
108
108
  build :replace_default_puma_configuration
109
109
  build :set_up_forego
110
110
  build :setup_rack_mini_profiler
111
111
  end
112
112
 
113
113
  def create_local_heroku_setup
114
- say "Creating local Heroku setup"
115
- build :create_review_apps_setup_script
116
- build :create_deploy_script
117
- build :create_heroku_application_manifest_file
114
+ if options[:heroku]
115
+ say "Creating local Heroku setup"
116
+ build :create_review_apps_setup_script
117
+ build :create_deploy_script
118
+ build :create_heroku_application_manifest_file
119
+ end
118
120
  end
119
121
 
120
122
  def create_heroku_apps
@@ -7,7 +7,7 @@ module Suspenders
7
7
  File.dirname(__FILE__),
8
8
  )
9
9
 
10
- def add_factory_bot
10
+ def add_draper_gem
11
11
  gem "draper"
12
12
  Bundler.with_clean_env { run "bundle install" }
13
13
  end
@@ -9,6 +9,7 @@ module Suspenders
9
9
 
10
10
  def add_factory_bot
11
11
  gem "factory_bot_rails", group: %i(development test)
12
+ gem "database_cleaner", group: %i(development test)
12
13
  Bundler.with_clean_env { run "bundle install" }
13
14
  end
14
15
 
@@ -16,6 +17,10 @@ module Suspenders
16
17
  copy_file "factory_bot_rspec.rb", "spec/support/factory_bot.rb"
17
18
  end
18
19
 
20
+ def set_up_factory_lint
21
+ copy_file 'factory_bot.rake', 'lib/tasks/factory_bot.rake'
22
+ end
23
+
19
24
  def provide_dev_prime_task
20
25
  copy_file "dev.rake", "lib/tasks/dev.rake"
21
26
  end
@@ -11,24 +11,36 @@ module Suspenders
11
11
  gem 'rubocop', require: false, group: :development
12
12
  gem 'rubocop-rspec', require: false, group: :development
13
13
  gem 'slim_lint', require: false, group: :development
14
+ gem 'overcommit', require: false, group: :development
15
+ gem 'rubycritic', require: false, group: :development
14
16
  Bundler.with_clean_env { run "bundle install" }
15
17
  end
16
18
 
17
19
  def setup_rubocop
18
- copy_file "rubocop.rake", "lib/tasks/rubocop.rake"
19
20
  copy_file "rubocop.yml", ".rubocop.yml"
20
21
  copy_file "rubocop_todo.yml", ".rubocop_todo.yml"
21
22
  end
22
23
 
23
24
  def setup_slim_lint
24
- copy_file "slim-lint.rake", "lib/tasks/slim-lint.rake"
25
25
  copy_file "slim-lint.yml", ".slim-lint.yml"
26
26
  end
27
27
 
28
+ def setup_overcommit
29
+ run "overcommit --install"
30
+ copy_file "overcommit.yml", ".overcommit.yml", force: true
31
+ run "overcommit --sign"
32
+ end
33
+
34
+ def setup_rubycritic
35
+ copy_file "reek", ".reek"
36
+ end
37
+
28
38
  def create_binstubs
29
39
  Bundler.with_clean_env do
30
40
  run "bundle binstubs rubocop"
31
41
  run "bundle binstubs slim_lint"
42
+ run "bundle binstubs overcommit"
43
+ run "bundle binstubs rubycritic"
32
44
  end
33
45
  end
34
46
  end
@@ -13,15 +13,6 @@ module Suspenders
13
13
  Bundler.with_clean_env { run "bundle install" }
14
14
  end
15
15
 
16
-
17
- def setup_brakeman
18
- copy_file "brakeman.rake", "lib/tasks/brakeman.rake"
19
- end
20
-
21
- def setup_bundler_audit
22
- copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
23
- end
24
-
25
16
  def create_binstubs
26
17
  Bundler.with_clean_env { run "bundle binstubs brakeman" }
27
18
  end
@@ -4,5 +4,5 @@ module Suspenders
4
4
  read("#{File.dirname(__FILE__)}/../../.ruby-version").
5
5
  strip.
6
6
  freeze
7
- VERSION = "2.29.0.alpha.1".freeze
7
+ VERSION = "2.29.0.alpha.2".freeze
8
8
  end
@@ -24,7 +24,7 @@ RSpec.describe "Suspend a new project with default configuration" do
24
24
  it "ensures project specs pass" do
25
25
  Dir.chdir(project_path) do
26
26
  Bundler.with_clean_env do
27
- expect(`rake`).to include('0 failures')
27
+ expect(`bundle exec rspec spec/`).to include('0 failures')
28
28
  end
29
29
  end
30
30
  end
@@ -230,6 +230,7 @@ RSpec.describe "Suspend a new project with default configuration" do
230
230
  expect(File).to exist("#{project_path}/bin/brakeman")
231
231
  expect(File).to exist("#{project_path}/bin/rubocop")
232
232
  expect(File).to exist("#{project_path}/bin/rspec")
233
+ expect(File).to exist("#{project_path}/bin/overcommit")
233
234
  end
234
235
 
235
236
  it "removes comments and extra newlines from config files" do
@@ -1,54 +1,53 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  git_source(:github) do |repo_name|
6
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
6
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
7
7
  "https://github.com/#{repo_name}.git"
8
8
  end
9
9
 
10
- ruby "<%= Suspenders::RUBY_VERSION %>"
11
-
12
- gem "active_interaction", "~> 3.6"
13
- gem "autoprefixer-rails"
14
- gem "coffee-rails", "~> 4.2"
15
- gem "email_validator"
16
- gem "flutie"
17
- gem "jquery-rails" #TODO keep it?
18
- gem "pg", ">= 0.18", "< 2.0"
19
- gem "puma", "~> 3.11"
20
- gem "rack-canonical-host"
21
- gem "rails", "<%= Suspenders::RAILS_VERSION %>"
22
- gem "rails-i18n"
23
- gem "recipient_interceptor"
24
- gem "sass-rails", "~> 5.0"
25
- gem "title"
26
- gem "uglifier", ">= 1.3.0"
27
- gem "bootsnap", ">= 1.1.0", require: false
10
+ ruby '<%= Suspenders::RUBY_VERSION %>'
11
+
12
+ gem 'active_interaction', '~> 3.6'
13
+ gem 'autoprefixer-rails'
14
+ gem 'coffee-rails', '~> 4.2'
15
+ gem 'email_validator'
16
+ gem 'flutie'
17
+ gem 'pg', '>= 0.18', '< 2.0'
18
+ gem 'puma', '~> 3.11'
19
+ gem 'rack-canonical-host'
20
+ gem 'rails', '<%= Suspenders::RAILS_VERSION %>'
21
+ gem 'rails-i18n'
22
+ gem 'recipient_interceptor'
23
+ gem 'sass-rails', '~> 5.0'
24
+ gem 'title'
25
+ gem 'uglifier', '>= 1.3.0'
26
+ gem 'bootsnap', '>= 1.1.0', require: false
28
27
  <% if options[:webpack] %>
29
- gem "webpacker"
28
+ gem 'webpacker'
30
29
  <% end %>
31
30
 
32
31
  group :development do
33
- gem "letter_opener"
34
- gem "listen", ">= 3.0.5", "< 3.2"
35
- gem "rack-mini-profiler", require: false
36
- gem "spring"
37
- gem "web-console", ">= 3.3.0"
32
+ gem 'letter_opener'
33
+ gem 'listen', '>= 3.0.5', '< 3.2'
34
+ gem 'rack-mini-profiler', require: false
35
+ gem 'spring'
36
+ gem 'web-console', '>= 3.3.0'
38
37
  end
39
38
 
40
39
  group :development, :test do
41
- gem "awesome_print"
42
- gem "dotenv-rails"
43
- gem "pry-byebug"
44
- gem "pry-rails"
40
+ gem 'awesome_print'
41
+ gem 'dotenv-rails'
42
+ gem 'pry-byebug'
43
+ gem 'pry-rails'
45
44
  end
46
45
 
47
46
  group :test do
48
- gem "launchy"
49
- gem "simplecov", require: false
50
- gem "timecop"
51
- gem "webmock"
47
+ gem 'launchy'
48
+ gem 'simplecov', require: false
49
+ gem 'timecop'
50
+ gem 'webmock'
52
51
  end
53
52
 
54
- gem "welaika-suspenders", "~> <%= Suspenders::VERSION %>", group: [:development, :test]
53
+ gem 'welaika-suspenders', '~> <%= Suspenders::VERSION %>', group: %i[development test]
data/templates/bin_setup CHANGED
@@ -1,24 +1,34 @@
1
- #!/bin/sh
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+ include FileUtils
2
4
 
3
- # Set up Rails app. Run this script immediately after cloning the codebase.
5
+ APP_ROOT = File.expand_path('..', __dir__)
4
6
 
5
- # Exit if any subcommand fails
6
- set -e
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
7
10
 
8
- # Set up Ruby dependencies via Bundler
9
- gem install bundler --conservative
10
- bundle check || bundle install
11
+ chdir APP_ROOT do
12
+ puts '== Installing dependencies =='
13
+ system! 'gem install bundler --conservative'
14
+ system('bundle check') || system!('bundle install')
11
15
 
12
- # Set up database and add any development seed data
13
- bin/rails dev:prime
16
+ system('bin/yarn')
14
17
 
15
- if [ ! -d .git/safe ] && echo $PATH | grep .git/safe > /dev/null; then
16
- echo "-----------------------------------------------------------------------"
17
- echo
18
- echo "-> When you trust this repo, remember to run: mkdir -p .git/safe"
19
- echo
20
- fi
18
+ puts "\n== Copying sample files =="
19
+ unless File.exist?('.env.local')
20
+ cp '.env', '.env.local'
21
+ end
21
22
 
22
- # Only if this isn't CI
23
- # if [ -z "$CI" ]; then
24
- # fi
23
+ puts "\n== Preparing database and seeds =="
24
+ system! 'bin/rake dev:prime'
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "selenium/webdriver"
3
+ require 'selenium/webdriver'
4
4
 
5
5
  Capybara.register_driver :chrome do |app|
6
6
  Capybara::Selenium::Driver.new(app, browser: :chrome)
@@ -8,12 +8,14 @@ end
8
8
 
9
9
  Capybara.register_driver :headless_chrome do |app|
10
10
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
11
- chromeOptions: { args: %w(headless disable-gpu) },
11
+ chromeOptions: { args: %w[headless disable-gpu] }
12
12
  )
13
13
 
14
- Capybara::Selenium::Driver.new app,
14
+ Capybara::Selenium::Driver.new(
15
+ app,
15
16
  browser: :chrome,
16
17
  desired_capabilities: capabilities
18
+ )
17
19
  end
18
20
 
19
21
  Capybara.javascript_driver = :headless_chrome
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'database_cleaner'
4
+
5
+ namespace :factory_bot do
6
+ desc 'Verify that all FactoryBot factories are valid'
7
+ task lint: :environment do
8
+ if Rails.env.test?
9
+ sh 'bundle exec rails db:migrate'
10
+ DatabaseCleaner.clean_with :truncation
11
+ DatabaseCleaner.strategy = :transaction
12
+ DatabaseCleaner.cleaning do
13
+ FactoryBot.lint(traits: true)
14
+ end
15
+ else
16
+ system('bundle exec rake factory_bot:lint RAILS_ENV=test')
17
+ raise if $CHILD_STATUS.exitstatus.nonzero?
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,14 @@
1
+ gemfile: 'Gemfile'
2
+
3
+ verify_signatures: false # (default: true)
4
+
5
+ PreCommit:
6
+ RuboCop:
7
+ enabled: true
8
+ on_warn: fail # Treat all warnings as failures
9
+ command: ['bundle', 'exec', 'rubocop'] # Invoke within Bundler context
10
+
11
+ SlimLint:
12
+ enabled: true
13
+ on_warn: fail # Treat all warnings as failures
14
+ command: ['bundle', 'exec', 'slim-lint'] # Invoke within Bundler context
@@ -2,7 +2,9 @@
2
2
 
3
3
  ENV['RACK_ENV'] = 'test'
4
4
 
5
- require File.expand_path('../../config/environment', __FILE__)
5
+ require File.expand_path('../config/environment', __dir__)
6
+
7
+
6
8
  abort('DATABASE_URL environment variable is set') if ENV['DATABASE_URL']
7
9
 
8
10
  require 'rspec/rails'
@@ -26,4 +28,3 @@ RSpec.configure do |config|
26
28
  # arbitrary gems may also be filtered via:
27
29
  # config.filter_gems_from_backtrace('gem name')
28
30
  end
29
-
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative 'config/application'
7
+
8
+ Rails.application.load_tasks
9
+ task(:default).clear
10
+
11
+ desc 'Run linters, quality, security and tests'
12
+ task :default do
13
+ sh 'bundle exec rubocop'
14
+ sh 'bundle exec rubycritic app/ config/ lib/ --no-browser --minimum-score 94 --format console'
15
+ sh 'bundle exec bundle-audit check --update'
16
+ sh 'bundle exec brakeman -z'
17
+ sh 'bundle exec rails db:migrate RAILS_ENV=test'
18
+ sh 'bundle exec rake factory_bot:lint RAILS_ENV=test'
19
+ sh 'bundle exec rspec spec/'
20
+ end
data/templates/reek ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ IrresponsibleModule:
3
+ enabled: false
4
+
5
+ UtilityFunction:
6
+ exclude:
7
+ - 'QueriesHelper'
@@ -25,3 +25,6 @@ Metrics/LineLength:
25
25
 
26
26
  Rails:
27
27
  Enabled: true
28
+
29
+ Style/Documentation:
30
+ Enabled: false
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.1
4
+ version: 2.29.0.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot
@@ -117,9 +117,7 @@ files:
117
117
  - templates/bin_deploy
118
118
  - templates/bin_setup
119
119
  - templates/bin_setup_review_app.erb
120
- - templates/brakeman.rake
121
120
  - templates/browserslist
122
- - templates/bundler_audit.rake
123
121
  - templates/capybara_helpers.rb
124
122
  - templates/chromedriver.rb
125
123
  - templates/config_locales_it.yml.erb
@@ -128,23 +126,25 @@ files:
128
126
  - templates/dotfiles/.env
129
127
  - templates/email.rb
130
128
  - templates/errors.rb
129
+ - templates/factory_bot.rake
131
130
  - templates/factory_bot_rspec.rb
132
131
  - templates/faker_rspec.rb
133
132
  - templates/flashes_helper.rb
134
133
  - templates/i18n.rb
135
134
  - templates/json_encoding.rb
135
+ - templates/overcommit.yml
136
136
  - templates/postgresql_database.yml.erb
137
137
  - templates/puma.rb
138
138
  - templates/queries_helper_rspec.rb
139
139
  - templates/rack_mini_profiler.rb
140
140
  - templates/rails_helper.rb
141
- - templates/rubocop.rake
141
+ - templates/rakefile_template.rb
142
+ - templates/reek
142
143
  - templates/rubocop.yml
143
144
  - templates/rubocop_todo.yml
144
145
  - templates/secrets.yml
145
146
  - templates/sentry.rb
146
147
  - templates/shoulda_matchers_config_rspec.rb
147
- - templates/slim-lint.rake
148
148
  - templates/slim-lint.yml
149
149
  - templates/slim.rb
150
150
  - templates/smtp.rb
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Rails.env.development? || Rails.env.test?
4
- namespace :brakeman do
5
- desc 'Run Brakeman'
6
- task :run, :output_files do |_t, args|
7
- require 'brakeman'
8
-
9
- files = args[:output_files].split(' ') if args[:output_files]
10
- Brakeman.run app_path: '.', output_files: files, print_report: true
11
- end
12
-
13
- desc 'Check your code with Brakeman'
14
- task :check do
15
- require 'brakeman'
16
- result = Brakeman.run app_path: '.', print_report: true
17
- exit Brakeman::Warnings_Found_Exit_Code unless result.filtered_warnings.empty?
18
- end
19
- end
20
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Rails.env.development? || Rails.env.test?
4
- require 'bundler/audit/task'
5
- Bundler::Audit::Task.new
6
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Rails.env.development? || Rails.env.test?
4
- require 'rubocop/rake_task'
5
-
6
- RuboCop::RakeTask.new
7
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if Rails.env.development? || Rails.env.test?
4
- require 'slim_lint/rake_task'
5
- SlimLint::RakeTask.new do |t|
6
- t.files = ['app/views']
7
- end
8
- end