If you are a Node-Red fan (and if not – why not) – you’ll know that the NODES – i.e. the modules that are provided with Node-Red or that people like myself create – get updated every now and then. And it is a pain in the bum to keep checking to see if any of them need updating.
So – how about a weekly or monthly email detailing any updates!
It turns out that there is a handy command called “npm outdated” which returns a list of out of date devices!
So here’s the general sequence…
cd .node-red // if you’re in the PI directory of your Pi or similar – this will take you to the Node Red directory
npm outdated // this will show you a list of out-dated nodes (or nothing).
You can then go off and do updates when you wish.
It occurred to me that this needed automating. One of the guys at the Node-Red groups (Mark Setrem) gave me this:
npm outdated --prefix ~/.node-red
That saves having to switch to the Node Red directory – and so from there – a simple flow…
The timestamp node can be set to output every week or month – the exec node contains what you see above – and the green email node contains email credentials.
The payload (email body) comes from the middle exec node, fill in the TOPIC in the timestamp and you have your SUBJECT line.
The output (which you can test by pressing the button on the timestamp – who’s payload is ignored)….
The whole operation takes several seconds but because of the way Node-Red works – it’s not holding anything up. Ok, formatting could be better – but who cares – it does the job.
The original information that started me off is on the Node-Red site..
I’d updated NODE and NPN to the latest versions and that made some nodes fail (SQLITE)… also I realised when thinking about it – that some of those nodes have not been updated in a while – here’s how I gotaround the lot…
sudo npm cache clean
sudo npm update -g --unsafe-perm node-red
So that gets you the latest Node-Red after any updates of Node etc…
The above gives you a list of your nodes that may be out of date either through a node update – or simply – age!!
npm update # to update all nodes, or
npm update foo # to only update a node called foo
Just adding in a little extra here (10/dec/2016) as I cracked formatting.
Simple really… in the Exec node itself I added a JSON flag
npm outdated -json --prefix ~/.node-red
and in the function I then simply used a table (the kind of clever CSS we often use on web pages is not too good in emails as there are many clients out there which still handle only the simplest of HTML – I learned that the hard way a while ago after developing a mass email system for a large organisation – my code was directly responsible for formatting and sending out many, many millions of emails running most hours of the day – you soon learn how many people are cheesed off at your attempts at styling)
So keeping it simple (ok, I should have used HEX for the colour – I’m being lazy here)..
Now… I DID try Antonio’s version (see the comments below) and got the rather lovely email below… other than the missing first letter !! and I would have expected it to include the location contents as well – for some reason it didn’t… but nice and simple…