jt_tools 0.0.14 → 0.0.19
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 +35 -11
- data/.gitattributes +5 -1
- data/.github/workflows/test.yml +100 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +9 -0
- data/.standard.yml +5 -1
- data/Gemfile +9 -3
- data/README.md +5 -1
- data/Rakefile +5 -5
- data/bin/ci-test +13 -0
- data/bin/lint +12 -0
- data/bin/rubocop +29 -0
- data/bin/test +24 -15
- data/jt_tools.gemspec +15 -14
- data/lib/install/.circleci/config.yml +59 -39
- data/lib/install/.gitattributes +4 -4
- data/lib/install/.github/{config.yml → dependabot.yml} +0 -0
- data/lib/install/.github/workflows/test.yml +147 -0
- data/lib/install/.rubocop.yml +12 -12
- data/lib/install/.simplecov +6 -6
- data/lib/install/Brewfile +11 -11
- data/lib/install/Gemfile.tools +7 -7
- data/lib/install/app.json +1 -1
- data/lib/install/bin/lint-pr +1 -1
- data/lib/install/bin/tools-setup +3 -1
- data/lib/install/bin/tools-upgrade +2 -2
- 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/package.json +5 -0
- data/rejuvenation.rb +6 -4
- data/template.rb +122 -112
- metadata +27 -5
- data/bin/standardrb +0 -29
data/lib/install/Gemfile.tools
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
source 'https://rubygems.org'
|
4
2
|
|
5
3
|
git_source(:github) do |repo_name|
|
@@ -10,19 +8,21 @@ end
|
|
10
8
|
gem 'oj'
|
11
9
|
|
12
10
|
group :tools do
|
13
|
-
gem 'pronto'
|
11
|
+
gem 'pronto', require: false
|
14
12
|
gem 'pronto-blacklist', require: false
|
15
13
|
gem 'pronto-erb_lint', require: false
|
16
|
-
gem 'pronto-
|
14
|
+
gem 'pronto-eslint', require: false
|
17
15
|
gem 'pronto-fasterer', require: false
|
18
16
|
gem 'pronto-rails_best_practices', require: false
|
19
17
|
gem 'pronto-reek', require: false
|
20
18
|
gem 'pronto-rubocop', require: false
|
21
|
-
# gem 'pronto-standardrb', require: false
|
22
19
|
gem 'pronto-yamllint', require: false
|
23
20
|
|
24
|
-
|
21
|
+
gem 'rubocop-performance', require: false
|
25
22
|
gem 'rubocop-rails', require: false
|
26
|
-
|
23
|
+
gem 'rubocop-minitest', require: false
|
24
|
+
|
27
25
|
gem 'standard', '>= 0.4.7', require: false
|
26
|
+
# gem 'pronto-standardrb', require: false
|
27
|
+
# gem 'rubocop-rspec', require: false
|
28
28
|
end
|
data/lib/install/app.json
CHANGED
data/lib/install/bin/lint-pr
CHANGED
data/lib/install/bin/tools-setup
CHANGED
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/package.json
ADDED
data/rejuvenation.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
2
4
|
|
3
5
|
EXTRACT_DEPENDENCY_NAME = /"?(.+?)@.+?"?(?:,\s+|\Z)/.freeze
|
4
6
|
EXTRACT_DEPENDENCY_DETAILS = /(^((?!= ).*?):\n.*?(?:\n\n|\Z))/m.freeze
|
5
7
|
|
6
8
|
def direct_dependencies_names
|
7
|
-
package_json = JSON.parse(File.open(
|
8
|
-
direct_dependencies = package_json.fetch_values(
|
9
|
+
package_json = JSON.parse(File.open('package.json').read)
|
10
|
+
direct_dependencies = package_json.fetch_values('dependencies', 'devDependencies', 'peerDependencies') {}
|
9
11
|
direct_dependencies.compact.inject([]) { |memo, v| memo.concat(v.keys) }
|
10
12
|
end
|
11
13
|
|
12
14
|
@dependencies = direct_dependencies_names
|
13
15
|
|
14
|
-
yarn_lock_content = File.open(
|
16
|
+
yarn_lock_content = File.open('yarn.lock').read
|
15
17
|
yarn_lock_content.scan(EXTRACT_DEPENDENCY_DETAILS).each do |dependency_block|
|
16
18
|
direct_dep = @dependencies.include?(dependency_block[1].match(EXTRACT_DEPENDENCY_NAME).to_a[1])
|
17
19
|
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,107 +29,112 @@ def add_template_repository_to_source_path
|
|
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
|
-
say
|
58
|
+
say '=> Adds service client API gems'
|
59
59
|
|
60
60
|
gem_group :test do
|
61
|
-
gem
|
62
|
-
gem
|
61
|
+
gem 'simplecov', require: false, group: :test
|
62
|
+
gem 'codecov', require: false, group: :test
|
63
|
+
gem 'rexml', require: false, group: :test # for hot fix of webdrivers and ruby 3
|
63
64
|
end
|
64
65
|
|
65
|
-
gem
|
66
|
+
gem 'oj'
|
66
67
|
|
67
68
|
gem_group :production, :staging do
|
68
|
-
gem
|
69
|
-
gem
|
70
|
-
gem
|
69
|
+
gem 'dalli'
|
70
|
+
gem 'r7insight'
|
71
|
+
gem 'rollbar'
|
71
72
|
end
|
72
73
|
|
73
|
-
directory
|
74
|
+
directory 'lib/install/.circleci', '.circleci'
|
74
75
|
|
75
|
-
if File.read(
|
76
|
-
gem
|
76
|
+
if File.read('Gemfile').include? 'rspec'
|
77
|
+
gem 'rspec_junit_formatter', require: false, group: :test
|
77
78
|
insert_into_file(
|
78
|
-
|
79
|
+
'spec/spec_helper.rb',
|
79
80
|
"require 'simplecov' if ENV['COVERAGE']\n",
|
80
81
|
after: /\A/
|
81
82
|
)
|
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
|
-
)
|
87
83
|
else
|
88
|
-
gem
|
84
|
+
gem 'minitest-ci', require: false, group: :test
|
89
85
|
insert_into_file(
|
90
|
-
|
86
|
+
'test/test_helper.rb',
|
91
87
|
"require 'simplecov' if ENV['COVERAGE']\n",
|
92
88
|
after: /\A/
|
93
89
|
)
|
94
|
-
|
95
|
-
|
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)",
|
90
|
+
gsub_file 'test/test_helper.rb',
|
91
|
+
'parallelize(workers: :number_of_processors)',
|
102
92
|
"parallelize(workers: :number_of_processors) unless ENV['COVERAGE']"
|
103
93
|
end
|
104
94
|
|
105
|
-
say
|
106
|
-
directory
|
107
|
-
|
95
|
+
say '=> Copying git configuration'
|
96
|
+
directory 'lib/install/.github', '.github'
|
97
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new('6.1.0')
|
98
|
+
gitattributes = <<~GITATTRIBUTES
|
99
|
+
*.gemspec diff=ruby
|
100
|
+
*.rake diff=ruby
|
101
|
+
*.rb diff=ruby
|
102
|
+
*.js diff=javascript
|
103
|
+
|
104
|
+
db/schema.rb merge=ours diff=ruby
|
105
|
+
yarn.lock merge=ours
|
106
|
+
Gemfile.lock merge=ours linguist-generated
|
107
|
+
GITATTRIBUTES
|
108
|
+
insert_into_file '.gitattributes', gitattributes
|
109
|
+
else
|
110
|
+
copy_file 'lib/install/.gitattributes', '.gitattributes'
|
111
|
+
end
|
108
112
|
|
109
|
-
say
|
110
|
-
copy_file
|
111
|
-
copy_file
|
113
|
+
say '=> Copying heroku configuration'
|
114
|
+
copy_file 'lib/install/app.json', 'app.json'
|
115
|
+
copy_file 'lib/install/Procfile', 'Procfile'
|
112
116
|
|
113
|
-
say
|
114
|
-
copy_file
|
117
|
+
say '=> Install Brew dependencies'
|
118
|
+
copy_file 'lib/install/Brewfile', 'Brewfile'
|
115
119
|
|
116
|
-
say
|
117
|
-
directory
|
120
|
+
say 'Setup git hooks'
|
121
|
+
directory 'lib/install/bin/git-hooks', 'bin/git-hooks'
|
118
122
|
|
119
|
-
require
|
123
|
+
require 'bundler'
|
120
124
|
Bundler.with_original_env do
|
121
|
-
say
|
122
|
-
run
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
run
|
127
|
-
run
|
125
|
+
say '=> Install tools'
|
126
|
+
run 'bin/tools-setup'
|
127
|
+
run 'BUNDLE_GEMFILE=Gemfile.tools bundle lock --add-platform x86_64-linux'
|
128
|
+
|
129
|
+
say '=> Generate binstubs for linters'
|
130
|
+
run 'BUNDLE_GEMFILE=Gemfile.tools bundle binstub --force pronto'
|
131
|
+
run 'BUNDLE_GEMFILE=Gemfile.tools bundle binstub --force rubocop'
|
132
|
+
run 'BUNDLE_GEMFILE=Gemfile.tools bundle binstub --force standard'
|
128
133
|
end
|
129
134
|
|
130
|
-
say
|
131
|
-
run
|
132
|
-
say
|
135
|
+
say '=> Set git hooks'
|
136
|
+
run 'git config core.hooksPath ./bin/git-hooks'
|
137
|
+
say '=> Install all new dependencies'
|
133
138
|
|
134
139
|
run <<~BREW_INSTALL
|
135
140
|
hash brew 2> /dev/null \
|
@@ -137,29 +142,32 @@ def add_template_repository_to_source_path
|
|
137
142
|
|| echo "Please install Homebrew: https://brew.sh/"
|
138
143
|
BREW_INSTALL
|
139
144
|
|
140
|
-
say
|
141
|
-
uncomment_lines
|
145
|
+
say '=> Update development config'
|
146
|
+
uncomment_lines(
|
147
|
+
'config/environments/development.rb',
|
148
|
+
/config\.file_watcher = ActiveSupport::EventedFileUpdateChecker/
|
149
|
+
)
|
142
150
|
|
143
|
-
say
|
151
|
+
say '=> Set up R7Insight'
|
144
152
|
r7insight_config = <<-CODE
|
145
153
|
if ENV['R7INSIGHT_TOKEN'].present?
|
146
154
|
Rails.logger = R7Insight.new(ENV['R7INSIGHT_TOKEN'], ENV['R7INSIGHT_REGION'])
|
147
155
|
end
|
148
156
|
CODE
|
149
|
-
insert_into_file
|
157
|
+
insert_into_file 'config/environments/production.rb',
|
150
158
|
"require 'r7_insight.rb'" + "\n\n",
|
151
|
-
before:
|
152
|
-
environment(r7insight_config, env:
|
153
|
-
if File.exist?(
|
154
|
-
insert_into_file
|
159
|
+
before: 'Rails.application.configure do'
|
160
|
+
environment(r7insight_config, env: 'production')
|
161
|
+
if File.exist?('config/environments/staging.rb')
|
162
|
+
insert_into_file 'config/environments/staging.rb',
|
155
163
|
"require 'r7_insight.rb'" + "\n\n",
|
156
|
-
before:
|
157
|
-
environment(r7insight_config, env:
|
164
|
+
before: 'Rails.application.configure do'
|
165
|
+
environment(r7insight_config, env: 'staging')
|
158
166
|
end
|
159
167
|
|
160
|
-
gem
|
168
|
+
gem 'connection_pool'
|
161
169
|
|
162
|
-
say
|
170
|
+
say '=> Set up Memcachier'
|
163
171
|
memcachier_config = <<-CODE
|
164
172
|
if ENV["MEMCACHIER_SERVERS"]
|
165
173
|
config.cache_store = :mem_cache_store,
|
@@ -171,40 +179,42 @@ def add_template_repository_to_source_path
|
|
171
179
|
end
|
172
180
|
|
173
181
|
CODE
|
174
|
-
environment(memcachier_config, env:
|
175
|
-
if File.exist?(
|
176
|
-
environment(memcachier_config, env:
|
182
|
+
environment(memcachier_config, env: 'production')
|
183
|
+
if File.exist?('config/environments/staging.rb')
|
184
|
+
environment(memcachier_config, env: 'staging')
|
177
185
|
end
|
178
186
|
|
179
187
|
Bundler.with_original_env do
|
180
|
-
say
|
181
|
-
run
|
182
|
-
run
|
188
|
+
say '=> Setup default bundle config'
|
189
|
+
run 'bundle config jobs 4'
|
190
|
+
run 'bundle config retry 3'
|
191
|
+
|
192
|
+
run 'bundle'
|
183
193
|
|
184
|
-
run
|
194
|
+
run 'bundle lock --add-platform x86_64-linux'
|
185
195
|
end
|
186
196
|
|
187
|
-
uncomment_lines
|
197
|
+
uncomment_lines 'bin/setup', /system\(.*?\\byarn\b/
|
188
198
|
|
189
199
|
insert_into_file(
|
190
|
-
|
191
|
-
"system!
|
192
|
-
after: "system!
|
200
|
+
'bin/setup',
|
201
|
+
"system! 'bin/tools-setup'\n",
|
202
|
+
after: "system! 'gem install bundler --conservative'\n"
|
193
203
|
)
|
194
204
|
|
195
|
-
say
|
196
|
-
say
|
197
|
-
say
|
198
|
-
say
|
199
|
-
say
|
200
|
-
say
|
201
|
-
say
|
202
|
-
say
|
203
|
-
say
|
204
|
-
say
|
205
|
-
say
|
206
|
-
say
|
207
|
-
say
|
208
|
-
say
|
209
|
-
say
|
210
|
-
say
|
205
|
+
say '**************************************************************************'
|
206
|
+
say '**************************************************************************'
|
207
|
+
say ''
|
208
|
+
say '1. Recommended Heroku Addons: Mailtrap, Rollbar, Cloudinary'
|
209
|
+
say ''
|
210
|
+
say '2. Setup Git Hooks to auto-check code and cleanup staled branches:'
|
211
|
+
say '$ `git config core.hooksPath bin/git-hooks`'
|
212
|
+
say ''
|
213
|
+
say '3. Please, set CODECOV_TOKEN, GITHUB_TOKEN and PRONTO_GITHUB_ACCESS_TOKEN'
|
214
|
+
say 'environment variables in CircleCI and your local env'
|
215
|
+
say ''
|
216
|
+
say ' For code coverage report aggregator, running code static analysis'
|
217
|
+
say 'and auto-update of the tools.'
|
218
|
+
say ''
|
219
|
+
say '**************************************************************************'
|
220
|
+
say '**************************************************************************'
|