-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.rb
127 lines (97 loc) · 3.44 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
def commit(message)
git add: "."
git commit: "-m '#{message}'"
end
def copy_file(file_name, directory = ".")
inside(directory) do
puts "CURRENT PATH: #{File.dirname(__FILE__)}"
file_path = File.expand_path("files/#{file_name}", File.dirname(__FILE__))
run "cp #{file_path} ."
end
end
def remove_file(file_name)
run "rm #{file_name}"
end
git :init
commit "Create Rails app"
copy_file "../files/README.md"
run %(sed -i '' "s/\\[APP NAME\\]/#{app_path.titleize}/" README.md)
commit "Use markdown readme"
run "sed -i '' '/^.*#/ d' Gemfile"
commit "Remove Gemfile comments"
run "sed -i '' '/tzinfo-data/ d' Gemfile"
commit "Remove unused gems"
gem "rack-cors"
gem "jsonapi-resources"
gem "bcrypt"
gem "doorkeeper"
commit "Add gems for all environments"
gem_group :development do
gem "bullet"
gem "dotenv-rails"
end
gem_group :development, :test do
gem "rspec-rails"
gem "coderay"
gem "standard"
end
commit "Add development gems"
gem_group :test do
gem "factory_bot_rails"
gem "rspec_junit_formatter"
end
commit "Add test gems"
gem_group :production do
gem "rack-attack"
end
commit "Add production gems"
run "bundle install"
commit "Bundle gems"
# https://github.com/doorkeeper-gem/doorkeeper/issues/1577
copy_file "../files/config/initializers/doorkeeper.rb", "config/initializers"
run "rails generate doorkeeper:install -f"
run "rails generate doorkeeper:migration"
# TODO: match variable number of spaces
run "sed -i '' 's/t.references :application, null: false/t.references :application/' db/migrate/*_create_doorkeeper_tables.rb"
copy_file "../files/config/initializers/doorkeeper.rb", "config/initializers"
copy_file "../files/config/locales/doorkeeper.en.yml", "config/locales"
copy_file "../files/spec/factories/access_token.rb", "spec/factories"
commit "Configure doorkeeper"
run "bundle binstubs bundler --force"
run "bundle binstubs rspec-core"
run "rails generate rspec:install"
commit "Set up RSpec"
run "rails generate model user email:string:uniq password_digest:string"
copy_file "../files/db/seeds.rb", "db"
copy_file "../files/app/models/user.rb", "app/models"
copy_file "../files/spec/factories/user.rb", "spec/factories"
remove_file "spec/models/user_spec.rb"
commit "Add user model"
copy_file "../files/app/controllers/application_controller.rb", "app/controllers"
copy_file "../files/app/resources/application_resource.rb", "app/resources"
commit "Expose Doorkeeper user to JR"
copy_file "../files/app/controllers/users_controller.rb", "app/controllers"
copy_file "../files/app/resources/user_resource.rb", "app/resources"
copy_file "../files/config/routes.rb", "config"
copy_file "../files/spec/requests/register_spec.rb", "spec/requests"
commit "Expose user create endpoint"
copy_file "../files/spec/rails_helper.rb", "spec"
copy_file "../files/spec/support/with_a_logged_in_user.rb", "spec/support"
commit "Add shared context for setting up a logged in user"
copy_file "../files/config/initializers/cors.rb", "config/initializers"
commit "Configure CORS"
copy_file "../files/bin/sample-data", "bin"
commit "Add sample data script"
copy_file "../files/.circleci/config.yml", ".circleci"
commit "Configure CircleCI"
run "rails db:create"
run "rails db:migrate"
run "rails db:seed"
commit "Set up database"
copy_file "../files/.irbrc", ".irbrc"
commit "Disable console autocomplete"
run "bundle exec standardrb --fix"
commit "Format to Standard"
# TODO: clean up gem file
# TODO: Ruby version in gemfile?
# TODO: better error output