vulcan 0.0.1
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/bin/vulcan +9 -0
- data/lib/vulcan/cli.rb +164 -0
- data/lib/vulcan/version.rb +5 -0
- data/lib/vulcan.rb +2 -0
- metadata +82 -0
data/bin/vulcan
ADDED
data/lib/vulcan/cli.rb
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
require "net/http/post/multipart"
|
3
|
+
require "rest_client"
|
4
|
+
require "thor"
|
5
|
+
require "tmpdir"
|
6
|
+
require "uri"
|
7
|
+
require "vulcan"
|
8
|
+
require "yaml"
|
9
|
+
|
10
|
+
class Vulcan::CLI < Thor
|
11
|
+
|
12
|
+
desc "build [COMMAND]", <<-DESC
|
13
|
+
build a piece of software for the heroku cloud using COMMANd as a build command
|
14
|
+
if no COMMAND is specified, a sensible default will be chosen for you
|
15
|
+
|
16
|
+
DESC
|
17
|
+
|
18
|
+
method_option :command, :aliases => "-c", :desc => "the command to run for compilation"
|
19
|
+
method_option :name, :aliases => "-n", :desc => "the name of the library (defaults ot the directory name)"
|
20
|
+
method_option :output, :aliases => "-o", :desc => "output build artifacts to this file"
|
21
|
+
method_option :prefix, :aliases => "-p", :desc => "the build/install --prefix of the software"
|
22
|
+
method_option :source, :aliases => "-s", :desc => "the source directory to build from"
|
23
|
+
method_option :verbose, :aliases => "-v", :desc => "show the full build output", :type => :boolean
|
24
|
+
|
25
|
+
def build
|
26
|
+
app = read_config[:app] || "need a server first, use vulcan create"
|
27
|
+
|
28
|
+
command = options[:command] || "./configure --prefix #{prefix} && make install"
|
29
|
+
name = options[:name] || File.basename(Dir.pwd)
|
30
|
+
output = options[:output] || "/tmp/#{name}.tgz"
|
31
|
+
prefix = options[:prefix] || "/app/vendor/#{name}"
|
32
|
+
source = options[:source] || Dir.pwd
|
33
|
+
server = URI.parse(ENV["MAKE_SERVER"] || "http://#{app}.herokuapp.com")
|
34
|
+
|
35
|
+
Dir.mktmpdir do |dir|
|
36
|
+
puts ">> Packaging local directory"
|
37
|
+
%x{ cd #{source} && tar czvf #{dir}/input.tgz . 2>&1 }
|
38
|
+
|
39
|
+
puts ">> Uploading code for build"
|
40
|
+
File.open("#{dir}/input.tgz", "r") do |input|
|
41
|
+
request = Net::HTTP::Post::Multipart.new "/make",
|
42
|
+
"code" => UploadIO.new(input, "application/octet-stream", "input.tgz"),
|
43
|
+
"command" => command,
|
44
|
+
"prefix" => prefix
|
45
|
+
|
46
|
+
puts ">> Building with: #{command}"
|
47
|
+
response = Net::HTTP.start(server.host, server.port) do |http|
|
48
|
+
http.request(request) do |response|
|
49
|
+
response.read_body do |chunk|
|
50
|
+
print chunk if options[:verbose]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
error "Unknown error, no build output given" unless response["X-Make-Id"]
|
56
|
+
|
57
|
+
puts ">> Downloading build artifacts to: #{output}"
|
58
|
+
|
59
|
+
File.open(output, "w") do |output|
|
60
|
+
begin
|
61
|
+
output.print RestClient.get("#{server}/output/#{response["X-Make-Id"]}")
|
62
|
+
rescue Exception => ex
|
63
|
+
puts ex.inspect
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
rescue Errno::EPIPE
|
69
|
+
error "Could not connect to build server: #{server}"
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "create APP_NAME", <<-DESC
|
73
|
+
create a build server on Heroku
|
74
|
+
|
75
|
+
DESC
|
76
|
+
|
77
|
+
def create(name)
|
78
|
+
secret = Digest::SHA1.hexdigest("--#{rand(10000)}--#{Time.now}--")
|
79
|
+
|
80
|
+
Dir.mktmpdir do |dir|
|
81
|
+
Dir.chdir(dir) do
|
82
|
+
system "env BUNDLE_GEMFILE= heroku create #{name} -s cedar"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
write_config :ap=> name, :host => "#{name}.herokuapp.com", :secret => secret
|
86
|
+
update
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
desc "update", <<-DESC
|
91
|
+
update the build server
|
92
|
+
|
93
|
+
DESC
|
94
|
+
|
95
|
+
def update
|
96
|
+
error "no apyet, create first" unless config[:app]
|
97
|
+
|
98
|
+
FileUtils.mkdir_p File.expand_path("~/.heroku/plugins/heroku-credentials")
|
99
|
+
|
100
|
+
File.open(File.expand_path("~/.heroku/plugins/heroku-credentials/init.rb"), "w") do |file|
|
101
|
+
file.puts <<-CONTENTS
|
102
|
+
class Heroku::Command::Credentials < Heroku::Command::Base
|
103
|
+
def index
|
104
|
+
puts Heroku::Auth.password
|
105
|
+
end
|
106
|
+
end
|
107
|
+
CONTENTS
|
108
|
+
end
|
109
|
+
|
110
|
+
Dir.mktmpdir do |dir|
|
111
|
+
Dir.chdir(dir) do
|
112
|
+
api_key = %x{ env BUNDLE_GEMFILE= heroku credentials }
|
113
|
+
|
114
|
+
system "git init"
|
115
|
+
system "git remote add heroku git@heroku.com:#{config[:app]}.git"
|
116
|
+
FileUtils.cp_r "#{server_path}/.", "."
|
117
|
+
File.open(".gitignore", "w") do |file|
|
118
|
+
file.puts ".env"
|
119
|
+
file.puts "node_modules"
|
120
|
+
end
|
121
|
+
system "ls -la"
|
122
|
+
system "git add ."
|
123
|
+
system "git commit -m commit"
|
124
|
+
system "git push heroku -f master"
|
125
|
+
|
126
|
+
%x{ env BUNDLE_GEMFILE= heroku config:add SECRET=#{config[:secret]} SPAWN_ENV=heroku HEROKU_APP=#{config[:app]} HEROKU_API_KEY=#{api_key} 2>&1 }
|
127
|
+
%x{ env BUNDLE_GEMFILE= heroku addons:add cloudant:oxygen }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def config_file
|
135
|
+
File.expand_path("~/.vulcan")
|
136
|
+
end
|
137
|
+
|
138
|
+
def config
|
139
|
+
read_config
|
140
|
+
end
|
141
|
+
|
142
|
+
def read_config
|
143
|
+
return {} unless File.exists?(config_file)
|
144
|
+
config = YAML.load_file(config_file)
|
145
|
+
config.is_a?(Hash) ? config : {}
|
146
|
+
end
|
147
|
+
|
148
|
+
def write_config(config)
|
149
|
+
full_config = read_config.merge(config)
|
150
|
+
File.open(config_file, "w") do |file|
|
151
|
+
file.puts YAML.dump(full_config)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def error(message)
|
156
|
+
puts "!! #{message}"
|
157
|
+
exit 1
|
158
|
+
end
|
159
|
+
|
160
|
+
def server_path
|
161
|
+
File.expand_path("../../../server", __FILE__)
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
data/lib/vulcan.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vulcan
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Dollar
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multipart-post
|
16
|
+
requirement: &70228915628200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70228915628200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rest-client
|
27
|
+
requirement: &70228915627580 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.7
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70228915627580
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: thor
|
38
|
+
requirement: &70228915626880 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.14.6
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70228915626880
|
47
|
+
description: Build software in the cloud
|
48
|
+
email: ddollar@gmail.com
|
49
|
+
executables:
|
50
|
+
- vulcan
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- bin/vulcan
|
55
|
+
- lib/vulcan/cli.rb
|
56
|
+
- lib/vulcan/version.rb
|
57
|
+
- lib/vulcan.rb
|
58
|
+
homepage: http://vulcan.com/
|
59
|
+
licenses: []
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.10
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Build software in the cloud
|
82
|
+
test_files: []
|