lib/meroku/cli.rb in meroku-2.0.7 vs lib/meroku/cli.rb in meroku-2.0.8
- old
+ new
@@ -17,43 +17,21 @@
meroku infrastrucuture spawn # Spawns server
HEREDOC
end
-
- #def self.start(*args)
- # case args.join(" ")
- # when "infrastructure spawn"
- # load_secrets || exit
- # node = Meroku::Infrastructure::Node.new.associate_address.install_packages.install_frontend_app
- # puts "spawned #{node.instance.try(:instance_id)}"
- # when "infrastructure despawn"
- # load_secrets || exit
- # Meroku::Infrastructure.despawn
- # when "signup"
- # signup
- # when "keys:add"
- # token_check || exit
- # keys_add
- # when "create"
- # token_check || exit
- # create
- # else
- # puts HELP
- # end
- #end
def signup
print "Email: "
email = STDIN.gets
print "Password: "
password = STDIN.noecho(&:gets).chomp
print "\n"
url = "https://www.meroku.com/users.json"
response_json = RestClient.post url, {:user=>{:email => email, :password => password, :password_confirmation => password}}.to_json, timeout: 1, :content_type => :json, :accept => :json
if JSON.parse(response_json)["errors"] && JSON.parse(response_json)["errors"].size > 0
- puts JSON.parse(response_json)["errors"].map{|x| x["detail"]}.join(".")
+ puts "error: #{JSON.parse(response_json)["errors"].map{|x| x["detail"]}.join(".")}"
else
email = JSON.parse(response_json)["data"]["attributes"]["email"]
token = JSON.parse(response_json)["data"]["attributes"]["token"]
puts "Signed up #{email}"
dirname = File.dirname("#{Dir.home}/.meroku")
@@ -73,11 +51,11 @@
data = `cat ~/.ssh/id_rsa.pub`.chomp
url = "https://www.meroku.com/publickeys.json"
response_json = RestClient.post url, {:publickey=>{:name => name, :data=>data}, :token=>session.token}.to_json, timeout: 1, :content_type => :json, :accept => :json
if JSON.parse(response_json)["errors"] && JSON.parse(response_json)["errors"].size > 0
- puts JSON.parse(response_json)["errors"].map{|x| x["detail"]}.join(".")
+ puts "error: #{JSON.parse(response_json)["errors"].map{|x| x["detail"]}.join(".")}"
else
name = JSON.parse(response_json)["data"]["attributes"]["name"]
puts "Added #{name}"
end
end
@@ -91,13 +69,13 @@
puts JSON.parse(response_json)["errors"].map{|x| x["detail"]}.join(".")
else
name = JSON.parse(response_json)["data"]["attributes"]["name"]
puts "Created #{name}, adding git remote"
puts "git remote remove meroku"
- `git remote remove meroku`
- puts "git remote add meroku git@www.meroku.com:#{name}.git"
- `git remote add meroku git@www.meroku.com:#{name}.git`
+ `git remote remove meroku 2>/dev/null`
+ puts "git remote add meroku #{token}@www.meroku.com:#{name}.git"
+ `git remote add meroku #{token}@www.meroku.com:#{name}.git`
end
end
def self.token_check
if !File.exist? "#{Dir.home}/.meroku/.token"
@@ -118,32 +96,9 @@
remote_env_file = "http://www.sam-we.com/dropbox/meroku-#{secret}/meroku.env"
File.write(env_file, Net::HTTP.get(URI.parse(remote_env_file)))
end
Dotenv.load(env_file)
end
-
-
-
- #def self.keys_add
- # if !File.exist? "#{Dir.home}/.ssh/id_rsa.pub"
- # puts "error: File #{Dir.home}/.ssh/id_rsa.pub not found"
- # puts "You can use this command to generate a key:"
- # puts " ssh-keygen -t rsa"
- # return nil
- # end
- # name = "id_rsa.pub"
- # data = `cat ~/.ssh/id_rsa.pub`.chomp
- # url = "https://www.meroku.com/publickeys.json"
- # token = `cat ~/.meroku/.token`.chomp
- # response_json = RestClient.post url, {:publickey=>{:name => name, :data=>data}, :token=>token}.to_json, timeout: 1, :content_type => :json, :accept => :json
- #
- # if JSON.parse(response_json)["errors"] && JSON.parse(response_json)["errors"].size > 0
- # puts JSON.parse(response_json)["errors"].map{|x| x["detail"]}.join(".")
- # else
- # name = JSON.parse(response_json)["data"]["attributes"]["name"]
- # puts "Added #{name}"
- # end
- #end
end
end