-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.rb
102 lines (87 loc) · 2.22 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
# frozen_string_literal: true
BASE_PATH = __dir__
# methods definitions
def actives_support_rspec
gsub_file('rails_helper.rb',
"# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }",
"Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }")
end
def add_factory_bot_include_configuration
gsub_file('rails_helper.rb',
'RSpec.configure do |config|',
"RSpec.configure do |config|\n config.include FactoryBot::Syntax::Methods")
end
def add_web_drivers
gsub_file('rails_helper.rb',
'begin',
"require 'webdrivers'\nbegin")
end
def add_capybara_support
path = "#{BASE_PATH}/src/capybara.rb"
run 'mkdir support'
run "cp #{path} support/capybara.rb"
end
def add_rubocop
path = "#{BASE_PATH}/src/.rubocop.yml"
run "cp #{path} .rubocop.yml"
end
def initials_commit
git :init
git add: '.'
git commit: "-a -m 'Initial commit'"
end
def upgrade_yarn
run 'yarn upgrade'
end
def install_vue
run 'bundle exec rails webpacker:install:vue'
end
def add_bootstrap
run 'yarn add bootstrap jquery popper.js'
end
def add_application_scss
file = File.open('application.scss', 'w')
file.puts "@import '~bootstrap/scss/bootstrap';"
end
def add_bootstrap_importer
gsub_file('application.js',
'// const imagePath = (name) => images(name, true)',
"// const imagePath = (name) => images(name, true)\nimport 'bootstrap'\nimport './src/application.scss'")
end
def fix_rubocop
run 'rubocop -a'
end
# main program
gem 'pry-rails'
gem_group :development, :test do
gem 'rspec-rails'
gem 'factory_bot_rails'
gem 'capybara'
gem 'webdrivers'
end
gem_group :developement do
gem 'rubocop', require: false
gem 'rubocop-performance', require: false
gem 'rubocop-rspec', require: false
end
after_bundle do
run 'spring stop'
generate 'rspec:install'
inside('spec') do
actives_support_rspec
add_web_drivers
add_capybara_support
add_factory_bot_include_configuration
end
add_rubocop
upgrade_yarn
install_vue
add_bootstrap
inside('app/javascript/packs/src') do
add_application_scss
end
inside('app/javascript/packs/') do
add_bootstrap_importer
end
fix_rubocop
end