Skip to content

Instantly share code, notes, and snippets.

@nicgirault
Last active February 24, 2018 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicgirault/f014fc555dcb78537de58029a9a6913f to your computer and use it in GitHub Desktop.
Save nicgirault/f014fc555dcb78537de58029a9a6913f to your computer and use it in GitHub Desktop.
Visualise dependencies updates in Slack #techdebtviz #slack
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