Last active
February 24, 2018 15:44
-
-
Save nicgirault/f014fc555dcb78537de58029a9a6913f to your computer and use it in GitHub Desktop.
Visualise dependencies updates in Slack #techdebtviz #slack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const npmCheck = require('npm-check') | |
const states = [ | |
{ | |
title: 'π€ Major update available', | |
filter: item => item.bump === 'major', | |
text: item => `${item.moduleName}: ${item.installed} β ${item.latest}`, | |
color: 'danger' | |
}, | |
{ | |
title: 'π Minor update available', | |
filter: item => item.bump === 'minor', | |
text: item => `${item.moduleName}: ${item.installed} β ${item.latest}`, | |
color: 'warning' | |
}, | |
{ | |
title: 'π¬ Packages that seem unused', | |
filter: item => item.unused, | |
text: item => item.moduleName, | |
color: 'warning' | |
}, | |
{ | |
title: 'π Up to date packages', | |
filter: item => item.bump === null, | |
text: item => `${item.moduleName}: ${item.installed} β ${item.latest}`, | |
color: 'good' | |
} | |
] | |
const getSlackMessage = () => { | |
return npmCheck() | |
.then(currentState => ({ | |
username: 'Lalibot', | |
text: 'Student App dependencies', | |
channel: '#techdebt', | |
attachments: states.map(state => ({ | |
fallback: state.title, | |
title: state.title, | |
color: state.color, | |
text: currentState.get('packages').filter(state.filter).map(state.text).join('\n') | |
})) | |
})) | |
} | |
module.exports = { | |
getSlackMessage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment