powder 0.1.6 → 0.1.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.
- data/CHANGELOG.md +13 -2
- data/Readme.md +36 -10
- data/bin/powder +156 -19
- data/lib/powder/version.rb +1 -1
- metadata +4 -20
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
-
###
|
1
|
+
### 0.1.7 ###
|
2
2
|
|
3
3
|
* 1 minor change
|
4
|
+
|
5
|
+
* adds proper support for alt names
|
6
|
+
([commit](https://github.com/Rodreegez/powder/commit/4b850b1dbb446f7d0c3a643d4cc7be99eebd417b))
|
7
|
+
* adds not_restarts command
|
8
|
+
([commit](https://github.com/Rodreegez/powder/commit/9371ccdf822a83db7f1fded365d01bd2c613aed3))
|
9
|
+
* adds always_restart command
|
10
|
+
([commit](https://github.com/Rodreegez/powder/commit/45bd64180930353ef6c45626ccae150091374828))
|
11
|
+
* pow down properly unloads pow processes
|
12
|
+
([commit](https://github.com/Rodreegez/powder/commit/a6373e73c746587eb1ae23aaa1a26fe331274e6d))
|
13
|
+
* adds host/unhost for dealing with no network
|
14
|
+
([commit](https://github.com/Rodreegez/powder/commit/547c3d1e2fbc155fea3c162a373fed017a739107))
|
4
15
|
* Don't break config/status when pow is down
|
5
|
-
([commit](https://github.com/Rodreegez/powder/commit/c3aa98943c51079e2e8a1dc0a983efe76e2964c7))
|
16
|
+
([commit](https://github.com/Rodreegez/powder/commit/c3aa98943c51079e2e8a1dc0a983efe76e2964c7))
|
6
17
|
|
7
18
|
### 0.1.5 / 2011-06-30 ###
|
8
19
|
|
data/Readme.md
CHANGED
@@ -9,21 +9,40 @@ powder manages [pow](http://pow.cx/)
|
|
9
9
|
|
10
10
|
### Linking apps in Pow ###
|
11
11
|
|
12
|
-
|
13
|
-
=> Link the current dir_name to ~/.pow/dir-name
|
14
|
-
# if the dir_name has underscores in, powder changes them to hyphens
|
12
|
+
powder will attempt to read .powder, which names a default symlink for the current project
|
15
13
|
|
16
|
-
$ powder
|
14
|
+
$ powder [-h|help]
|
15
|
+
=> Display usage information
|
16
|
+
# Lists name and brief descriptions of the tasks available
|
17
|
+
|
18
|
+
$ powder link
|
19
|
+
=> Link the current dir to ~/.pow/<current_directory>
|
20
|
+
|
21
|
+
$ powder link [bacon]
|
22
|
+
=> Link the current dir to ~/.pow/bacon
|
23
|
+
=> Create .powder, contents bacon
|
24
|
+
|
25
|
+
$ powder link [bacon] --no-create
|
26
|
+
=> Link the current dir to ~/.pow/bacon
|
27
|
+
|
28
|
+
$ powder link [bacon] --force
|
29
|
+
=> Remove the current pow symlink, and .powder
|
17
30
|
=> Link the current dir to ~/.pow/bacon
|
18
|
-
|
19
|
-
|
31
|
+
=> Create .powder, contents bacon
|
32
|
+
|
33
|
+
# For both forms of link, if the current directory doesn't
|
34
|
+
# look like an app that can be powed it will offer to download
|
35
|
+
# a basic config.ru for Rails 2
|
20
36
|
|
21
|
-
$ powder
|
22
|
-
=> Unlink current_dir
|
37
|
+
$ powder unlink
|
38
|
+
=> Unlink current_dir or the symlink defined in .powder
|
23
39
|
|
24
|
-
$ powder
|
40
|
+
$ powder unlink bacon
|
25
41
|
=> Unlink bacon
|
26
42
|
|
43
|
+
$ powder cleanup
|
44
|
+
=> remove all invalid symbolic links
|
45
|
+
|
27
46
|
### Working with Pow ###
|
28
47
|
|
29
48
|
$ powder applog
|
@@ -45,7 +64,7 @@ powder manages [pow](http://pow.cx/)
|
|
45
64
|
=> Opens the pow link in a browser
|
46
65
|
# aliased as powder -o
|
47
66
|
|
48
|
-
$ powder open bacon
|
67
|
+
$ powder open [bacon]
|
49
68
|
=> Opens http://bacon.dev in a browser
|
50
69
|
# if you have set up alternative top level domains in .powconfig,
|
51
70
|
# then the first listed domain will be opened.
|
@@ -54,6 +73,13 @@ powder manages [pow](http://pow.cx/)
|
|
54
73
|
=> Restart the current app
|
55
74
|
# aliased as powder -r
|
56
75
|
|
76
|
+
$ powder always_restart
|
77
|
+
=> Always restart the current app
|
78
|
+
# aliased as powder -a
|
79
|
+
|
80
|
+
$ powder no_restarts
|
81
|
+
=> don't do any automatic restarting of the current app
|
82
|
+
|
57
83
|
$ powder status
|
58
84
|
=> Get Pow's current status information
|
59
85
|
|
data/bin/powder
CHANGED
@@ -9,15 +9,18 @@ require 'powder/version'
|
|
9
9
|
module Powder
|
10
10
|
class CLI < Thor
|
11
11
|
include Thor::Actions
|
12
|
-
default_task :
|
12
|
+
default_task :help
|
13
13
|
|
14
14
|
map '-r' => 'restart'
|
15
|
+
map '-a' => 'always_restart'
|
15
16
|
map '-l' => 'list'
|
16
17
|
map '-L' => 'link'
|
18
|
+
map '-d' => 'default'
|
17
19
|
map '-o' => 'open'
|
18
20
|
map '-v' => 'version'
|
19
21
|
map 'update' => 'install'
|
20
22
|
|
23
|
+
POWDER_CONFIG = ".powder"
|
21
24
|
POW_PATH = "#{ENV['HOME']}/.pow"
|
22
25
|
POW_DAEMON_PLIST_PATH="#{ENV['HOME']}/Library/LaunchAgents/cx.pow.powd.plist"
|
23
26
|
POW_FIREWALL_PLIST_PATH = "/Library/LaunchDaemons/cx.pow.firewall.plist"
|
@@ -25,39 +28,77 @@ module Powder
|
|
25
28
|
desc "up", "Enable pow"
|
26
29
|
def up
|
27
30
|
if File.exists? POW_FIREWALL_PLIST_PATH
|
28
|
-
%x{sudo launchctl load
|
31
|
+
%x{sudo launchctl load #{POW_FIREWALL_PLIST_PATH}}
|
29
32
|
else
|
30
33
|
say "Pow firewall configuration missing."
|
31
34
|
end
|
35
|
+
if File.exists? POW_DAEMON_PLIST_PATH
|
36
|
+
%x{launchctl load #{POW_DAEMON_PLIST_PATH}}
|
37
|
+
else
|
38
|
+
say "Pow daemon configuration missing."
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
desc "down", "Disable pow"
|
35
43
|
def down
|
36
44
|
if File.exists? POW_FIREWALL_PLIST_PATH
|
37
45
|
if not %x{sudo launchctl list | grep cx.pow.firewall}.empty?
|
38
|
-
%x{sudo launchctl unload
|
46
|
+
%x{sudo launchctl unload #{POW_FIREWALL_PLIST_PATH}}
|
39
47
|
end
|
40
48
|
if ports = File.open(POW_FIREWALL_PLIST_PATH).read.match(/fwd .*?,([\d]+).*?dst-port ([\d]+)/)
|
41
49
|
http_port, dst_port = ports[1..2]
|
42
50
|
end
|
43
51
|
end
|
44
|
-
|
52
|
+
|
53
|
+
if File.exists? POW_DAEMON_PLIST_PATH
|
54
|
+
%x{launchctl unload #{POW_DAEMON_PLIST_PATH}}
|
55
|
+
end
|
56
|
+
|
45
57
|
http_port ||= 20559
|
46
58
|
dst_port ||= 80
|
47
|
-
|
59
|
+
|
48
60
|
if rule = %x{sudo ipfw show | grep ",#{http_port} .* dst-port #{dst_port} in"}.split.first
|
49
61
|
%x{sudo ipfw delete #{rule} && sudo sysctl -w net.inet.ip.forwarding=0}
|
50
62
|
end
|
51
63
|
end
|
52
64
|
|
53
65
|
desc "link", "Link a pow"
|
66
|
+
method_option :force, :type => :boolean, :default => false, :alias => '-f', :desc => "remove the old configuration, overwrite .powder"
|
67
|
+
method_option :"no-config", :type => :boolean, :default => false, :alias => '-n', :desc => "do not write a .powder file"
|
54
68
|
def link(name=nil)
|
69
|
+
return unless is_powable?
|
70
|
+
if File.symlink?(POW_PATH)
|
71
|
+
current_path = %x{pwd}.chomp
|
72
|
+
if name
|
73
|
+
write_pow_config(name)
|
74
|
+
else
|
75
|
+
name = get_pow_name
|
76
|
+
end
|
77
|
+
symlink_path = "#{POW_PATH}/#{name}"
|
78
|
+
FileUtils.rm_f(symlink_path) if options[:force]
|
79
|
+
FileUtils.ln_s(current_path, symlink_path) unless File.exists?(symlink_path)
|
80
|
+
say "Your application is now available at http://#{name}.#{domain}/"
|
81
|
+
else
|
82
|
+
say "Pow is not installed."
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "default", "Set this app as default"
|
87
|
+
def default(name=nil)
|
55
88
|
return unless is_powable?
|
56
89
|
current_path = %x{pwd}.chomp
|
57
|
-
name ||=
|
58
|
-
symlink_path = "#{POW_PATH}
|
59
|
-
FileUtils.
|
60
|
-
|
90
|
+
name ||= get_pow_name
|
91
|
+
symlink_path = "#{POW_PATH}/default"
|
92
|
+
FileUtils.rm_f symlink_path if File.exists?(symlink_path)
|
93
|
+
FileUtils.ln_sf(current_path, symlink_path)
|
94
|
+
say "Your application(#{name}) is now default at http://localhost/"
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "un_default", "remove current default app"
|
98
|
+
def un_default(name=nil)
|
99
|
+
name ||= get_pow_name
|
100
|
+
symlink_path = "#{POW_PATH}/default"
|
101
|
+
FileUtils.rm_f symlink_path if File.exists?(symlink_path)
|
61
102
|
end
|
62
103
|
|
63
104
|
desc "restart", "Restart current pow"
|
@@ -67,20 +108,54 @@ module Powder
|
|
67
108
|
%x{touch tmp/restart.txt}
|
68
109
|
end
|
69
110
|
|
111
|
+
desc "always_restart", "Always restart current pow"
|
112
|
+
def always_restart
|
113
|
+
return unless is_powable?
|
114
|
+
FileUtils.mkdir_p('tmp')
|
115
|
+
%x{touch tmp/always_restart.txt}
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "no_restarts", "Reset this app's restart settings"
|
119
|
+
def no_restarts
|
120
|
+
return unless is_powable?
|
121
|
+
FileUtils.rm_f Dir.glob('tmp/*restart.txt')
|
122
|
+
end
|
123
|
+
|
70
124
|
desc "list", "List current pows"
|
71
125
|
def list
|
72
|
-
Dir[POW_PATH + "/*"].map
|
126
|
+
pows = Dir[POW_PATH + "/*"].map do |link|
|
127
|
+
realpath = File.readlink(link)
|
128
|
+
app_is_current = (realpath == Dir.pwd) ? '*' : ' '
|
129
|
+
[app_is_current, File.basename(link), realpath.gsub(ENV['HOME'], '~')]
|
130
|
+
end
|
131
|
+
print_table(pows)
|
73
132
|
end
|
74
133
|
|
75
134
|
desc "open", "Open a pow in the browser"
|
76
135
|
def open(name=nil)
|
77
|
-
%x{open http://#{name ||
|
136
|
+
%x{open http://#{name || get_pow_name}.#{domain}}
|
78
137
|
end
|
79
138
|
|
80
|
-
desc "
|
81
|
-
|
139
|
+
desc "unlink", "Unlink a pow app"
|
140
|
+
method_option :delete, :type => :boolean, :default => false, :alias => '-e', :desc => "delete .powder"
|
141
|
+
def unlink(name=nil)
|
82
142
|
return unless is_powable?
|
83
|
-
FileUtils.rm_f POW_PATH + '/' + (name ||
|
143
|
+
FileUtils.rm_f POW_PATH + '/' + (name || get_pow_name)
|
144
|
+
say "Successfully removed #{(name || get_pow_name)}"
|
145
|
+
if options[:delete]
|
146
|
+
FileUtils.rm_f POWDER_CONFIG
|
147
|
+
say "Successfully removed #{POWDER_CONFIG}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
desc "remove", "An alias to Unlink (depreciated)"
|
152
|
+
alias :remove :unlink
|
153
|
+
|
154
|
+
desc "cleanup", "Clean up invalid symbolic link"
|
155
|
+
def cleanup
|
156
|
+
Dir[POW_PATH + "/*"].map { |symlink|
|
157
|
+
FileUtils.rm(symlink) unless File.exists? File.readlink(symlink)
|
158
|
+
}
|
84
159
|
end
|
85
160
|
|
86
161
|
desc "install", "Installs pow"
|
@@ -112,7 +187,36 @@ module Powder
|
|
112
187
|
def version
|
113
188
|
say "powder #{Powder::VERSION}"
|
114
189
|
end
|
115
|
-
|
190
|
+
|
191
|
+
desc "host", "Updates hosts file to map pow domains to 127.0.0.1"
|
192
|
+
def host
|
193
|
+
hosts_file_path = "/etc/hosts"
|
194
|
+
pow_domain_records = Dir[POW_PATH + "/*"].map { |a| "127.0.0.1\t#{File.basename(a)}.#{domain}\t#powder" }
|
195
|
+
hosts_file = File.read("/etc/hosts").split("\n").delete_if {|row| row =~ /.+(#powder)/}
|
196
|
+
first_loopback_index = hosts_file.index {|i| i =~ /^(127.0.0.1).+/}
|
197
|
+
hosts_file = hosts_file.insert(first_loopback_index + 1, pow_domain_records)
|
198
|
+
File.open("#{ENV['HOME']}/hosts-powder", "w") do
|
199
|
+
|file| file.puts hosts_file.join("\n")
|
200
|
+
end
|
201
|
+
%x{cp #{hosts_file_path} #{ENV['HOME']}/hosts-powder.bak}
|
202
|
+
%x{sudo mv #{ENV['HOME']}/hosts-powder #{hosts_file_path}}
|
203
|
+
%x{dscacheutil -flushcache}
|
204
|
+
say "Domains added to hosts file, old host file is saved at #{ENV['HOME']}/hosts-powder.bak"
|
205
|
+
end
|
206
|
+
|
207
|
+
desc "unhost", "Removes pow domains from hostfile"
|
208
|
+
def unhost
|
209
|
+
hosts_file_path = "/etc/hosts"
|
210
|
+
hosts_file = File.read("/etc/hosts").split("\n").delete_if {|row| row =~ /.+(#powder)/}
|
211
|
+
File.open("#{ENV['HOME']}/hosts-powder", "w") do
|
212
|
+
|file| file.puts hosts_file.join("\n")
|
213
|
+
end
|
214
|
+
%x{cp #{hosts_file_path} #{ENV['HOME']}/hosts-powder.bak}
|
215
|
+
%x{sudo mv #{ENV['HOME']}/hosts-powder #{hosts_file_path}}
|
216
|
+
%x{dscacheutil -flushcache}
|
217
|
+
say "Domains removed from hosts file, old host file is saved at #{ENV['HOME']}/hosts-powder.bak"
|
218
|
+
end
|
219
|
+
|
116
220
|
desc "config", "Shows current pow configuration"
|
117
221
|
def config
|
118
222
|
results = %x{curl --silent -H host:pow localhost/config.json}.gsub(':','=>')
|
@@ -137,15 +241,48 @@ module Powder
|
|
137
241
|
end
|
138
242
|
|
139
243
|
private
|
140
|
-
|
244
|
+
|
141
245
|
def current_dir_name
|
142
246
|
File.basename(%x{pwd}.chomp)
|
143
247
|
end
|
144
248
|
|
249
|
+
def configured_pow_name
|
250
|
+
return nil unless File.exists?(POWDER_CONFIG)
|
251
|
+
|
252
|
+
File.foreach(POWDER_CONFIG) do |line|
|
253
|
+
next if line =~ /^($|#)/
|
254
|
+
return line.chomp
|
255
|
+
end
|
256
|
+
|
257
|
+
return nil
|
258
|
+
end
|
259
|
+
|
145
260
|
def current_dir_pow_name
|
146
261
|
current_dir_name.tr('_', '-')
|
147
262
|
end
|
148
263
|
|
264
|
+
def get_pow_name
|
265
|
+
configured_pow_name || current_dir_pow_name
|
266
|
+
end
|
267
|
+
|
268
|
+
def write_pow_config(name=nil)
|
269
|
+
return if ! name || options[:"no-config"]
|
270
|
+
powder_exists = File.exists?(POWDER_CONFIG)
|
271
|
+
configured_name = get_pow_name
|
272
|
+
|
273
|
+
unlink if powder_exists && configured_name != name
|
274
|
+
|
275
|
+
if options[:force] || ! powder_exists
|
276
|
+
File.open(POWDER_CONFIG, "w") do |f|
|
277
|
+
f.puts(name)
|
278
|
+
end
|
279
|
+
say "Created powder config #{POWDER_CONFIG}"
|
280
|
+
elsif !options[:force] && powder_exists && configured_name != name
|
281
|
+
say "Cowardly refusing to overwrite #{POWDER_CONFIG}"
|
282
|
+
exit 1
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
149
286
|
def is_powable?
|
150
287
|
if File.exists?('config.ru') || File.exists?('public/index.html')
|
151
288
|
true
|
@@ -171,12 +308,12 @@ module Powder
|
|
171
308
|
end
|
172
309
|
|
173
310
|
def is_rails2_app?
|
174
|
-
File.exists?('config/environment.rb') &&
|
311
|
+
File.exists?('config/environment.rb') &&
|
175
312
|
!`grep RAILS_GEM_VERSION config/environment.rb`.empty? ? 'Rails 2' : nil
|
176
313
|
end
|
177
|
-
|
314
|
+
|
178
315
|
def is_radiant_app?
|
179
|
-
File.exists?('config/environment.rb') &&
|
316
|
+
File.exists?('config/environment.rb') &&
|
180
317
|
!`grep Radiant::Initializer config/environment.rb`.empty? ? 'Radiant' : nil
|
181
318
|
end
|
182
319
|
|
data/lib/powder/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: powder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 6
|
10
|
-
version: 0.1.6
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.7
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Phil Nash
|
@@ -16,7 +11,7 @@ autorequire:
|
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
13
|
|
19
|
-
date: 2011-
|
14
|
+
date: 2011-11-02 00:00:00 +00:00
|
20
15
|
default_executable:
|
21
16
|
dependencies:
|
22
17
|
- !ruby/object:Gem::Dependency
|
@@ -27,11 +22,6 @@ dependencies:
|
|
27
22
|
requirements:
|
28
23
|
- - ">="
|
29
24
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 57
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
- 11
|
34
|
-
- 5
|
35
25
|
version: 0.11.5
|
36
26
|
type: :runtime
|
37
27
|
version_requirements: *id001
|
@@ -69,23 +59,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
59
|
requirements:
|
70
60
|
- - ">="
|
71
61
|
- !ruby/object:Gem::Version
|
72
|
-
hash: 3
|
73
|
-
segments:
|
74
|
-
- 0
|
75
62
|
version: "0"
|
76
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
64
|
none: false
|
78
65
|
requirements:
|
79
66
|
- - ">="
|
80
67
|
- !ruby/object:Gem::Version
|
81
|
-
hash: 3
|
82
|
-
segments:
|
83
|
-
- 0
|
84
68
|
version: "0"
|
85
69
|
requirements: []
|
86
70
|
|
87
71
|
rubyforge_project: powder
|
88
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.5.2
|
89
73
|
signing_key:
|
90
74
|
specification_version: 3
|
91
75
|
summary: Makes Pow even easier
|