bin/powder in powder-0.2.0 vs bin/powder in powder-0.2.1
- old
+ new
@@ -18,11 +18,10 @@
map '-l' => 'list'
map '-L' => 'link'
map '-d' => 'default'
map '-o' => 'open'
map '-v' => 'version'
- map 'update' => 'install'
POWDER_CONFIG = ".powder"
POW_ENV = ".powenv"
POW_PATH = "#{ENV['HOME']}/.pow"
POW_CONFIG = "#{ENV['HOME']}/.powconfig"
@@ -46,11 +45,11 @@
desc "test", "Run pow with RAILS_ENV=test"
def test
env("RAILS_ENV", "test")
end
- desc "dev", "Run pow with RAILS_ENV=development"
+ desc "development", "Run pow with RAILS_ENV=development"
def development
env("RAILS_ENV", "development")
end
desc "dev", "An alias to development"
@@ -122,11 +121,11 @@
symlink_path = "#{POW_PATH}/#{name}"
FileUtils.rm_f(symlink_path) if options[:force]
FileUtils.ln_s(current_path, symlink_path) unless File.exists?(symlink_path)
say "Your application is now available at http://#{name}.#{domain}/"
else
- say "Pow is not installed."
+ say "Pow is not installed. That is, the ${HOME}/.pow symlink does not exist."
end
end
desc "default", "Set this app as default"
def default(name=nil)
@@ -184,11 +183,11 @@
desc "open", "Open a pow in the browser"
method_option :browser, :type => :string, :default => false, :aliases => '-b', :desc => 'browser to open with'
method_option :xip, :type => :boolean, :default => false, :alias => '-x', :desc => "open xip.io instead of .domain"
def open(name=nil)
- browser = options.browser? ? "-a \'#{options.browser}\'" : nil
+ browser = options.browser? ? "-a \'#{options.browser}\'" : nil
if options.xip?
local_ip = '0.0.0.0'
begin
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
@@ -224,15 +223,18 @@
Dir[POW_PATH + "/*"].map { |symlink|
FileUtils.rm(symlink) unless File.exists? File.readlink(symlink)
}
end
- desc "install", "Installs pow"
+ desc "install", "Installs or updates pow"
def install
%x{curl get.pow.cx | sh}
end
+ desc "update", "An alias to install"
+ alias :update :install
+
desc "log", "Tails the Pow log"
def log
path_to_log_file = "#{ENV['HOME']}/Library/Logs/Pow/apps/#{current_dir_name}.log"
if File.exist? path_to_log_file
system "tail -f #{path_to_log_file}"
@@ -327,11 +329,11 @@
results = %x{curl --silent -H host:pow localhost#{http_port}/status.json}.gsub(':','=>')
return say("Error: Cannot get Pow status. Pow may be down. Try 'powder up' first.") if results.empty? || !(results =~ /^\{/)
json = eval results
json.each {|k,v| say "#{k.ljust(12, ' ')} #{v}"}
end
-
+
desc "portmap PORT", "Map a port to an app"
method_option :name, :type => :string, :aliases => '-n', :desc => 'name of the port map'
method_option :force, :type => :boolean, :default => false, :alias => '-f', :desc => "remove the old configuration, overwrite .powder"
def portmap(port)
if File.symlink?(POW_PATH)
@@ -346,10 +348,20 @@
say "Pow is not installed."
end
end
+ desc "env_rvm", "Create or add rvm env to .powenv"
+ def env_rvm
+ if File.exists?(%x{pwd}.chomp + "/.rvmrc")
+ say %x{rvm env . -- --env >> #{POW_ENV}}
+ show_env
+ else
+ say ".rvmrc does not exist."
+ end
+ end
+
private
def powenv_exists?
File.exists?(POW_ENV)
end
@@ -441,16 +453,11 @@
if File.exists?('config.ru') || File.exists?('public/index.html')
true
elsif legacy = (is_rails2_app? || is_radiant_app?)
say "This appears to be a #{legacy} application. You need a config.ru file."
if yes? "Do you want to autogenerate a basic config.ru for #{legacy}?"
- uri = URI.parse("https://raw.github.com/gist/909308")
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = true
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
- request = Net::HTTP::Get.new(uri.request_uri)
- create_file "config.ru", http.request(request).body
+ create_file "config.ru", get_gist("https://gist.github.com/sstephenson/909308/raw")
return true
else
say "Did not create config.ru"
return false
end
@@ -487,23 +494,23 @@
rack_initializer = %x{pwd}.chomp + "/rdebug.rb"
unless File.exists?(rack_initializer) || File.exists?(rails_initializer)
say "Its appears that the required initializer for rdebug doesn't exists in your application."
if yes? "Do you want to create it(y/n)?"
if yes? "This is a Rails/Radiant app(y/n)?"
- create_file rails_initializer, get_gist(1135055)
+ create_file rails_initializer, get_gist("https://gist.github.com/csiszarattila/1135055/raw")
else
- create_file rack_initializer, get_gist(1262647)
+ create_file rack_initializer, get_gist("https://gist.github.com/csiszarattila/1262647/raw")
append_to_file 'config.ru', "\nrequire 'rdebug.rb'"
end
restart
else
return false
end
end
end
- def get_gist(id)
- uri = URI.parse("https://raw.github.com/gist/#{id}")
+ def get_gist(url)
+ uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
http.request(request).body