With the latest version of the CLI, hooks are not firing anymore for me.
If I downgrade salesforce-alm to 49.11.0 it's working again.
Is anyone using them and seeing similar issues ?
https://github.com/forcedotcom/cli/issues/578
With the latest version of the CLI, hooks are not firing anymore for me.
If I downgrade salesforce-alm to 49.11.0 it's working again.
Is anyone using them and seeing similar issues ?
https://github.com/forcedotcom/cli/issues/578
Anyone knowing how to get Org Connection from a CLI Hook ?
Using the --json switch with an SFDX command returns JSON to stdout. However, if I consume a command in a node process, e.g.
child_process.execFileSync('sfdx', ['force:limits:api:display', '-u', 'alias', '--json']).toString();
It does return the JSON, but due to the CLI formatting if the JSON (i.e. the colours) we get all the ANSI escape codes too (so instead of e.g. { } we get \u001b[97m{ \u001b[97m}) making it more effort to parse. Is there a way to get raw JSON back instead of formatted?
Hi, I have this method in my node app to parse sfdx commands json response:
private asyncSfdxCommand(command: string) {
return new Promise((resolve, reject) => {
exec(command, (error, standardOutput, standardError) => {
if (error) {
reject();
return;
} else if (standardError) {
reject(standardError);
return;
}
resolve(standardOutput);
});
});
}
And I use it this way:const myResponse = JSON.parse(await this.asyncSfdxCommand(`sfdx force:limits:api:display -u MyExampleUser --verbose --json`));
In the variable I get myResponse the json perfectly parsed and I can get access to all the properties.
Hope it helps.
In a custom SFDX CLI plugin, how do I return a nice non-zero status code and error message so that they can be correctly interpreted by shell scripts and also programs reading the --json output ?
Thanks Matthias.
I looked into SfdxError and set exitCode : that's what I was looking for, thanks.
Hi, does anyone use pre-commit hooks to reorder XML files to minimize diffs down the pipeline ? Do you have best practices crafted from this experience ?
Our process is older (still using MDAPI) and a bit weird, but we end up doing a lot of things on a build server -- have jobs that retrieve the metadata from an org, then immediately format it before committing.
I imagine a git pre-commit hook could work.
You can also customize the SFDX CLI with command hooks, so perhaps you could implement a "postretrieve" command hook to sort and format the XML files as well. Good post here:
https://developer.salesforce.com/blogs/2020/09/the-cli-and-salesforce-extensions.html*** Salesforce CLI plugin for Custom Metadata Types is now available ***
Hello SFDX enthusiasts.
We are happy to announce that the CLI plugin for custom metadata types is available in CLI v49. These new commands simplify development and help you build automation and synchronize your source from scratch orgs when working with custom metadata types.
You can use the Salesforce command-line interface to create custom metadata types, fields and records. Additionally, you now will be able to bulk insert records from a CSV file or use an existing custom object / setting to generate custom metadata types from it.
Plugin - force:cmdt
Commands -
More details on the usage of various commands, with descriptions, flags and examples, is available in the CLI reference manual and help documentation.
Custom Metadata Types Documentation: https://help.salesforce.com/articleView?id=custommetadatatypes_cli.htm&type=5
Salesforce CLI Command Reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_force_cmdt.htm#cli_reference_force_cmdt
Trailhead unit coming soon !!
Hello dear community,
I'm creating a sfdx plugin that, for now, scans certain type of metadata to enforces the usage of bypassing practice
https://github.com/jonathanwiesel/sfdx-valkyrie
I noticed that when installing using the "sfdx plugins:install" command you can either just indicate the plugin name (to fetch from npm) or a git url:
$ sfdx plugins:install myplugin
$ sfdx plugins:install https://github.com/someuser/someplugin
$ sfdx plugins:install someuser/someplugin
When fetching from npm (example 1) it will get the latest published version to npm, however when installing from a git url, for example github, which version will it fetch? the latest commit from the master branch? the latest release / tag?
Hi All,
I am trying to authenticate with SFDX and JWT for CLI authentication.
I have created certification and all the necessary steps are done.
But I am getting below error.
Error: Unexpected arguments:
"stack": "Error: Unexpected arguments: –i, <consumer_key>, –u, <devhubusername>, –f, /Users/Ashish/certificates/server.key, --trace, error\nSee more help with --help\n at validateArgs (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@oclif/parser/lib/validate.js:10:19)\n at Object.validate (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@oclif/parser/lib/validate.js:57:5)\n at Object.parse (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@oclif/parser/lib/index.js:26:7)\n at AuthJwtGrantCommand.parse (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@oclif/command/lib/command.js:83:41)\n at AuthJwtGrantCommand.init (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/command/lib/sfdxCommand.js:203:44)\nOuter stack:\n at Function.wrap (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/node_modules/@salesforce/core/lib/sfdxError.js:151:27)\n at AuthJwtGrantCommand.catch (/Users/Ashish/.local/share/sfdx/node_modules/salesforce-alm/dist/ToolbeltCommand.js:247:46)",
"warnings": []
}
anybody know the solution for it.
TIA
In case if this is not solved, can you retry with the following steps?
https://salesforcerealm.com/2020/03/07/authenticate-sfdx-using-jwt/Let me know if it helps.
I tried to install a custom CLI Plugin in a CI build in Gitlab, but I wasn't able to whitelist it.
I tried to moved the whitelist file as explained here, but I'm still getting the prompt asking for validation:
https://developer.salesforce.com/blogs/2017/10/salesforce-dx-cli-plugin-update.html
Was someone able to do it ? I was able to do it in Azure DevOps, not sure what I'm missing in Gitlab.
I'm using the salesforcedx official docker image:
https://hub.docker.com/r/salesforce/salesforcedx
It's not the first time I'm struggling to make it work, what about having a Salesforce CLI Environment Variable or a flag to give our own path for the unsignedPluginWhiteList.json file ? Am I the only one thinking this would be easier ?
As said in this blog post: "As we get closer to finalizing the developer plugin interface and supporting CLI architecture, we will be providing more information on the steps you, as a plugin developer, need to take to sign your plugins." but this was 2,5 years ago so I've lost hope for it, maybe a env variable or flag would ease this install process.
Looking for advice on unit testing. Specifically around org connections and code that requires processing and updating metadata from a Salesforce Org.
Can Mocha tests even have a live org connection?
Is there a way to mock the org connection data in my plugins?
Is it possible to use Jest like we do for LWC or is that just looking for trouble?