Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11 from Springworks/update-dependencies
Browse files Browse the repository at this point in the history
Update dependencies and use semantic-release
  • Loading branch information
Mathias Fernström committed May 11, 2016
2 parents 48ea953 + c05cb72 commit d52b5d5
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 76 deletions.
1 change: 0 additions & 1 deletion .istanbul.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ reporting:
print: summary
reports:
- lcov
- teamcity
22 changes: 15 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
sudo: false
language: node_js
node_js:
- '4'
script:
- npm run lint
- npm test
after_success:
- npm run coveralls
- '4'
- '6'
notifications:
email: false
slack:
secure: aX0oEq3Wqzkl8z5Z9Z0rYuHC+zCCkynAuip4bErlG5hf6gfScgUrYOv5DfE/pY3kajNBlPGk6aqlrajzJ3J0ZmrRqdI17h4MyG17/bmAmgYK+WQhaIrdxXL/+GW1lECJuxXja/L6IPq7je6lVBlxncmIlp/OqcTVlHDmC2idlQ8lMJskwF//k8hkA8NKBikQzisAaNH3qKCtSGLQyMqYHFD/U07wGfhS55cEUQp/mxYLTaEH85eTAoez/Am7uuvAsqli4TCK5Vj7v0pk5lrbC4+9q2aunlzi66IhR54YOLjMj3nogkaOoYEZNOr5HIq6YfXL33i2H67HvCS4uojZjmfagX/V2A1JHam7BTGqJGpaWHmRBCFSIq85o3myGCsN3lGactQkUpIVGxbRCviLbanfZRiTv8ld60JmAdVNqKgbCw5of2wshQtObN98Xnej9V+8+BNN3kAULlAUd3TMj+4JbNlFf2T5CEktR8qtwUjbxgr4/5RMRWpQgAFdRbnF9wtWr80Z+0sQbhHkI+dBBzKHEze1Z1+0O07EBTlD3H2GBlDD6HcBxZ9G/7kbLZvEnxya65wnAvQ5BT0xw7e9bNxnXCSwpYqEES2SvqYUd0IqadFlZucuiM6HtxzUCRVzphZoUgt4qAODgn7XQKvf6YLx7vEnJkptZUAduraNUj0=
sudo: false
script:
- npm run lint
- npm test
after_success:
- npm run coveralls
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all'
- python travis_after_all.py
- export $(cat .to_export_back) &> /dev/null
- npm run semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
3 changes: 1 addition & 2 deletions bin/deployment-completed.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node

var record_deployment = require('../lib/cli/record-deployment');
record_deployment.run(process);
require('../lib/cli/record-deployment').run(process);
3 changes: 1 addition & 2 deletions bin/deployment-suggestion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env node

var deployment_notifier = require('../lib/cli/suggest-deployment');
deployment_notifier.run(process);
require('../lib/cli/suggest-deployment').run(process);
65 changes: 37 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,62 @@
{
"name": "deployment-notifier",
"version": "1.2.4",
"description": "Sends notifications about deployments for a Git repo",
"private": false,
"license": "MIT",
"main": "./lib/index.js",
"scripts": {
"prepublish": "npm run build",
"build": "rm -rf lib && babel src --out-dir lib",
"test": "NODE_ENV=test istanbul cover _mocha",
"lint": "eslint .",
"coveralls": "cat ./coverage/lcov.info | coveralls"
"coveralls": "cat ./coverage/lcov.info | coveralls",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"commit": "commit-wizard"
},
"bin": {
"deployment-suggestion": "./bin/deployment-suggestion.js",
"deployment-completed": "./bin/deployment-completed.js"
},
"dependencies": {
"@springworks/input-validator": "4.0.12",
"commander": "2.9.0",
"node-slack": "0.0.7",
"request": "2.72.0"
},
"devDependencies": {
"@springworks/test-harness": "1.3.4",
"babel-cli": "6.8.0",
"babel-core": "6.8.0",
"babel-eslint": "6.0.4",
"babel-plugin-transform-strict-mode": "6.8.0",
"babel-preset-es2015": "6.6.0",
"babel-register": "6.8.0",
"coveralls": "2.11.9",
"eslint": "2.9.0",
"eslint-config-springworks": "7.0.3",
"eslint-plugin-import": "1.7.0",
"eslint-plugin-mocha": "2.2.0",
"eslint-plugin-should-promised": "1.0.8",
"eslint-plugin-springworks": "2.0.1",
"istanbul": "1.0.0-alpha.2",
"mocha": "2.4.5",
"pre-git": "3.8.4",
"semantic-release": "4.3.5"
},
"config": {
"pre-git": {
"commit-msg": "conventional"
}
},
"engines": {
"node": ">=4.2.2",
"npm": ">=3.3.12"
"node": ">=4",
"npm": ">=2.7"
},
"repository": {
"type": "git",
"url": "git://github.com/Springworks/node-deployment-notifier.git"
"url": "https://github.com/Springworks/node-deployment-notifier.git"
},
"author": "Springworks",
"bugs": {
"url": "https://github.com/Springworks/node-deployment-notifier/issues"
},
"dependencies": {
"@springworks/input-validator": "3.1.2",
"commander": "2.9.0",
"node-slack": "0.0.7",
"request": "2.65.0"
},
"devDependencies": {
"@springworks/test-harness": "1.2.0",
"babel-cli": "6.3.17",
"babel-core": "6.3.17",
"babel-eslint": "4.1.2",
"babel-plugin-transform-strict-mode": "6.3.13",
"babel-preset-es2015": "6.3.13",
"babel-register": "6.3.13",
"coveralls": "2.11.4",
"eslint": "1.5.1",
"eslint-config-springworks": "3.1.1",
"eslint-plugin-mocha": "1.0.0",
"eslint-plugin-should-promised": "1.0.5",
"istanbul": "0.3.21",
"mocha": "2.3.3"
}
}
19 changes: 9 additions & 10 deletions src/deployment-advisor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@ exports.create = function(git_service, slack_notifier) {


internals.suggestDeployment = function({ git_service, slack_notifier }, app_name, latest_tag_name, deployment_url) {
return git_service
.getChangesBetweenTags(latest_tag_name)
return git_service.getChangesBetweenTags(latest_tag_name)
.then(changelog => {
if (changelog) {
return git_service
.getLatestAuthorName()
.then(last_author => {
const attachments = [internals.generateDeploymentSuggestionSlackAttachment(changelog, latest_tag_name)];
const message = `Hey, *${last_author}*. Might be a good time to deploy *${app_name}*.\n:package: ${deployment_url}`;
return slack_notifier.sendDeploymentMessage(message, attachments);
});
if (!changelog) {
return null;
}
return git_service.getLatestAuthorName()
.then(last_author => {
const attachments = [internals.generateDeploymentSuggestionSlackAttachment(changelog, latest_tag_name)];
const message = `Hey, *${last_author}*. Might be a good time to deploy *${app_name}*.\n:package: ${deployment_url}`;
return slack_notifier.sendDeploymentMessage(message, attachments);
});
})
.catch(err => {
console.error('suggestDeployment failed', err);
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/index-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const index = require('../../src');

describe(__filename, () => {
describe('test/acceptance/index-test.js', () => {

describe('index', () => {
const mock_process = {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/configurator-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const configurator = require('../../src/configurator');
const internals = {};

describe(__filename, () => {
describe('test/unit/configurator-test.js', () => {

describe('create', () => {
let env;
Expand Down
22 changes: 11 additions & 11 deletions test/unit/deployment-advisor-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const deployment_advisor = require('../../src/deployment-advisor');
const dependency_helper = require('../../test-util/dependency-helper');

describe(__filename, function() {
describe('test/unit/deployment-advisor-test.js', () => {
let sinon_sandbox;
let mock_git_service;
let mock_slack_notifier;
Expand All @@ -15,7 +15,7 @@ describe(__filename, function() {
sinon_sandbox.restore();
});

beforeEach(function mockDependencies() {
beforeEach('mockDependencies', () => {
mock_git_service = dependency_helper.mockGitService();
mock_slack_notifier = dependency_helper.mockSlackNotifier();

Expand All @@ -41,19 +41,19 @@ describe(__filename, function() {
describe('when dependencies succeed', () => {
let send_deployment_message_stub;

beforeEach(function mockSendMessage() {
beforeEach('mockSendMessage', () => {
send_deployment_message_stub = sinon_sandbox.stub(mock_slack_notifier, 'sendDeploymentMessage').returns(Promise.resolve(null));
});

describe('when changelog contains changes', () => {
const changelog = 'These are all the changes';
const author_name = 'John Doe';

beforeEach(function mockChangelog() {
beforeEach('mockChangelog', () => {
sinon_sandbox.stub(mock_git_service, 'getChangesBetweenTags').returns(Promise.resolve(changelog));
});

beforeEach(function mockLastAuthor() {
beforeEach('mockLastAuthor', () => {
sinon_sandbox.stub(mock_git_service, 'getLatestAuthorName').returns(Promise.resolve(author_name));
});

Expand Down Expand Up @@ -94,11 +94,11 @@ describe(__filename, function() {
const changelog = '';
const author_name = '';

beforeEach(function mockChangelog() {
beforeEach('mockChangelog', () => {
sinon_sandbox.stub(mock_git_service, 'getChangesBetweenTags').returns(Promise.resolve(changelog));
});

beforeEach(function mockLastAuthor() {
beforeEach('mockLastAuthor', () => {
sinon_sandbox.stub(mock_git_service, 'getLatestAuthorName').returns(Promise.resolve(author_name));
});

Expand All @@ -113,7 +113,7 @@ describe(__filename, function() {

describe('when git_service fails', () => {

beforeEach(function mockChangelog() {
beforeEach('mockChangelog', () => {
const err = new Error('Mocked getChangesBetweenTags error');
sinon_sandbox.stub(mock_git_service, 'getChangesBetweenTags').returns(Promise.reject(err));
});
Expand All @@ -126,15 +126,15 @@ describe(__filename, function() {

describe('when only slack_notifier fails', () => {

beforeEach(function mockChangelog() {
beforeEach('mockChangelog', () => {
sinon_sandbox.stub(mock_git_service, 'getChangesBetweenTags').returns(Promise.resolve('These are all the changes'));
});

beforeEach(function mockLastAuthor() {
beforeEach('mockLastAuthor', () => {
sinon_sandbox.stub(mock_git_service, 'getLatestAuthorName').returns(Promise.resolve('John Doe'));
});

beforeEach(function mockFailedSendMessage() {
beforeEach('mockFailedSendMessage', () => {
const err = new Error('Mocked getChangesBetweenTags error');
sinon_sandbox.stub(mock_slack_notifier, 'sendDeploymentMessage').returns(Promise.reject(err));
});
Expand Down
6 changes: 3 additions & 3 deletions test/unit/deployment-recorder-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const deployment_recorder = require('../../src/deployment-recorder');
const dependency_helper = require('../../test-util/dependency-helper');

describe(__filename, function() {
describe('test/unit/deployment-recorder-test.js', () => {
let sinon_sandbox;
let mock_git_service;
let mock_slack_notifier;
Expand Down Expand Up @@ -52,11 +52,11 @@ describe(__filename, function() {
get_changes_since_tag_stub = sinon_sandbox.stub(mock_git_service, 'getChangesBetweenTags').returns(Promise.resolve(changelog));
});

beforeEach(function mockSendSlackMessage() {
beforeEach('mockSendSlackMessage', () => {
send_slack_deployment_message_stub = sinon_sandbox.stub(mock_slack_notifier, 'sendDeploymentMessage').returns(Promise.resolve(null));
});

beforeEach(function mockSendWebhookMessage() {
beforeEach('mockSendWebhookMessage', () => {
send_webhook_deployment_message_stub = sinon_sandbox.stub(mock_webhook_notifier, 'sendDeploymentMessage').returns(Promise.resolve(null));
});

Expand Down
10 changes: 5 additions & 5 deletions test/unit/git/git-service-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const git_service = require('../../../src/git/git-service');

describe(__filename, function() {
describe('test/unit/git/git-service-test.js', () => {
const mock_child_process = {};
let sinon_sandbox;

Expand Down Expand Up @@ -37,7 +37,7 @@ describe(__filename, function() {
describe('when exec() succeeds', () => {
const result_str = 'This is the change';

beforeEach(function mockSuccessfulCommand() {
beforeEach('mockSuccessfulCommand', () => {
execute_command_stub = sinon_sandbox.stub(git_service.internals, 'executeCommand').returns(Promise.resolve(result_str));
});

Expand Down Expand Up @@ -66,7 +66,7 @@ describe(__filename, function() {

describe('when exec() fails', () => {

beforeEach(function mockFailingExecuteCommand() {
beforeEach('mockFailingExecuteCommand', () => {
const err = new Error('Mocked exec() error');
execute_command_stub = sinon_sandbox.stub(git_service.internals, 'executeCommand').returns(Promise.reject(err));
});
Expand All @@ -87,7 +87,7 @@ describe(__filename, function() {
describe('when exec() succeeds', () => {
const result_str = 'This is the change';

beforeEach(function mockSuccessfulCommand() {
beforeEach('mockSuccessfulCommand', () => {
execute_command_stub = sinon_sandbox.stub(git_service.internals, 'executeCommand').returns(Promise.resolve(result_str));
});

Expand Down Expand Up @@ -123,7 +123,7 @@ describe(__filename, function() {
describe('when exec() succeeds', () => {
const result_str = 'John Doe';

beforeEach(function mockSuccessfulCommand() {
beforeEach('mockSuccessfulCommand', () => {
execute_command_stub = sinon_sandbox.stub(git_service.internals, 'executeCommand').returns(Promise.resolve(result_str));
});

Expand Down
8 changes: 4 additions & 4 deletions test/unit/http/webhook-notifier-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const webhook_notifier = require('../../../src/http/webhook-notifier');

describe(__filename, () => {
describe('test/unit/http/webhook-notifier-test.js', () => {
const webhook_url = 'https://internet.com';
const basic_auth = {
username: 'user',
Expand Down Expand Up @@ -68,7 +68,7 @@ describe(__filename, () => {
describe('when request succeeds', () => {
let send_request_stub;

beforeEach(function mockSendRequest() {
beforeEach('mockSendRequest', () => {
const mock_response = {};
const mock_body = {};
send_request_stub = sinon_sandbox.stub(webhook_notifier.internals, 'sendRequest').callsArgWithAsync(2, null, mock_response, mock_body);
Expand Down Expand Up @@ -108,7 +108,7 @@ describe(__filename, () => {

describe('when request fails with error status code', () => {

beforeEach(function mockFailedSendRequest() {
beforeEach('mockFailedSendRequest', () => {
const mock_response = { statusCode: 404 };
const mock_body = {};
sinon_sandbox.stub(webhook_notifier.internals, 'sendRequest').callsArgWithAsync(2, null, mock_response, mock_body);
Expand All @@ -123,7 +123,7 @@ describe(__filename, () => {

describe('when request fails with error', () => {

beforeEach(function mockFailedSendRequest() {
beforeEach('mockFailedSendRequest', () => {
const mock_err = new Error('Mocked timeout');
sinon_sandbox.stub(webhook_notifier.internals, 'sendRequest').callsArgWithAsync(2, mock_err, null, null);
});
Expand Down
2 changes: 1 addition & 1 deletion test/unit/slack/slack-notifier-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const slack_notifier = require('../../../src/slack/slack-notifier');

describe(__filename, () => {
describe('test/unit/slack/slack-notifier-test.js', () => {
let sinon_sandbox;

beforeEach(() => {
Expand Down

0 comments on commit d52b5d5

Please sign in to comment.