Comparing version 0.0.5 to 0.0.6
10
index.js
@@ -12,5 +12,13 @@ // Description: | ||
const getMessage = (hook) => { | ||
const url = `https://www.npmjs.com/package/${hook.name}`; | ||
switch (hook.event) { | ||
case 'package:star': | ||
return `${hook.change.user} starred ${hook.name} – ${url}`; | ||
case 'package:unstar': | ||
return `${hook.change.user} unstarred ${hook.name} – ${url}`; | ||
case 'package:publish': | ||
return `${hook.name}@${hook.change.version} published – https://www.npmjs.com/package/${hook.name}`; | ||
return `${hook.name}@${hook.change.version} published – ${url}`; | ||
case 'package:unpublish': | ||
return `${hook.name}@${hook.change.version} unpublished – ${url}`; | ||
} | ||
@@ -17,0 +25,0 @@ }; |
{ | ||
"name": "hubot-npm", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Hubot script for npm notifications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,3 @@ # hubot-npm | ||
``` | ||
<HUBOT_URL>:<PORT>/hubot/npm?room=<room> | ||
<hubot_url>:<port>/hubot/npm?room=<room> | ||
``` | ||
@@ -41,3 +41,3 @@ | ||
``` | ||
wombat hook add npm <HUBOT_URL>:<PORT>/hubot/npm?room=<room> <secret> | ||
wombat hook add <user|package|scope> <hubot_url>:<port>/hubot/npm?room=<room> <secret> | ||
``` |
@@ -12,3 +12,6 @@ 'use strict'; | ||
const events = { | ||
publish: require('./events/publish') | ||
'package:publish': require('./events/package:publish'), | ||
'package:unpublish': require('./events/package:unpublish'), | ||
'package:star': require('./events/package:star'), | ||
'package:unstar': require('./events/package:unstar') | ||
}; | ||
@@ -36,28 +39,80 @@ | ||
describe('when a package is published', () => { | ||
it('announces the package to the room', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm?room=test-room') | ||
.send(events.publish) | ||
.expect(200) | ||
.end((err) => { | ||
assert.ifError(err); | ||
sinon.assert.calledWith( | ||
robot.send, | ||
sinon.match({ | ||
room: ['#test-room'] | ||
}), | ||
'npm-hook-test@0.0.4 published – https://www.npmjs.com/package/npm-hook-test' | ||
); | ||
done(); | ||
}); | ||
}); | ||
it('supports the package:publish hook', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm?room=test-room') | ||
.send(events['package:publish']) | ||
.expect(200) | ||
.end((err) => { | ||
assert.ifError(err); | ||
sinon.assert.calledWith( | ||
robot.send, | ||
sinon.match({ | ||
room: ['#test-room'] | ||
}), | ||
'npm-hook-test@0.0.4 published – https://www.npmjs.com/package/npm-hook-test' | ||
); | ||
done(); | ||
}); | ||
}); | ||
it('returns a 400 when the room is missing', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm') | ||
.send(events.publish) | ||
.expect(400, done); | ||
}); | ||
it('supports the package:unpublish hook', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm?room=test-room') | ||
.send(events['package:unpublish']) | ||
.expect(200) | ||
.end((err) => { | ||
assert.ifError(err); | ||
sinon.assert.calledWith( | ||
robot.send, | ||
sinon.match({ | ||
room: ['#test-room'] | ||
}), | ||
'npm-hook-test@0.0.4 unpublished – https://www.npmjs.com/package/npm-hook-test' | ||
); | ||
done(); | ||
}); | ||
}); | ||
it('supports the package:star hook', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm?room=test-room') | ||
.send(events['package:star']) | ||
.expect(200) | ||
.end((err) => { | ||
assert.ifError(err); | ||
sinon.assert.calledWith( | ||
robot.send, | ||
sinon.match({ | ||
room: ['#test-room'] | ||
}), | ||
'a-user starred npm-hook-test – https://www.npmjs.com/package/npm-hook-test' | ||
); | ||
done(); | ||
}); | ||
}); | ||
it('supports the package:unstar hook', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm?room=test-room') | ||
.send(events['package:unstar']) | ||
.expect(200) | ||
.end((err) => { | ||
assert.ifError(err); | ||
sinon.assert.calledWith( | ||
robot.send, | ||
sinon.match({ | ||
room: ['#test-room'] | ||
}), | ||
'a-user unstarred npm-hook-test – https://www.npmjs.com/package/npm-hook-test' | ||
); | ||
done(); | ||
}); | ||
}); | ||
it('returns a 400 when the room is missing', (done) => { | ||
request(robot.router) | ||
.post('/hubot/npm') | ||
.send(events.publish) | ||
.expect(400, done); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12
7172
202
1