strobe 0.2.0 → 0.3.0
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/README.md +7 -0
- data/bin/strobe +18 -1
- data/lib/strobe/addons/social/twitter.rb +1 -5
- data/lib/strobe/cli/main.rb +77 -81
- data/lib/strobe/cli/preview.rb +18 -7
- data/lib/strobe/cli/settings.rb +1 -1
- data/lib/strobe/cli.rb +12 -3
- data/lib/strobe/connection.rb +5 -0
- data/lib/strobe/middleware/proxy.rb +2 -2
- data/lib/strobe/resource/base.rb +18 -4
- data/lib/strobe/resources/application.rb +59 -9
- data/lib/strobe/resources/platform_install.rb +17 -0
- data/lib/strobe/resources.rb +1 -0
- data/lib/strobe/version.rb +1 -1
- data/lib/strobe.rb +29 -4
- metadata +72 -90
data/README.md
CHANGED
data/bin/strobe
CHANGED
@@ -1,4 +1,21 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'strobe'
|
3
3
|
|
4
|
-
|
4
|
+
begin
|
5
|
+
Strobe::CLI::Main.start(ARGV)
|
6
|
+
rescue Strobe::StrobeError => e
|
7
|
+
warn e.message
|
8
|
+
puts e.backtrace.join("\n") if ENV['DEBUG']
|
9
|
+
exit false
|
10
|
+
rescue Interrupt => e
|
11
|
+
puts "\nQuitting..."
|
12
|
+
puts e.backtrace.join("\n") if ENV['DEBUG']
|
13
|
+
exit false
|
14
|
+
rescue SystemExit => e
|
15
|
+
exit e.status
|
16
|
+
rescue Exception => e
|
17
|
+
warn "Unfortunately, a fatal error has occurred. " +
|
18
|
+
"Please report this error to Strobe Support at " +
|
19
|
+
"http://support.strobeapp.com/home so that we can fix it. Thanks!"
|
20
|
+
raise e
|
21
|
+
end
|
@@ -39,8 +39,7 @@ module Strobe
|
|
39
39
|
|
40
40
|
case @request.path_info
|
41
41
|
when "/authentication"
|
42
|
-
env['REQUEST_METHOD'] == 'DELETE' ?
|
43
|
-
unauthenticate : authenticate
|
42
|
+
env['REQUEST_METHOD'] == 'DELETE' ? unauthenticate : authenticate
|
44
43
|
when "/callback"
|
45
44
|
callback
|
46
45
|
else
|
@@ -48,9 +47,6 @@ module Strobe
|
|
48
47
|
end
|
49
48
|
|
50
49
|
@response.finish
|
51
|
-
rescue Exception => e
|
52
|
-
puts e.message
|
53
|
-
puts e.backtrace
|
54
50
|
end
|
55
51
|
|
56
52
|
private
|
data/lib/strobe/cli/main.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require "bpm"
|
3
|
+
rescue LoadError
|
4
|
+
end
|
2
5
|
|
3
6
|
module Strobe
|
4
7
|
class CLI::Main < CLI
|
@@ -18,57 +21,9 @@ module Strobe
|
|
18
21
|
end
|
19
22
|
map %w(-v --version) => :version
|
20
23
|
|
21
|
-
# TODO: add ability to extend CLI with addons
|
22
|
-
# TODO: remove this after it works in Hellfire
|
23
|
-
method_option "provisioning-profile", :type => :string
|
24
|
-
method_option "certificate", :type => :string
|
25
|
-
method_option "application-id", :type => :numeric, :banner => "Use application with given id"
|
26
|
-
action "phonegap:configure:ios", "configure ios for phonegap" do
|
27
|
-
pswd = @input.ask_for_password "password: "
|
28
|
-
provisioning_path = options["provisioning-profile"]
|
29
|
-
certificate_path = options["certificate"]
|
30
|
-
|
31
|
-
id = options['application-id'] || config[:application_id]
|
32
|
-
response = Strobe.connection.get "/applications/#{id}?include=platform_installs"
|
33
|
-
if response.status == 200
|
34
|
-
ios = response.body["platform_installs"].detect { |p| p["platform_id"] == 1 }
|
35
|
-
if ios
|
36
|
-
boundary = "57f5d6d3e21c57f5d6d3e2157f5d6d3e21c57f5"
|
37
|
-
body = []
|
38
|
-
body << "--#{boundary}\r\n"
|
39
|
-
body << "Content-Disposition: form-data; name=\"application[ios_cert_file]\"; filename=\"cert.p12\"\r\n"
|
40
|
-
body << "Content-Type: application/octet-stream\r\n"
|
41
|
-
body << "\r\n"
|
42
|
-
body << File.read(certificate_path)
|
43
|
-
body << "\r\n--#{boundary}\r\n"
|
44
|
-
body << "Content-Disposition: form-data; name=\"application[ios_profile_file]\"; filename=\"provision.mobileprovision\"\r\n"
|
45
|
-
body << "Content-Type: application/octet-stream\r\n"
|
46
|
-
body << "\r\n"
|
47
|
-
body << File.read(provisioning_path)
|
48
|
-
body << "\r\n--#{boundary}\r\n"
|
49
|
-
body << "Content-Disposition: form-data; name=\"application[ios_password]\"\r\n"
|
50
|
-
body << "\r\n"
|
51
|
-
body << "#{pswd}\r\n"
|
52
|
-
body << "--#{boundary}--\r\n"
|
53
|
-
|
54
|
-
response = Strobe.connection.post "/platform_installs/#{ios["id"]}/pages/configuration", body.join, "Content-Type" => "multipart/form-data; boundary=#{boundary}", "Connection" => ""
|
55
|
-
if response.status == 201 || response.status == 204
|
56
|
-
say "Successfuly updated ios keys"
|
57
|
-
else
|
58
|
-
say "Something went wrong, server responded with #{response.status}:"
|
59
|
-
puts response.body
|
60
|
-
end
|
61
|
-
else
|
62
|
-
say "[ERROR] ios seems to be not installed in this application"
|
63
|
-
end
|
64
|
-
else
|
65
|
-
say "[ERROR] #{response.body}"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
24
|
method_option "global", :type => :boolean, :banner => "Set option globally (for all applications)"
|
70
25
|
method_option "unset", :type => :boolean, :banner => "Unset a config option"
|
71
|
-
action "config", "configure strobe", :usage => "config [KEY] [VALUE]" do
|
26
|
+
action "config", "configure strobe", :usage => "config [KEY] [VALUE]" do |key, *val|
|
72
27
|
val = val.first
|
73
28
|
case
|
74
29
|
when val
|
@@ -99,7 +54,7 @@ module Strobe
|
|
99
54
|
|
100
55
|
action "open", "opens application in browser" do
|
101
56
|
resource get_application
|
102
|
-
url = resource
|
57
|
+
url = resource.web_url
|
103
58
|
|
104
59
|
Launchy.open("http://#{url}")
|
105
60
|
end
|
@@ -157,39 +112,41 @@ module Strobe
|
|
157
112
|
end
|
158
113
|
end
|
159
114
|
|
115
|
+
method_option "port", :type => :string, :banner => "port to start server on", :aliases => "-p", :default => "9292"
|
160
116
|
action "preview", "preview your application as it would show up on Strobe Platform" do
|
161
|
-
preview_strobe_application
|
117
|
+
preview_strobe_application(options[:port])
|
162
118
|
end
|
163
119
|
|
164
120
|
application_path_option
|
165
|
-
method_option "message",
|
166
|
-
method_option "
|
121
|
+
method_option "message", :type => :string, :banner => "add rollback message", :aliases => "-m"
|
122
|
+
method_option "production", :type => :boolean, :banner => "rollback a production environment"
|
167
123
|
action "rollback", "rollback application to a state from given deploy" do |sha|
|
168
124
|
ensure_computer_is_registered
|
169
125
|
|
170
126
|
id = options['application-id'] || config[:application_id]
|
171
127
|
resource Application.get!(id)
|
172
128
|
|
173
|
-
host = resource
|
174
|
-
host = "staging.#{host}"
|
129
|
+
host = resource.web_url
|
130
|
+
host = "staging.#{host}" unless options[:production]
|
175
131
|
|
176
132
|
unless agree "Rolling back '#{resource[:name]}' to #{sha} for http://#{host}, continue? [Yn] "
|
177
133
|
say "exiting..."
|
178
134
|
exit
|
179
135
|
end
|
180
136
|
|
181
|
-
host = resource.rollback! sha, :environment => options[:
|
137
|
+
host = resource.rollback! sha, :environment => (options[:production] ? "production" : "staging"),
|
182
138
|
:message => options[:message]
|
183
139
|
|
184
140
|
say "The application has successfully been rolled back to #{sha} and is available at #{host}"
|
185
141
|
end
|
186
142
|
|
187
143
|
application_path_option
|
188
|
-
method_option "
|
189
|
-
method_option "
|
190
|
-
method_option "
|
191
|
-
method_option "
|
192
|
-
method_option "
|
144
|
+
method_option "organization-id", :type => :numeric, :banner => "select an account with given id"
|
145
|
+
method_option "message", :type => :string, :banner => "add deploy message", :aliases => "-m"
|
146
|
+
method_option "production", :type => :boolean, :banner => "deploy to a production environment"
|
147
|
+
method_option "sc-build", :type => :boolean, :banner => "run `sc-build -c` before deploying"
|
148
|
+
method_option "no-sc-build", :type => :boolean, :banner => "skip the `sc-build -c` step"
|
149
|
+
method_option "url", :banner => "set application's url"
|
193
150
|
action "deploy", "deploy your application to Strobe" do
|
194
151
|
ensure_computer_is_registered
|
195
152
|
|
@@ -197,19 +154,18 @@ module Strobe
|
|
197
154
|
resource Application.get! application_id, :lazy => true
|
198
155
|
|
199
156
|
if options[:url]
|
200
|
-
resource
|
201
|
-
save {}
|
157
|
+
resource.set_web_url!(options[:url])
|
202
158
|
end
|
203
159
|
|
204
|
-
host = resource
|
205
|
-
host = "staging.#{host}"
|
160
|
+
host = resource.web_url
|
161
|
+
host = "staging.#{host}" unless options[:production]
|
206
162
|
|
207
163
|
unless agree "Deploying '#{resource[:name]}' to http://#{host}, continue? [Yn] "
|
208
164
|
say "exiting..."
|
209
165
|
exit
|
210
166
|
end
|
211
167
|
else
|
212
|
-
resource
|
168
|
+
resource account_for_deploy(options[:"organization-id"]).applications.new
|
213
169
|
end
|
214
170
|
|
215
171
|
resource[:path] = determine_application_root
|
@@ -225,20 +181,29 @@ module Strobe
|
|
225
181
|
end
|
226
182
|
|
227
183
|
settings.register_app_path(path)
|
184
|
+
|
185
|
+
resource.set_web_url!(options[:url])
|
228
186
|
end
|
229
187
|
end
|
230
188
|
|
231
189
|
run_sc_build
|
232
190
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
191
|
+
begin
|
192
|
+
host = resource.deploy! :environment => (options[:production] ? "production" : "staging"),
|
193
|
+
:callback => CLI::DeployProgress.new,
|
194
|
+
:message => options[:message] || git_message,
|
195
|
+
:sproutcore => is_sproutcore?,
|
196
|
+
:bpm_project => bpm_project,
|
197
|
+
:scm_version => scm_version,
|
198
|
+
:github_url => github_url,
|
199
|
+
:path => config["deploy_directory"],
|
200
|
+
:pre_deploy => config["pre_deploy_hook"],
|
201
|
+
:post_deploy => config["post_deploy_hook"]
|
202
|
+
|
203
|
+
say "The application has successfully been deployed and is available at #{host}"
|
204
|
+
rescue Strobe::DeployInterrupted => e
|
205
|
+
say "[ERROR] #{e.message}"
|
206
|
+
end
|
242
207
|
end
|
243
208
|
|
244
209
|
|
@@ -255,10 +220,10 @@ module Strobe
|
|
255
220
|
if options['url'].blank?
|
256
221
|
say "[ERROR] You need to specify what to set"
|
257
222
|
else
|
258
|
-
|
223
|
+
url = options['url']
|
259
224
|
|
260
|
-
|
261
|
-
say "The application is now running at #{resource
|
225
|
+
if resource.set_web_url!(url)
|
226
|
+
say "The application is now running at #{resource.web_url}"
|
262
227
|
end
|
263
228
|
end
|
264
229
|
end
|
@@ -299,7 +264,7 @@ module Strobe
|
|
299
264
|
config.set_application_id! application[:id]
|
300
265
|
settings.register_app_path(path)
|
301
266
|
|
302
|
-
say "You can now deploy to #{application[:name]} (http://#{application
|
267
|
+
say "You can now deploy to #{application[:name]} (http://#{application.web_url})"
|
303
268
|
end
|
304
269
|
|
305
270
|
private
|
@@ -335,6 +300,7 @@ module Strobe
|
|
335
300
|
end
|
336
301
|
|
337
302
|
def bpm_project
|
303
|
+
return nil unless defined?(BPM)
|
338
304
|
BPM::Project.nearest_project Dir.pwd
|
339
305
|
end
|
340
306
|
|
@@ -353,7 +319,7 @@ module Strobe
|
|
353
319
|
table applications, options do |t|
|
354
320
|
t.column :id
|
355
321
|
t.column :name
|
356
|
-
t.column :url
|
322
|
+
t.column :url do |app| app.web_url end
|
357
323
|
t.column :path do |app|
|
358
324
|
config = settings.configs.find do |c|
|
359
325
|
c[:application_id] == app[:id]
|
@@ -383,6 +349,36 @@ module Strobe
|
|
383
349
|
end
|
384
350
|
end
|
385
351
|
|
352
|
+
def account_for_deploy(account_id = nil)
|
353
|
+
if account_id
|
354
|
+
Account.get!(account_id)
|
355
|
+
else
|
356
|
+
accounts = Account.where(:owner => true).all
|
357
|
+
if accounts.length > 1
|
358
|
+
pick_account(accounts)
|
359
|
+
else
|
360
|
+
accounts.first
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
def pick_account(accounts)
|
366
|
+
table accounts, :index => true do |t|
|
367
|
+
t.column :id
|
368
|
+
t.column :name
|
369
|
+
end
|
370
|
+
|
371
|
+
while true
|
372
|
+
index = ask "Pick an organization: ", :direct => true
|
373
|
+
|
374
|
+
if index.to_i > 0 and account = accounts[index.to_i - 1]
|
375
|
+
return account
|
376
|
+
end
|
377
|
+
|
378
|
+
say "Invalid entry. Please enter one of the numbers in brackets"
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
386
382
|
def ensure_computer_is_registered
|
387
383
|
unless settings[:token]
|
388
384
|
say "This computer is not yet registered with a Strobe account."
|
data/lib/strobe/cli/preview.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'rack'
|
2
|
-
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bpm'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
3
7
|
|
4
8
|
module Strobe
|
5
9
|
module CLI::Preview
|
@@ -36,23 +40,30 @@ module Strobe
|
|
36
40
|
|
37
41
|
private
|
38
42
|
|
39
|
-
def preview_strobe_application
|
40
|
-
is_sproutcore?? preview_sproutcore_application : preview_html_application
|
43
|
+
def preview_strobe_application(port)
|
44
|
+
is_sproutcore?? preview_sproutcore_application(port) : preview_html_application(port)
|
41
45
|
end
|
42
46
|
|
43
47
|
def bpm_project
|
48
|
+
return nil unless defined?(BPM)
|
44
49
|
@bpm_project ||= BPM::Project.nearest_project(Dir.pwd)
|
45
50
|
end
|
46
51
|
|
47
|
-
def preview_html_application
|
52
|
+
def preview_html_application(port)
|
48
53
|
app = wrap(Rack::Static.new lambda { |e| [] }, :urls => [ '/' ], :root => '.')
|
49
|
-
Server.start :app => app, :host => '0.0.0.0', :server => "thin", :Port =>
|
54
|
+
Server.start :app => app, :host => '0.0.0.0', :server => "thin", :Port => port
|
55
|
+
rescue Exception => e
|
56
|
+
if e.message[0,11] == "no acceptor"
|
57
|
+
raise InvalidPortError, "Can't start server on port 9292. Either it is in use or requires root privileges."
|
58
|
+
else
|
59
|
+
raise e
|
60
|
+
end
|
50
61
|
end
|
51
62
|
|
52
|
-
def preview_sproutcore_application
|
63
|
+
def preview_sproutcore_application(port)
|
53
64
|
require 'strobe/sproutcore'
|
54
65
|
SC::Rack::Service.strobe_stack(self)
|
55
|
-
SC::Tools.start ['server'] + ARGV[1..-1] + [ '--port',
|
66
|
+
SC::Tools.start ['server'] + ARGV[1..-1] + [ '--port', port ]
|
56
67
|
end
|
57
68
|
end
|
58
69
|
end
|
data/lib/strobe/cli/settings.rb
CHANGED
data/lib/strobe/cli.rb
CHANGED
@@ -21,9 +21,18 @@ module Strobe
|
|
21
21
|
class_option "yes", :type => :boolean, :aliases => "-y", :banner => "answer yes to all confirmation questions"
|
22
22
|
|
23
23
|
def self.start(args)
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
begin
|
25
|
+
$__ARGV = args
|
26
|
+
IdentityMap.wrap do
|
27
|
+
super
|
28
|
+
end
|
29
|
+
rescue Strobe::UnauthenticatedError => e
|
30
|
+
if Settings.global[:token]
|
31
|
+
puts "[ERROR] Your token is invalid, please login to get a valid token"
|
32
|
+
CLI::Main.start( [ "login" ] )
|
33
|
+
else
|
34
|
+
raise e
|
35
|
+
end
|
27
36
|
end
|
28
37
|
rescue NotifiableError => e
|
29
38
|
raise if $__ARGV.include?('--backtrace')
|
data/lib/strobe/connection.rb
CHANGED
@@ -86,6 +86,8 @@ module Strobe
|
|
86
86
|
raise UnauthenticatedError, msg
|
87
87
|
when 404
|
88
88
|
raise ResourceNotFoundError, msg
|
89
|
+
when 412
|
90
|
+
raise OutdatedStrobeVersionError, msg
|
89
91
|
when 500...600
|
90
92
|
raise ServerError.new("The server puked :(", :response => to_hash, :request => @request.to_hash)
|
91
93
|
end
|
@@ -151,6 +153,7 @@ module Strobe
|
|
151
153
|
http = Net::HTTP.new host, port || 80
|
152
154
|
http.read_timeout = 900 # For deploys
|
153
155
|
http.open_timeout = 10
|
156
|
+
http.use_ssl = true if port == 443
|
154
157
|
http
|
155
158
|
end
|
156
159
|
|
@@ -172,6 +175,8 @@ module Strobe
|
|
172
175
|
|
173
176
|
headers['authorization'] ||= authorization_header
|
174
177
|
|
178
|
+
headers['user-agent'] = Strobe.user_agent
|
179
|
+
|
175
180
|
if method == "GET" || method == "HEAD"
|
176
181
|
|
177
182
|
case body
|
@@ -93,7 +93,7 @@ module Strobe
|
|
93
93
|
scheme = scheme_from_env(env)
|
94
94
|
host, port = p1.split(':')
|
95
95
|
path = p2 || '/'
|
96
|
-
port = (port || 80).to_i
|
96
|
+
port = (port || (scheme == 'http' ? 80 : 443)).to_i
|
97
97
|
|
98
98
|
url = "#{scheme}://#{host}"
|
99
99
|
|
@@ -179,7 +179,7 @@ module Strobe
|
|
179
179
|
def handle!
|
180
180
|
EM.next_tick do
|
181
181
|
begin
|
182
|
-
conn = EM::HttpRequest.new(url)
|
182
|
+
conn = EM::HttpRequest.new(url, {:ssl => { :verify_peer => false }})
|
183
183
|
|
184
184
|
@http = case request_method
|
185
185
|
when 'GET' then conn.get request_options
|
data/lib/strobe/resource/base.rb
CHANGED
@@ -192,6 +192,9 @@ module Strobe
|
|
192
192
|
uri = "#{uri}/#{self[:id]}" if self[:id]
|
193
193
|
uri
|
194
194
|
end
|
195
|
+
alias create_uri http_uri
|
196
|
+
alias update_uri http_uri
|
197
|
+
alias delete_uri http_uri
|
195
198
|
|
196
199
|
def request
|
197
200
|
@response = yield
|
@@ -230,15 +233,23 @@ module Strobe
|
|
230
233
|
end
|
231
234
|
|
232
235
|
def create
|
233
|
-
|
236
|
+
_run_save_callbacks do
|
237
|
+
_run_create_callbacks do
|
238
|
+
connection.post create_uri, request_params, {}
|
239
|
+
end
|
240
|
+
end
|
234
241
|
end
|
235
242
|
|
236
243
|
def update
|
237
|
-
|
244
|
+
_run_save_callbacks do
|
245
|
+
_run_update_callbacks do
|
246
|
+
connection.put update_uri, request_params, {}
|
247
|
+
end
|
248
|
+
end
|
238
249
|
end
|
239
250
|
|
240
251
|
def delete
|
241
|
-
connection.delete
|
252
|
+
connection.delete delete_uri
|
242
253
|
end
|
243
254
|
|
244
255
|
def handle_errors(errors, key = nil)
|
@@ -248,7 +259,10 @@ module Strobe
|
|
248
259
|
when Hash
|
249
260
|
handle_errors(v, key)
|
250
261
|
else
|
251
|
-
|
262
|
+
messages = Array.wrap(v)
|
263
|
+
messages.each do |message|
|
264
|
+
self.errors.add(key, message)
|
265
|
+
end
|
252
266
|
end
|
253
267
|
end
|
254
268
|
end
|
@@ -3,6 +3,9 @@ require 'uri'
|
|
3
3
|
require 'digest/sha1'
|
4
4
|
|
5
5
|
module Strobe
|
6
|
+
|
7
|
+
class DeployInterrupted < StandardError; end
|
8
|
+
|
6
9
|
module Resources
|
7
10
|
class Application
|
8
11
|
include Resource::Collection
|
@@ -11,11 +14,29 @@ module Strobe
|
|
11
14
|
has n, :teams
|
12
15
|
has n, :users
|
13
16
|
has n, :deploys
|
17
|
+
has n, :platform_installs
|
14
18
|
|
15
19
|
filter :path
|
16
20
|
|
17
21
|
validates "account", "name", :presence => true
|
18
22
|
|
23
|
+
def web_install
|
24
|
+
# TODO: eventually it will be better to us name for identifying web platform
|
25
|
+
install = self.platform_installs.detect { |p| p.web? }
|
26
|
+
raise "Application does not have web platform" unless install
|
27
|
+
install.reload!
|
28
|
+
end
|
29
|
+
|
30
|
+
def web_url
|
31
|
+
web_install['install_uri']
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_web_url!(url)
|
35
|
+
install = web_install
|
36
|
+
install['url'] = url
|
37
|
+
install.save!
|
38
|
+
end
|
39
|
+
|
19
40
|
def rollback!(sha, opts = {})
|
20
41
|
environment = opts[:environment]
|
21
42
|
message = opts[:message]
|
@@ -35,12 +56,21 @@ module Strobe
|
|
35
56
|
response
|
36
57
|
end
|
37
58
|
|
38
|
-
[ environment, self
|
59
|
+
[ environment, self.web_url ].compact.join('.')
|
39
60
|
end
|
40
61
|
|
41
62
|
def deploy!(opts = {})
|
42
63
|
self['path'] = opts[:path] if opts[:path]
|
43
|
-
|
64
|
+
|
65
|
+
if opts[:pre_deploy]
|
66
|
+
unless Kernel.system(opts[:pre_deploy])
|
67
|
+
raise Strobe::DeployInterrupted, "pre deploy hook returned non-zero status, deploy was stopped"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# TODO: trappist and/or monastery freaks out when we pass production environment
|
72
|
+
# explicitly, we should fix this as it's not intuitive
|
73
|
+
environment = (opts[:environment] == "production" ? nil : opts[:environment])
|
44
74
|
callback = opts[:callback]
|
45
75
|
message = opts[:message]
|
46
76
|
github_url = opts[:github_url]
|
@@ -62,10 +92,11 @@ module Strobe
|
|
62
92
|
packfile = build_packfile(opts)
|
63
93
|
response = connection.put(uri, packfile, packfile.headers)
|
64
94
|
callback.deploy_complete if callback
|
95
|
+
Kernel.system(opts[:post_deploy]) if opts[:post_deploy]
|
65
96
|
response
|
66
97
|
end
|
67
98
|
|
68
|
-
[ environment, self
|
99
|
+
[ environment, self.web_url ].compact.join('.')
|
69
100
|
end
|
70
101
|
|
71
102
|
private
|
@@ -93,22 +124,39 @@ module Strobe
|
|
93
124
|
files.empty?
|
94
125
|
end
|
95
126
|
|
127
|
+
def add_directory(packfile, directory, glob)
|
128
|
+
Dir.chdir directory do
|
129
|
+
Dir[glob].each do |filename|
|
130
|
+
next unless File.file?(filename)
|
131
|
+
packfile.file filename, read(filename)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
|
96
137
|
def build_packfile(opts)
|
138
|
+
project_path = Dir.pwd
|
97
139
|
Dir.chdir self[:path] do
|
98
140
|
PackFile.build(opts) do |m|
|
99
|
-
Dir
|
100
|
-
|
101
|
-
m
|
141
|
+
if project_path != Dir.pwd
|
142
|
+
# the deploy directory differs from project's directory
|
143
|
+
add_directory(m, project_path, "strobe/**/*")
|
102
144
|
end
|
103
145
|
|
104
|
-
|
105
|
-
|
146
|
+
# Make sure to build bpm before add_directory **/* so
|
147
|
+
# we get the changes from the rebuild
|
106
148
|
if project = opts[:bpm_project]
|
107
149
|
project.rebuild_dependency_list(nil, false)
|
108
150
|
project.build :production, true
|
109
151
|
end
|
110
152
|
|
153
|
+
# Add all files in current directory
|
154
|
+
add_directory(m, ".", "**/*")
|
155
|
+
|
156
|
+
|
111
157
|
if opts[:sproutcore]
|
158
|
+
picked_root_app = false
|
159
|
+
|
112
160
|
Dir["static/*"].each do |appdir|
|
113
161
|
next if File.file?(appdir)
|
114
162
|
|
@@ -217,7 +265,9 @@ module Strobe
|
|
217
265
|
|
218
266
|
@files.each do |path, data|
|
219
267
|
size = data.respond_to?(:bytesize) ? data.bytesize : data.size
|
220
|
-
|
268
|
+
digest = "#{Digest::SHA1.hexdigest("blob #{size}\0#{data}")}\0#{size}\0#{path}\n"
|
269
|
+
digest = digest.force_encoding("BINARY") if digest.respond_to?(:force_encoding)
|
270
|
+
head << digest
|
221
271
|
body << data
|
222
272
|
end
|
223
273
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Strobe
|
2
|
+
module Resources
|
3
|
+
class PlatformInstall
|
4
|
+
include Resource::Collection
|
5
|
+
|
6
|
+
has 1, :application
|
7
|
+
|
8
|
+
def update_uri
|
9
|
+
"/platform_installs/#{self[:id]}/configuration"
|
10
|
+
end
|
11
|
+
|
12
|
+
def web?
|
13
|
+
self['platform_id'] == 4
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/strobe/resources.rb
CHANGED
data/lib/strobe/version.rb
CHANGED
data/lib/strobe.rb
CHANGED
@@ -39,10 +39,12 @@ module Strobe
|
|
39
39
|
|
40
40
|
|
41
41
|
# Errors
|
42
|
-
class StrobeError
|
43
|
-
class ResourceNotFoundError
|
44
|
-
class UnauthenticatedError
|
45
|
-
class ValidationError
|
42
|
+
class StrobeError < StandardError; end
|
43
|
+
class ResourceNotFoundError < StrobeError ; end
|
44
|
+
class UnauthenticatedError < StrobeError ; end
|
45
|
+
class ValidationError < StrobeError ; end
|
46
|
+
class OutdatedStrobeVersionError < StrobeError ; end
|
47
|
+
class InvalidPortError < StrobeError ; end
|
46
48
|
|
47
49
|
class NotifiableError < StrobeError
|
48
50
|
attr_reader :data
|
@@ -83,4 +85,27 @@ module Strobe
|
|
83
85
|
"/"
|
84
86
|
end
|
85
87
|
end
|
88
|
+
|
89
|
+
def self.ruby_digest
|
90
|
+
engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby"
|
91
|
+
|
92
|
+
version = case engine
|
93
|
+
when "jruby" then JRUBY_VERSION
|
94
|
+
when "rbx" then Rubinius::VERSION
|
95
|
+
else RUBY_VERSION
|
96
|
+
end
|
97
|
+
|
98
|
+
platform = defined?(RUBY_PLATFORM) ? RUBY_PLATFORM : "unknown"
|
99
|
+
|
100
|
+
"#{engine}/#{version} (#{platform})"
|
101
|
+
rescue Exception => e
|
102
|
+
# Be cool, don't freak out
|
103
|
+
"unknown/0 (unknown)"
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.user_agent
|
107
|
+
type = ENV['RUBY_PACKAGER'] ? 'pkg' : 'cli'
|
108
|
+
"strobe-#{type}/#{Strobe::VERSION} #{Strobe.ruby_digest}"
|
109
|
+
end
|
110
|
+
|
86
111
|
end
|
metadata
CHANGED
@@ -1,127 +1,113 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: strobe
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Carl Lerche
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-25 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: activemodel
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2158028000 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
18
|
+
requirements:
|
22
19
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
20
|
+
- !ruby/object:Gem::Version
|
24
21
|
version: 3.0.0
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bpm
|
29
23
|
prerelease: false
|
30
|
-
|
31
|
-
|
32
|
-
requirements:
|
33
|
-
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 1.0.0.beta.3.pre
|
36
|
-
type: :runtime
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: *2158028000
|
25
|
+
- !ruby/object:Gem::Dependency
|
39
26
|
name: mime-types
|
40
|
-
|
41
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
27
|
+
requirement: &2158027420 !ruby/object:Gem::Requirement
|
42
28
|
none: false
|
43
|
-
requirements:
|
29
|
+
requirements:
|
44
30
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
31
|
+
- !ruby/object:Gem::Version
|
46
32
|
version: 1.16.0
|
47
33
|
type: :runtime
|
48
|
-
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rack
|
51
34
|
prerelease: false
|
52
|
-
|
35
|
+
version_requirements: *2158027420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rack
|
38
|
+
requirement: &2158026620 !ruby/object:Gem::Requirement
|
53
39
|
none: false
|
54
|
-
requirements:
|
40
|
+
requirements:
|
55
41
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
57
43
|
version: 1.3.0
|
58
44
|
type: :runtime
|
59
|
-
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: thin
|
62
45
|
prerelease: false
|
63
|
-
|
46
|
+
version_requirements: *2158026620
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: thin
|
49
|
+
requirement: &2158026040 !ruby/object:Gem::Requirement
|
64
50
|
none: false
|
65
|
-
requirements:
|
51
|
+
requirements:
|
66
52
|
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
53
|
+
- !ruby/object:Gem::Version
|
68
54
|
version: 1.2.0
|
69
55
|
type: :runtime
|
70
|
-
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: em-http-request
|
73
56
|
prerelease: false
|
74
|
-
|
57
|
+
version_requirements: *2158026040
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: em-http-request
|
60
|
+
requirement: &2158021320 !ruby/object:Gem::Requirement
|
75
61
|
none: false
|
76
|
-
requirements:
|
62
|
+
requirements:
|
77
63
|
- - ~>
|
78
|
-
- !ruby/object:Gem::Version
|
64
|
+
- !ruby/object:Gem::Version
|
79
65
|
version: 1.0.0.beta
|
80
66
|
type: :runtime
|
81
|
-
version_requirements: *id006
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: thor
|
84
67
|
prerelease: false
|
85
|
-
|
68
|
+
version_requirements: *2158021320
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: &2158020680 !ruby/object:Gem::Requirement
|
86
72
|
none: false
|
87
|
-
requirements:
|
73
|
+
requirements:
|
88
74
|
- - ~>
|
89
|
-
- !ruby/object:Gem::Version
|
75
|
+
- !ruby/object:Gem::Version
|
90
76
|
version: 0.14.0
|
91
77
|
type: :runtime
|
92
|
-
version_requirements: *id007
|
93
|
-
- !ruby/object:Gem::Dependency
|
94
|
-
name: oauth
|
95
78
|
prerelease: false
|
96
|
-
|
79
|
+
version_requirements: *2158020680
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: oauth
|
82
|
+
requirement: &2158020140 !ruby/object:Gem::Requirement
|
97
83
|
none: false
|
98
|
-
requirements:
|
84
|
+
requirements:
|
99
85
|
- - ~>
|
100
|
-
- !ruby/object:Gem::Version
|
86
|
+
- !ruby/object:Gem::Version
|
101
87
|
version: 0.4.5
|
102
88
|
type: :runtime
|
103
|
-
version_requirements: *id008
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: launchy
|
106
89
|
prerelease: false
|
107
|
-
|
90
|
+
version_requirements: *2158020140
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: launchy
|
93
|
+
requirement: &2158019680 !ruby/object:Gem::Requirement
|
108
94
|
none: false
|
109
|
-
requirements:
|
110
|
-
- -
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version:
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
113
99
|
type: :runtime
|
114
|
-
|
115
|
-
|
116
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2158019680
|
102
|
+
description: The client library for deploying applications to Strobe's HTML5 deployment
|
103
|
+
platform
|
104
|
+
email:
|
117
105
|
- carl@strobecorp.com
|
118
|
-
executables:
|
106
|
+
executables:
|
119
107
|
- strobe
|
120
108
|
extensions: []
|
121
|
-
|
122
109
|
extra_rdoc_files: []
|
123
|
-
|
124
|
-
files:
|
110
|
+
files:
|
125
111
|
- lib/strobe/addons/social/facebook.rb
|
126
112
|
- lib/strobe/addons/social/twitter.rb
|
127
113
|
- lib/strobe/addons/social.rb
|
@@ -155,6 +141,7 @@ files:
|
|
155
141
|
- lib/strobe/resources/deploy.rb
|
156
142
|
- lib/strobe/resources/me.rb
|
157
143
|
- lib/strobe/resources/membership.rb
|
144
|
+
- lib/strobe/resources/platform_install.rb
|
158
145
|
- lib/strobe/resources/signup.rb
|
159
146
|
- lib/strobe/resources/team.rb
|
160
147
|
- lib/strobe/resources/user.rb
|
@@ -166,33 +153,28 @@ files:
|
|
166
153
|
- CHANGELOG.md
|
167
154
|
- README.md
|
168
155
|
- bin/strobe
|
169
|
-
has_rdoc: true
|
170
156
|
homepage: http://rubygems.org/gems/strobe
|
171
157
|
licenses: []
|
172
|
-
|
173
158
|
post_install_message:
|
174
159
|
rdoc_options: []
|
175
|
-
|
176
|
-
require_paths:
|
160
|
+
require_paths:
|
177
161
|
- lib
|
178
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
163
|
none: false
|
180
|
-
requirements:
|
181
|
-
- -
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
version:
|
184
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
169
|
none: false
|
186
|
-
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
189
173
|
version: 1.3.6
|
190
174
|
requirements: []
|
191
|
-
|
192
175
|
rubyforge_project: strobe
|
193
|
-
rubygems_version: 1.
|
176
|
+
rubygems_version: 1.8.6
|
194
177
|
signing_key:
|
195
178
|
specification_version: 3
|
196
179
|
summary: A deployment tool for HTML5 applications
|
197
180
|
test_files: []
|
198
|
-
|