jt_tools 0.0.4 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +24 -6
- data/.standard.yml +10 -0
- data/Gemfile +3 -1
- data/README.md +3 -1
- data/Rakefile +5 -5
- data/bin/test +9 -8
- data/jt_tools.gemspec +14 -14
- data/lib/install/.circleci/config.yml +31 -40
- data/lib/install/.editorconfig +1 -232
- data/lib/install/.erb-lint.yml +6 -6
- data/lib/install/.reek.yml +8 -13
- data/lib/install/.rubocop.yml +37 -1
- data/lib/install/.simplecov +8 -8
- data/lib/install/Brewfile +13 -12
- data/lib/install/Gemfile.tools +2 -0
- data/lib/install/app.json +19 -13
- data/lib/install/bin/circleci-auto_upgrade_tools +3 -3
- data/lib/install/bin/git-hooks/{post-merge.sample → post-merge} +5 -1
- data/lib/install/bin/git-hooks/{pre-push.sample → pre-push} +0 -0
- data/lib/install/bin/heroku-postdeploy +1 -1
- data/lib/install/bin/lint-pr +1 -1
- data/lib/install/bin/tools-setup +4 -1
- data/lib/install/bin/tools-upgrade +5 -2
- data/lib/install/config/rails_best_practices.yml +5 -5
- data/lib/jt_tools.rb +2 -2
- data/lib/jt_tools/railtie.rb +2 -2
- data/lib/jt_tools/version.rb +1 -1
- data/lib/tasks/install.rake +3 -3
- data/rejuvenation.rb +4 -5
- data/template.rb +139 -80
- metadata +9 -8
data/lib/install/.erb-lint.yml
CHANGED
@@ -10,17 +10,17 @@ linters:
|
|
10
10
|
- .rubocop.yml
|
11
11
|
Layout/InitialIndentation:
|
12
12
|
Enabled: false
|
13
|
+
Layout/LineLength:
|
14
|
+
Enabled: false
|
13
15
|
Layout/TrailingEmptyLines:
|
14
16
|
Enabled: false
|
15
17
|
Layout/TrailingWhitespace:
|
16
18
|
Enabled: false
|
17
|
-
Naming/FileName:
|
18
|
-
Enabled: false
|
19
|
-
Style/FrozenStringLiteralComment:
|
20
|
-
Enabled: false
|
21
|
-
Layout/LineLength:
|
22
|
-
Enabled: false
|
23
19
|
Lint/UselessAssignment:
|
24
20
|
Enabled: false
|
21
|
+
Naming/FileName:
|
22
|
+
Enabled: false
|
25
23
|
Rails/OutputSafety:
|
26
24
|
Enabled: false
|
25
|
+
Style/FrozenStringLiteralComment:
|
26
|
+
Enabled: false
|
data/lib/install/.reek.yml
CHANGED
@@ -2,26 +2,21 @@
|
|
2
2
|
detectors:
|
3
3
|
IrresponsibleModule:
|
4
4
|
enabled: false
|
5
|
+
DuplicateMethodCall:
|
6
|
+
max_calls: 4
|
7
|
+
FeatureEnvy:
|
8
|
+
enabled: false
|
5
9
|
UncommunicativeVariableName:
|
6
10
|
accept:
|
7
11
|
- e
|
12
|
+
- i
|
13
|
+
- v
|
8
14
|
UnusedPrivateMethod:
|
9
15
|
enabled: false
|
10
|
-
|
11
|
-
|
16
|
+
UtilityFunction:
|
17
|
+
enabled: false
|
12
18
|
|
13
19
|
directories:
|
14
20
|
"**/app/controllers/**":
|
15
21
|
InstanceVariableAssumption:
|
16
22
|
enabled: false
|
17
|
-
UtilityFunction:
|
18
|
-
enabled: false
|
19
|
-
"**/app/jobs/**":
|
20
|
-
UtilityFunction:
|
21
|
-
enabled: false
|
22
|
-
"**/app/helpers/**":
|
23
|
-
UtilityFunction:
|
24
|
-
enabled: false
|
25
|
-
"**/spec/**":
|
26
|
-
UtilityFunction:
|
27
|
-
enabled: false
|
data/lib/install/.rubocop.yml
CHANGED
@@ -4,11 +4,18 @@ require:
|
|
4
4
|
- rubocop-rails
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
TargetRubyVersion: 2.
|
7
|
+
TargetRubyVersion: 2.7
|
8
8
|
Exclude:
|
9
9
|
- 'db/migrate/**/*'
|
10
10
|
- 'db/schema.rb'
|
11
11
|
|
12
|
+
Layout/DotPosition:
|
13
|
+
Enabled: true
|
14
|
+
EnforcedStyle: leading
|
15
|
+
|
16
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
17
|
+
Enabled: true
|
18
|
+
|
12
19
|
Layout/EmptyLinesAroundBlockBody:
|
13
20
|
Exclude:
|
14
21
|
- 'db/schema.rb'
|
@@ -39,9 +46,21 @@ Layout/MultilineOperationIndentation:
|
|
39
46
|
Layout/ParameterAlignment:
|
40
47
|
EnforcedStyle: with_fixed_indentation
|
41
48
|
|
49
|
+
Layout/SpaceAroundMethodCallOperator:
|
50
|
+
Enabled: true
|
51
|
+
|
42
52
|
Layout/SpaceInLambdaLiteral:
|
43
53
|
EnforcedStyle: require_space
|
44
54
|
|
55
|
+
Lint/DeprecatedOpenSSLConstant:
|
56
|
+
Enabled: true
|
57
|
+
|
58
|
+
Lint/RaiseException:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
Lint/StructNewOverride:
|
62
|
+
Enabled: true
|
63
|
+
|
45
64
|
Metrics/AbcSize:
|
46
65
|
Exclude:
|
47
66
|
- 'test/**/*.rb'
|
@@ -75,16 +94,33 @@ Style/ClassAndModuleChildren:
|
|
75
94
|
Style/Documentation:
|
76
95
|
Enabled: false
|
77
96
|
|
97
|
+
Style/ExponentialNotation:
|
98
|
+
Enabled: true
|
99
|
+
|
78
100
|
Style/FrozenStringLiteralComment:
|
79
101
|
Enabled: true
|
80
102
|
|
103
|
+
Style/HashEachMethods:
|
104
|
+
Enabled: true
|
105
|
+
|
106
|
+
Style/HashTransformKeys:
|
107
|
+
Enabled: true
|
108
|
+
|
109
|
+
Style/HashTransformValues:
|
110
|
+
Enabled: true
|
111
|
+
|
81
112
|
Style/SafeNavigation:
|
82
113
|
Enabled: false
|
83
114
|
|
115
|
+
Style/SlicingWithRange:
|
116
|
+
Enabled: true
|
117
|
+
|
84
118
|
Style/StabbyLambdaParentheses:
|
85
119
|
EnforcedStyle: require_no_parentheses
|
86
120
|
|
87
121
|
Style/StringLiterals:
|
122
|
+
Enabled: true
|
123
|
+
EnforcedStyle: double_quotes
|
88
124
|
Exclude:
|
89
125
|
- 'db/schema.rb'
|
90
126
|
|
data/lib/install/.simplecov
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if defined?(Spring) && ENV[
|
4
|
-
puts
|
5
|
-
puts
|
3
|
+
if defined?(Spring) && ENV["DISABLE_SPRING"].nil?
|
4
|
+
puts "**** NO COVERAGE FOR YOU! ****"
|
5
|
+
puts "Please disable Spring to get COVERAGE by `DISABLE_SPRING=1 COVERAGE=1 bin/rspec`"
|
6
6
|
else
|
7
|
-
SimpleCov.start
|
7
|
+
SimpleCov.start "rails" do
|
8
8
|
add_filter %w[app/views bin spec test]
|
9
9
|
|
10
10
|
maximum_coverage_drop 0.5
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
if ENV["CODECOV_TOKEN"]
|
14
|
+
require "codecov"
|
15
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
16
|
+
end
|
17
17
|
end
|
data/lib/install/Brewfile
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
tap
|
4
|
-
cask_args appdir:
|
3
|
+
tap "caskroom/cask"
|
4
|
+
cask_args appdir: "/Applications"
|
5
5
|
|
6
|
-
tap
|
6
|
+
tap "heroku/brew"
|
7
7
|
|
8
|
-
|
9
|
-
brew
|
10
|
-
brew
|
11
|
-
brew
|
12
|
-
brew
|
13
|
-
brew
|
14
|
-
brew
|
15
|
-
brew
|
16
|
-
brew
|
8
|
+
brew "circleci"
|
9
|
+
brew "graphicsmagick" # For ActiveStorage
|
10
|
+
brew "heroku"
|
11
|
+
brew "hub" # For creating Pull Request from CLI
|
12
|
+
brew "postgresql"
|
13
|
+
brew "rbenv"
|
14
|
+
brew "ruby-build"
|
15
|
+
brew "vips" # For ActiveStorage
|
16
|
+
brew "yamllint" # For Linters
|
17
|
+
brew "yarn"
|
data/lib/install/Gemfile.tools
CHANGED
@@ -20,6 +20,8 @@ group :tools do
|
|
20
20
|
gem 'pronto-rubocop', require: false
|
21
21
|
gem 'pronto-yamllint', require: false
|
22
22
|
|
23
|
+
# gem 'rubocop-minitest', require: false
|
23
24
|
gem 'rubocop-performance', require: false
|
24
25
|
gem 'rubocop-rails', require: false
|
26
|
+
# gem 'rubocop-rspec', require: false
|
25
27
|
end
|
data/lib/install/app.json
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
{
|
2
|
-
"name": "APP NAME",
|
3
2
|
"scripts": {
|
4
3
|
"postdeploy": "bin/heroku-postdeploy"
|
5
4
|
},
|
6
5
|
"env": {
|
7
|
-
"RAILS_MASTER_KEY": {
|
8
|
-
"required": true
|
9
|
-
},
|
10
|
-
"ROLLBAR_ACCESS_TOKEN": {
|
11
|
-
"required": true
|
12
|
-
},
|
13
|
-
"ROLLBAR_ENDPOINT": {
|
14
|
-
"required": true
|
15
|
-
},
|
16
|
-
"SECRET_KEY_BASE": {
|
17
|
-
"generator": "secret"
|
18
|
-
},
|
19
6
|
"BUNDLE_WITHOUT": "development:test:production",
|
20
7
|
"DISABLE_DATABASE_ENVIRONMENT_CHECK": "1",
|
8
|
+
"JEMALLOC_ENABLED": "true",
|
21
9
|
"LANG": "en_US.UTF-8",
|
22
10
|
"MALLOC_ARENA_MAX": "2",
|
23
11
|
"NODE_ENV": "production",
|
24
12
|
"RACK_ENV": "staging",
|
25
13
|
"RAILS_ENV": "staging",
|
26
14
|
"RAILS_LOG_TO_STDOUT": "enabled",
|
15
|
+
"RAILS_MASTER_KEY": {
|
16
|
+
"required": true
|
17
|
+
},
|
27
18
|
"RAILS_MAX_THREADS": "5",
|
28
19
|
"RAILS_SERVE_STATIC_FILES": "enabled",
|
29
20
|
"REDIS_PROVIDER": "REDISTOGO_URL",
|
21
|
+
"ROLLBAR_ACCESS_TOKEN": {
|
22
|
+
"required": true
|
23
|
+
},
|
24
|
+
"ROLLBAR_ENDPOINT": {
|
25
|
+
"required": true
|
26
|
+
},
|
30
27
|
"ROLLBAR_ENV": "staging",
|
28
|
+
"SECRET_KEY_BASE": {
|
29
|
+
"generator": "secret"
|
30
|
+
},
|
31
31
|
"SIDEKIQ_CONCURRENCY": "5",
|
32
32
|
"WEB_CONCURRENCY": "2"
|
33
33
|
},
|
@@ -38,6 +38,12 @@
|
|
38
38
|
"redistogo:nano"
|
39
39
|
],
|
40
40
|
"buildpacks": [
|
41
|
+
{
|
42
|
+
"url": "https://github.com/gaffneyc/heroku-buildpack-jemalloc.git"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"url": "heroku/nodejs"
|
46
|
+
},
|
41
47
|
{
|
42
48
|
"url": "heroku/ruby"
|
43
49
|
}
|
@@ -4,7 +4,7 @@ set -e
|
|
4
4
|
|
5
5
|
echo "-----Create and switch to new branch-----"
|
6
6
|
|
7
|
-
current_date
|
7
|
+
current_date=$(date +"%Y%m%d%H%M")
|
8
8
|
new_branch_name="auto-upgrade-tools-dependencies-${current_date}"
|
9
9
|
git checkout -b $new_branch_name
|
10
10
|
|
@@ -17,11 +17,11 @@ if bin/tools-upgrade; then
|
|
17
17
|
git config user.email "circleci.bot@example.com"
|
18
18
|
|
19
19
|
git commit -am "Upgrades Gemfile.tools dependencies"
|
20
|
-
git push https://$GITHUB_TOKEN@github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git -f
|
20
|
+
git push "https://$GITHUB_TOKEN@github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git" -f
|
21
21
|
|
22
22
|
curl -X POST \
|
23
23
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
24
|
-
-d '{"title":"
|
24
|
+
-d '{"title":"Upgrades tools dependencies","base":"master","head":"'$CIRCLE_PROJECT_USERNAME':'$new_branch_name'"}' \
|
25
25
|
https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls
|
26
26
|
exit 0
|
27
27
|
else
|
File without changes
|
data/lib/install/bin/lint-pr
CHANGED
data/lib/install/bin/tools-setup
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
-
set -
|
3
|
+
set -eo pipefail
|
4
|
+
|
5
|
+
([[ (-x "$(command -v brew)") ]] && brew bundle check || brew bundle --no-lock) \
|
6
|
+
|| (echo "*** Please upgrade manually system dependencies: ***" && cat Brewfile)
|
4
7
|
|
5
8
|
export BUNDLE_GEMFILE=Gemfile.tools
|
6
9
|
|
7
10
|
bundle update --jobs=4 --retry=3
|
8
11
|
|
9
|
-
yarn check || yarn install
|
12
|
+
bin/yarn check || bin/yarn install
|
@@ -11,11 +11,11 @@ KeepFindersOnTheirOwnModelCheck: {}
|
|
11
11
|
LawOfDemeterCheck: {}
|
12
12
|
# LongLineCheck: { max_line_length: 80 }
|
13
13
|
MoveCodeIntoControllerCheck: {}
|
14
|
-
MoveCodeIntoHelperCheck: { array_count:
|
15
|
-
MoveCodeIntoModelCheck: { use_count:
|
14
|
+
MoveCodeIntoHelperCheck: { array_count: 10 }
|
15
|
+
MoveCodeIntoModelCheck: { use_count: 10 }
|
16
16
|
MoveFinderToNamedScopeCheck: {}
|
17
|
-
MoveModelLogicIntoModelCheck: { use_count:
|
18
|
-
NeedlessDeepNestingCheck: { nested_count:
|
17
|
+
MoveModelLogicIntoModelCheck: { use_count: 10 }
|
18
|
+
NeedlessDeepNestingCheck: { nested_count: 5 }
|
19
19
|
NotRescueExceptionCheck: {}
|
20
20
|
NotUseDefaultRouteCheck: {}
|
21
21
|
NotUseTimeAgoInWordsCheck: {}
|
@@ -27,7 +27,7 @@ RemoveTrailingWhitespaceCheck: {}
|
|
27
27
|
# RemoveUnusedMethodsInControllersCheck: { except_methods: [] }
|
28
28
|
# RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
|
29
29
|
# RemoveUnusedMethodsInModelsCheck: { except_methods: [] }
|
30
|
-
ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count:
|
30
|
+
ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 5 }
|
31
31
|
ReplaceInstanceVariableWithLocalVariableCheck: {}
|
32
32
|
RestrictAutoGeneratedRoutesCheck: {}
|
33
33
|
SimplifyRenderInControllersCheck: {}
|
data/lib/jt_tools.rb
CHANGED
data/lib/jt_tools/railtie.rb
CHANGED
data/lib/jt_tools/version.rb
CHANGED
data/lib/tasks/install.rake
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
install_template_path = File.expand_path(
|
4
|
-
bin_path = ENV[
|
3
|
+
install_template_path = File.expand_path("../../template.rb", __dir__).freeze
|
4
|
+
bin_path = ENV["BUNDLE_BIN"] || "./bin"
|
5
5
|
|
6
6
|
namespace :jt_tools do
|
7
|
-
desc
|
7
|
+
desc "Install jt-tools in this application"
|
8
8
|
task install: :environment do
|
9
9
|
exec "#{RbConfig.ruby} #{bin_path}/rails app:template LOCATION=#{install_template_path}"
|
10
10
|
end
|
data/rejuvenation.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
|
2
|
-
require 'json'
|
1
|
+
require "json"
|
3
2
|
|
4
3
|
EXTRACT_DEPENDENCY_NAME = /"?(.+?)@.+?"?(?:,\s+|\Z)/.freeze
|
5
4
|
EXTRACT_DEPENDENCY_DETAILS = /(^((?!= ).*?):\n.*?(?:\n\n|\Z))/m.freeze
|
6
5
|
|
7
6
|
def direct_dependencies_names
|
8
|
-
package_json = JSON.parse(File.open(
|
9
|
-
direct_dependencies = package_json.fetch_values(
|
7
|
+
package_json = JSON.parse(File.open("package.json").read)
|
8
|
+
direct_dependencies = package_json.fetch_values("dependencies", "devDependencies", "peerDependencies") {}
|
10
9
|
direct_dependencies.compact.inject([]) { |memo, v| memo.concat(v.keys) }
|
11
10
|
end
|
12
11
|
|
13
12
|
@dependencies = direct_dependencies_names
|
14
13
|
|
15
|
-
yarn_lock_content = File.open(
|
14
|
+
yarn_lock_content = File.open("yarn.lock").read
|
16
15
|
yarn_lock_content.scan(EXTRACT_DEPENDENCY_DETAILS).each do |dependency_block|
|
17
16
|
direct_dep = @dependencies.include?(dependency_block[1].match(EXTRACT_DEPENDENCY_NAME).to_a[1])
|
18
17
|
puts dependency_block[0] if direct_dep
|
data/template.rb
CHANGED
@@ -7,17 +7,17 @@
|
|
7
7
|
# In that case, use `git clone` to download them to a local temporary dir.
|
8
8
|
def add_template_repository_to_source_path
|
9
9
|
if __FILE__.match?(%r{\Ahttps?://})
|
10
|
-
require
|
11
|
-
require
|
10
|
+
require "shellwords"
|
11
|
+
require "tmpdir"
|
12
12
|
|
13
|
-
source_paths.unshift(temp_dir = Dir.mktmpdir(
|
13
|
+
source_paths.unshift(temp_dir = Dir.mktmpdir("jt_tools-"))
|
14
14
|
at_exit { FileUtils.remove_entry(temp_dir) }
|
15
15
|
git clone: [
|
16
|
-
|
17
|
-
|
16
|
+
"--quiet",
|
17
|
+
"https://github.com/jetthoughts/jt_tools.git",
|
18
18
|
temp_dir
|
19
19
|
].map { |args| Shellwords.escape(args) }
|
20
|
-
.join(
|
20
|
+
.join(" ")
|
21
21
|
|
22
22
|
if (branch = __FILE__[%r{jt_tools/(.+)/template.rb}, 1])
|
23
23
|
Dir.chdir(temp_dir) { git checkout: branch }
|
@@ -29,120 +29,179 @@ end
|
|
29
29
|
|
30
30
|
add_template_repository_to_source_path
|
31
31
|
|
32
|
-
say
|
33
|
-
directory
|
32
|
+
say "=> Copying binstubs"
|
33
|
+
directory "lib/install/bin", "bin"
|
34
34
|
|
35
|
-
chmod
|
35
|
+
chmod "bin", 0o755 & ~File.umask, verbose: false
|
36
36
|
|
37
|
-
say
|
38
|
-
copy_file
|
37
|
+
say "=> Copying tools gemfile"
|
38
|
+
copy_file "lib/install/Gemfile.tools", "Gemfile.tools"
|
39
39
|
|
40
|
-
run
|
40
|
+
run "yarn add -D eslint jest-junit"
|
41
41
|
|
42
|
-
say
|
43
|
-
copy_file
|
44
|
-
copy_file
|
45
|
-
copy_file
|
46
|
-
copy_file
|
47
|
-
copy_file
|
48
|
-
copy_file
|
49
|
-
copy_file
|
50
|
-
copy_file
|
51
|
-
copy_file
|
52
|
-
copy_file
|
42
|
+
say "Copying lint configurations"
|
43
|
+
copy_file "lib/install/.better-html.yml", ".better-html.yml"
|
44
|
+
copy_file "lib/install/.erb-lint.yml", ".erb-lint.yml"
|
45
|
+
copy_file "lib/install/.eslintrc.js", ".eslintrc.js"
|
46
|
+
copy_file "lib/install/.pronto.yml", ".pronto.yml"
|
47
|
+
copy_file "lib/install/.pronto_eslint_npm.yml", ".pronto_eslint_npm.yml"
|
48
|
+
copy_file "lib/install/.rubocop.yml", ".rubocop.yml"
|
49
|
+
copy_file "lib/install/.yamllint.yml", ".yamllint.yml"
|
50
|
+
copy_file "lib/install/.reek.yml", ".reek.yml"
|
51
|
+
copy_file "lib/install/config/rails_best_practices.yml", "config/rails_best_practices.yml"
|
52
|
+
copy_file "lib/install/.editorconfig", ".editorconfig"
|
53
53
|
|
54
|
-
say
|
55
|
-
copy_file
|
56
|
-
copy_file
|
54
|
+
say "=> Copying services configuration"
|
55
|
+
copy_file "lib/install/.simplecov", ".simplecov"
|
56
|
+
copy_file "lib/install/codecov.yml", "codecov.yml"
|
57
57
|
|
58
|
-
|
59
|
-
say '=> Adds service client API gems'
|
58
|
+
say "=> Adds service client API gems"
|
60
59
|
|
61
60
|
gem_group :test do
|
62
|
-
gem
|
63
|
-
gem
|
61
|
+
gem "simplecov", require: false, group: :test
|
62
|
+
gem "codecov", require: false, group: :test
|
64
63
|
end
|
65
64
|
|
66
|
-
gem
|
65
|
+
gem "oj"
|
67
66
|
|
68
67
|
gem_group :production, :staging do
|
69
|
-
gem
|
70
|
-
gem
|
68
|
+
gem "dalli"
|
69
|
+
gem "r7insight"
|
70
|
+
gem "rollbar"
|
71
71
|
end
|
72
72
|
|
73
|
-
directory
|
73
|
+
directory "lib/install/.circleci", ".circleci"
|
74
74
|
|
75
|
-
if File.read(
|
76
|
-
gem
|
75
|
+
if File.read("Gemfile").include? "rspec"
|
76
|
+
gem "rspec_junit_formatter", require: false, group: :test
|
77
77
|
insert_into_file(
|
78
|
-
|
78
|
+
"spec/spec_helper.rb",
|
79
79
|
"require 'simplecov' if ENV['COVERAGE']\n",
|
80
80
|
after: /\A/
|
81
81
|
)
|
82
|
+
insert_into_file(
|
83
|
+
".circleci/config.yml",
|
84
|
+
"\n" + " - run: bin/rspec --format RspecJunitFormatter --out tmp/reports/rspec-results.xml --format progress",
|
85
|
+
after: "# rails test"
|
86
|
+
)
|
82
87
|
else
|
83
|
-
gem
|
88
|
+
gem "minitest-ci", require: false, group: :test
|
84
89
|
insert_into_file(
|
85
|
-
|
90
|
+
"test/test_helper.rb",
|
86
91
|
"require 'simplecov' if ENV['COVERAGE']\n",
|
87
92
|
after: /\A/
|
88
93
|
)
|
94
|
+
insert_into_file(
|
95
|
+
".circleci/config.yml",
|
96
|
+
"\n" + ' - run: bin/rails test "test/**/*_test.rb"',
|
97
|
+
after: "# rails test"
|
98
|
+
)
|
99
|
+
|
100
|
+
gsub_file "test/test_helper.rb",
|
101
|
+
"parallelize(workers: :number_of_processors)",
|
102
|
+
"parallelize(workers: :number_of_processors) unless ENV['COVERAGE']"
|
89
103
|
end
|
90
104
|
|
91
|
-
directory
|
105
|
+
directory "lib/install/.dependabot", ".dependabot"
|
92
106
|
|
93
|
-
say
|
94
|
-
copy_file
|
95
|
-
copy_file
|
107
|
+
say "=> Copying heroku configuration"
|
108
|
+
copy_file "lib/install/app.json", "app.json"
|
109
|
+
copy_file "lib/install/Procfile", "Procfile"
|
96
110
|
|
97
|
-
say
|
98
|
-
copy_file
|
111
|
+
say "=> Install Brew dependencies"
|
112
|
+
copy_file "lib/install/Brewfile", "Brewfile"
|
99
113
|
|
100
|
-
say
|
101
|
-
directory
|
114
|
+
say "Setup git hooks"
|
115
|
+
directory "lib/install/bin/git-hooks", "bin/git-hooks"
|
102
116
|
|
103
|
-
require
|
117
|
+
require "bundler"
|
104
118
|
Bundler.with_original_env do
|
105
|
-
say
|
106
|
-
run
|
119
|
+
say "=> Install tools"
|
120
|
+
run "bin/tools-setup"
|
107
121
|
|
108
|
-
say
|
109
|
-
run
|
110
|
-
run
|
122
|
+
say "=> Generate binstubs for linters"
|
123
|
+
run "BUNDLE_GEMFILE=Gemfile.tools bundle binstub --force pronto"
|
124
|
+
run "BUNDLE_GEMFILE=Gemfile.tools bundle binstub --force rubocop"
|
111
125
|
end
|
112
126
|
|
113
|
-
say
|
114
|
-
run
|
127
|
+
say "=> Set git hooks"
|
128
|
+
run "git config core.hooksPath ./bin/git-hooks"
|
129
|
+
say "=> Install all new dependencies"
|
115
130
|
|
116
|
-
say '=> Install all new dependencies'
|
117
131
|
run <<~BREW_INSTALL
|
118
132
|
hash brew 2> /dev/null \
|
119
|
-
&& (brew bundle check || brew bundle install) \
|
133
|
+
&& (brew bundle check || brew bundle install --no-lock) \
|
120
134
|
|| echo "Please install Homebrew: https://brew.sh/"
|
121
135
|
BREW_INSTALL
|
122
136
|
|
123
|
-
say
|
124
|
-
uncomment_lines
|
137
|
+
say "=> Update development config"
|
138
|
+
uncomment_lines "config/environments/development.rb", /config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/
|
139
|
+
|
140
|
+
say "=> Set up R7Insight"
|
141
|
+
r7insight_config = <<-CODE
|
142
|
+
if ENV['R7INSIGHT_TOKEN'].present?
|
143
|
+
Rails.logger = R7Insight.new(ENV['R7INSIGHT_TOKEN'], ENV['R7INSIGHT_REGION'])
|
144
|
+
end
|
145
|
+
CODE
|
146
|
+
insert_into_file "config/environments/production.rb",
|
147
|
+
"require 'r7_insight.rb'" + "\n\n",
|
148
|
+
before: "Rails.application.configure do"
|
149
|
+
environment(r7insight_config, env: "production")
|
150
|
+
if File.exist?("config/environments/staging.rb")
|
151
|
+
insert_into_file "config/environments/staging.rb",
|
152
|
+
"require 'r7_insight.rb'" + "\n\n",
|
153
|
+
before: "Rails.application.configure do"
|
154
|
+
environment(r7insight_config, env: "staging")
|
155
|
+
end
|
156
|
+
|
157
|
+
gem "connection_pool"
|
158
|
+
|
159
|
+
say "=> Set up Memcachier"
|
160
|
+
memcachier_config = <<-CODE
|
161
|
+
if ENV["MEMCACHIER_SERVERS"]
|
162
|
+
config.cache_store = :mem_cache_store,
|
163
|
+
ENV["MEMCACHIER_SERVERS"].split(","), {
|
164
|
+
username: ENV["MEMCACHIER_USERNAME"], password: ENV["MEMCACHIER_PASSWORD"],
|
165
|
+
failover: true, socket_timeout: 1.5, socket_failure_delay: 0.2, down_retry_delay: 60,
|
166
|
+
pool_size: ENV.fetch("RAILS_MAX_THREADS") { 5 },
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
CODE
|
171
|
+
environment(memcachier_config, env: "production")
|
172
|
+
if File.exist?("config/environments/staging.rb")
|
173
|
+
environment(memcachier_config, env: "staging")
|
174
|
+
end
|
175
|
+
|
176
|
+
Bundler.with_original_env do
|
177
|
+
say "=> Setup default bundle config"
|
178
|
+
run "bundle config jobs 4"
|
179
|
+
run "bundle config retry 3"
|
125
180
|
|
126
|
-
|
127
|
-
say '=> Setup default bundle config'
|
128
|
-
run 'bundle config jobs 4'
|
129
|
-
run 'bundle config retry 3'
|
181
|
+
run "bundle"
|
130
182
|
end
|
131
183
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
say
|
141
|
-
say
|
142
|
-
say
|
143
|
-
say
|
144
|
-
say
|
145
|
-
say
|
146
|
-
say
|
147
|
-
say
|
148
|
-
say
|
184
|
+
uncomment_lines 'bin/setup', /system\(.*?\\byarn\b/
|
185
|
+
|
186
|
+
insert_into_file(
|
187
|
+
"bin/setup",
|
188
|
+
"system!('bin/tools-setup')\n",
|
189
|
+
after: "system('bundle check') || system!('bundle install')\n"
|
190
|
+
)
|
191
|
+
|
192
|
+
say "**************************************************************************"
|
193
|
+
say "**************************************************************************"
|
194
|
+
say ""
|
195
|
+
say "1. Recommended Heroku Addons: Mailtrap, Rollbar, Cloudinary"
|
196
|
+
say ""
|
197
|
+
say "2. Setup Git Hooks to auto-check code and cleanup staled branches:"
|
198
|
+
say "$ `git config core.hooksPath bin/git-hooks`"
|
199
|
+
say ""
|
200
|
+
say "3. Please, set CODECOV_TOKEN, GITHUB_TOKEN and PRONTO_GITHUB_ACCESS_TOKEN"
|
201
|
+
say "environment variables in CircleCI and your local env"
|
202
|
+
say ""
|
203
|
+
say " For code coverage report aggregator, running code static analysis"
|
204
|
+
say "and auto-update of the tools."
|
205
|
+
say ""
|
206
|
+
say "**************************************************************************"
|
207
|
+
say "**************************************************************************"
|