vulcan 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vulcan/cli.rb CHANGED
@@ -115,7 +115,8 @@ update the build server
115
115
 
116
116
  Dir.mktmpdir do |dir|
117
117
  Dir.chdir(dir) do
118
- api_key = %x{ env BUNDLE_GEMFILE= heroku credentials }
118
+ api_key = %x{ env BUNDLE_GEMFILE= heroku credentials 2>&1 }.chomp
119
+ error "invalid api key detected, try running `heroku credentials`" if api_key =~ / /
119
120
 
120
121
  system "git init"
121
122
  system "git remote add heroku git@heroku.com:#{config[:app]}.git"
@@ -1,5 +1,5 @@
1
1
  module Vulcan
2
2
 
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
 
5
5
  end
data/server/web.js CHANGED
@@ -14,34 +14,48 @@ var app = express.createServer(
14
14
  require('connect-form')({ keepExtensions: true })
15
15
  );
16
16
 
17
+ // connect to couchdb
17
18
  var couchdb_url = require('url').parse(process.env.CLOUDANT_URL);
18
-
19
19
  var couchdb_options = couchdb_url.auth ?
20
- {
21
- auth: { username: couchdb_url.auth.split(':')[0], password: couchdb_url.auth.split(':')[1] }
22
- } :
20
+ { auth: { username: couchdb_url.auth.split(':')[0], password: couchdb_url.auth.split(':')[1] } } :
23
21
  { }
24
-
25
22
  var db = new(cradle.Connection)(couchdb_url.hostname, couchdb_url.port || 5984, couchdb_options).database('make');
26
-
27
23
  db.create();
28
24
 
25
+ // POST /make starts a build
29
26
  app.post('/make', function(request, response, next) {
27
+
28
+ // require a form
30
29
  if (! request.form) {
31
- response.send('invalid');
30
+ response.write('invalid form');
31
+ response.send(500);
32
32
  } else {
33
+
34
+ // form handler
33
35
  request.form.complete(function(err, fields, files) {
36
+
37
+ // if there's an error
34
38
  if (err) {
39
+
40
+ // pass through to the next handler
35
41
  next(err);
42
+
36
43
  } else {
44
+
45
+ // match on the shared secret
37
46
  if (fields.secret != process.env.SECRET) {
47
+ response.write('invalid secret');
38
48
  response.send(500);
39
49
  } else {
50
+
40
51
  var id = uuid();
41
52
  var command = fields.command;
42
53
  var prefix = fields.prefix;
43
54
 
55
+ // create a couchdb documents for this build
44
56
  var doc = db.save(id, { command:command, prefix:prefix }, function(err, doc) {
57
+
58
+ // save the input tarball as an attachment
45
59
  db.saveAttachment(
46
60
  doc.id,
47
61
  doc.rev,
@@ -49,14 +63,16 @@ app.post('/make', function(request, response, next) {
49
63
  'application/octet-stream',
50
64
  fs.createReadStream(files.code.path),
51
65
  function(err, data) {
66
+
67
+ // spawn bin/make with this build id
52
68
  var ls = spawner.spawn('bin/make ' + id, function(err) {
53
- console.log('couldnt spawn: ' + err);
69
+ response.write('could not spawn: ' + err);
70
+ response.send(500);
54
71
  });
55
72
 
56
73
  ls.on('error', function(error) {
57
- response.writeHead(500);
58
- console.log('error: ' + error);
59
- response.end();
74
+ response.write('error: ' + err);
75
+ response.send(500);
60
76
  });
61
77
 
62
78
  ls.on('data', function(data) {
@@ -69,6 +85,7 @@ app.post('/make', function(request, response, next) {
69
85
  }
70
86
  );
71
87
 
88
+ // return the build id as a header
72
89
  response.header('X-Make-Id', id);
73
90
  });
74
91
  }
@@ -77,7 +94,10 @@ app.post('/make', function(request, response, next) {
77
94
  }
78
95
  });
79
96
 
97
+ // download build output
80
98
  app.get('/output/:id', function(request, response, next) {
99
+
100
+ // from couchdb
81
101
  var stream = db.getAttachment(request.params.id, 'output');
82
102
 
83
103
  stream.on('data', function(chunk) {
@@ -87,8 +107,10 @@ app.get('/output/:id', function(request, response, next) {
87
107
  stream.on('end', function(chunk) {
88
108
  response.end();
89
109
  });
110
+
90
111
  });
91
112
 
113
+ // start up the webserver
92
114
  var port = process.env.PORT || 3000;
93
115
  console.log('listening on port ' + port);
94
116
  app.listen(port);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vulcan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multipart-post
16
- requirement: &70286582431000 !ruby/object:Gem::Requirement
16
+ requirement: &70260058252980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70286582431000
24
+ version_requirements: *70260058252980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &70286582430240 !ruby/object:Gem::Requirement
27
+ requirement: &70260058252160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70286582430240
35
+ version_requirements: *70260058252160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: thor
38
- requirement: &70286582429540 !ruby/object:Gem::Requirement
38
+ requirement: &70260058251500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.14.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70286582429540
46
+ version_requirements: *70260058251500
47
47
  description: Build software in the cloud
48
48
  email: ddollar@gmail.com
49
49
  executables: