-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrysler.rb
108 lines (84 loc) · 2.69 KB
/
chrysler.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
#!/usr/bin/env ruby
# rails-app-template.rb
# Usage: rails new app-name --database=postgresql -m https://raw.githubusercontent.com/seanrankin/chrysler/master/chrysler.rb
# Get the path of the application template
path = File.expand_path File.dirname(__FILE__)
remotePath = "https://raw.githubusercontent.com/seanrankin/chrysler/master"
publish = yes? "Do you want to deploy to Heroku?"
if publish
appname = ask("What do you want to name this app?")
end
root_controller = yes? "Should we create a default controller?"
if root_controller
root_controller_name = ask("What is the root controllers name?").underscore
end
haml = yes? "Do you want to use HAML for templating?"
if haml
gem "haml"
gem "haml-rails"
end
# Add commonly used gems
# gem('compass-rails', group: :assets)
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
gem "jquery-datatables-rails"
gem_group :production, :staging do
gem "rails_12factor"
end
gem_group :development do
gem "quiet_assets" # removes asset pipline messages in development making the log easier to read
end
# Get rid of sqlite
gsub_file "Gemfile", /^gem\s+["']sqlite3["'].*$/,''
# Set ruby version for Heroku
# insert_into_file 'Gemfile', "\nruby '2.0.0'", after: "source 'https://rubygems.org'\n"
# Bundle!
run "bundle install"
# Just in case, drop before creating the DB
rake("db:drop")
rake("db:create")
# Add default controller
if root_controller
generate :controller, "#{root_controller_name} index"
route "root to: '#{root_controller_name}\#index'"
end
# Install Bootstrap 3 with Less
run "rails generate bootstrap:install less"
run "rails g bootstrap:layout application -f"
# Install DataTables
run "rails generate jquery:datatables:install bootstrap3"
# Generate some test scaffolding
# generate(:scaffold, "User name:string")
rake("db:migrate")
rake("db:seed")
# run "rails g bootstrap:themed Users -f"
# Utility files
run "touch .env"
run "touch Procfile"
run "touch Guardfile"
# Create a default script file
run "curl -o app/assets/javascripts/scripts.coffee #{remotePath}/scripts.coffee"
# run "curl -o app/views/layouts/application.html.erb #{remotePath}/application.html.erb"
if haml
run "rails generate haml:application_layout convert"
remove_file "app/views/layouts/application.html.erb"
end
# Add git
git :init
# Hide secret data from git
append_file ".gitignore", "config/database.yml"
append_file ".gitignore", ".env"
# Run initial commit
git add: ".", commit: "'-m initial commit'"
# Create and push to heroku
if publish
run "heroku create #{appname}"
run "git push heroku master"
run "heroku run rake db:migrate"
run "heroku run rake db:seed"
run "heroku open --app #{appname}"
end
# Open project in Atom
run "atom ."
run "rails s"