SFignore: The .forceignore Salesforce SFDX Plugin

Salesforce SFDX projects are a great way to build both declaratively and through code for the Salesforce platform. It’s very common to want to ignore particular files from being pushed or pulled between Orgs and your local project, and this is achieved through .forceignore file. The file has some odd (and undocumented) syntax however, and the process is also known to have a few bugs, and getting the right entries in the file can be hard… and that’s where the SFignore SFDX plugin comes in.

The .forceignore file and the process behind it is sprinkled with black magic – Todd Halfpenny, 2020

I’ve created the SFignore plugin initially through an internal need for the work I’ve been doing with the Caddify project at MobileCaddy. A lot of this work has been around using Salesforce 2GP (second generation packaging) tools to create packages for our new product. Our workflow includes pushing, pulling, deploying to many different shape orgs and includes a fair bit of code and metadata that is used solely for non-production scenarios (test setup, demo data, org cleaning, etc) and we want to make sure that nothing accidentally gets put into our managed package releases. The .forceignore file that is used by the SFDX CLI tooling and tracking allows us to do this – or most of it at least… but it’s syntax is nuanced and is lacking in documentation.

The SFignore plugin gives me an easier way to add entries to the .forceignore file, by taking away the guessing of syntax and the need to remember the correct suffixes for the different metadata types. This is useful, as would you know (or remember) if the correct suffix for a SiteDotCom entry should be SiteDotCom, siteDotCom, or site? And what about AppMenu? Would you know whether to use appMenu, AppMenu, Menu, menu? Only one of these is right, and the syntax differs further depending on whether the change is local or remote. Oh you also need to encode (some) special characters too… if you didn’t know that then this could be why your entry for “Custom: Sales Profile.profile” isn’t working as you expected.

The initial release only supports entries for remote changes, and only a subset of metadata types that I’ve had to use so far… but the roadmap for it includes;

  • Support for local syntax
  • Wildcarding – currently only supports specific entries
  • An extension for vscode.

Here’s an example of using the plugin, where we’re wanting to add an entry to ignore pulls for the profile Custom: Sales Profile.

sfdx sfignore:add -n "Custom: Sales Profile" -m Profile

This results in the following entry being added;

Custom%3A Sales Profile.profile

The -m flag specifies the metadata type, and the valid values should match those as seen on Salesforce’s metadata coverage report and the output of a sfdx force:source:status command.

It should also be noted that something’s appear to be impossible to achieve with the .forceignore file, including;

  • Adding some tests – yeah, sorry
  • Specifying specific custom fields
  • Specifying specific custom metadata
  • Specifying specific record types

If you know how to achieve the above I’d be very happy to hear about it.

You can find the source for SFignore SFDX plugin on github, and you can download it from the npm registry too

sfdx plugins:install sfignore

If you use the plugin and need more metadata types added then please raise an issue on github, or even better fork the repo and create a PR.

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

Solved: Opening a new Salesforce scratch org not working

Just a quickie… have you ever created a new Salesforce scratch org then tried to open it from the CLI with sfdx force:org:open only to be routed to login.salesfoce.com? Well I have, and it was really annoying me.

But I have a solution (at least it works for me), just enter the domain of your new scratch org – this is output by the CLI command -straight into your browser. On doing this I’m taken into my org in a logged in state.

The Salesforce Podcasts I listen to

I’m a big fan of podcasts, and although my daily commute is often only a few seconds long (I work from home most days) when I do travel up to London for clients meets, or to attend the many Salesforce Trailblazer groups, it’s a journey upwards of 1.5 hours, so it’s an ideal time to get some listening in.

I’m going to list here a few of the podcasts that I regularly enjoy, and also a couple of new ones that I’ve subscribed to just recently.

8) Salesforce Developer Podcast

Although it was only launched a couple of weeks ago, around Dreamforce ‘19, there are already a handful of episodes available. Josh Birk – Principal Developer Evangelist at Salesforce – interviews folk from the Salesforce ecosystem. The shows are relatively short at 15-30 mins and have covered topics such as porting Aura to LWC, Blockchain, and PMD (Apex static analysis tool), and have included great folk such as Fabien Taillon and Brian Fear.

7) DEVel-UP – A RAD Women Podcast

Another pretty new podcast, and one I’m really enjoying already. The shows, like the Salesforce Developer Podcast, follow an interview format. It’s hosted by Blanca V. Leon-Carter – VP of Community Engagement at RAD Women. Each interview (so far at least) has been with folk who’ve been engaged with the RAD (RAD Apex Developer) Women project,either as grads, coaches (or both), and include really brilliant women such as MVP Bonny Hinners and Ladies be Architect co-lead Susanah Kate St.Germain.

6) The SaaS Revolution Show

OK, so not a true Salesforce podcast,but one I certainly recommend as someone working in the Salesforce and SaaS world. Alex Theuma chats to folk from all roles within the SaaS ecosystem, and covers topics from scaling businesses to business models, and company culture to content marketing.

5) Bet on the Web

Alright, you got me… it’s another non-Salesforce specific podcast. Bet on the Web is hosted by Mike Hartinginton and Matt Netkow from Ionic – a cross platform mobile (and desktop) UI framework. The episodes are released (mostly) monthly and focus on web technologies. This podcast should be of Interest to Salesforce developers since many of the topics discussed are relevant to the lovely new(ish) world of Lightning (specifically LWC). This is a show I’ve been listening to since the first episode, and is hugely relevant to us at MobileCaddy due to the fact we use Ionic in our stack when delivering mobile apps to the Salesforce world.

4) Salesforce Posse

This is a kind-of-regular podcast from two folk I know pretty well, Anup Jadhav (MVP and a former co-lead of the London Developers’ Trailblazer group that I help run) and Francis Pindar (also an MVP and one of my co-organisers of the Salesforce community conference London’s Calling). This podcast covers subjects and news relevant to both developers and architects, and is one that I certainly recommend you put on your list.

3) Code Coverage

This pretty irregular podcast (irregular in release schedule, not format) is hosted by two Salesforce developer superstars in the form of MVP Steven Herod and MVP Matt Lacey. There have only been three episodes this year, and the last one was in July, but when the pair do get together they discuss the latest Salesforce news along with some good deep technical discussions.

2) Two WiT

This podcast just never fails to make me smile… apart from when the ladies took a few months out of their pretty regular monthly release schedule. Hosted by MVP Kristi Campbell and MVP Melinda Smith the show is a brilliant mix of thoughts and mind-farts on everyday life, and views and discussion on Salesforce related topics. Although not specifically a dev-related podcast, I find it hugely valuable to hear from folk who are experts in other parts of the Salesforce world. The latest episode, an interview with Military Trailblazer LaRon Butler was doubly amazing… and if you do nothing else after reading this article please listen to this one. LaRon’s story is incredible, and her story-telling is just brilliant.

1) Good Day, Sir! Podcast

And so we come to my favourite Salesforce podcast… and yes it’s the Good Day,Sir! podcast hosted by MVP Jeremy Ross and MVP John De Santiago (who deliberately isn’t on twitter). Shows are released almost every week, and are usually John & Jeremy’s take on the latest goings-on in the Salesforce (and wider tech) sphere, along with a good amount (IMO) of beer and whiskey chat. They’re both well versed in their craft,but it’s not just their knowledge that’s good to hear, they’re also happy to turn down the Kool-Aid and call a spade a spade.

But you know what? The goodness of the Good Day, Sir! Podcast doesn’t end with the show. Oh No! They also have an incredible community of listeners (and probably some non-listeners) who come together and share and help each other out on their slack channel. Go register to join it right now!

So there you have it, that’s my run-down of podcasts to check out. But do you have others I’ve missed (I’m sure I have), if so please comment and share away.

Recommendations received since publishing the article;

  1. Cloudfocus Weekly Podcast – Suggested by Randi Thompson 
  2. Cloud Force Collective -Suggested by Randi Thompson 
  3. One of These Things -Suggested by Randi Thompson 
  4. WizardCast -Suggested by Randi Thompson 
  5. SalesforceWay -Suggested by Paul Battison

 

Salesforce Meetup – MavensMate

As my final days at EE come around, I’m starting to make some headway in getting to understand more about the architecture and nuances of frontend development and the associated frameworks. Hand in hand with this education also comes an implicit syllabus relating to the development workflow, and in particular the tooling that’s available. I wrote about a JS tooling workshop I attended in this post and this week I attended one of the Salesforce developer meetups and there we also covered tooling, specifically David Helmer talked about MavensMate and how that can be used in Salesforce development.

Like the previous events that I’ve attended the meetup was held at the Make Positive offices and once again they were great hosts and sponsors, supplying beer and pizza, just what the doctor ordered.

Mavensmate is a plugin for several IDEs, most commonly used with sublime but there are plans to also include support for atom.io too in the near future. Essentially it gives developers an open source, apex IDE.

Primarily built and supported by Joe Ferraro it’s a cross platform tool that gives Salesforce developers a tool to match those available to developers who are using other languages such as PHP and JavaScript.

David kicked off his talk by announcing that it’ll take the form of a live demo…. there was the inevitable feeling in the room that we could be in for some good-ol squirming. What followed though was anything but, thanks it seems to the wonderful features of, not only Sublime Text, but also Mavensmate itself.

Demonstrations of many features were presented. Key ones (read those that I made a note of and can remember) were;

  • It’s open source… pull it and contribute
  • Editing and compilation of apex code (via force.com platform)
  • Resource bundle handling and uploading
  • Templating
  • Auto completion of functions and variables
  • Apex Testing – And whilst your tests are running there’s a whole host of games you can play (pacman etc), genius
  • Anonymous apex (exec) – runs ad-hoc code platform.
  • Project meta data can be pulled down viewed
  • Fetching debug logs

See the MavensMate documentation pages for more information.

I had tried previously to get MavensMate running in Sublime Text 3 on Ubuntu, but without luck… but I’ll certainly be trying again and will contact Joe if I’m still having issues.

Sadly I was unable to hang around and chat with the other Salesforcers, they’re a good bunch and it was a shame not to catch  up with them… hopefully next time.