7

Related to this question How to handle the change to "Salesforce DX project format" and keep the revision history?, being able to see the source code for e.g.:

sfdx force:mdapi:convert --rootdir <retrieve dir name>

would make it a lot easier to write a git mv equivalent.

Given the Node underpinnings, I thought I might just be able to see the implementation in the installed sfdx software but I can't find it even if it is there.

So my question is, is the source code for the sfdx tools available to build on when writing your own sfdx plugin?

PS

May 2020 Salesforce blog post: Open Sourcing Salesforce CLI.

4

You can find GitHub Repo for Salesforce CLI source code here. Though This code is read-only and not meant to be executed, edited, or contributed to.

Salesforce open sourced CLI, Check this blog post here

| improve this answer | |
  • 1
    Thanks for posting this! – Keith C May 4 at 11:27
3

The source code is published to npm in the salesforce-alm module. There's no public repo for the code yet.

If you want to review the source for sfdx force:mdapi:convert, you can download the module from npm (e.g. npm pack salesforce-alm) or look at the version installed by sfdx (in ~/.local/share/sfdx/client/node_modules/salesforce-alm on linux).

The force:mdapi:convert command is in dist/commands/mdapi/mdapi_convert.js, although the actual logic is in dist/lib/mdapiConvertApi.js.

You can use the node debugger with Chrome DevTools to step through the code. Add a debugger; statement to MdapiConvertCommand.execute, for example, and start the node debugger:

~/.local/share/sfdx/client/bin/node --inspect ~/.local/share/sfdx/client/bin/sfdx.js force:mdapi:convert --rootdir src/

(The current version has source maps, but the code isn't minified. You might need to delete all of the source maps to make the source readable, e.g. find ~/.local/share/sfdx/client/node_modules/salesforce-alm/dist -name \*.map | xargs rm)

| improve this answer | |
  • Sorry, xn. I felt obliged to make the (presumably recently published) repository link the accepted answer. – Keith C May 4 at 11:29
  • 1
    That's the best answer now. – xn. May 4 at 15:07
2

The best answer for now is, "not yet".

The DX team have positioned themselves as pro open source and have discussed making some part of the CLI source code part of the OSS footprint of Salesforce in public presentations in the past. However, as of yet, there is not a public statement on a specific timeline for the roadmap for this or how much of it would be OSS (core engine, versus specific commands/modules, for instance).

| improve this answer | |
  • Thanks for taking the time to clarify. Didn't want to be missing the opportunity of a better starting point just through not knowing. – Keith C Sep 22 '17 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.