tol 0.0.6 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/tol/cli.rb +27 -5
- data/lib/tol/codecheck.rb +8 -8
- data/lib/tol/config.rb +34 -0
- data/lib/tol/database.rb +10 -8
- data/lib/tol/heroku.rb +56 -0
- data/lib/tol/newapp.rb +378 -0
- data/lib/tol/version.rb +1 -1
- data/tol.gemspec +1 -0
- metadata +29 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ab6e6a19ac970ed9d4bc706e4b8438d6730f0a8c
|
4
|
+
data.tar.gz: 2457cfa0d43abedcbce76b1e3de68c5d157d4597
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6ce0d708e2a1b3ef00306aef74ae8158c65b112213617f8d69e970aa4a58a0b41a485a207e616cb752dad29ef2036bb4d680457d2a52f89a58267fe580efa29
|
7
|
+
data.tar.gz: 9533bfb7334f3a2b27431802c19aa0b9347ae52607fcdebd96ea9e03a9e35cfcd82390574b9d92fcc21b9efacbfac24a438998b8cb89e5935659254625b2db05
|
data/lib/tol/cli.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'tol/database'
|
2
2
|
require 'tol/codecheck'
|
3
|
+
require 'tol/newapp'
|
4
|
+
require 'tol/heroku'
|
3
5
|
|
4
6
|
module Tol
|
5
7
|
class CLI
|
@@ -14,6 +16,14 @@ class CLI
|
|
14
16
|
Tol::Database.new.run
|
15
17
|
when "codecheck"
|
16
18
|
Tol::Codecheck.new.run
|
19
|
+
when "newapp:aws"
|
20
|
+
Tol::Newapp.new.awsbuckets
|
21
|
+
when "newapp:heroku"
|
22
|
+
Tol::Newapp.new.heroku
|
23
|
+
when "newapp:www"
|
24
|
+
Tol::Newapp.new.www_redirect
|
25
|
+
when "heroku:deploy"
|
26
|
+
Tol::Heroku.new.deploy
|
17
27
|
else
|
18
28
|
help
|
19
29
|
end
|
@@ -21,24 +31,36 @@ class CLI
|
|
21
31
|
end
|
22
32
|
|
23
33
|
def help
|
24
|
-
puts " #{"Take Off Labs".foreground(:green).underline} :: " +
|
25
|
-
"#{"A collection of useful tools for Rails development".underline}\n\n"
|
34
|
+
puts " #{Rainbow("Take Off Labs").foreground(:green).underline} :: " +
|
35
|
+
"#{Rainbow("A collection of useful tools for Rails development").underline}\n\n"
|
26
36
|
|
27
37
|
database_help
|
28
38
|
codecheck_help
|
39
|
+
newapp_help
|
40
|
+
heroku_help
|
29
41
|
help_help
|
30
42
|
end
|
31
43
|
|
32
44
|
def database_help
|
33
|
-
puts " #{"tol db".foreground(:red)}
|
45
|
+
puts " #{Rainbow("tol db").foreground(:red)} \# Copies the latest version of the database from Heroku to the local development system."
|
34
46
|
end
|
35
47
|
|
36
48
|
def codecheck_help
|
37
|
-
puts " #{"tol codecheck".foreground(:red)}
|
49
|
+
puts " #{Rainbow("tol codecheck").foreground(:red)} \# Checks the code for left over binding.pry or console.log."
|
50
|
+
end
|
51
|
+
|
52
|
+
def newapp_help
|
53
|
+
puts " #{Rainbow("tol newapp:aws").foreground(:red)} \# Set up Amazon Web Services S3 Buckets + (Carrierwave & Asset Sync)."
|
54
|
+
puts " #{Rainbow("tol newapp:heroku").foreground(:red)} \# Set up Heroku."
|
55
|
+
puts " #{Rainbow("tol newapp:www").foreground(:red)} \# Set up a middleware that redirects non-www to www."
|
56
|
+
end
|
57
|
+
|
58
|
+
def heroku_help
|
59
|
+
puts " #{Rainbow("tol heroku:deploy").foreground(:red)} \# Deploy the app to Heroku."
|
38
60
|
end
|
39
61
|
|
40
62
|
def help_help
|
41
|
-
puts " #{"tol help".foreground(:red)}
|
63
|
+
puts " #{Rainbow("tol help").foreground(:red)} \# Displays this help message."
|
42
64
|
end
|
43
65
|
end
|
44
66
|
end
|
data/lib/tol/codecheck.rb
CHANGED
@@ -17,30 +17,30 @@ class Codecheck
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def check_for_binding_pry
|
20
|
-
puts "Checking for binding.pry".foreground(:yellow)
|
20
|
+
puts Rainbow("Checking for binding.pry").foreground(:yellow)
|
21
21
|
result = `find . -name "*.rb" -exec grep -H "binding.pry" {} \\\;`
|
22
22
|
if result.length > 0
|
23
|
-
puts "The following binding.pry's have been found".foreground(:red)
|
23
|
+
puts Rainbow("The following binding.pry's have been found").foreground(:red)
|
24
24
|
result.split("\n").each do |res|
|
25
25
|
puts res[0..self.terminal_columns - 2]
|
26
26
|
end
|
27
|
-
puts "Please fix".foreground(:red)
|
27
|
+
puts Rainbow("Please fix").foreground(:red)
|
28
28
|
else
|
29
|
-
puts "No binding.pry's found".foreground(:green)
|
29
|
+
puts Rainbow("No binding.pry's found").foreground(:green)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
def check_for_console_log
|
34
|
-
puts "Checking for console.log".foreground(:yellow)
|
34
|
+
puts Rainbow("Checking for console.log").foreground(:yellow)
|
35
35
|
result = `find . -name "*.js*" -exec grep -H "console.log" {} \\\;`
|
36
36
|
if result.length > 0
|
37
|
-
puts "The following console.log's have been found".foreground(:red)
|
37
|
+
puts Rainbow("The following console.log's have been found").foreground(:red)
|
38
38
|
result.split("\n").each do |res|
|
39
39
|
puts res[0..self.terminal_columns - 2]
|
40
40
|
end
|
41
|
-
puts "Please fix!".foreground(:red)
|
41
|
+
puts Rainbow("Please fix!").foreground(:red)
|
42
42
|
else
|
43
|
-
puts "No console.log's found".foreground(:green)
|
43
|
+
puts Rainbow("No console.log's found").foreground(:green)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/tol/config.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Tol
|
2
|
+
class Config
|
3
|
+
require 'rainbow'
|
4
|
+
require 'highline/import'
|
5
|
+
|
6
|
+
require 'yaml'
|
7
|
+
require 'etc'
|
8
|
+
|
9
|
+
def self.read_config
|
10
|
+
keys = ["collaborators", "awskey", "awssecret"]
|
11
|
+
config = {}
|
12
|
+
|
13
|
+
begin
|
14
|
+
global = YAML::load(IO.read("/Users/#{Etc.getlogin}/tol.yml"))
|
15
|
+
config.merge!(global)
|
16
|
+
rescue
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
local = YAML::load(IO.read("tol.yml"))
|
21
|
+
config.merge!(local)
|
22
|
+
rescue
|
23
|
+
end
|
24
|
+
|
25
|
+
return config
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.get_option(key)
|
29
|
+
config = self.read_config
|
30
|
+
return config[key]
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
data/lib/tol/database.rb
CHANGED
@@ -12,11 +12,13 @@ class Database
|
|
12
12
|
apps = Tol::Heroku.new.list_of_applications
|
13
13
|
|
14
14
|
if apps.length == 0
|
15
|
-
puts "No Heroku apps found".foreground(:red)
|
15
|
+
puts Rainbow("No Heroku apps found").foreground(:red)
|
16
|
+
puts "Add your remotes to .git/config"
|
17
|
+
# TODO: Automatically add remotes
|
16
18
|
elsif apps.length == 1
|
17
19
|
download(apps[0])
|
18
20
|
else
|
19
|
-
puts "Multiple Heroku apps found".foreground(:green)
|
21
|
+
puts Rainbow("Multiple Heroku apps found").foreground(:green)
|
20
22
|
|
21
23
|
choose do |menu|
|
22
24
|
menu.prompt = "Which database should I download?"
|
@@ -32,13 +34,13 @@ class Database
|
|
32
34
|
end
|
33
35
|
|
34
36
|
def download(heroku_app)
|
35
|
-
puts "Downloading database for #{heroku_app.underline}".foreground(:green)
|
37
|
+
puts Rainbow("Downloading database for #{heroku_app.underline}").foreground(:green)
|
36
38
|
|
37
|
-
puts "Step 1. Detecting local database settings.".foreground(:yellow)
|
39
|
+
puts Rainbow("Step 1. Detecting local database settings.").foreground(:yellow)
|
38
40
|
@settings = Tol::RailsApp.new.database_settings["development"]
|
39
41
|
|
40
42
|
choose do |menu|
|
41
|
-
puts "Step 2. Which version of the database should I download?".foreground(:green)
|
43
|
+
puts Rainbow("Step 2. Which version of the database should I download?").foreground(:green)
|
42
44
|
|
43
45
|
menu.prompt = "Please pick up database version?"
|
44
46
|
|
@@ -49,7 +51,7 @@ class Database
|
|
49
51
|
end
|
50
52
|
|
51
53
|
menu.choice "Most Recent Snapshot (Fast)" do
|
52
|
-
puts "... Downloading. Please wait.".foreground(:yellow)
|
54
|
+
puts Rainbow("... Downloading. Please wait.").foreground(:yellow)
|
53
55
|
url = ""
|
54
56
|
Bundler.with_clean_env do
|
55
57
|
url = `heroku pgbackups:url --app #{heroku_app}`
|
@@ -58,13 +60,13 @@ class Database
|
|
58
60
|
end
|
59
61
|
|
60
62
|
menu.choice "New Snapshot (Slowest)" do
|
61
|
-
puts "... Capturing database on Heroku. Please wait".foreground(:yellow)
|
63
|
+
puts Rainbow("... Capturing database on Heroku. Please wait").foreground(:yellow)
|
62
64
|
db = ""
|
63
65
|
Bundler.with_clean_env do
|
64
66
|
db = `heroku pgbackups:capture --app #{heroku_app} --expire`
|
65
67
|
end
|
66
68
|
|
67
|
-
puts "... Downloading. Please wait.".foreground(:yellow)
|
69
|
+
puts Rainbow("... Downloading. Please wait.").foreground(:yellow)
|
68
70
|
url = ""
|
69
71
|
Bundler.with_clean_env do
|
70
72
|
url = `heroku pgbackups:url --app #{heroku_app}`
|
data/lib/tol/heroku.rb
CHANGED
@@ -1,10 +1,66 @@
|
|
1
|
+
require 'tol/config'
|
2
|
+
require 'bundler'
|
3
|
+
|
1
4
|
module Tol
|
2
5
|
class Heroku
|
6
|
+
require 'rainbow'
|
7
|
+
require 'highline/import'
|
8
|
+
|
3
9
|
def list_of_applications
|
4
10
|
git_config = File.read(".git/config")
|
5
11
|
git_config.scan(/heroku\..*:(.*)\.git/i).map do |result|
|
6
12
|
result[0]
|
7
13
|
end
|
8
14
|
end
|
15
|
+
|
16
|
+
def deploy
|
17
|
+
puts Rainbow("Deploying to Heroku").foreground(:green)
|
18
|
+
|
19
|
+
puts "Identifying git branch"
|
20
|
+
branch = `git rev-parse --abbrev-ref HEAD`.gsub("\n", "")
|
21
|
+
|
22
|
+
puts "Identified local branch #{Rainbow(branch).foreground(:green)}. Please confirm."
|
23
|
+
choose do |menu|
|
24
|
+
menu.prompt = "Continue?"
|
25
|
+
|
26
|
+
menu.choice "Yes" do
|
27
|
+
end
|
28
|
+
|
29
|
+
menu.choice "No" do
|
30
|
+
return
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "Identifying Heroku application"
|
35
|
+
apps = list_of_applications
|
36
|
+
if apps.length == 0
|
37
|
+
puts Rainbow("No Heroku apps found").foreground(:red)
|
38
|
+
puts "Add your remotes to .git/config"
|
39
|
+
# TODO: Automatically add remotes
|
40
|
+
elsif apps.length == 1
|
41
|
+
deploy_to(apps[0], branch)
|
42
|
+
else
|
43
|
+
puts Rainbow("Multiple Heroku apps found").foreground(:green)
|
44
|
+
|
45
|
+
choose do |menu|
|
46
|
+
menu.prompt = "Where to deploy?"
|
47
|
+
apps.each do |app|
|
48
|
+
menu.choice app do
|
49
|
+
deploy_to(app, branch)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
menu.choice "None"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def deploy_to(remote, branch)
|
59
|
+
Bundler.with_clean_env do
|
60
|
+
system("git push -f #{remote} #{branch}:master")
|
61
|
+
system("heroku run rake db:migrate --remote #{remote}")
|
62
|
+
system("heroku restart --remote #{remote}")
|
63
|
+
end
|
64
|
+
end
|
9
65
|
end
|
10
66
|
end
|
data/lib/tol/newapp.rb
ADDED
@@ -0,0 +1,378 @@
|
|
1
|
+
require 'tol/config'
|
2
|
+
|
3
|
+
module Tol
|
4
|
+
class Newapp
|
5
|
+
require 'rainbow'
|
6
|
+
require 'highline/import'
|
7
|
+
require 'aws-sdk'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
# TODO: Create real config file.
|
11
|
+
# TODO: Save remotes in config file. Create command to add them to .git/config
|
12
|
+
|
13
|
+
# Setup the buckets
|
14
|
+
def awsbuckets
|
15
|
+
puts Rainbow("Step 1. Creating AWS buckets").foreground(:green)
|
16
|
+
|
17
|
+
puts "Please enter the name of the application:"
|
18
|
+
name = STDIN.gets.gsub("\n", "")
|
19
|
+
|
20
|
+
region = ""
|
21
|
+
choose do |menu|
|
22
|
+
menu.prompt = "Which region?"
|
23
|
+
menu.choice "US Standard" do region = "us-east-1" end
|
24
|
+
menu.choice "US West (Oregon)" do region = "us-west-2" end
|
25
|
+
menu.choice "US West (N. California)" do region = "us-west-1" end
|
26
|
+
menu.choice "EU (Ireland)" do region = "eu-west-1" end
|
27
|
+
menu.choice "Asia (Singapore)" do region = "ap-southeast-1" end
|
28
|
+
menu.choice "Asia (Sydney)" do region = "ap-southeast-2" end
|
29
|
+
menu.choice "Asia (Tokyo)" do region = "ap-northeast-1" end
|
30
|
+
menu.choice "S. America (Sao Paolo)" do region = "sa-east-1" end
|
31
|
+
end
|
32
|
+
|
33
|
+
AWS.config(
|
34
|
+
access_key_id: Tol::Config.get_option("awskey"),
|
35
|
+
secret_access_key: Tol::Config.get_option("awssecret"),
|
36
|
+
region: region
|
37
|
+
)
|
38
|
+
|
39
|
+
["assets", "production", "development", "staging"].each do |suffix|
|
40
|
+
create_bucket("#{name}-#{suffix}")
|
41
|
+
end
|
42
|
+
|
43
|
+
puts Rainbow("Step 2. Carrierwave").foreground(:green)
|
44
|
+
|
45
|
+
choose do |menu|
|
46
|
+
menu.prompt = "Using carrierwave?"
|
47
|
+
menu.choice "Yes" do
|
48
|
+
create_carrierwave_config(name, region)
|
49
|
+
|
50
|
+
# TODO: Add gem to gemfile automatically
|
51
|
+
puts Rainbow("Add the following line to Gemfile").foreground(:green)
|
52
|
+
puts "gem carrierwave"
|
53
|
+
puts ""
|
54
|
+
end
|
55
|
+
|
56
|
+
menu.choice "No" do end
|
57
|
+
end
|
58
|
+
|
59
|
+
puts "Step 3. Asset Sync"
|
60
|
+
|
61
|
+
choose do |menu|
|
62
|
+
menu.prompt = "Using asset sync?"
|
63
|
+
menu.choice "Yes" do
|
64
|
+
create_asset_sync_config(name, region)
|
65
|
+
|
66
|
+
# TODO: Add gem to gemfile automatically
|
67
|
+
puts Rainbow("Add the following line to Gemfile").foreground(:green)
|
68
|
+
puts "gem asset_sync"
|
69
|
+
puts ""
|
70
|
+
|
71
|
+
# TODO: Settings in production.rb, staging.rb automatically
|
72
|
+
puts Rainbow("Add the following line to " + \
|
73
|
+
"config/environments/production.rb").foreground(:green)
|
74
|
+
puts "config.action_controller.asset_host = 'https://#{name}-assets.s3.amazonaws.com'"
|
75
|
+
|
76
|
+
puts Rainbow("Add the following line to " + \
|
77
|
+
"config/environments/staging.rb").foreground(:green)
|
78
|
+
puts "config.action_controller.asset_host = 'https://#{name}-assets.s3.amazonaws.com'"
|
79
|
+
end
|
80
|
+
menu.choice "No"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_bucket(name)
|
85
|
+
puts Rainbow("Creating bucket #{name}").foreground(:yellow)
|
86
|
+
s3 = AWS::S3.new
|
87
|
+
bucket = s3.buckets.create(name)
|
88
|
+
bucket.cors.set(
|
89
|
+
:allowed_methods => %w(GET),
|
90
|
+
:allowed_origins => %w(*),
|
91
|
+
:max_age_seconds => 3600
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def create_carrierwave_config(name, region)
|
96
|
+
aws_key = Tol::Config.get_option("awskey")
|
97
|
+
aws_secret = Tol::Config.get_option("awssecret")
|
98
|
+
|
99
|
+
content = <<-eos
|
100
|
+
CarrierWave.configure do |config|
|
101
|
+
config.fog_credentials = {
|
102
|
+
provider: 'AWS',
|
103
|
+
aws_access_key_id: '#{aws_key}',
|
104
|
+
aws_secret_access_key: '#{aws_secret}',
|
105
|
+
region: '#{region}'
|
106
|
+
}
|
107
|
+
config.fog_directory = "#{name}-" + Rails.env
|
108
|
+
end
|
109
|
+
eos
|
110
|
+
File.open("config/initializers/carrierwave.rb", "w") do |f|
|
111
|
+
f.write(content)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def create_asset_sync_config(name, region)
|
116
|
+
aws_key = Tol::Config.get_option("awskey")
|
117
|
+
aws_secret = Tol::Config.get_option("awssecret")
|
118
|
+
|
119
|
+
content = <<-eos
|
120
|
+
if defined?(AssetSync)
|
121
|
+
AssetSync.configure do |config|
|
122
|
+
config.fog_provider = 'AWS'
|
123
|
+
config.aws_access_key_id = '#{aws_key}'
|
124
|
+
config.aws_secret_access_key = '#{aws_secret}'
|
125
|
+
config.fog_directory = "#{name}-assets"
|
126
|
+
config.fog_region = "#{region}"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
eos
|
130
|
+
|
131
|
+
File.open("config/initializers/asset_sync.rb", "w") do |f|
|
132
|
+
f.write(content)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# New APP
|
137
|
+
# Generate a new Heroku application
|
138
|
+
def heroku
|
139
|
+
puts Rainbow("Step 1. Create new Heroku application").foreground(:green)
|
140
|
+
|
141
|
+
puts "Please enter the name of the new Heroku application:"
|
142
|
+
name = STDIN.gets.gsub("\n", "")
|
143
|
+
|
144
|
+
createapp = nil
|
145
|
+
Bundler.with_clean_env do
|
146
|
+
createapp = `heroku create #{name}`
|
147
|
+
end
|
148
|
+
|
149
|
+
if !createapp.include?("done, stack is cedar")
|
150
|
+
puts createapp
|
151
|
+
choose do |menu|
|
152
|
+
menu.prompt = "Continue?"
|
153
|
+
|
154
|
+
menu.choice "Yes" do
|
155
|
+
end
|
156
|
+
|
157
|
+
menu.choice "No" do
|
158
|
+
return
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
environment(name)
|
164
|
+
collaborators(name)
|
165
|
+
database(name)
|
166
|
+
domains(name)
|
167
|
+
email(name)
|
168
|
+
asset_sync(name)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Set up multi-environment system, if necessary (e.g., staging and production)
|
172
|
+
def environment(app)
|
173
|
+
choose do |menu|
|
174
|
+
puts Rainbow("Step 2. Adding the Rails environment").foreground(:green)
|
175
|
+
|
176
|
+
menu.prompt = "Which environment?"
|
177
|
+
|
178
|
+
menu.choice "production" do
|
179
|
+
Bundler.with_clean_env do
|
180
|
+
system("heroku config:set RACK_ENV=production RAILS_ENV=production --app #{app}")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
menu.choice "staging" do
|
185
|
+
Bundler.with_clean_env do
|
186
|
+
system("heroku config:set RACK_ENV=staging RAILS_ENV=staging --app #{app}")
|
187
|
+
system("cp config/environments/production.rb config/environments/staging.rb")
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# Adding collaborators
|
194
|
+
def collaborators(app)
|
195
|
+
choose do |menu|
|
196
|
+
puts Rainbow("Step 3. Adding collaborators").foreground(:green)
|
197
|
+
menu.prompt = "Which collaborators?"
|
198
|
+
|
199
|
+
menu.choice "Default" do
|
200
|
+
Tol::Config.get_option("collaborators").each do |email|
|
201
|
+
Bundler.with_clean_env do
|
202
|
+
system("heroku sharing:add #{email} --app #{app}")
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
menu.choice "No" do
|
208
|
+
puts "No problem!"
|
209
|
+
end
|
210
|
+
# TODO: Add a custom option, which allows entering more collaborators
|
211
|
+
# from the console.
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# Adding database
|
216
|
+
def database(app)
|
217
|
+
choose do |menu|
|
218
|
+
puts Rainbow("Step 4. Adding database addons").foreground(:green)
|
219
|
+
menu.prompt = "Which database?"
|
220
|
+
|
221
|
+
menu.choice "Postgres" do
|
222
|
+
Bundler.with_clean_env do
|
223
|
+
system("heroku addons:add heroku-postgresql:dev --app #{app}")
|
224
|
+
system("heroku addons:add pgbackups:auto-month --app #{app}")
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
menu.choice "None" do
|
229
|
+
puts "No problem!"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
# Adding domains
|
235
|
+
def domains(app)
|
236
|
+
puts "Step 5. Adding custom domains".foreground(:green)
|
237
|
+
|
238
|
+
continue = true
|
239
|
+
while continue do
|
240
|
+
choose do |menu|
|
241
|
+
menu.prompt = "Add another domain?"
|
242
|
+
menu.choice "Yes" do
|
243
|
+
puts "Enter domain (e.g., www.example.com, example.com, *.example.com):"
|
244
|
+
domain = STDIN.gets.gsub("\n", "")
|
245
|
+
Bundler.with_clean_env do
|
246
|
+
system("heroku domains:add '#{domain}' --app #{app}")
|
247
|
+
end
|
248
|
+
end
|
249
|
+
menu.choice "No" do
|
250
|
+
puts "No problem!"
|
251
|
+
continue = false
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
# Adding email system
|
258
|
+
def email(app)
|
259
|
+
choose do |menu|
|
260
|
+
puts Rainbow("Step 6. Adding email addons").foreground(:green)
|
261
|
+
menu.prompt = "Which email system?"
|
262
|
+
|
263
|
+
menu.choice "Mandrill" do
|
264
|
+
Bundler.with_clean_env do
|
265
|
+
system("heroku addons:add mandrill:starter --app #{app}")
|
266
|
+
end
|
267
|
+
|
268
|
+
puts Rainbow("Please paste " + \
|
269
|
+
"and complete ").foreground(:green) + \
|
270
|
+
"the following in your environment file (e.g., production.rb)"
|
271
|
+
content = <<-eos
|
272
|
+
config.action_mailer.default_url_options = { :host => 'http://<DOMAIN HERE>' }
|
273
|
+
config.action_mailer.delivery_method = :smtp
|
274
|
+
config.action_mailer.perform_deliveries = true
|
275
|
+
config.action_mailer.raise_delivery_errors = false
|
276
|
+
config.action_mailer.default :charset => "utf-8"
|
277
|
+
config.action_mailer.smtp_settings = {
|
278
|
+
:port => '587',
|
279
|
+
:address => 'smtp.mandrillapp.com',
|
280
|
+
:user_name => ENV['MANDRILL_USERNAME'],
|
281
|
+
:password => ENV['MANDRILL_APIKEY'],
|
282
|
+
:domain => '<DOMAIN HERE>',
|
283
|
+
:authentication => :plain
|
284
|
+
}
|
285
|
+
eos
|
286
|
+
puts content
|
287
|
+
end
|
288
|
+
|
289
|
+
menu.choice "Sendgrid" do
|
290
|
+
Bundler.with_clean_env do
|
291
|
+
system("heroku addons:add sendgrid:starter --app #{app}")
|
292
|
+
end
|
293
|
+
|
294
|
+
puts Rainbow("Please paste " + \
|
295
|
+
"and complete ").foreground(:green) + \
|
296
|
+
"the following in your environment file (e.g., production.rb)"
|
297
|
+
content = <<-eos
|
298
|
+
config.action_mailer.default_url_options = { :host => 'http://<DOMAIN HERE>' }
|
299
|
+
config.action_mailer.delivery_method = :smtp
|
300
|
+
config.action_mailer.perform_deliveries = true
|
301
|
+
config.action_mailer.raise_delivery_errors = false
|
302
|
+
config.action_mailer.default :charset => "utf-8"
|
303
|
+
config.action_mailer.smtp_settings = {
|
304
|
+
:address => 'smtp.sendgrid.net',
|
305
|
+
:port => '587',
|
306
|
+
:authentication => :plain,
|
307
|
+
:user_name => ENV['SENDGRID_USERNAME'],
|
308
|
+
:password => ENV['SENDGRID_PASSWORD'],
|
309
|
+
:domain => '<DOMAIN HERE>'
|
310
|
+
}
|
311
|
+
eos
|
312
|
+
puts content
|
313
|
+
end
|
314
|
+
|
315
|
+
menu.choice "None" do
|
316
|
+
puts "No problem!"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
# Enable asset sync
|
322
|
+
def asset_sync(app)
|
323
|
+
choose do |menu|
|
324
|
+
puts Rainbow("Step 7. Adding Asset Sync").foreground(:green)
|
325
|
+
menu.prompt = "Using Asset Sync?"
|
326
|
+
|
327
|
+
menu.choice "Yes" do
|
328
|
+
Bundler.with_clean_env do
|
329
|
+
system("heroku labs:enable user-env-compile --app #{app}")
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
menu.choice "No" do
|
334
|
+
puts "No problem!"
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
|
339
|
+
### WWW Redirect
|
340
|
+
def www_redirect
|
341
|
+
content = <<-eos
|
342
|
+
class WwwMiddleware
|
343
|
+
def initialize(app)
|
344
|
+
@app = app
|
345
|
+
end
|
346
|
+
|
347
|
+
def call(env)
|
348
|
+
request = Rack::Request.new(env)
|
349
|
+
subdomains = request.host.split(".")
|
350
|
+
if (subdomains[0] || "") != "www" && (subdomains[1] || "") != "herokuapp"
|
351
|
+
[301, {"Location" => request.url.sub("//", "//www.")}, self]
|
352
|
+
else
|
353
|
+
@app.call(env)
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
def each(&block)
|
358
|
+
end
|
359
|
+
end
|
360
|
+
eos
|
361
|
+
|
362
|
+
FileUtils.mkdir_p("lib/middleware")
|
363
|
+
File.open("lib/middleware/www_middleware.rb", "w") do |f|
|
364
|
+
f.write(content)
|
365
|
+
end
|
366
|
+
|
367
|
+
puts Rainbow("Add the following line to " + \
|
368
|
+
"config/application.rb").foreground(:red)
|
369
|
+
puts "config.autoload_paths += %W( \#\{ config.root \}/lib/middleware )"
|
370
|
+
puts ""
|
371
|
+
|
372
|
+
puts Rainbow("Add the following line to " + \
|
373
|
+
"config/environments/production.rb").foreground(:red)
|
374
|
+
puts "config.middleware.use \"WwwMiddleware\""
|
375
|
+
puts ""
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
data/lib/tol/version.rb
CHANGED
data/tol.gemspec
CHANGED
metadata
CHANGED
@@ -1,62 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tol
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Alex Tandrau
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: pry
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rainbow
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: highline
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aws-sdk
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0'
|
62
69
|
description: A collection of tools used at Take Off Labs for Rails development
|
@@ -77,33 +84,34 @@ files:
|
|
77
84
|
- lib/tol.rb
|
78
85
|
- lib/tol/cli.rb
|
79
86
|
- lib/tol/codecheck.rb
|
87
|
+
- lib/tol/config.rb
|
80
88
|
- lib/tol/database.rb
|
81
89
|
- lib/tol/heroku.rb
|
90
|
+
- lib/tol/newapp.rb
|
82
91
|
- lib/tol/rails_app.rb
|
83
92
|
- lib/tol/version.rb
|
84
93
|
- tol.gemspec
|
85
94
|
homepage: http://www.takeofflabs.com
|
86
95
|
licenses: []
|
96
|
+
metadata: {}
|
87
97
|
post_install_message:
|
88
98
|
rdoc_options: []
|
89
99
|
require_paths:
|
90
100
|
- lib
|
91
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
102
|
requirements:
|
94
|
-
- -
|
103
|
+
- - '>='
|
95
104
|
- !ruby/object:Gem::Version
|
96
105
|
version: '0'
|
97
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
107
|
requirements:
|
100
|
-
- -
|
108
|
+
- - '>='
|
101
109
|
- !ruby/object:Gem::Version
|
102
110
|
version: '0'
|
103
111
|
requirements: []
|
104
112
|
rubyforge_project:
|
105
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.2.2
|
106
114
|
signing_key:
|
107
|
-
specification_version:
|
115
|
+
specification_version: 4
|
108
116
|
summary: Heroku interactions, etc.
|
109
117
|
test_files: []
|