dokkufy 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50b47f06de94cfecf2237ed3dcdb4a36e40af05a
4
- data.tar.gz: 4b15258dc926085290f93c3be7f729e6f492f9b3
3
+ metadata.gz: 04789fa5bbd4f59f47a969ef3a5ddb13a64c221b
4
+ data.tar.gz: 961bff96b825c09fdcd7cbef8b022cbe6b32bf0d
5
5
  SHA512:
6
- metadata.gz: 3bf673633db7acd72c29ab4d3c1adb60da88a74849ebea71ac424e0112076d95968c289109c7a8bbc75adeeb67d925064cceb946f0457da3fd21023027a5992f
7
- data.tar.gz: 89453ba7ebf8650bd13cbb0429816cdd2b7c8cf3697addc222282529058fcbacc5cd8f2c3e497a2ec7256bcc934b617ad5d85fea2751264e8ccd767f55d109c5
6
+ metadata.gz: 13dcbb9bd528df50311a78f217aafde4febcf5c337df9c0de1e9aa832edebfdfdbfd71d7b97b86cd07b072d420ccf23f7bcd7f8582f4aabb20ff5cfbcb184176
7
+ data.tar.gz: 0902c6fc1876b6614362d005b29c7126963b3334297198abe55b3f62a577c5493f6e0c4b855057548888a0e81346bcac37cd031194019e0bd4a75ec121d5879e
data/README.md CHANGED
@@ -4,7 +4,7 @@ A [Dokku](https://github.com/progrium/dokku) toolbelt inspired by the [Heroku to
4
4
 
5
5
  ## Planned commands
6
6
 
7
- ```sh
7
+ ```
8
8
  dokkufy <command>
9
9
  help shows this list
10
10
  server installs Dokku on a Ubuntu 12.04 or 14.04 server
@@ -13,6 +13,7 @@ dokkufy <command>
13
13
  plugin:install installs a plugin on the server
14
14
  plugin:uninstall uninstalls a plugin on the server
15
15
  app adds a dokku remote for a server to an app
16
+ app:clear removes a dokku remote for a server for an app
16
17
 
17
18
  dokku <command> runs dokku commands on the server attached to this app
18
19
  ```
@@ -57,8 +58,25 @@ dokkufy plugin:uninstall <plugin_name_or_id> [<hostname> <username>]
57
58
 
58
59
  Uninstalls a Dokku plugin either by name or ID (as received by `dokkufy plugin:list`) on a server. Simply performs a delete of the folder. Server instances already deployed with this plugin will need to be redeployed.
59
60
 
61
+ ### dokkufy app
62
+
63
+ ```sh
64
+ dokkufy app <git_repo> [OR <hostname> <dokku_username>]
65
+ ```
66
+
67
+ Adds a dokku remote to the local git repository for an app. Also writes this remote to a `.dokkurc` file.
68
+
69
+ ### dokkufy app:clear
70
+
71
+ ```sh
72
+ dokkufy app:clear
73
+ ```
74
+
75
+ Removes any `dokku` remotes for the local git repository and deletes the `.dokkurc` file.
76
+
60
77
  ## Release notes
61
78
 
79
+ * **0.0.7** Adds the (un)dokkufication of apps
62
80
  * **0.0.6** Adds plugin uninstall
63
81
  * **0.0.5** Small bug fix to plugin installs
64
82
  * **0.0.4** Adds plugin listing and installing
data/bin/dokkufy CHANGED
@@ -55,5 +55,32 @@ Commander.configure do
55
55
  end
56
56
  end
57
57
 
58
+ command :'app' do |c|
59
+ c.syntax = 'dokkufy app <git_repo> [OR <hostname> <dokku_username>]'
60
+ c.description = "Binds this app to a Dokku instance through git and a config file"
61
+ c.action do |args, options|
62
+ if args.empty?
63
+ git = Dokkufy::Git.new
64
+ if git.dokku_remote_present?
65
+ args = [git.dokku_remote]
66
+ else
67
+ hostname = ask('Server hostname or IP: ')
68
+ username = ask('Dokku username on server [dokku]: ')
69
+ username = "dokku" if username.strip == ""
70
+ args = [hostname, username]
71
+ end
72
+ end
73
+ Dokkufy::App.new(args).dokkufy
74
+ end
75
+ end
76
+
77
+ command :'app:clear' do |c|
78
+ c.syntax = 'dokkufy app:clear'
79
+ c.description = "Undokkufies this app"
80
+ c.action do |args, options|
81
+ Dokkufy::Git.new.clear
82
+ end
83
+ end
84
+
58
85
  default_command :help
59
86
  end
@@ -0,0 +1,28 @@
1
+ module Dokkufy
2
+ class App
3
+
4
+ attr_accessor :hostname, :username, :repo, :app_name
5
+
6
+ def initialize args
7
+ if args.length == 1
8
+ self.repo = args.first
9
+ self.username = args.first.split("@").first
10
+ self.hostname = args.first.split("@").last.split(":").first
11
+ self.app_name = args.first.split("@").last.split(":").last
12
+ elsif args.length == 2
13
+ self.hostname = args.first
14
+ self.username = args.last
15
+ self.app_name = File.basename(Dir.getwd)
16
+ self.repo = "#{username}@#{hostname}:#{app_name}"
17
+ else
18
+ raise ArgumentError("Invalid number of arguments")
19
+ end
20
+ end
21
+
22
+ def dokkufy
23
+ puts "Using #{repo}"
24
+ Dokkufy::Git.new.dokku_remote = repo
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,51 @@
1
+ module Dokkufy
2
+ class Git
3
+
4
+ def dokku_remote_present?
5
+ !dokku_remote.nil?
6
+ end
7
+
8
+ def dokku_remote
9
+ @dokku_remote ||= git_remote || dokkufile_remote
10
+ end
11
+
12
+ def dokku_remote=(remote)
13
+ @dokku_remote = remote
14
+ set_git_remote
15
+ set_dokkufile_remote
16
+ end
17
+
18
+ def clear
19
+ `rm .dokkurc`
20
+ `git remote remove dokku`
21
+ end
22
+
23
+ private
24
+
25
+ def git_remote
26
+ output = `git remote -v`
27
+ output.lines.each do |line|
28
+ return line.split(" ")[1] if line.include?("dokku@")
29
+ end
30
+ nil
31
+ end
32
+
33
+ def dokkufile_remote
34
+ output = File.open(".dokkurc").read
35
+ return output.strip unless output.empty?
36
+ rescue
37
+ nil
38
+ end
39
+
40
+ def set_git_remote
41
+ puts "Setting git remote"
42
+ `git remote add dokku #{@dokku_remote}`
43
+ end
44
+
45
+ def set_dokkufile_remote
46
+ puts "Writing .dokkurc"
47
+ `echo #{@dokku_remote} > .dokkurc`
48
+ end
49
+
50
+ end
51
+ end
data/lib/dokkufy/info.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Dokkufy
2
- VERSION = "0.0.6" unless defined? Dokkufy::VERSION
2
+ VERSION = "0.0.7" unless defined? Dokkufy::VERSION
3
3
  NAME = "dokkufy" unless defined? Dokkufy::NAME
4
4
  DESCRIPTION = "A Dokku toolchain" unless defined? Dokkufy::DESCRIPTION
5
5
  end
data/lib/dokkufy.rb CHANGED
@@ -1,7 +1,9 @@
1
- require "dokkufy/info"
2
- require "dokkufy/utils"
3
- require "dokkufy/server"
4
- require "dokkufy/plugin"
1
+ require 'dokkufy/info'
2
+ require 'dokkufy/utils'
3
+ require 'dokkufy/server'
4
+ require 'dokkufy/plugin'
5
+ require 'dokkufy/app'
6
+ require 'dokkufy/git'
5
7
 
6
8
  module Dokkufy
7
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dokkufy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristiano Betta
@@ -69,6 +69,8 @@ files:
69
69
  - bin/dokkufy
70
70
  - dokkufy.gemspec
71
71
  - lib/dokkufy.rb
72
+ - lib/dokkufy/app.rb
73
+ - lib/dokkufy/git.rb
72
74
  - lib/dokkufy/info.rb
73
75
  - lib/dokkufy/plugin.rb
74
76
  - lib/dokkufy/server.rb