appli 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/appli.rb +1 -1
- data/lib/commands/apps.rb +57 -0
- data/lib/commands/cap.rb +2 -5
- data/lib/commands/system.rb +0 -13
- metadata +2 -1
data/lib/appli.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
desc 'Display a list of all applications which you have access to'
|
2
|
+
usage "appli apps"
|
3
|
+
command "apps", :global => true do
|
4
|
+
apps = get("applications")
|
5
|
+
|
6
|
+
hash = [[:name, "Name", 30], [:identifier , "Identifier", 30], [:ssh_port, "SSH Port", 12], [:host, "Host", 30]]
|
7
|
+
total = hash.inject(0) {|e,r| e + r.last}
|
8
|
+
puts "-" * total
|
9
|
+
for item in hash
|
10
|
+
key, value, chars = item
|
11
|
+
print value.to_s.ljust(chars)
|
12
|
+
end
|
13
|
+
puts
|
14
|
+
puts "-" * total
|
15
|
+
for app in apps.sort_by {|a| a['application']['name'].upcase }
|
16
|
+
for item in hash
|
17
|
+
key, value, chars = item
|
18
|
+
data = case key
|
19
|
+
when :host then app['application']['host']['name']
|
20
|
+
else
|
21
|
+
app['application'][key.to_s].to_s
|
22
|
+
end
|
23
|
+
print data.ljust(chars)
|
24
|
+
end
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
puts "-" * total
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Create a new application with the provided identifier"
|
31
|
+
usage "appli create {identifier}"
|
32
|
+
command "create", :global => true do |identifier|
|
33
|
+
puts "Creating new application with identifier '#{identifier}'. Please wait - this may take a few minutes."
|
34
|
+
result = api('applications', {:application => {:identifier => identifier, :name => identifier}}.to_json)
|
35
|
+
if errors
|
36
|
+
puts "\nAn error occured while creating your application:"
|
37
|
+
for e in JSON.parse(errors)
|
38
|
+
puts " * #{e.join(' ')}"
|
39
|
+
end
|
40
|
+
puts
|
41
|
+
Process.exit(1)
|
42
|
+
else
|
43
|
+
application = JSON.parse(result)['application']
|
44
|
+
puts "\n\e[44;37mApplication has been built successfully and is now running on '#{application['host'] ? application['host']['name'] : 'unknown host'}'.\e[0m"
|
45
|
+
puts
|
46
|
+
puts "You can now use a number of commands to work with your application, see documentation at www.applihq.com for"
|
47
|
+
puts "full details. You can also manage the application using your web browser at the domain above."
|
48
|
+
puts
|
49
|
+
puts "You may be looking for one of the following commands:"
|
50
|
+
puts
|
51
|
+
puts " * appli #{identifier} ssh"
|
52
|
+
puts " * appli #{identifier} db:import"
|
53
|
+
puts " * appli #{identifier} db:console"
|
54
|
+
puts " * appli #{identifier} capify config/deploy.rb"
|
55
|
+
puts
|
56
|
+
end
|
57
|
+
end
|
data/lib/commands/cap.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
desc 'Generates a pre-configured capistrano deployment recipe.'
|
2
|
-
desc 'This file is then copied into config/deploy.rb unless a file already exists. This will'
|
3
|
-
desc 'only function if you are in the root of an application with a \'Capify\' file already'
|
4
|
-
desc 'generated.'
|
5
2
|
usage "appli [application] capify {export path}"
|
6
3
|
command "capify", :required_args => 1 do |file|
|
7
|
-
|
8
|
-
File.open(file, 'w') {|f| f.write(
|
4
|
+
contents = get("applications/#{@options[:application]}/capistrano")['config']
|
5
|
+
File.open(file, 'w') {|f| f.write(contents) }
|
9
6
|
puts "Generated capistrano deployment receipe at '#{file}'."
|
10
7
|
puts
|
11
8
|
puts "You should now edit this file to include the path to your repository. Along with any additional"
|
data/lib/commands/system.rb
CHANGED
@@ -36,17 +36,4 @@ desc 'SSH to the named server'
|
|
36
36
|
usage "appli [application] ssh"
|
37
37
|
command "ssh" do
|
38
38
|
exec "ssh -p #{application['ssh_port']} app@#{host['name']}"
|
39
|
-
end
|
40
|
-
|
41
|
-
desc 'Create a MySQL console connection for your first database'
|
42
|
-
usage "appli [application] mysql"
|
43
|
-
command "mysql" do
|
44
|
-
database = get("applications/#{@options[:application]}/databases").first
|
45
|
-
if database
|
46
|
-
database = database['database']
|
47
|
-
puts "Connecting to database '#{database['name']}' on '#{database['host']['name']}'"
|
48
|
-
exec("ssh -t -p #{application['ssh_port']} app@#{host['name']} mysql -u #{database['username']} -p#{database['password']} -h #{database['host']['name']} #{database['name']}")
|
49
|
-
else
|
50
|
-
error("No database was not found for this application.")
|
51
|
-
end
|
52
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- bin/appli
|
35
35
|
- lib/appli/command.rb
|
36
36
|
- lib/appli.rb
|
37
|
+
- lib/commands/apps.rb
|
37
38
|
- lib/commands/cap.rb
|
38
39
|
- lib/commands/gems.rb
|
39
40
|
- lib/commands/mysql.rb
|