hubot-appveyor
Advanced tools
Comparing version 0.0.1 to 0.0.7
@@ -6,11 +6,15 @@ "use strict"; | ||
const build_1 = require('./scripts/build'); | ||
const builds_1 = require('./scripts/builds'); | ||
const deploy_1 = require('./scripts/deploy'); | ||
const error_1 = require('./scripts/error'); | ||
const appveyor_1 = require('./lib/appveyor'); | ||
const config_1 = require('./lib/config'); | ||
module.exports = (robot) => { | ||
const appveyor = new appveyor_1.AppVeyor(robot.http, config_1.Config.appveyor.token, config_1.Config.appveyor.account); | ||
const appveyor = new appveyor_1.AppVeyor(robot.http.bind(robot), config_1.Config.appveyor.token, config_1.Config.appveyor.account); | ||
error_1.default(robot); | ||
hello_1.default(robot); | ||
build_1.default(robot, appveyor); | ||
builds_1.default(robot, appveyor); | ||
deploy_1.default(robot, appveyor); | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -18,9 +18,16 @@ "use strict"; | ||
if (resp.statusCode !== 200) | ||
return reject(new Error(`Got an unexpected status code: ${resp.statusCode}`)); | ||
return resolve({ | ||
ok: false, | ||
statusCode: resp.statusCode | ||
}); | ||
const o = JSON.parse(data); | ||
resolve({ | ||
accountName: this.accountName, | ||
projectSlug: projectSlug, | ||
version: o.version, | ||
link: `https://ci.appveyor.com/project/${this.accountName}/${projectSlug}/build/${o.version}` | ||
ok: true, | ||
statusCode: resp.statusCode, | ||
body: { | ||
accountName: this.accountName, | ||
projectSlug: projectSlug, | ||
version: o.version, | ||
link: `https://ci.appveyor.com/project/${this.accountName}/${projectSlug}/build/${o.version}` | ||
} | ||
}); | ||
@@ -30,2 +37,29 @@ }); | ||
} | ||
builds(projectSlug) { | ||
return new Promise((resolve, reject) => { | ||
this.get(`https://ci.appveyor.com/api/projects/${this.accountName}/${projectSlug}/history?recordsNumber=5`, (err, resp, data) => { | ||
if (err) | ||
return reject(err); | ||
if (resp.statusCode !== 200) | ||
return resolve({ ok: false, statusCode: resp.statusCode }); | ||
const o = JSON.parse(data); | ||
resolve({ | ||
ok: true, | ||
statusCode: resp.statusCode, | ||
body: { | ||
accountName: this.accountName, | ||
projectSlug: projectSlug, | ||
builds: o.builds.map((build) => ({ | ||
version: build.version, | ||
message: build.message, | ||
branch: build.branch, | ||
committer: build.committerName, | ||
status: build.status, | ||
link: `https://ci.appveyor.com/project/${this.accountName}/${projectSlug}/build/${build.version}` | ||
})) | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
deploy(projectSlug, version, environment) { | ||
@@ -43,6 +77,13 @@ const body = JSON.stringify({ | ||
if (resp.statusCode !== 200) | ||
return reject(new Error(`Got an unexpected status code: ${resp.statusCode}`)); | ||
return resolve({ | ||
ok: false, | ||
statusCode: resp.statusCode | ||
}); | ||
const o = JSON.parse(data); | ||
resolve({ | ||
link: `https://ci.appveyor.com/project/${this.accountName}/${projectSlug}/deployment/${o.deploymentId}` | ||
ok: true, | ||
statusCode: resp.statusCode, | ||
body: { | ||
link: `https://ci.appveyor.com/project/${this.accountName}/${projectSlug}/deployment/${o.deploymentId}` | ||
} | ||
}); | ||
@@ -59,4 +100,11 @@ }); | ||
} | ||
get(url, callback) { | ||
this.http(url) | ||
.header('Authorization', `Bearer ${this.token}`) | ||
.header('Content-Type', 'application/json') | ||
.header('Accept', 'application/json') | ||
.get()(callback); | ||
} | ||
} | ||
exports.AppVeyor = AppVeyor; | ||
//# sourceMappingURL=appveyor.js.map |
@@ -10,4 +10,5 @@ "use strict"; | ||
}, | ||
announce_channel: "#finbot-announce" | ||
announce_channel: "#finbot-announce", | ||
error_channel: "#finbot-coders" | ||
}; | ||
//# sourceMappingURL=config.js.map |
@@ -10,3 +10,5 @@ "use strict"; | ||
.then((data) => { | ||
let msgData = { | ||
if (!data.ok) | ||
return res.reply(`Could not start build. Got status code ${data.statusCode}`); | ||
const msgData = { | ||
channel: res.message.room, | ||
@@ -16,6 +18,6 @@ text: 'Build started', | ||
{ | ||
fallback: `Started build of '${projectSlug}' v${data.version}: ${data.link}`, | ||
fallback: `Started build of '${projectSlug}' v${data.body.version}: ${data.body.link}`, | ||
title: `Started build of '${projectSlug}'`, | ||
title_link: data.link, | ||
text: `v${data.version}`, | ||
title_link: data.body.link, | ||
text: `v${data.body.version}`, | ||
color: '#7CD197' | ||
@@ -27,5 +29,5 @@ } | ||
slackAdapter.customMessage(msgData); | ||
robot.brain.set(`${projectSlug}/${data.version}`, JSON.stringify({ username: res.message.user.name })); | ||
robot.brain.set(`${projectSlug}/${data.body.version}`, JSON.stringify({ username: res.message.user.name })); | ||
}) | ||
.catch(res.reply); | ||
.catch((reason) => robot.emit('error', reason, res)); | ||
}); | ||
@@ -32,0 +34,0 @@ robot.router.post('/hubot/appveyor/webhook', (req, res) => { |
@@ -11,2 +11,4 @@ "use strict"; | ||
.then((data) => { | ||
if (!data.ok) | ||
return res.reply(`Could not deploy. Got status code ${data.statusCode}`); | ||
let msgData = { | ||
@@ -17,5 +19,5 @@ channel: res.message.room, | ||
{ | ||
fallback: `Started deploy of '${project}' v${version} to '${environment}': ${data.link}`, | ||
fallback: `Started deploy of '${project}' v${version} to '${environment}': ${data.body.link}`, | ||
title: `Started deploy of '${project}' v${version}`, | ||
title_link: data.link, | ||
title_link: data.body.link, | ||
text: `v${version}`, | ||
@@ -29,5 +31,5 @@ color: '#2795b6' | ||
}) | ||
.catch(res.reply); | ||
.catch((reason) => robot.emit('error', reason, res)); | ||
}); | ||
}; | ||
//# sourceMappingURL=deploy.js.map |
@@ -5,5 +5,5 @@ "use strict"; | ||
robot.respond(/hello/i, (res) => { | ||
res.reply("Yeah, hello etc"); | ||
res.reply("Yeah, hello etc..."); | ||
}); | ||
}; | ||
//# sourceMappingURL=hello.js.map |
{ | ||
"name": "hubot-appveyor", | ||
"version": "0.0.1", | ||
"version": "0.0.7", | ||
"author": "David Wood <david.p.wood@gmail.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
59373
21
289
1