Thursday, November 14, 2019

Quick Tips: Setup SFDX Manually without Admin access


We all have faced challenges while working in different enterprise environments, where there may be lot of controls/ checks/ red-tape to get by. In such situations, getting access to simple tools (even git) can take lot of time.

Note: This tutorial is to be followed at your own risk, as it may not be complaint to your organization's IT policies.


What is SFDX?

SFDX is a command line utility for managing salesforce builds/ deployments. Being command line, it can be easily embedded to automation chains, to help build fully automated build and deployment processes. To get started, refer https://trailhead.salesforce.com/en/content/learn/trails/sfdx_get_started

Setup SFDX on Windows machine without admin access

As you may have already realized, SFDX installation needs admin access to one's machine. Which may be a luxury a lot of developers may not have. So, i tried to provide a step-by-step guide to setup SFDX on your computer without any admin access

Steps:

Note: The path in commands is provided only for guidance. Ensure, you are using right path, as per your machine's folder structure
  1. Download latest NodeJS Zip file package (v13.1 - https://nodejs.org/dist/v13.1.0/node-v13.1.0-win-x64.zip)

  2. Unzip folder to desired location. Say \Tools\nodejs
    1. Note: zip extraction may generate the folder name as per nodejs packaging. In my case, the path was \Tools\nodejs\node-v13.1.0-win-x64

  3. Open command prompt (Win + R; type cmd and press enter)

  4. Within command prompt navigate to nodejs path (ensure to use correct path no your machine)
    cd Tools\nodejs\node-v13.1.0-win-x64

  5. Test if NodeJS works fine. Type following command in command prompt
    node –v
    Should display version of nodejs for e.g. v13.1.0

  6. Run nodevars to setup local variables
    nodevars

  7. Install sfdx command line using NPM (comes along with NodeJS)
    npm install sfdx-cli –global

  8. Voilla!! This should result in successful installation of sfdx on your desired folder. To test run this command
    sfdx –v
    It should result in sfdx version for e.g.
    sfdx-cli/7.33.2 win32-x64 node-v13.1.0


Note, this does not install sfdx as a global utility i.e. to use sfdx, you have to always provide an absolute path (\Tools\nodejs\node-v13.1.0-win-x64\sfdx) to run the command. However, it does allow you to use SFDX on your machine.

Wednesday, January 23, 2019

Time to Migrate from Salesforce Force.com IDE to VS Code

Image Credit: Visualstudio marketplace


Why?

In case you don’t know Salesforce is phasing out Force.com IDE (planned for June 2018) to promote newer IDE choices. There are already many IDEs out there to take Eclipse based Force.com IDE’s place. However, Salesforce is officially promoting Microsoft Visual Studio Code (aka VS Code) as official IDE.

What is VS Code?

VS Code is a platform-independent, light-weight and keyboard focused IDE for Salesforce (sorry for folks who loved menus and GUI). VS Code does have visual menus and options, however, using keyboard shortcuts is just do damn fast. There is surely some learning curve involved. But, once you get rolling, you would hate using mouse, as it takes a lot of work to raise your hand, move mouse, point and click and navigate, when you can just press “Ctrl + /” to comment current code selection.

VS Code features

  • Lightweight – In case  you have worked a lot with Eclipse, you might have noticed that it was a memory hogging tool. To much relief, VS Code is a comparatively very lightweight
  • Fast – I remember there were times in large projects, where we waited for minutes to allow Eclipse to load properly. Thankfully, with VS Code you would have minimum such encounters (if any). Primarily, due to it’s lightweight model and lazy loading of extensions, it ensure it’s just loading the things, that your project needs. Others, will be loaded on demand
  • Inbuild GIT capabilities – This was one of the most profound experience I’ve had in using GIT in a development IDE (others may have had better experiences). But, the sheer ease of using GIT within VS Code is ecstatic. Whether it’s about identifying current branch, items to pull from remote, items to push to remote server, files changed. It’s so ingeniously baked within user interface that you would wonder why it wasn’t done in other IDEs.
  • Intellisense - VS Code packs amazing intellisense capabilities, so you don't need to remember all variables or classes it displays a list of available values for you to choose
  • Shortcuts, Shortcuts and Shortcuts – VS Code is heavy on shortcuts and allow users to configure custom shortcuts to increase personalization.
  • Addons/ Plugins – like Eclipse, VS Code has a vibrant community of developers publishing plugins / add-ons to add more features to VS Code. There are plugins for almost all usual needs and specific needs as well
  • Platform Independent – VS Code supports Windows/ Mac/ Linux. This can be very helpful in particular when you have team members using different mix of machines
  • Language Agnostic – This is beauty. Doesn’t matter if you work on Lightning components, Apex, Visualforce, NodeJS, PHP, C# (obviously) or any other programming language/ technology, it is most probable supported (natively or extensions). So, no switching between different IDEs, when you are you have a backend NodeJS server running on heroku
  • Fast Coding and Refactoring capabilities – being the new kid on the block, VS code gets advantage of adopting time proven best practices, tips and tricks to ease day to day life of developers and help them become more productive. Common things like searching a particular text in all files, or paragraphs within in all files, or replacing variable name in entire class, it can be done like a breeze.

Myth vs Reality

  • It’s only for SFDX based projects – Well that’s a big misconception, something a lot of people have asked about. VS Code can be used for both SFDX and non SFDX based projects. It really boils down to the extensions you would choose.
  • It’s too complicated (no GUI) – it certainly has a learning curve for folks who have used GUI heavy IDEs. They can start by using available GUI / menu options. Also, as you'll find below, there are extensions which provide rich menu based development features (check Forcecode)
  • It’s too Dark – Unless you are afraid of darkness, dark theme helps in saving energy and your eyes. You can still choose to switch to one of many available themes

How to get started?

It’s simple. Follow these steps:
  1. Download and install VS Code
  2. Install plugins (you’ll need some plugins for Salesforce development)
  3. Get Started

Extensions (plugins) Recommendations

  • SFDX extensions - natively provided by Salesforce and officially supported. These tools are and should be foundational platform for all Salesforce extensions.
  • Forcecode - one of the most prominent Force.com development extensions on VS Code (at least prior to SFDX). I prefer it for conventional development, as it provides true IDE features like menu based retrieve, deploy, execute script, update on save etc. 
  • GitLens - parsing old git logs and commits can be tiring sometimes. GitLens solves this by providing intuitive features like inline commit view, last version comparison etc.
  • To-do Tree - if you utilize best practices of inserting to-do in code, for later reference, this extension can ease up the process of finding all todos 
  • Apex PMD - Static code analysis for your Apex and Visualforce code

Popular Posts