hak 0.1.2

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 (5) hide show
  1. checksums.yaml +7 -0
  2. data/bin/hak +157 -0
  3. data/lib/hak/version.rb +3 -0
  4. data/lib/hak.rb +7 -0
  5. metadata +63 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b356190ba61bd76cbc3669b9e1b784501094d50c
4
+ data.tar.gz: 86fea509dcdd34d6c9acdca09a611afcf2499266
5
+ SHA512:
6
+ metadata.gz: 90afc3220af9094d43e676cfe250a2769ba705ba88f8a9b8d8bc3683cd6c09ba0f9312dcb677a7eacc77bd431d5f3005f221dacbee3e1a1516ab0ba5f1eec93f
7
+ data.tar.gz: 97264daeb64493dcad58d061861bb6bebdfbdeb625bc3aaf21792e235889538478deecd19d78d6a63fc094a05ca4584faad89036a43a7f61c217afdf3609f2b1
data/bin/hak ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+
6
+ program :name, 'hakberry'
7
+ program :version, '0.1.2'
8
+ program :description, 'A site deployment tool using Vagrant and Docker'
9
+
10
+ default_command :help
11
+
12
+ command :create do |c|
13
+ c.syntax = 'hak create site.com'
14
+ c.summary = 'creates hakberry site'
15
+ c.description = ''
16
+ c.example 'description', 'hak create site.com'
17
+ c.action do |args, options|
18
+ app = args[0]
19
+ exec "cp -Rfp ~/.hak/site.com ./#{app}"
20
+ end
21
+ end
22
+
23
+ command :on do |c|
24
+ c.syntax = 'hak on'
25
+ c.summary = 'powers on the hakbery server'
26
+ c.description = 'sets up the entire docker based environment along with proxy'
27
+ c.example 'description', 'hak on'
28
+ c.action do |args, options|
29
+
30
+ # if ~/.hak not exists, initialize it
31
+ if !Dir.exists?(File.expand_path('~/.hak'))
32
+ exec "mkdir ~/.hak && cd ~/.hak && mkdir tmp && cd tmp && wget https://github.com/jaequery/hakberry/archive/master.zip && unzip master.zip && mv hakberry-master/.server/* ~/.hak && cd ~/.hak && rm -rf tmp && vagrant up"
33
+ else
34
+ exec "cd ~/.hak && vagrant up"
35
+ end
36
+ end
37
+ end
38
+
39
+ command :off do |c|
40
+ c.syntax = 'hak off'
41
+ c.summary = 'shuts off hakberry server'
42
+ c.description = 'shuts off the hakberry server'
43
+ c.example 'description', 'hak off'
44
+ c.action do |args, options|
45
+ exec "cd ~/.hak && vagrant halt"
46
+ end
47
+ end
48
+
49
+ command :destroy do |c|
50
+ c.syntax = 'hak destroy'
51
+ c.summary = 'destroys hakberry server'
52
+ c.description = 'destroys the hakberry server'
53
+ c.example 'description', 'hak destroy'
54
+ c.action do |args, options|
55
+ exec "cd ~/.hak && vagrant destroy"
56
+ end
57
+ end
58
+
59
+ command :start do |c|
60
+ c.syntax = 'hak start [options]'
61
+ c.summary = 'starts site'
62
+ c.description = 'this starts the website'
63
+ c.example 'description', 'hak start site.com'
64
+ c.action do |args, options|
65
+ if args.empty?
66
+ puts "usage: hak start site.com"
67
+ else
68
+ app = args[0]
69
+ app_path = '/hakberry' + File.expand_path(Dir.pwd).split(File.expand_path('~/'))[1].to_s + '/' + app
70
+ puts app_path
71
+ vhosts = ["www.#{app}", "#{app}", "#{app}.hakberry.com"].join(',')
72
+ exec "cd ~/.hak && vagrant ssh -c 'cd #{app_path} && export VHOSTS=\"#{vhosts}\" && docker-compose up -d' && vagrant ssh -c 'cd #{app_path} && docker-compose logs'"
73
+ end
74
+ end
75
+ end
76
+
77
+ command :stop do |c|
78
+ c.syntax = 'hak stop [options]'
79
+ c.summary = 'stops site'
80
+ c.description = 'stops the site'
81
+ c.example 'description', 'hak stop site.com'
82
+ c.action do |args, options|
83
+ if args.empty?
84
+ puts "usage: hak stop site.com"
85
+ else
86
+ app = args[0]
87
+ app_path = '/hakberry' + File.expand_path(Dir.pwd).split(File.expand_path('~/'))[1].to_s + '/' + app
88
+ vhosts = ["www.#{app}", "#{app}", "#{app}.hakberry.com"].join(',')
89
+ exec "cd ~/.hak && vagrant ssh -c 'cd #{app_path} && export VHOSTS=\"#{vhosts}\" && docker-compose stop'"
90
+ end
91
+ end
92
+ end
93
+
94
+ command :logs do |c|
95
+ c.syntax = 'hak logs [options]'
96
+ c.summary = 'shows the application logs'
97
+ c.description = ''
98
+ c.example 'description', 'hak logs site.com'
99
+ c.action do |args, options|
100
+ if args.empty?
101
+ puts "usage: hak logs site.com"
102
+ else
103
+ app = args[0]
104
+ app_path = '/hakberry' + File.expand_path(Dir.pwd).split(File.expand_path('~/'))[1].to_s + '/' + app
105
+ exec "cd ~/.hak && vagrant ssh -c 'cd #{app_path} && docker-compose logs'"
106
+ end
107
+ end
108
+ end
109
+
110
+ command :console do |c|
111
+ c.syntax = 'hak console [options]'
112
+ c.summary = 'shows the application console'
113
+ c.description = ''
114
+ c.example 'description', 'hak console site.com'
115
+ c.action do |args, options|
116
+ if args.empty?
117
+ puts "usage: hak console site.com"
118
+ else
119
+ app = args[0]
120
+ app_path = '/hakberry' + File.expand_path(Dir.pwd).split(File.expand_path('~/'))[1].to_s + '/' + app
121
+ exec "cd ~/.hak && vagrant ssh -c 'cd #{app_path} && bin/docker/run.sh \"padrino console\" '"
122
+ end
123
+ end
124
+ end
125
+
126
+ command :ssh do |c|
127
+ c.syntax = 'hak ssh [options]'
128
+ c.summary = 'ssh into the application environment'
129
+ c.description = ''
130
+ c.example 'description', 'hak ssh site.com'
131
+ c.action do |args, options|
132
+ if args.empty?
133
+ puts "usage: hak ssh site.com"
134
+ else
135
+ app = args[0]
136
+ app_path = '/hakberry' + File.expand_path(Dir.pwd).split(File.expand_path('~/'))[1].to_s + '/' + app
137
+ exec "cd ~/.hak && vagrant ssh -c 'cd #{app_path} && bin/docker/run.sh \"bash\"'"
138
+ end
139
+ end
140
+ end
141
+
142
+ command :run do |c|
143
+ c.syntax = 'hak run [options]'
144
+ c.summary = 'runs command inside application environment'
145
+ c.description = ''
146
+ c.example 'description', "hak run site.com 'ls -lnha'"
147
+ c.action do |args, options|
148
+ if args.empty?
149
+ puts "usage: hak run site.com 'cd / && ls -lnha'"
150
+ else
151
+ app = args[0]
152
+ cmds = args[1]
153
+ app_path = '/hakberry' + File.expand_path(Dir.pwd).split(File.expand_path('~/'))[1].to_s + '/' + app
154
+ exec "cd ~/.hak && vagrant ssh -c 'cd #{app_path} && bin/docker/run.sh \"#{cmds}\"'"
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,3 @@
1
+ module Hak
2
+ VERSION = "0.1.2"
3
+ end
data/lib/hak.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "hak/version"
2
+ require 'rubygems'
3
+ require 'commander/import'
4
+
5
+ module Hak
6
+
7
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hak
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - jaequery
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.4'
27
+ description: Hak is like NPM for websites. You can download, start, and deploy websites
28
+ directly from the CLI.
29
+ email:
30
+ - jaequery@gmail.com
31
+ executables:
32
+ - hak
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - bin/hak
37
+ - lib/hak.rb
38
+ - lib/hak/version.rb
39
+ homepage: http://hakberry.com
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.4.6
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Hak is NPM for websites
63
+ test_files: []