hak 0.3.6 → 0.3.7

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hak +45 -13
  3. data/lib/hak/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3706b3e79dbd722ce1f04144949576281440acca
4
- data.tar.gz: 409a2d706a48e55aefa5959e7f923b6869040069
3
+ metadata.gz: 8fa4f3e8c13734a9fd62d935ac3239a5c69b0930
4
+ data.tar.gz: 45e61a65496a632201fe8ee9e2bd13a1364cdb97
5
5
  SHA512:
6
- metadata.gz: 65d16b2f51a1dd05f6c64f92127798f2c18512fa12dbeb4865a3226c07617af773a4f7bdf5c216fcaa57a992539489e53e7badc277b79273ce01cfd52d8ebf8e
7
- data.tar.gz: dcfd3573127ff50b72f5d96c75ae74c00c64c8762a6df14cad064c36f3448a7b9a913e40053d547af2ec90159e2c47db9789d83b914bbba72aa1d47cd8ba429d
6
+ metadata.gz: 4d5685322c8338b1351baf0af0be46f3ff38f2e2c7fb3547ae9140fa56d7da43f136bd19d77baf4bbfff4255dab5789aec79b464079646da53a807d2629d454a
7
+ data.tar.gz: c56b8b8db7895e0e6905f39c44e52e5b279eb814d334129745d8a722018b325ed1e13520664e0679ba97c9391695bfa5ba5876a5a30c65229f4706133fd63cf6
data/bin/hak CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
6
6
  require 'pp'
7
7
 
8
8
  program :name, 'hakberry'
9
- program :version, '0.3.6'
9
+ program :version, '0.3.7'
10
10
  program :description, 'Hak - start hacking!'
11
11
 
12
12
  default_command :help
@@ -42,7 +42,7 @@ command :create do |c|
42
42
  c.summary = 'creates site'
43
43
  c.description = ''
44
44
  c.example 'description', 'hak create something.com'
45
- c.action do |args, options|
45
+ c.action do |args, options|
46
46
 
47
47
  if args.empty?
48
48
  puts "ex: hak create something"
@@ -67,7 +67,7 @@ command :create do |c|
67
67
  system "cp -Rfp ~/.hak/#{repo} #{folder}"
68
68
 
69
69
  # rename virtual host to app name
70
- file_path = "#{folder}/docker-compose.yml"
70
+ file_path = "#{folder}/docker-compose.yml"
71
71
  file = File.open(file_path, "r+")
72
72
  content = file.read
73
73
  host = "#{folder}.docker"
@@ -94,7 +94,7 @@ command :on do |c|
94
94
  # if ~/.hak not exists, initialize it
95
95
  if !Dir.exists?(File.expand_path('~/.hak'))
96
96
  system "mkdir -p ~/.hak/packages"
97
- end
97
+ end
98
98
 
99
99
  # if ~/.dinghy not exists, initialize it
100
100
  if !Dir.exists?(File.expand_path('~/.dinghy'))
@@ -109,14 +109,14 @@ command :on do |c|
109
109
  system "sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve"
110
110
  system "sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve"
111
111
  system "dinghy create --provider xhyve"
112
-
113
-
112
+
113
+
114
114
  end
115
115
 
116
116
  system "eval $(dinghy env)"
117
117
 
118
118
  # start up
119
- system "dinghy up"
119
+ system "dinghy up"
120
120
  end
121
121
  end
122
122
 
@@ -149,7 +149,7 @@ command :up do |c|
149
149
  c.description = 'this starts up the website'
150
150
  c.example 'description', 'hak up'
151
151
  c.action do |args, options|
152
- system "docker-compose up -d && docker-compose logs"
152
+ h_com "docker-compose up -d && docker-compose logs"
153
153
  end
154
154
  end
155
155
 
@@ -159,7 +159,7 @@ command :down do |c|
159
159
  c.description = 'turns the site down'
160
160
  c.example 'description', 'hak down'
161
161
  c.action do |args, options|
162
- system "docker-compose stop"
162
+ h_com "docker-compose stop"
163
163
  end
164
164
  end
165
165
 
@@ -169,12 +169,12 @@ command :logs do |c|
169
169
  c.description = ''
170
170
  c.example 'description', 'hak logs'
171
171
  c.action do |args, options|
172
- system "docker-compose logs"
172
+ h_com "docker-compose logs"
173
173
  end
174
174
  end
175
175
 
176
176
  command :ssh do |c|
177
-
177
+
178
178
  c.syntax = 'hak ssh'
179
179
  c.summary = 'ssh to your app'
180
180
  c.description = ''
@@ -195,9 +195,41 @@ command :ssh do |c|
195
195
  #app = apps[0]
196
196
  else
197
197
  app = args[0]
198
- system "docker-compose run #{app} bash"
198
+ h_com "docker-compose run #{app} bash"
199
+ end
200
+
201
+ end
202
+
203
+ end
204
+
205
+ command :ps do |c|
206
+ c.syntax = 'hak ps'
207
+ c.summary = 'lists your running websites'
208
+ c.description = ''
209
+ c.example 'description', 'hak ps'
210
+ c.action do |args, options|
211
+ container_names = h_com('docker ps --format "{{.Names}}"', true)
212
+ lines = container_names.lines
213
+ sites = lines.map do | line |
214
+ line.split('_')[0]
199
215
  end
200
-
216
+
217
+ sites.shift
218
+
219
+ puts "Running websites"
220
+ puts sites.uniq
221
+ end
222
+ end
223
+
224
+
225
+ def h_com(command, hide=false)
226
+ exec = "eval $(dinghy env) && #{command}"
227
+
228
+ if hide
229
+ res = `#{exec}`
230
+ else
231
+ res = system exec
201
232
  end
202
233
 
234
+ return res
203
235
  end
data/lib/hak/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hak
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jaequery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander