railsonfire 0.2.15 → 0.2.16
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/railsonfire +3 -5
- data/railsonfire.gemspec +6 -10
- metadata +8 -25
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -80
- data/lib/railsonfire.rb +0 -8
- data/lib/railsonfire/cli.rb +0 -2
- data/lib/railsonfire/commands.rb +0 -2
- data/lib/railsonfire/commands/create.rb +0 -124
- data/lib/railsonfire/commands/post-receive +0 -20
- data/lib/railsonfire/commands/post_receive.rb +0 -9
- data/lib/railsonfire/helpers/base.rb +0 -79
- data/lib/railsonfire/helpers/base_cli.rb +0 -6
- data/lib/railsonfire/helpers/constants.rb +0 -6
- data/lib/railsonfire/helpers/key.rb +0 -48
- data/lib/railsonfire/railsonfire.rb +0 -114
- data/lib/railsonfire/subcommands.rb +0 -18
- data/lib/railsonfire/subcommands/auth.rb +0 -79
- data/lib/railsonfire/subcommands/config.rb +0 -30
- data/lib/railsonfire/subcommands/github.rb +0 -67
- data/lib/railsonfire/subcommands/heroku.rb +0 -80
data/bin/railsonfire
CHANGED
@@ -19,11 +19,9 @@ Ynhi9CV9Q9alALkNpKGyhBEMuS4HNtcrVQIDAQAB
|
|
19
19
|
include Railsonfire::Helper
|
20
20
|
|
21
21
|
begin
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
puts "You have an old version of Railsonfire installed. Please update by running gem update railsonfire."
|
26
|
-
end
|
22
|
+
puts 'We renamend to Codeship'
|
23
|
+
puts ' You can configure all your projects through our website now at https://www.codeship.io. Give it a try, it is really easy and powerful.'
|
24
|
+
puts ' If you have any questions send an email to support@codeship.io so we can help you.'
|
27
25
|
rescue Exception => e
|
28
26
|
if e.class != SystemExit && e.class != Interrupt
|
29
27
|
puts ""
|
data/railsonfire.gemspec
CHANGED
@@ -1,28 +1,24 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "railsonfire"
|
3
|
-
s.version = "0.2.
|
3
|
+
s.version = "0.2.16"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Florian Motlik"]
|
7
|
-
s.description = "
|
8
|
-
s.email = "flo@
|
7
|
+
s.description = "We renamed to Codeship.io and you can configure your project now through the website at https://www.codeship.io"
|
8
|
+
s.email = "flo@codeship.io"
|
9
9
|
s.executables = ["railsonfire"]
|
10
10
|
s.extra_rdoc_files = [
|
11
11
|
"LICENSE.txt",
|
12
12
|
"README.rdoc"
|
13
13
|
]
|
14
14
|
s.files = [
|
15
|
-
"Gemfile",
|
16
|
-
"Gemfile.lock",
|
17
|
-
"LICENSE.txt",
|
18
15
|
"bin/railsonfire",
|
19
16
|
"railsonfire.gemspec",
|
20
|
-
]
|
21
|
-
s.homepage = "https://www.
|
17
|
+
]
|
18
|
+
s.homepage = "https://www.codeship.io"
|
22
19
|
s.licenses = ["MIT"]
|
23
|
-
s.require_paths = ["lib"]
|
24
20
|
s.rubygems_version = "1.8.10"
|
25
|
-
s.summary = "
|
21
|
+
s.summary = "We renamed to Codeship.io"
|
26
22
|
|
27
23
|
s.add_dependency("launchy", "2.1.2")
|
28
24
|
s.add_dependency("sshkey", "1.3.1")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railsonfire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.16
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: launchy
|
@@ -235,8 +235,9 @@ dependencies:
|
|
235
235
|
- - ! '>='
|
236
236
|
- !ruby/object:Gem::Version
|
237
237
|
version: '0'
|
238
|
-
description:
|
239
|
-
|
238
|
+
description: We renamed to Codeship.io and you can configure your project now through
|
239
|
+
the website at https://www.codeship.io
|
240
|
+
email: flo@codeship.io
|
240
241
|
executables:
|
241
242
|
- railsonfire
|
242
243
|
extensions: []
|
@@ -244,29 +245,11 @@ extra_rdoc_files:
|
|
244
245
|
- LICENSE.txt
|
245
246
|
- README.rdoc
|
246
247
|
files:
|
247
|
-
- Gemfile
|
248
|
-
- Gemfile.lock
|
249
|
-
- LICENSE.txt
|
250
248
|
- bin/railsonfire
|
251
249
|
- railsonfire.gemspec
|
252
|
-
-
|
253
|
-
- lib/railsonfire/subcommands/config.rb
|
254
|
-
- lib/railsonfire/subcommands/github.rb
|
255
|
-
- lib/railsonfire/subcommands/heroku.rb
|
256
|
-
- lib/railsonfire/commands/post-receive
|
257
|
-
- lib/railsonfire/commands/create.rb
|
258
|
-
- lib/railsonfire/commands/post_receive.rb
|
259
|
-
- lib/railsonfire/cli.rb
|
260
|
-
- lib/railsonfire/subcommands.rb
|
261
|
-
- lib/railsonfire/railsonfire.rb
|
262
|
-
- lib/railsonfire/commands.rb
|
263
|
-
- lib/railsonfire/helpers/key.rb
|
264
|
-
- lib/railsonfire/helpers/base.rb
|
265
|
-
- lib/railsonfire/helpers/constants.rb
|
266
|
-
- lib/railsonfire/helpers/base_cli.rb
|
267
|
-
- lib/railsonfire.rb
|
250
|
+
- LICENSE.txt
|
268
251
|
- README.rdoc
|
269
|
-
homepage: https://www.
|
252
|
+
homepage: https://www.codeship.io
|
270
253
|
licenses:
|
271
254
|
- MIT
|
272
255
|
post_install_message:
|
@@ -290,6 +273,6 @@ rubyforge_project:
|
|
290
273
|
rubygems_version: 1.8.24
|
291
274
|
signing_key:
|
292
275
|
specification_version: 3
|
293
|
-
summary:
|
276
|
+
summary: We renamed to Codeship.io
|
294
277
|
test_files: []
|
295
278
|
has_rdoc:
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
railsonfire (0.2.15)
|
5
|
-
activesupport (= 3.2.8)
|
6
|
-
gems (= 0.7.0)
|
7
|
-
git (= 1.2.5)
|
8
|
-
heroku (= 2.31.2)
|
9
|
-
httparty (= 0.9.0)
|
10
|
-
json_pure (= 1.7.5)
|
11
|
-
launchy (= 2.1.2)
|
12
|
-
multi_json (= 1.3.6)
|
13
|
-
sshkey (= 1.3.1)
|
14
|
-
thor (= 0.16.0)
|
15
|
-
|
16
|
-
GEM
|
17
|
-
remote: http://rubygems.org/
|
18
|
-
specs:
|
19
|
-
activesupport (3.2.8)
|
20
|
-
i18n (~> 0.6)
|
21
|
-
multi_json (~> 1.0)
|
22
|
-
addressable (2.3.2)
|
23
|
-
coderay (1.0.7)
|
24
|
-
diff-lcs (1.1.3)
|
25
|
-
excon (0.16.2)
|
26
|
-
gems (0.7.0)
|
27
|
-
git (1.2.5)
|
28
|
-
heroku (2.31.2)
|
29
|
-
heroku-api (~> 0.3.4)
|
30
|
-
launchy (>= 0.3.2)
|
31
|
-
netrc (~> 0.7.7)
|
32
|
-
rest-client (~> 1.6.1)
|
33
|
-
rubyzip
|
34
|
-
heroku-api (0.3.5)
|
35
|
-
excon (~> 0.16.1)
|
36
|
-
httparty (0.9.0)
|
37
|
-
multi_json (~> 1.0)
|
38
|
-
multi_xml
|
39
|
-
i18n (0.6.1)
|
40
|
-
json_pure (1.7.5)
|
41
|
-
launchy (2.1.2)
|
42
|
-
addressable (~> 2.3)
|
43
|
-
method_source (0.8)
|
44
|
-
mime-types (1.19)
|
45
|
-
multi_json (1.3.6)
|
46
|
-
multi_xml (0.5.1)
|
47
|
-
netrc (0.7.7)
|
48
|
-
pry (0.9.10)
|
49
|
-
coderay (~> 1.0.5)
|
50
|
-
method_source (~> 0.8)
|
51
|
-
slop (~> 3.3.1)
|
52
|
-
rake (0.9.2.2)
|
53
|
-
rest-client (1.6.7)
|
54
|
-
mime-types (>= 1.16)
|
55
|
-
rspec (2.11.0)
|
56
|
-
rspec-core (~> 2.11.0)
|
57
|
-
rspec-expectations (~> 2.11.0)
|
58
|
-
rspec-mocks (~> 2.11.0)
|
59
|
-
rspec-core (2.11.1)
|
60
|
-
rspec-expectations (2.11.3)
|
61
|
-
diff-lcs (~> 1.1.3)
|
62
|
-
rspec-mocks (2.11.2)
|
63
|
-
rubyzip (0.9.9)
|
64
|
-
simplecov (0.6.4)
|
65
|
-
multi_json (~> 1.0)
|
66
|
-
simplecov-html (~> 0.5.3)
|
67
|
-
simplecov-html (0.5.3)
|
68
|
-
slop (3.3.3)
|
69
|
-
sshkey (1.3.1)
|
70
|
-
thor (0.16.0)
|
71
|
-
|
72
|
-
PLATFORMS
|
73
|
-
ruby
|
74
|
-
|
75
|
-
DEPENDENCIES
|
76
|
-
pry
|
77
|
-
railsonfire!
|
78
|
-
rake
|
79
|
-
rspec
|
80
|
-
simplecov
|
data/lib/railsonfire.rb
DELETED
data/lib/railsonfire/cli.rb
DELETED
data/lib/railsonfire/commands.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
require 'railsonfire/helpers/base'
|
2
|
-
require 'railsonfire/helpers/key'
|
3
|
-
require 'railsonfire/helpers/constants'
|
4
|
-
require 'active_support/core_ext/hash/deep_merge'
|
5
|
-
|
6
|
-
|
7
|
-
class CLI < BASECLI
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
File.dirname(__FILE__)
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "create", "Create a new Railsonfire project"
|
14
|
-
def create
|
15
|
-
invoke "auth:login"
|
16
|
-
send_signal :create_started
|
17
|
-
return unless is_git_managed?
|
18
|
-
if git_remotes.empty?
|
19
|
-
say "We couldn't find any GitHub remotes. Please add your GitHub remote with git remote add YOUR_GITHUB_REMOTE and start again."
|
20
|
-
return false
|
21
|
-
end
|
22
|
-
remote = ask_for_git_remote
|
23
|
-
set_project_data remote
|
24
|
-
|
25
|
-
if yes? "Create Project (y/n)?" and project.create
|
26
|
-
if(is_github_remote? remote)
|
27
|
-
send_signal :configure_github
|
28
|
-
configure_github
|
29
|
-
else
|
30
|
-
send_signal :create_post_receive
|
31
|
-
invoke "post_receive"
|
32
|
-
end
|
33
|
-
configure
|
34
|
-
true
|
35
|
-
else
|
36
|
-
send_signal :create_cancelled
|
37
|
-
false
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
def project
|
43
|
-
Railsonfire.project
|
44
|
-
end
|
45
|
-
|
46
|
-
def ask_for_git_remote
|
47
|
-
return git_remotes[0] if git_remotes.size == 1
|
48
|
-
select "Select the repository you store your code in and we should clone from:", git_remotes
|
49
|
-
end
|
50
|
-
|
51
|
-
def git_remotes
|
52
|
-
Git.open("./").remotes.collect(&:url).select{|u| is_github_remote? u}
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
def set_project_data remote
|
57
|
-
if(is_github_remote? remote)
|
58
|
-
project.name = github_repo_name_from remote
|
59
|
-
project.owner = github_repo_owner_from remote
|
60
|
-
send_signal :create_with_github
|
61
|
-
else
|
62
|
-
project.url = remote
|
63
|
-
project.name = ask "Name of your Project:"
|
64
|
-
send_signal :create_with_generic_git
|
65
|
-
end
|
66
|
-
say "Owner: #{project.owner}" if project.owner
|
67
|
-
say "Name: #{project.name}"
|
68
|
-
say "Repository: #{project.url}" if project.url
|
69
|
-
end
|
70
|
-
|
71
|
-
def is_github_remote? remote
|
72
|
-
remote["github.com"] != nil
|
73
|
-
end
|
74
|
-
def github_repo_name_from remote
|
75
|
-
if remote.start_with?("https")
|
76
|
-
remote.split("/")[4].split(".")[0]
|
77
|
-
else
|
78
|
-
split_git_remote(remote).last
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def github_repo_owner_from remote
|
83
|
-
if remote.start_with?("https")
|
84
|
-
remote.split("/")[3]
|
85
|
-
else
|
86
|
-
split_git_remote(remote).first
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def split_git_remote remote
|
91
|
-
remote.sub("git@github.com:", "").sub(".git", "").split("/")
|
92
|
-
end
|
93
|
-
|
94
|
-
def configure_github
|
95
|
-
invoke "github:upload_key"
|
96
|
-
invoke "github:add_hook"
|
97
|
-
end
|
98
|
-
|
99
|
-
def configure
|
100
|
-
merge_new_project_config
|
101
|
-
configure_heroku
|
102
|
-
write_config_file
|
103
|
-
end
|
104
|
-
|
105
|
-
def merge_new_project_config
|
106
|
-
new = {
|
107
|
-
"id" => Railsonfire.project.uuid,
|
108
|
-
"setup" => {
|
109
|
-
"commands" => ["bundle install", "bundle exec rake db:schema:load"]
|
110
|
-
},
|
111
|
-
"test" => {
|
112
|
-
"commands" => ["bundle exec rake"]
|
113
|
-
},
|
114
|
-
"deploy" => {
|
115
|
-
},
|
116
|
-
"ruby_versions" => [RUBY_VERSION]
|
117
|
-
}
|
118
|
-
Railsonfire.config.deep_merge!(new)
|
119
|
-
end
|
120
|
-
|
121
|
-
def configure_heroku
|
122
|
-
invoke "railsonfire:heroku:configure" if yes? "Do you want to configure deployment to Heroku (y/n)?"
|
123
|
-
end
|
124
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
while read oldrev newrev ref
|
4
|
-
do
|
5
|
-
echo "STARTING [$oldrev $newrev $ref]"
|
6
|
-
email=`git log $newrev --format=%ce -n 1`
|
7
|
-
name=`git log $newrev --format=%cn -n 1`
|
8
|
-
message=`git log $newrev --format=%B -n 1`
|
9
|
-
echo $email
|
10
|
-
|
11
|
-
wget --post-data "payload={\"ref\":\"$ref\", \
|
12
|
-
\"after\":\"$newrev\", \
|
13
|
-
\"commits\": \
|
14
|
-
[{ \
|
15
|
-
\"id\":\"$newrev\", \
|
16
|
-
\"author\":{\"email\":\"$email\", \"name\":\"$name\"}, \
|
17
|
-
\"message\":\"$message\" \
|
18
|
-
}] \
|
19
|
-
}" https://railsonfire.com/hook/<%= config[:uuid] %>
|
20
|
-
done
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
|
-
class CLI < BASECLI
|
4
|
-
desc "post_receive", "Create a PostReceive File for the current Project"
|
5
|
-
def post_receive
|
6
|
-
template("post-receive", "post-receive", {:uuid => Railsonfire.project.uuid})
|
7
|
-
#@cli.should_receive(:template).with("post-receive", "post-receive", {:uuid => project.uuid})
|
8
|
-
end
|
9
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'git'
|
2
|
-
require 'yaml'
|
3
|
-
require 'httparty'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
module Railsonfire
|
7
|
-
module Helper
|
8
|
-
def shell
|
9
|
-
Thor::Base.shell.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def notify class_name, message, parameters = {}
|
13
|
-
token = Railsonfire.user ? Railsonfire.user.railsonfire_token : ""
|
14
|
-
post_json "#{Railsonfire::DOMAIN}/airbrake/proxy", {
|
15
|
-
"error_class" => class_name,
|
16
|
-
"error_message" => message + " - #{token}",
|
17
|
-
"parameters" => parameters.merge({:railsonfire_id => token})
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def send_signal signal
|
22
|
-
begin
|
23
|
-
token = Railsonfire.user ? Railsonfire.user.railsonfire_token : ""
|
24
|
-
HTTParty.post("#{Railsonfire::DOMAIN}/users/signal?railsonfire_token=#{token}&signal=#{signal}")
|
25
|
-
rescue Exception => e
|
26
|
-
notify e.class, e.message
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def is_git_managed?
|
31
|
-
dir_exists?("./.git").tap do |git_folder|
|
32
|
-
error "Start railsonfire in the root folder of a git managed project" unless git_folder
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def write_config_file
|
37
|
-
create_file(
|
38
|
-
Railsonfire::RAILSONFIRE_FILE,
|
39
|
-
Railsonfire.config.to_yaml.gsub("---\n", "").gsub("\n\n", "\n").gsub(": \n", ":\n"),
|
40
|
-
:force => true
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
def success message
|
45
|
-
say message, Thor::Shell::Color::GREEN
|
46
|
-
end
|
47
|
-
|
48
|
-
def error message
|
49
|
-
say message, Thor::Shell::Color::RED
|
50
|
-
end
|
51
|
-
|
52
|
-
def warning message
|
53
|
-
say message, Thor::Shell::Color::YELLOW
|
54
|
-
end
|
55
|
-
|
56
|
-
def heroku
|
57
|
-
@heroku ||= ::Heroku::Auth.api
|
58
|
-
end
|
59
|
-
|
60
|
-
def select msg, elements
|
61
|
-
elements.each_with_index do |element, index|
|
62
|
-
success(block_given? ? yield(element, index + 1) : ("%s. %s" % [index + 1, element]))
|
63
|
-
end
|
64
|
-
result = ask(msg, :limited_to => (1..elements.count).map(&:to_s)).to_i
|
65
|
-
elements[result - 1]
|
66
|
-
end
|
67
|
-
|
68
|
-
def post_json path, body
|
69
|
-
HTTParty.post(path,
|
70
|
-
:headers => {"Content-Type" => "application/json"},
|
71
|
-
:body => body.to_json)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
def dir_exists? dir
|
76
|
-
File.exists?(dir) && File.directory?(dir)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'sshkey'
|
2
|
-
require 'openssl'
|
3
|
-
require 'base64'
|
4
|
-
|
5
|
-
module Railsonfire
|
6
|
-
module Helper
|
7
|
-
module Keys
|
8
|
-
def create_ssh_key
|
9
|
-
SSHKey.generate()
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
def create_keys key
|
14
|
-
{}.tap do |keys|
|
15
|
-
cipher_data = create_encryption_cipher
|
16
|
-
keys[:cipher_iv] = encode(encrypt(cipher_data[:iv]))
|
17
|
-
keys[:cipher_key] = encode(encrypt(cipher_data[:key]))
|
18
|
-
keys[:public_key] = key.ssh_public_key
|
19
|
-
keys[:private_key] = encode(encrypt_symmetrically key.rsa_private_key, cipher_data[:cipher])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
def create_encryption_cipher
|
25
|
-
cipher = OpenSSL::Cipher.new("AES256")
|
26
|
-
cipher.encrypt
|
27
|
-
iv = cipher.random_iv
|
28
|
-
key = cipher.random_key
|
29
|
-
{:cipher => cipher, :iv => iv, :key => key}
|
30
|
-
end
|
31
|
-
|
32
|
-
def encrypt content
|
33
|
-
rsa_key = OpenSSL::PKey::RSA.new(ENV["public-key"])
|
34
|
-
rsa_key.public_encrypt(content)
|
35
|
-
end
|
36
|
-
|
37
|
-
def encrypt_symmetrically content, cipher
|
38
|
-
ciphertext = cipher.update(content)
|
39
|
-
ciphertext << cipher.final
|
40
|
-
ciphertext
|
41
|
-
end
|
42
|
-
|
43
|
-
def encode content
|
44
|
-
Base64.encode64 content
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'railsonfire/helpers/key'
|
2
|
-
require 'railsonfire/helpers/constants'
|
3
|
-
require 'httparty'
|
4
|
-
require 'json'
|
5
|
-
require 'yaml'
|
6
|
-
require 'active_support/core_ext/hash/keys'
|
7
|
-
|
8
|
-
module Railsonfire
|
9
|
-
include Railsonfire::Helper
|
10
|
-
|
11
|
-
def self.config
|
12
|
-
@config ||= File.exists?(RAILSONFIRE_FILE) ? stringify(YAML.load(File.read(RAILSONFIRE_FILE))) : {}
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.login token, github_token
|
16
|
-
@user = Railsonfire::User.new token, github_token
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.user
|
20
|
-
@user
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.project
|
24
|
-
id = Railsonfire.config["id"]
|
25
|
-
if id
|
26
|
-
@project ||= Project.new user.railsonfire_token, id
|
27
|
-
else
|
28
|
-
@project ||= Project.new user.railsonfire_token
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Project
|
33
|
-
include Helper
|
34
|
-
include Helper::Keys
|
35
|
-
|
36
|
-
attr_accessor :name, :owner, :url
|
37
|
-
attr_reader :ssh_public_key, :ssh_private_key, :uuid
|
38
|
-
|
39
|
-
def initialize token, id = nil
|
40
|
-
@token = token
|
41
|
-
load_project_data token, id if id
|
42
|
-
end
|
43
|
-
|
44
|
-
def create
|
45
|
-
send_signal :starting_create
|
46
|
-
ssh_key = create_ssh_key
|
47
|
-
@ssh_public_key = ssh_key.ssh_public_key
|
48
|
-
@ssh_private_key = ssh_key.rsa_private_key
|
49
|
-
keys = create_keys ssh_key
|
50
|
-
body = {:name => name, :owner => owner, :repo_url => url}.merge(keys)
|
51
|
-
response = HTTParty.post("#{Railsonfire::DOMAIN}/projects?token=#@token", :headers => {"Content-Type" => "application/json"}, :body => body.to_json)
|
52
|
-
case response.code
|
53
|
-
when 201
|
54
|
-
@uuid = response.body
|
55
|
-
Railsonfire.config["id"] = @uuid
|
56
|
-
send_signal :created
|
57
|
-
true
|
58
|
-
when 404
|
59
|
-
shell.say "Could not authenticate with Railsonfire. Please logout and back in via the railsonfire gem."
|
60
|
-
notify("create-authenticate", "Could not authenticate with Railsonfire")
|
61
|
-
false
|
62
|
-
else
|
63
|
-
shell.say "An Error occured on the Railsonfire Servers and we were notified. Please try again or contact us at flo@railsonfire.com"
|
64
|
-
notify("create-error", "Error occured when creating a project")
|
65
|
-
false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
def load_project_data token, id
|
71
|
-
response = HTTParty.get("#{Railsonfire::DOMAIN}/projects/#{id}/project_data?access_token=#{token}")
|
72
|
-
if response.code != 200
|
73
|
-
shell.say "An Error occured on the Railsonfire server"
|
74
|
-
notify("load_project", "Project data couldn't be loaded", {:token => token, :id => id})
|
75
|
-
return nil
|
76
|
-
else
|
77
|
-
data = JSON.parse(response.body)
|
78
|
-
@name = data["name"]
|
79
|
-
@owner = data["owner"]
|
80
|
-
@ssh_public_key = data["public_key"]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
class User
|
85
|
-
attr_reader :github_token, :railsonfire_token
|
86
|
-
def initialize railsonfire_token, github_token
|
87
|
-
@railsonfire_token = railsonfire_token
|
88
|
-
@github_token = github_token
|
89
|
-
end
|
90
|
-
|
91
|
-
def config
|
92
|
-
JSON.parse(HTTParty.get(Railsonfire::DOMAIN + "/projects/#{Railsonfire.config["id"]}/get_config?railsonfire_token=#{@railsonfire_token}").body)
|
93
|
-
end
|
94
|
-
|
95
|
-
def set_config key, value
|
96
|
-
HTTParty.post(Railsonfire::DOMAIN + "/projects/#{Railsonfire.config["id"]}/add_config?railsonfire_token=#{@railsonfire_token}", :headers => {"Content-Type" => "application/json"}, :body => {"config" => {key => value}}.to_json)
|
97
|
-
end
|
98
|
-
|
99
|
-
def remove_config key
|
100
|
-
HTTParty.delete(Railsonfire::DOMAIN + "/projects/#{Railsonfire.config["id"]}/remove_config?railsonfire_token=#{@railsonfire_token}&key=#{key}")
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
private
|
106
|
-
def self.stringify hash
|
107
|
-
hash.tap do |h|
|
108
|
-
h.stringify_keys!
|
109
|
-
h.each do |key, value|
|
110
|
-
stringify h[key] if h[key].is_a?(Hash)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'railsonfire/subcommands/heroku'
|
2
|
-
require 'railsonfire/subcommands/github'
|
3
|
-
require 'railsonfire/subcommands/auth'
|
4
|
-
require 'railsonfire/subcommands/config'
|
5
|
-
|
6
|
-
class CLI < BASECLI
|
7
|
-
desc "heroku", "Manage Heroku connection with Railsonfire"
|
8
|
-
subcommand "heroku", Railsonfire::Heroku
|
9
|
-
|
10
|
-
desc "auth", "Configure your authentication with Railsonfire"
|
11
|
-
subcommand "auth", Auth
|
12
|
-
|
13
|
-
desc "github", "Manage GitHub connection with your Projects"
|
14
|
-
subcommand "github", Github
|
15
|
-
|
16
|
-
desc "config", "Manage configuration values set for your Railsonfire account"
|
17
|
-
subcommand "config", Railsonfire::Config
|
18
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'launchy'
|
2
|
-
require 'httparty'
|
3
|
-
require 'heroku'
|
4
|
-
|
5
|
-
class Auth < BASECLI
|
6
|
-
CREDENTIALS_PATH = "#{ENV["HOME"]}/.railsonfire/"
|
7
|
-
CREDENTIALS_FILE = CREDENTIALS_PATH + "credentials"
|
8
|
-
desc "login", "Authenticate the local machine with Railsonfire"
|
9
|
-
def login
|
10
|
-
if File.exists?(CREDENTIALS_FILE)
|
11
|
-
say "Credentials Found. Checking with Railsonfire Servers"
|
12
|
-
token = File.read(CREDENTIALS_FILE)
|
13
|
-
else
|
14
|
-
Dir.mkdir(CREDENTIALS_PATH) unless File.exists?(CREDENTIALS_PATH)
|
15
|
-
token = load_token_from_heroku
|
16
|
-
token ||= ask_user_for_token
|
17
|
-
File.open(CREDENTIALS_FILE, "w").tap do |file|
|
18
|
-
file.write(token)
|
19
|
-
file.close
|
20
|
-
end
|
21
|
-
end
|
22
|
-
begin
|
23
|
-
response = HTTParty.get("#{Railsonfire::DOMAIN}/users/#{token}/token")
|
24
|
-
if response.code == 200 || response.code == 404
|
25
|
-
Railsonfire.login(token, response.body)
|
26
|
-
send_signal :logged_in
|
27
|
-
success "Credentials verified and logged in successfully"
|
28
|
-
true
|
29
|
-
else
|
30
|
-
error "Couldn't authenticate with Railsonfire servers. Please try again and check your Token."
|
31
|
-
notify("login", "Couldn't authenticate with railsonfire", {:token => token, :body => response.body})
|
32
|
-
logout
|
33
|
-
exit
|
34
|
-
end
|
35
|
-
rescue Exception => e
|
36
|
-
exit if e.class == SystemExit
|
37
|
-
logout
|
38
|
-
error "There was an Error when communicating with the Railsonfire server."
|
39
|
-
error "Please login again and make sure you logged in with the correct Railsonfire Token."
|
40
|
-
notify(e.class, "Request Error: #{e.message}", {:backtrace => e.backtrace, :error_class => e.class})
|
41
|
-
exit
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "logout", "Delete all Authentication Data from the local machine"
|
46
|
-
def logout
|
47
|
-
say "Removing local credentials"
|
48
|
-
File.delete(CREDENTIALS_FILE) if File.exists?(CREDENTIALS_FILE)
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
def load_token_from_heroku
|
53
|
-
unless Heroku::Auth.read_credentials
|
54
|
-
warning "You are not authenticated with Heroku locally, thus we can not automatically detect your credentials."
|
55
|
-
return nil
|
56
|
-
end
|
57
|
-
success "Reading your credentials from Heroku.This may take a few seconds."
|
58
|
-
h = heroku
|
59
|
-
apps = h.get_apps.body.collect{|app| railsonfire_id = h.get_config_vars(app["name"]).body["RAILSONFIRE_ID"]; railsonfire_id ? [app["name"], railsonfire_id] : nil}.compact
|
60
|
-
case apps.count
|
61
|
-
when 0
|
62
|
-
error("Couldn't find any Heroku Addon Data for Railsonfire.")
|
63
|
-
return nil
|
64
|
-
when 1
|
65
|
-
app = apps.first
|
66
|
-
else
|
67
|
-
warning "You seem to have added Railsonfire to several apps. Please select the Heroku App you want to register with"
|
68
|
-
app = select("Please select the Heroku App you added our Addon to", apps){|element, index| "#{index}. #{element.first}"}
|
69
|
-
end
|
70
|
-
response = post_json("#{Railsonfire::DOMAIN}/heroku/exchange_token", {:railsonfire_id => app.last, :email => Heroku::Auth.get_credentials.first})
|
71
|
-
response.code == 200 ? response.body : nil
|
72
|
-
end
|
73
|
-
|
74
|
-
def ask_user_for_token
|
75
|
-
success("Please enter your Railsonfire Token. The Website to copy the token will open shortly")
|
76
|
-
Launchy.open("https://www.railsonfire.com/users/edit")
|
77
|
-
ask("Key:")
|
78
|
-
end
|
79
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'launchy'
|
2
|
-
require 'httparty'
|
3
|
-
|
4
|
-
class Railsonfire::Config < BASECLI
|
5
|
-
desc "show", "show the current config values set for your Railsonfire project"
|
6
|
-
def show
|
7
|
-
invoke "auth:login"
|
8
|
-
send_signal :show_config
|
9
|
-
say "No configuration values set" and return if Railsonfire.user.config.empty?
|
10
|
-
Railsonfire.user.config.each do |cfg|
|
11
|
-
say "#{cfg[0]}=#{cfg[1]}"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
desc "add", "Asks you for a Key and Value to add to your Railsonfire config"
|
16
|
-
def add
|
17
|
-
invoke "auth:login"
|
18
|
-
send_signal :add_config
|
19
|
-
key = ask "Key:"
|
20
|
-
value = ask "Value:"
|
21
|
-
Railsonfire.user.set_config key, value
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "remove", "Remove a configuration value"
|
25
|
-
def remove
|
26
|
-
invoke "auth:login"
|
27
|
-
send_signal :remove_config
|
28
|
-
Railsonfire.user.remove_config(ask "Key:")
|
29
|
-
end
|
30
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
|
-
class Github < BASECLI
|
4
|
-
GITHUB_KEY_URL = "https://api.github.com/repos/%s/%s/keys?access_token=%s"
|
5
|
-
RAILSONFIRE_HOOK_URL = "http://railsonfire.com/hook/%s"
|
6
|
-
GITHUB_HOOK_URL = "https://api.github.com/repos/%s/%s/hooks?access_token=%s"
|
7
|
-
|
8
|
-
desc "upload_key", "Upload the projects ssh Key to GitHub"
|
9
|
-
def upload_key
|
10
|
-
return false unless Railsonfire.user || invoke("auth:login")
|
11
|
-
send_signal :github_upload_key_started
|
12
|
-
return false unless has_github_token
|
13
|
-
project = Railsonfire.project
|
14
|
-
say "Adding SSH Key to Github Repository %s/%s" % [project.owner, project.name]
|
15
|
-
key = project.ssh_public_key.sub("\n", "") + " railsonfire/#{project.owner}/#{project.name}"
|
16
|
-
json = {:title => "railsonfire", :key => key}.to_json
|
17
|
-
response = HTTParty.post(github_url(GITHUB_KEY_URL), {:body => json})
|
18
|
-
if response.code != 201
|
19
|
-
error "Could not upload ssh key to Github"
|
20
|
-
error " Please make sure your Railsonfire account is connected with Github on https://www.railsonfire.com/users/edit and run railsonfire github upload_key"
|
21
|
-
error " If you do not want to give us access to your projects metadata and add the SSH key by hand please go to the edit page of your project and follow the instructions"
|
22
|
-
notify("github-key-upload", "Could not upload key to github", {:body => response.body, :code => response.code})
|
23
|
-
send_signal :github_upload_key_failed
|
24
|
-
false
|
25
|
-
else
|
26
|
-
send_signal :github_upload_key_finished
|
27
|
-
true
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
desc "add_hook", "Add Hook to GitHub repository"
|
32
|
-
def add_hook
|
33
|
-
return false unless Railsonfire.user || invoke("auth:login")
|
34
|
-
send_signal :github_add_hook_started
|
35
|
-
return false unless has_github_token
|
36
|
-
project = Railsonfire.project
|
37
|
-
say "Adding Post Receive Hook to Github Repository %s/%s" % [project.owner, project.name]
|
38
|
-
url = RAILSONFIRE_HOOK_URL % [Railsonfire.config["id"]]
|
39
|
-
json = {:name => "web", :config => {:url => url}}.to_json
|
40
|
-
response = HTTParty.post(github_url(GITHUB_HOOK_URL), {:body => json})
|
41
|
-
if response.code != 201
|
42
|
-
send_signal :github_add_hook_failed
|
43
|
-
error "Could not add post-receive Hook Github"
|
44
|
-
error " Please make sure your Railsonfire account is connected with Github on https://www.railsonfire.com/users/edit and run railsonfire github add_hook"
|
45
|
-
error " If you do not want to give us access to your projects metadata and set your Post-Receive-Hook by hand please go to the edit page of your project and follow the instructions"
|
46
|
-
notify("github-hook-upload", "Could not hook to github", {:body => response.body, :code => response.code})
|
47
|
-
false
|
48
|
-
else
|
49
|
-
send_signal :github_add_hook_finished
|
50
|
-
true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def has_github_token
|
57
|
-
token = Railsonfire.user.github_token
|
58
|
-
has_token = !(token.nil? || token.empty?)
|
59
|
-
warning("Your account isn't connected with GitHub so we can not set the SSH Key and Hook automatically") unless has_token
|
60
|
-
return has_token
|
61
|
-
end
|
62
|
-
|
63
|
-
def github_url url
|
64
|
-
project = Railsonfire.project
|
65
|
-
url % [project.owner, project.name, Railsonfire.user.github_token]
|
66
|
-
end
|
67
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'railsonfire/helpers/base'
|
2
|
-
require 'heroku'
|
3
|
-
require 'active_support/core_ext/hash/deep_merge'
|
4
|
-
require 'heroku/command'
|
5
|
-
|
6
|
-
class Railsonfire::Heroku < BASECLI
|
7
|
-
|
8
|
-
desc "upload_key", "Upload a key to Heroku"
|
9
|
-
def upload_key
|
10
|
-
invoke "auth:login"
|
11
|
-
send_signal :heroku_upload_key_started
|
12
|
-
say "Adding SSH Key to Heroku"
|
13
|
-
if project.ssh_public_key
|
14
|
-
heroku.post_key(project.ssh_public_key + " railsonfire/#{project.owner}/#{project.name}")
|
15
|
-
send_signal :heroku_upload_key_finished
|
16
|
-
else
|
17
|
-
error "Couldn't upload Key to Heroku"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "configure", "Configure Deployment to Heroku"
|
22
|
-
def configure
|
23
|
-
invoke "auth:login"
|
24
|
-
send_signal :heroku_configure_started
|
25
|
-
apps = heroku.get_apps.body.collect{|app| app["name"]}.sort
|
26
|
-
no_deployment = "No deployment to "
|
27
|
-
staging_name = select "Name of your Staging application:", apps + [no_deployment + "Staging"]
|
28
|
-
staging_name = "" if staging_name.start_with? no_deployment
|
29
|
-
production_name = select "Name of your Production application:", apps + [no_deployment + "Production"]
|
30
|
-
production_name = "" if production_name.start_with? no_deployment
|
31
|
-
has_pgbackups = has_pgbackups_addon_installed production_name unless production_name.empty?
|
32
|
-
deploy = {
|
33
|
-
"deploy" => {
|
34
|
-
"heroku" => {
|
35
|
-
"staging" =>{
|
36
|
-
"name" => staging_name
|
37
|
-
},
|
38
|
-
"production" =>{
|
39
|
-
"name" => production_name,
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}
|
44
|
-
deploy.deep_merge!("deploy" => {"heroku" => {"production" => {"backup" => false}}}) if production_name != "" and !has_pgbackups
|
45
|
-
invoke "upload_key"
|
46
|
-
invoke "credentials"
|
47
|
-
Railsonfire.config.deep_merge!(deploy)
|
48
|
-
write_config_file
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "credentials", "Upload Heroku Credentials to Railsonfire user"
|
52
|
-
def credentials
|
53
|
-
invoke "auth:login"
|
54
|
-
send_signal :heroku_credentials_started
|
55
|
-
token_key = "heroku_token"
|
56
|
-
config = Railsonfire.user.config
|
57
|
-
if config[token_key]
|
58
|
-
say "Your currently stored Heroku Token is:"
|
59
|
-
say " Token: #{config[token_key]}"
|
60
|
-
end
|
61
|
-
heroku_token = Heroku::Auth.get_credentials.last
|
62
|
-
if config[token_key] != heroku_token
|
63
|
-
return if config[token_key] != nil and no? "Do you want to replace your current Heroku Credentials with #{heroku_token}"
|
64
|
-
say "Setting Heroku token on Railsonfire"
|
65
|
-
Railsonfire.user.set_config token_key, heroku_token
|
66
|
-
send_signal :heroku_credentials_set
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
def has_pgbackups_addon_installed app
|
72
|
-
!heroku.get_addons(app).body.collect{|addon| addon["name"]}.select{|addon| addon["pgbackups"]}.empty?.tap do |h|
|
73
|
-
warning "You should add the pgbackups addon to #{app} with \"heroku addons:add pgbackups:auto-month --app #{app}\" and enable Backup in your railsonfire.yml file" if h
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def project
|
78
|
-
Railsonfire.project
|
79
|
-
end
|
80
|
-
end
|