sf-package-version-checker – SFDX Plugin to notify on completion of Salesforce Package Builds

If you’ve ever built Salesforce packages with the SFDX commands (in fact long before this) you’ll know that the creation of a package can take some time, especially if your package has dependencies.

At MobileCaddy we’ve been adopting the SFDX CLI as much as we can – and in fact embracing the SFDX ethos as a whole – and recently we’ve been working with the Salesforce second-generation packaging (2GP). During this I’ve found that the standard SFDX command to create a package version would continue to give me status updates every 30 seconds for 10 minutes by default, and even though I could set the overall timeout to a longer value (using the –wait flag, and specifying a number of minutes) I often forgot that the task was running and found myself forgetting to watch the terminal window. What I really wanted was something that would notify once the build had completed successfully (or erroneously).

So, during one of the package builds (~25 minutes in this case, if I remember correctly) I put together the basis for a new SFDX plugin that I could run to monitor the latest package build request, and then ping up a desktop notification when it had completed.

I was actually on the line-up for the (now postponed) CzechDreamin’ 2020, with a talk titled “Take your SFDX Plugins to the Next Level”. The talk covers many ways to interact with SFDX plugins other than via the CLI, and one of the topics included was the use of the node-notifier npm module to create native desktop notifications, and so I put this to good use.

You can very easily support basic (and more advanced) notifications with node-notifier for Mac, Linux and Windows environments; here’s some sample code (similar to that used in my plugin);

First import node-notifier (after installing it with npm/yarn)

import * as notifier from 'node-notifier'

Then to use it have code similar to this;

notifier.notify({
 'title': 'Latest Packaging Version Creation Complete',
 'subtitle': ‘Success’,
 'message': SubscriberPackageVersionId: ' + res.SubscriberPackageVersionId
 'icon': iconPath,
 'sound': true,
 'timeout': 30
 });

This results in this type of experience;

The source code (with little over 100 lines of actual logic) can be found in the github repo, and the plugin can be installed as an SFDX CLI plugin and run with the following commands;

$ sfdx plugins:install sf-package-version-checker
$ 
$ sfdx pkgvsn:monitor

Adding a mobile number to Twitter

For a side project I’m currently working on (codenamed Shedwina, more details to follow later) I wanted to set up a Twitter NodeJS bot. On logging into https://dev.twitter.com as my bot account and trying to create a new app I got the error message that the account needed to have a mobile number associated with it. This in itself shouldn’t have been an issue but to set up a mobile number you need to send an SMS to a shortcode… sadly there was no option for EE in the UK and the long number option failed to work even after a few attempts.

I then come up with an idea… and it worked. Basically I installed the official Twitter client on my phone and checked the box which allowed the use of my phone number in the set-up phase. This has the desired affect and upon the next attempt at creating the app over at https://dev.twitter.com all worked like a dream.