Following the SFDX Trailhead Trails

Just some notes I took whilst trying to understand SFDX a bit more. This is a bit of a stream of conciousness in frustration... so bear with it. 

So, I've had an intro to SFDX previously and had it installed on my PC previously during the intro, and I sort of got the concepts but I had to get a new PC and now I have to start again, on my own.

Previously things that have got me lost and confused are

  • Just start by doing NPM Install
  • Using Bash, type ...
  • “In a command window, enter SFDX”...

Grrr, just start from the begining, don't assume I have a mac, don't assume I know what Bash or Powershell is (well I have basic concepts and started learning enterprise computing on Unix), and which Command Window are you talking about.

Other things I need to know are:

  • How to work with sandboxes, and download ALL metadata from a Sandbox.
  • I'm not really interested in package development - I think it's completely impossible to split out a complex org with a few managed packages (let's not event get started on FinancialForce), to even attempt package development on an existing org.
  • How to use Bitbucket rather than Github, as Bitbucket has free private repositories and it's never OK to put your client's metadat in a public github repo. Ever!
  • How to then deploy to Production
  • How do you use scratch orgs to test things for multiple users in an org
  • How to get data into a scratch org so it's meaningful.
  • How to do testing in a scratch org.

So that's why I tried to work it all out, and created VS Code for Non Developers and the Installing the Dev Tools page. 

Following the Trails

Starting with https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/set-up-your-salesforce-dx-environment?trail_id=sfdx_get_started

  • It looks like you install CLI without installing VS Code - why?
  • The command window they talked about is CMD or Powershell. Apparently it's best to use Powershell. No I'm not even going to mention Mac things.
  • You can get to Powershell from within VS Code by going to the Terminal menu.
  • “Create an alias DevHub by using -a and make this the default org using -d.” why is this so hard? What is an Alias? Why do I want one?

Now the second trail https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/set-up-the-project-on-your-local-machine?trail_id=sfdx_get_started

  • Start with good folder management. WHERE do you want me to create this folder to store my metadata?
  • HOW do I move to that folder in Powershell? At least I know my basic DOS commands.
  • Show us some simple shortcuts now like tab to prefill the directory after you type a few letters in
  • Next they jump RIGHT INTO Git without explaining it! Geez.
  • And I type a git command it it gives me an error!
  • Installing Git for Windows is so confusing, I just had to accept all the default prompts.
  • Now, I've got git installed, cloned the sample package, made a branch, there is meant to be an easy way in VSCode to keep track of my branches and where I'm at in Git, plus I stilll want to know how to stick it in bitbucket.
    • I go to the Source menu and it says no source control providers registered.
    • I look in Extensions for Git - there are far too many. I try Git Extensions for VS Code. Nope, that's not it. Off to Google.
    • Aha! Git IS magically installed, you just have to be in an Open folder that is already under source control for it to show in the Source panel. Now I can see the branch icon and see that I'm in the correct branch.
  • Note that you can use Open folder in VS Code to use Explorer to open folders rather than using cd.. etc
  • So, once you set up Dev Hub in your Dev Org, you can't actually see anything in your Org? Where is the UI to see all the scratch orgs I own?

Now the third trail https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/create-and-test-our-scratch-org?trail_id=sfdx_get_started

  • How am I going to remember all these commands - yeah, I know I can do help, but I will be forever in help trying to work out what's next.
  • Why isn't there a UI to do all this, I still see no advantage of using the CLI
  • We're at pushing code to the org without any understanding of what is going on, and what the SFDX project contains.

So I have finished that badge, I've got an org open with the Dreamhouse App, and I still don't know much about DX at all.
And I still don't have anything in my dev hub environment to tell me that I have a Scratch Org created.


Then I did Packages Development Model

Badge https://trailhead.salesforce.com/content/learn/modules/sfdx_dev_model/sfdx_dev_model_evolve_to_dx?trail_id=sfdx_get_started and still didn't learn much

Next Module https://trailhead.salesforce.com/content/learn/modules/sfdx_app_dev/sfdx_app_dev_setup_dx?trail_id=sfdx_get_started

  • Hmm, I read some of the documentation the trailhead links to and finally get enough info to find out how to see my scratch orgs in the Dev Hub - it's a tab named Active Scratch Orgs.
  • But it's not like you can just open the scratch org from there - no, that would be too easy, no you have to use the silly CLI.
  • Ah, now we are getting somewhere - finally talking about aliases
    • sfdx force:org:open -u DevHub
  • Useful. But why do all these orgs open to the setup menu by default. Do not want.
  • Ah finally Aliases are starting to make sense. Still not 100% sure about using them with production orgs? Can you?


Next Module https://trailhead.salesforce.com/content/learn/modules/sfdx_app_dev/sfdx_app_dev_create_app?trail_id=sfdx_get_started

  • Hmm, they did not say OPEN VS Code, but the first scren shot is VS Code - again, do NOT assume!
  • Starts off with navigate to where you want to create this project. AGAIN. Tell me some basic folder housekeeping. Where do I want to create this project?
  • Ah finally some basic understanding of what the folder is.
  • Wait! I've just created a scratch org and I'm still in my Dreamhouse Git folder - does this matter? How do I fix this mess?
  • OK, I like how you can create a Perm Set in the org, then immedately refer to it in DX.
  • OMG now they are diving straight into Github SSL URL - gezus! And now telling you to set folders in .gitignore without explaining it. Thank goodness I have half a clue about what they are even saying here.
  • So now let me try and remember how I do a local git setup for that folder (I will get to bitbucket much later).
    • Oh cool Git to see the commands, then Git Init to initalise the folder and see it in the source menu with all my changes shown.
    • So you open the file in the Source panel right click and add to .gitignore, then modify that to be for the whole folder, save the file, and then your Source panel looks better.
    • Do I have to add .forceignore to .gitignore?
    • Then I created a new branch for this testing. Then I staged the changes and committed them. But I did it all throught the UI. Could not work out how to do it via CLI
  • OK, now that I have pulled those changes into the local folder, I can start to see the folder structure, and start to see that each field is in it's own .XML file, but looks like the metadata in .object files in MM.
  • Ooh that using SOQL to extract data into a JSON file is mighty handy!


Next module https://trailhead.salesforce.com/content/learn/modules/sfdx_app_dev/sfdx_app_dev_build_app?trail_id=sfdx_get_started and https://trailhead.salesforce.com/content/learn/modules/sfdx_app_dev/sfdx_app_dev_create_visuals?trail_id=sfdx_get_started

  • This one was easy because I now knew what they were doing based on my Dev 601 course (now of course basically useless information now that Aura is not a thing anymore).
  • Either I've done something wrong or it doesn't work well, as it doesn't do anything when you click on one of the hotels in the list, or when you click on one of the Markers.
    • Just goes to show you how ridiculously hard actual Lightning Component development is - all that and it just shows 3 markers on a map, and 3 items in a list.
    • And it's not even the new Maps Lightning Base Component and we are months after release!
  • Once again they need a few more hints and steps to check in your changes to git. Oh there is one “Don't forget to add everything to your VCS” messge at the bottom.
  • Ah, I see, we are in the same folder but we are pushing to a new org. Nice.
  • Also I had to learn how to delete at scratch org
    • $ sfdx force:org:delete -u MyOrgAlias -p
  • But don't use the $ - it's just an mac thing!
  • Oh that is weird creating an org for two minutes then deleting it again. Cool, but weird.
  • No I did not learn anything by guessing which commands were what in the “test”


Module https://trailhead.salesforce.com/content/learn/modules/sfdx_app_dev/sfdx_app_dev_deploy?trail_id=sfdx_get_started

  • Time to test my git again. Got git init but could not get the branching to work via the CLI. Discovered ctrl+shift+p
    • Still not sure of the order - dx commands first or Git commands.
    • And of course still not in bitbucket.
    • The point of all this is that you have to get really fluid wiht the process.
  • Ah, OK, password creation and app install - one of the things I was unsure off
    • But of course I just installed the damn app in my dev org didn't I - the instructions should be clearer!
  • Oh FFS, again they are obviously assuming Mac, because I can't unzip a file using Powershell apparently! Grrr.
    • I have to use expand-archive in PS version 5
  • Ok that was a useful excercise converting an app to DX format and setting up a new org, with the app. I am sure that I will forget all of that in the next hearbeat though.
  • Good to know the force:org:list command
  • Good to know how to connect to existing orgs, but again, I am sure I will forget.
  • Ol that was useful to then install that DX project in a real org, even though it was a dev org.


Skipped throught the next few boring modules, now onto https://trailhead.salesforce.com/content/learn/modules/unlocked-packages-for-customers/build-your-first-unlocked-package?trail_id=sfdx_get_started

  • I'm not yet sure what this one is about.
  • But I've reached my daily scratch org limit, so that's it, I'm done for the day.


Overall

  • Usefull
  • But now I've got to test what I've done and see if I can get back there.