-
Notifications
You must be signed in to change notification settings - Fork 3
/
template.rb
755 lines (589 loc) · 18.9 KB
/
template.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
BASE_URL = 'https://raw.githubusercontent.com/infinum/default_rails_template/master'.freeze
# Readme.md
README_MD = <<-HEREDOC.strip_heredoc
[![Build Status](https://docs.semaphoreci.com/essentials/status-badges/)](https://semaphoreci.com/infinum/APP)
![Health score](https://revisor.infinum.com/api/v1/badges/add-project-key?type=health_score)
![CVE count](https://revisor.infinum.com/api/v1/badges/add-project-key?type=cve_count)
# README
## [Technical Documentation](docs/README.md)
## Dependencies
### System
* Ruby (defined in .ruby-version file)
* Node.js (defined in [package.json](https://classic.yarnpkg.com/en/docs/package-json/#toc-engines))
* Yarn (defined in [package.json](https://classic.yarnpkg.com/en/docs/package-json/#toc-engines))
## Setup
Run:
```bash
./bin/setup
```
Run after each git pull:
```bash
./bin/update
```
## Test suite
Run:
```bash
bundle exec rspec
```
HEREDOC
create_file 'README.md', README_MD, force: true
# Technical documentation
[
'docs/README.md',
'docs/architecture.md',
'docs/development_workflow.md'
].each do |filename|
get("#{BASE_URL}/#{filename}", filename)
end
# Staging environment config
create_file 'config/environments/staging.rb', "require_relative 'production'"
DB_CONFIG = <<-HEREDOC.strip_heredoc
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
host: <%= Rails.application.secrets.fetch(:database_host) %>
port: <%= Rails.application.secrets.fetch(:database_port) %>
database: <%= Rails.application.secrets.fetch(:database_name) %>
username: <%= Rails.application.secrets.fetch(:database_username) %>
password: <%= Rails.application.secrets.fetch(:database_password) %>
development:
<<: *default
database: #{app_name}_development
test:
<<: *default
database: #{app_name}_test
staging:
<<: *default
production:
<<: *default
HEREDOC
create_file 'config/database.yml', DB_CONFIG, force: true
# bin scripts
BIN_SETUP = <<-HEREDOC.strip_heredoc
#!/usr/bin/env ruby
require 'pathname'
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
puts '== Installing dependencies =='
system 'gem install bundler --conservative'
system 'bundle check || bundle install'
# puts '== Installing JS dependencies =='
# system 'yarn install'
puts "== Installing overcommit =="
system 'overcommit --install'
puts '== Copy sample secrets =='
system 'cp config/application.example.yml config/application.yml'
puts '== Preparing database =='
system 'bin/rake db:setup'
puts '== Removing old logs and tempfiles =='
system 'rm -f log/*'
system 'rm -rf tmp/cache'
end
HEREDOC
create_file 'bin/setup', BIN_SETUP, force: true
BIN_UPDATE = <<-HEREDOC.strip_heredoc
#!/usr/bin/env ruby
require 'pathname'
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
puts '== Installing dependencies =='
system 'gem install bundler --conservative'
system 'bundle check || bundle install'
# puts '== Installing JS dependencies =='
# system 'yarn install'
puts '== Copy sample secrets =='
system 'cp config/application.example.yml config/application.yml'
puts '== Preparing database =='
system 'bin/rake db:migrate'
end
HEREDOC
create_file 'bin/update', BIN_UPDATE, force: true
BIN_PREPARE_CI = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== pull secrets ==========="
bundle exec secrets pull -e development -y
HEREDOC
create_file 'bin/prepare_ci', BIN_PREPARE_CI, force: true
chmod 'bin/prepare_ci', 0755, verbose: false
BIN_AUDIT = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== bundle audit ==========="
time bundle exec bundle-audit update --quiet
time bundle exec bundle-audit check
echo "=========== brakeman ==========="
time bundle exec brakeman -q --color
HEREDOC
create_file 'bin/audit', BIN_AUDIT, force: true
chmod 'bin/audit', 0755, verbose: false
BIN_LINT = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== zeitwerk check ==========="
time bundle exec rails zeitwerk:check
echo "=========== rubocop ==========="
time bundle exec rubocop --format simple --format github --color --parallel
HEREDOC
create_file 'bin/lint', BIN_LINT, force: true
chmod 'bin/lint', 0755, verbose: false
BIN_TEST = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== rails db:test:prepare ==========="
time RAILS_ENV=test bundle exec rails db:test:prepare
echo "=========== rspec ==========="
time bundle exec rspec --force-color
HEREDOC
create_file 'bin/test', BIN_TEST, force: true
chmod 'bin/test', 0755, verbose: false
# bundler config
BUNDLER_CI_BUILD_CONFIG = <<~HEREDOC.strip_heredoc
---
BUNDLE_DEPLOYMENT: "true"
BUNDLE_WITHOUT: "development deploy"
HEREDOC
create_file '.bundle/ci-build/config', BUNDLER_CI_BUILD_CONFIG, force: true
BUNDLER_CI_DEPLOY_CONFIG = <<~HEREDOC.strip_heredoc
---
BUNDLE_DEPLOYMENT: "true"
BUNDLE_WITHOUT: "development test ci"
# use line below when using dox
# BUNDLE_WITHOUT: "development"
HEREDOC
create_file '.bundle/ci-deploy/config', BUNDLER_CI_DEPLOY_CONFIG, force: true
# bugsnag
BUGSNAG_CONFIG = <<-HEREDOC.strip_heredoc
Bugsnag.configure do |config|
config.api_key = Rails.application.secrets.fetch(:bugsnag_api_key)
config.notify_release_stages = %w(production staging)
end
HEREDOC
create_file 'config/initializers/bugsnag.rb', BUGSNAG_CONFIG
# Remove gems we don't use.
%w(jbuilder tzinfo-data byebug web-console importmap-rails brakeman rubocop-rails-omakase turbo-rails stimulus-rails).each do |unwanted_gem|
gsub_file('Gemfile', /gem "#{unwanted_gem}".*\n/, '')
end
# Remove comments from the Gemfile
gsub_file('Gemfile', /^\s*#+.*\n/, '')
# Add gems
append_to_file 'Gemfile', after: /gem "rails".*\n/ do
<<-HEREDOC.strip_heredoc
gem 'bugsnag'
gem 'figaro'
gem 'pry-byebug'
gem 'pry-rails'
gem 'strong_migrations'
HEREDOC
end
append_to_file 'Gemfile', after: "group :development do\n" do
<<-HEREDOC
gem 'annotate'
gem 'better_errors'
gem 'binding_of_caller'
gem 'bullet'
gem 'overcommit', require: false
HEREDOC
end
# end
append_to_file 'Gemfile' do
<<-HEREDOC.strip_heredoc
group :test do
gem 'rspec-rails'
end
HEREDOC
end
append_to_file 'Gemfile' do
<<-HEREDOC.strip_heredoc
group :ci do
gem 'brakeman', require: false
gem 'bundler-audit', require: false
gem 'rubocop-infinum', require: false
end
HEREDOC
end
environment <<~HEREDOC, env: 'development'
config.action_mailer.delivery_method = :letter_opener
config.after_initialize do
Bullet.enable = true
Bullet.rails_logger = true
Bullet.add_footer = true
end
HEREDOC
# Suppress Puma SignalException
append_to_file 'config/puma.rb', after: /pidfile ENV.*\n/ do
<<~RUBY
# Suppress SignalException when SIGTERM is received
#
raise_exception_on_sigterm false
RUBY
end
# Stop crawlers
append_to_file 'public/robots.txt' do
<<-HEREDOC.strip_heredoc
# no bot may crawl
User-agent: *
Disallow: /
HEREDOC
end
# Secrets
SECRETS_YML_FILE = <<-HEREDOC.strip_heredoc
default: &default
secret_key_base: <%= Figaro.env.secret_key_base! %>
database_name: <%= Figaro.env.database_name! %>
database_username: <%= Figaro.env.database_username! %>
database_password: <%= Figaro.env.database_password! %>
database_host: <%= Figaro.env.database_host! %>
database_port: <%= Figaro.env.database_port! %>
bugsnag_api_key: <%= Figaro.env.bugsnag_api_key! %>
redis_url: <%= Figaro.env.redis_url! %>
development:
<<: *default
test:
<<: *default
staging:
<<: *default
production:
<<: *default
HEREDOC
create_file 'config/secrets.yml', SECRETS_YML_FILE, force: true
FIGARO_FILE = <<-HEREDOC.strip_heredoc
database_host: localhost
database_username: postgres
database_password: ''
database_name: ''
database_port: '5432'
bugsnag_api_key: ''
redis_url: 'redis://localhost:6379'
development:
secret_key_base: #{SecureRandom.hex(64)}
test:
secret_key_base: #{SecureRandom.hex(64)}
HEREDOC
create_file 'config/application.example.yml', FIGARO_FILE
# Rubocop
get("#{BASE_URL}/.rubocop.yml", '.rubocop.yml')
# Overcommit
OVERCOMMIT_YML_FILE = <<-HEREDOC.strip_heredoc
gemfile: Gemfile
CommitMsg:
HardTabs:
enabled: true
PreCommit:
BundleAudit:
enabled: true
flags: ['--update']
on_warn: fail
command: ['bundle', 'exec', 'bundle-audit']
BundleCheck:
enabled: true
RuboCop:
enabled: true
on_warn: fail
command: ['bundle', 'exec', 'rubocop']
RailsSchemaUpToDate:
enabled: true
TrailingWhitespace:
enabled: true
exclude:
- '**/db/structure.sql'
HardTabs:
enabled: true
PrePush:
Brakeman:
enabled: true
command: ['bundle', 'exec', 'brakeman']
ZeitwerkCheck:
enabled: true
description: 'Checks project structure for Zeitwerk compatibility'
command: ['bundle', 'exec', 'rails zeitwerk:check']
HEREDOC
create_file '.overcommit.yml', OVERCOMMIT_YML_FILE
# .gitignore
GITIGNORED_FILES = <<-HEREDOC.strip_heredoc
.sass-cache
powder
public/system
dump.rdb
logfile
.DS_Store
config/application.yml
HEREDOC
append_file '.gitignore', GITIGNORED_FILES
# remove bundler ci config folders from gitignore
append_to_file '.gitignore', "/*\n!/.bundle/ci-build\n!/.bundle/ci-deploy", after: '/.bundle'
# .github/PULL_REQUEST_TEMPLATE.md
PULL_REQUEST_TEMPLATE_FILE = <<-HEREDOC.strip_heredoc
Task: [#__TASK_NUMBER__](__ADD_URL_TO_PRODUCTIVE_TASK__)
#### Aim
#### Solution
HEREDOC
create_file '.github/PULL_REQUEST_TEMPLATE.md', PULL_REQUEST_TEMPLATE_FILE
# .github/CODEOWNERS
CODEOWNERS_FILE = <<-HEREDOC.strip_heredoc
# For more info about the file read https://help.github.com/en/articles/about-code-owners
# Set default PR reviewers. For example:
# * @github_username1 @github_username2
HEREDOC
create_file '.github/CODEOWNERS', CODEOWNERS_FILE
# .github/dependabot.yml
DEPENDABOT_FILE = <<-HEREDOC.strip_heredoc
version: 2
updates:
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 2
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 2
HEREDOC
create_file '.github/dependabot.yml', DEPENDABOT_FILE
# .git-hooks/pre_push/zeitwerk_check.rb
ZEITWERK_CHECK_FILE = <<-HEREDOC.strip_heredoc
# frozen_string_literal: true
module Overcommit
module Hook
module PrePush
class ZeitwerkCheck < Base
def run
result = execute(command)
return :pass if result.success?
extract_messages result.stderr.split("\\n"),
/^expected file (?<file>[[:alnum:]].*\.rb)/
end
end
end
end
end
HEREDOC
create_file '.git-hooks/pre_push/zeitwerk_check.rb', ZEITWERK_CHECK_FILE
# Ignore rubocop warnings in db/seeds.rb
SEEDS_DISABLE_IGNORE = <<-HEREDOC.strip_heredoc
# rubocop:disable Layout/LineLength
HEREDOC
SEEDS_ENABLE_IGNORE = <<-HEREDOC.strip_heredoc
# rubocop:enable Layout/LineLength
HEREDOC
prepend_file 'db/seeds.rb', SEEDS_DISABLE_IGNORE
append_file 'db/seeds.rb', SEEDS_ENABLE_IGNORE
## Ask about default PR reviewers
default_reviewers = ask('Who are default pull request reviewers (defined in .github/CODEOWNERS)? E.g.: @github_username1 @github_username2. Default reviewers:', :green)
append_to_file '.github/CODEOWNERS' do
<<~HEREDOC
* #{default_reviewers}
HEREDOC
end
get("#{BASE_URL}/build.yml", '.github/workflows/build.yml')
get("#{BASE_URL}/delete-cache.yml", '.github/workflows/delete-cache.yml')
## Docker
if no?('Will this application use Docker? [Yes]', :green)
# Mina
get("#{BASE_URL}/mina_deploy.rb", 'config/deploy.rb')
append_to_file 'Gemfile' do
<<~HEREDOC.strip_heredoc
group :deploy do
gem 'mina-infinum', require: false
end
HEREDOC
end
BIN_DEPLOY = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== setting env variables ==========="
environment=$1
echo "=========== mina deploy =============="
time bundle exec mina $environment ssh_keyscan_domain
time bundle exec mina $environment setup
time bundle exec mina $environment deploy
HEREDOC
create_file 'bin/deploy', BIN_DEPLOY, force: true
chmod 'bin/deploy', 0755, verbose: false
BIN_PUBLISH_DOCS = <<~HEREDOC.strip_heredoc
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
echo "=========== setting env variables ==========="
environment=$1
echo "=========== rails db:test:prepare ==========="
time bundle exec rails db:test:prepare
echo "=========== mina dox publish ==========="
time bundle exec mina "$environment" ssh_keyscan_domain
time bundle exec mina "$environment" dox:publish
HEREDOC
create_file 'bin/publish_docs', BIN_PUBLISH_DOCS, force: true
chmod 'bin/publish_docs', 0755, verbose: false
get("#{BASE_URL}/deploy-staging.yml", '.github/workflows/deploy-staging.yml')
get("#{BASE_URL}/deploy-production.yml", '.github/workflows/deploy-production.yml')
## Users allowed to manually trigger deploys
staging_deployers = ask('Who can manually trigger a deploy to staging? (Example: @username1 @username2)', :green)
gsub_file('.github/workflows/deploy-staging.yml', 'DEPLOY USERS GO HERE', staging_deployers)
production_deployers = ask('Who can manually trigger a deploy to production? (Example: @username1 @username2)', :green)
gsub_file('.github/workflows/deploy-production.yml', 'DEPLOY USERS GO HERE', production_deployers)
else
# remove push trigger for build workflow, the build-image workflow will be used instead
gsub_file '.github/workflows/build.yml', /\n\s*push:\n.*$/, ''
get "#{BASE_URL}/docker/build-image.yml", '.github/workflows/build-image.yml'
get "#{BASE_URL}/docker/extract_params", 'bin/extract_params'
chmod 'bin/extract_params', 0755, verbose: false
get "#{BASE_URL}/docker/connect_to_container", 'bin/connect_to_container'
chmod 'bin/connect_to_container', 0755, verbose: false
inside '.docker' do
get "#{BASE_URL}/docker/.docker/Aptfile", 'Aptfile'
run 'touch .psqlrc'
end
get "#{BASE_URL}/docker/.dockerignore", '.dockerignore'
get "#{BASE_URL}/docker/docker-compose.yml", 'docker-compose.yml'
require 'bundler'
gsub_file 'docker-compose.yml', 'placeholder-app', app_name
gsub_file 'docker-compose.yml', 'RUBY_VERSION: 3.1.1', "RUBY_VERSION: #{RUBY_VERSION}"
gsub_file 'docker-compose.yml', 'BUNDLER_VERSION: 2.3.7', "BUNDLER_VERSION: #{Bundler::VERSION}"
if yes?('Will this application need Node runtime? [No]', :green)
get "#{BASE_URL}/docker/Dockerfile.with_node", 'Dockerfile'
node_version = `node -v`.chomp.sub('v', '')
node_major = node_version.scan(/^[[:digit:]]+/).first
append_to_file 'docker-compose.yml', <<-HEREDOC.chomp, after: /BUNDLER_VERSION: .*$/
\n NODE_MAJOR: #{node_major}
NODE_VERSION: #{node_version}
HEREDOC
else
get "#{BASE_URL}/docker/Dockerfile", 'Dockerfile'
end
end
## Frontend
uses_frontend = yes?('Will this application have a frontend? [No]', :green)
if uses_frontend
append_to_file 'Gemfile', after: "gem 'pry-rails'\n" do
<<~HEREDOC
gem 'slim'
gem 'jsbundling-rails'
gem 'cssbundling-rails'
gem 'view_component'
gem 'stimulus-rails'
gem 'turbo-rails'
HEREDOC
end
append_to_file 'Gemfile', after: " gem 'rubocop-infinum', require: false\n" do
" gem 'slim_lint', require: false\n"
end
get("#{BASE_URL}/.slim-lint.yml", '.slim-lint.yml')
node_version = `node -v`.chomp.sub('v', '')
create_file '.node-version', node_version
PACKAGE_JSON_FILE = <<~HEREDOC
{
"name": "#{app_name}",
"private": true,
"version": "0.1.0",
"scripts": {
"lint-css": "stylelint",
"lint-js": "eslint"
},
"stylelint": {
"extends": "@infinumrails/stylelint-config-scss"
},
"eslintConfig": {
"extends": "@infinumrails/eslint-config-js"
},
"engines": {
"node": "#{node_version}"
}
}
HEREDOC
create_file 'package.json', PACKAGE_JSON_FILE
append_to_file '.overcommit.yml', after: "command: ['bundle', 'exec', 'rubocop']\n" do
<<-HEREDOC
SlimLint:
enabled: true
on_warn: fail
command: ['bundle', 'exec', 'slim-lint']
EsLint:
enabled: true
on_warn: fail
required_executable: 'yarn'
command: ['yarn', 'lint-js']
Stylelint:
enabled: true
on_warn: fail
required_executable: 'node_modules/.bin/stylelint'
command: ['node_modules/.bin/stylelint']
HEREDOC
end
append_to_file '.gitignore' do
<<~HEREDOC
node_modules
HEREDOC
end
STYLELINTIGNORE_FILE = <<~HEREDOC
*.*
!app/assets/**/*.css
!app/assets/**/*.scss
HEREDOC
create_file '.stylelintignore', STYLELINTIGNORE_FILE
append_to_file 'bin/lint' do
<<~HEREDOC
echo "=========== slim lint ==========="
time bundle exec slim-lint app/views
echo "=========== JS lint ==========="
time yarn lint-js app
echo "=========== CSS lint ==========="
time yarn lint-css --allow-empty-input app
HEREDOC
end
run 'yarn add --dev @infinumrails/eslint-config-js @infinumrails/stylelint-config-scss eslint postcss stylelint'
gsub_file('.github/workflows/build.yml', /^.*use_node: false.*\n/, '')
end
# Finish
# enable Rails.application.secrets
application <<~HEREDOC
def secrets
config_for(:secrets)
end
HEREDOC
## Bundle install
run 'bundle install'
## Add ruby to PLATFORMS to enable bundle install on CI
run 'bundle lock --add-platform ruby'
## Needed by the rails_command that follow
run 'cp config/application.example.yml config/application.yml'
## Initialize rspec
rails_command 'generate rspec:install'
run 'bundle binstubs rspec-core'
## add annotate task file and ignore its rubocop violations
rails_command 'generate annotate:install'
ANNOTATE_TASK_FILE = 'lib/tasks/auto_annotate_models.rake'
prepend_file ANNOTATE_TASK_FILE, "# frozen_string_literal: true\n\n"
append_to_file ANNOTATE_TASK_FILE, after: "its thing in production.\n" do
"# rubocop:disable Metrics/BlockLength, Rails/RakeEnvironment\n"
end
append_file ANNOTATE_TASK_FILE,
"# rubocop:enable Metrics/BlockLength, Rails/RakeEnvironment\n"
## add strong migrations config
rails_command 'generate strong_migrations:install'
## Overcommit install and sign
run 'overcommit --install'
run 'overcommit --sign'
run 'overcommit --sign pre-push'
# Install frontend gems
if uses_frontend
rails_command 'javascript:install:esbuild'
rails_command 'css:install:tailwind'
rails_command 'turbo:install'
rails_command 'stimulus:install'
end
# Fix default rubocop errors
run 'bundle exec rubocop -A'