heroswitch 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/PostInstall.txt +3 -0
- data/README.rdoc +78 -0
- data/Rakefile +1 -0
- data/bin/heroswitch +10 -0
- data/heroswitch.gemspec +19 -0
- data/lib/heroswitch.rb +8 -0
- data/lib/heroswitch/cli.rb +42 -0
- data/lib/heroswitch/credentials.rb +57 -0
- data/test/test_helper.rb +3 -0
- data/test/test_heroswitch.rb +11 -0
- data/test/test_heroswitch_cli.rb +15 -0
- metadata +77 -0
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
= heroswitch
|
2
|
+
|
3
|
+
* http://github.com/JohnFord/heroswitch
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Heroswitch allows you to easily switch between multiple Heroku account profiles. For example, if you have a work and a personal account, or if you have a seperate account for each client you work with, switching between account manually can be a tedious process. With just a few lines of configuration, heroswitch solves that pain.
|
8
|
+
|
9
|
+
== REQUIREMENTS:
|
10
|
+
|
11
|
+
You will need to create a credentials file in ~/.heroku for each account you wish to switch between. Name the files account_name.credentials. Example:
|
12
|
+
|
13
|
+
work.credentials file:
|
14
|
+
username@work.com
|
15
|
+
work_heroku_password
|
16
|
+
|
17
|
+
personal.credentials file:
|
18
|
+
username@gmail.com
|
19
|
+
personal_heroku_password
|
20
|
+
|
21
|
+
(Sorry about the plaintext credentials. Talk to Heroku about that!)
|
22
|
+
|
23
|
+
You will also want to setup a special ssh-config for each account in your ~/.ssh/config file. You will need a section for each account, changing the Host param to match the name of your account.
|
24
|
+
|
25
|
+
Host personal.heroku.com
|
26
|
+
HostName heroku.com
|
27
|
+
User git
|
28
|
+
IdentityFile ~/.ssh/path/to/personal/account/private_key.identity
|
29
|
+
IdentitiesOnly yes
|
30
|
+
|
31
|
+
Last, you will need to remember to use "account".heroku.com when adding heroku remotes. i.e.:
|
32
|
+
|
33
|
+
$ git remote add heroku git@personal.heroku.com:MyApp.git
|
34
|
+
|
35
|
+
|
36
|
+
== INSTALL:
|
37
|
+
|
38
|
+
The <code>heroswitch</code> application is distributed as a RubyGem and is available immediately after installation.
|
39
|
+
|
40
|
+
sudo gem install heroswitch
|
41
|
+
|
42
|
+
Alternately, download the gem and install manually.
|
43
|
+
|
44
|
+
== USAGE
|
45
|
+
|
46
|
+
Print your current credentials to the screen
|
47
|
+
$ heroswitch
|
48
|
+
|
49
|
+
Show a list of the accounts for which you've setup credentials
|
50
|
+
$ heroswitch -l
|
51
|
+
|
52
|
+
Switch to a different account profile
|
53
|
+
$ heroswitch personal
|
54
|
+
|
55
|
+
== LICENSE:
|
56
|
+
|
57
|
+
(The MIT License)
|
58
|
+
|
59
|
+
Copyright (c) 2010 John Ford
|
60
|
+
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
62
|
+
a copy of this software and associated documentation files (the
|
63
|
+
'Software'), to deal in the Software without restriction, including
|
64
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
65
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
66
|
+
permit persons to whom the Software is furnished to do so, subject to
|
67
|
+
the following conditions:
|
68
|
+
|
69
|
+
The above copyright notice and this permission notice shall be
|
70
|
+
included in all copies or substantial portions of the Software.
|
71
|
+
|
72
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
73
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
74
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
75
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
76
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
77
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
78
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rake' ; FileList['tasks/*.rake'].each { |file| import file }
|
data/bin/heroswitch
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2010-8-24.
|
4
|
+
# Copyright (c) 2010. All rights reserved.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/heroswitch")
|
8
|
+
require "heroswitch/cli"
|
9
|
+
|
10
|
+
Heroswitch::CLI.execute(STDOUT, ARGV)
|
data/heroswitch.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
spec = Gem::Specification.new do |s|
|
2
|
+
s.name = 'heroswitch'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.author = "John Ford"
|
5
|
+
s.email = "jwford@gmail.com"
|
6
|
+
s.summary = "Easily switch between multiple heroku accounts."
|
7
|
+
s.description = %{Switch between multiple Heroku accounts.}
|
8
|
+
s.files = Dir['lib/**/*.rb'] + Dir['test/**/*.rb'] + Dir['tasks/**/*.rb'] + %w[
|
9
|
+
PostInstall.txt
|
10
|
+
Rakefile
|
11
|
+
heroswitch.gemspec
|
12
|
+
README.rdoc
|
13
|
+
]
|
14
|
+
s.require_path = 'lib'
|
15
|
+
s.autorequire = 'heroswitch'
|
16
|
+
s.has_rdoc = false
|
17
|
+
s.homepage = "http://github.com/JohnFord/heroswitch"
|
18
|
+
s.executables = ['heroswitch']
|
19
|
+
end
|
data/lib/heroswitch.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Heroswitch
|
4
|
+
class CLI
|
5
|
+
def self.execute(stdout, arguments=[])
|
6
|
+
|
7
|
+
parser = OptionParser.new do |opts|
|
8
|
+
opts.banner = <<-BANNER.gsub(/^ /,'')
|
9
|
+
Switch easily between multiple heroku envinments.
|
10
|
+
|
11
|
+
Usage: #{File.basename($0)} [options] [account]
|
12
|
+
|
13
|
+
Omit the account name to show the current credentials.
|
14
|
+
|
15
|
+
Options are:
|
16
|
+
BANNER
|
17
|
+
opts.separator ""
|
18
|
+
#opts.on("-l", "--list", "List accounts and exit") { options[:list_credentials] = true }
|
19
|
+
opts.on("-l", "--list", "List accounts and exit") { Heroswitch::Credentials.list_credentials; exit }
|
20
|
+
opts.on("-h", "--help", "Show this help message.") { stdout.puts opts; exit }
|
21
|
+
opts.parse!(arguments)
|
22
|
+
opts.banner = <<-BANNER.gsub(/^ /,'')
|
23
|
+
Manage multiple Heroku accounts
|
24
|
+
|
25
|
+
Usage: #{File.basename($0)} [options] [account]
|
26
|
+
|
27
|
+
Options are:
|
28
|
+
BANNER
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
account = ARGV[0]
|
33
|
+
|
34
|
+
if account
|
35
|
+
Heroswitch::Credentials.switch account
|
36
|
+
else
|
37
|
+
Heroswitch::Credentials.show_credentials
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "ftools"
|
2
|
+
module Heroswitch
|
3
|
+
class Credentials
|
4
|
+
HEROKU_HOME = File.join ENV["HOME"], ".heroku"
|
5
|
+
CREDENTIALS_FILE = "credentials"
|
6
|
+
|
7
|
+
def self.show_credentials
|
8
|
+
credentials_path = File.join HEROKU_HOME, CREDENTIALS_FILE
|
9
|
+
if File.exists? credentials_path
|
10
|
+
credentials = `cat #{credentials_path}`.split "\n"
|
11
|
+
puts "\nYour active Heroku credentials are:\n\n"
|
12
|
+
puts credentials.first
|
13
|
+
puts '*' * credentials.last.size
|
14
|
+
puts "\n"
|
15
|
+
else
|
16
|
+
puts "ERROR: Heroku credentials not found!"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.list_credentials
|
21
|
+
puts "\nYou have credentials files for the following accounts in\n"
|
22
|
+
puts "#{HEROKU_HOME}\n\n"
|
23
|
+
Dir[HEROKU_HOME+"/*."+CREDENTIALS_FILE].each do |file|
|
24
|
+
puts " #{(File.basename file).gsub(/\.#{CREDENTIALS_FILE}/, "")}"
|
25
|
+
end
|
26
|
+
puts "\n"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.switch(account)
|
30
|
+
account_path = File.join HEROKU_HOME, account + '.' + CREDENTIALS_FILE
|
31
|
+
credentials_path = File.join HEROKU_HOME, CREDENTIALS_FILE
|
32
|
+
puts "\nSwitching to the \"#{account}\" Heroku account..."
|
33
|
+
if File.exists? account_path
|
34
|
+
File.copy(account_path, credentials_path)
|
35
|
+
print_reminder account
|
36
|
+
else
|
37
|
+
puts "ERROR: Heroku account credentials do not exist!"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.print_reminder(account)
|
42
|
+
puts <<-OUT.gsub(/^ /,'')
|
43
|
+
|
44
|
+
\033[31mRemember to add an entry in your ~/.ssh/config file like:\033[0m
|
45
|
+
Host \033[33m#{account}\033[0m.heroku.com
|
46
|
+
HostName heroku.com
|
47
|
+
User git
|
48
|
+
IdentityFile ~/.ssh/path/to/#{account}/account/private_key.identity
|
49
|
+
IdentitiesOnly yes
|
50
|
+
|
51
|
+
\033[31mAlso, use \033[33m#{account}.heroku.com\033[31m when setting up your heroku remote in git:\033[0m
|
52
|
+
$ git remote add heroku git@\033[33m#{account}.heroku.com\033[0m:MyApp.git
|
53
|
+
|
54
|
+
OUT
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
2
|
+
require 'heroswitch/cli'
|
3
|
+
|
4
|
+
class TestHeroswitchCli < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Heroswitch::CLI.execute(@stdout_io = StringIO.new, [])
|
7
|
+
@stdout_io.rewind
|
8
|
+
@stdout = @stdout_io.read
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_truth
|
12
|
+
assert true
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroswitch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- John Ford
|
14
|
+
autorequire: heroswitch
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-25 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Switch between multiple Heroku accounts.
|
23
|
+
email: jwford@gmail.com
|
24
|
+
executables:
|
25
|
+
- heroswitch
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/heroswitch/cli.rb
|
32
|
+
- lib/heroswitch/credentials.rb
|
33
|
+
- lib/heroswitch.rb
|
34
|
+
- test/test_helper.rb
|
35
|
+
- test/test_heroswitch.rb
|
36
|
+
- test/test_heroswitch_cli.rb
|
37
|
+
- PostInstall.txt
|
38
|
+
- Rakefile
|
39
|
+
- heroswitch.gemspec
|
40
|
+
- README.rdoc
|
41
|
+
- bin/heroswitch
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://github.com/JohnFord/heroswitch
|
44
|
+
licenses: []
|
45
|
+
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project:
|
72
|
+
rubygems_version: 1.3.7
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Easily switch between multiple heroku accounts.
|
76
|
+
test_files: []
|
77
|
+
|