-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
38 lines (31 loc) · 944 Bytes
/
deploy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const program = require('commander');
const request = require('request');
const fs = require('fs');
function deploy(url, path, token, id, version, esoVersion) {
console.log("deploy to %s", url);
const formData = {
id,
version,
updatefile: fs.createReadStream(path),
// description: description,
// changelog: changelog,
compatible: esoVersion
};
return new Promise((resolve, reject) => {
const options = { headers: { 'x-api-token': token }, url, formData };
return request.post(options, (error, httpResponse, body) => {
if (error) {
reject(error)
}
if (httpResponse.statusCode - 200 > 100) {
reject(httpResponse.statusMessage)
}
console.log(`Successfully published to ESO.\n${body}`)
resolve(body)
})
});
}
program
.command('upload [url] [path] [token] [id] [version] [esoVersion]')
.action(deploy);
program.parse(process.argv);