What I am trying to do is to automatize a process of passing results from one SFDX command to another SFDX command and I struggle to implement that.
My source command is
sfdx force:package:installed:list -u sourceOrg
I could even run JSON variant of it like
sfdx force:package:installed:list -u sourceOrg --json
so that it returns me a json data which I can then assign to a javascript variable and select SubscriberPackageVersionId
of these results
var a = {
"status": 0,
"result": [
{
"Id": "0A3E00000002ricKAA",
"SubscriberPackageId": "033300000004PVbAAM",
"SubscriberPackageName": "License Management App",
"SubscriberPackageNamespace": "sfLma",
"SubscriberPackageVersionId": "04t30000001DWL0AAO",
"SubscriberPackageVersionName": "1.20",
"SubscriberPackageVersionNumber": "1.20.0.1"
},
{
"Id": "0A3E00000002rigKAA",
"SubscriberPackageId": "033A0000000PB5YIAW",
"SubscriberPackageName": "DocuSign For Salesforce",
"SubscriberPackageNamespace": "dsfs",
"SubscriberPackageVersionId": "04tA0000000SEKIIA4",
"SubscriberPackageVersionName": "6.6.4",
"SubscriberPackageVersionNumber": "6.6.4.2"
}
]
}
a.result.map(x=>x.SubscriberPackageVersionId)
Then using results of a.result.map(x=>x.SubscriberPackageVersionId)
I could pass it to the destination command like following
FOR %%P IN (04t30000001DWL0AAO,04tA0000000SEKIIA4) DO sfdx force:package:install -i %%P -u %1 -r -w 1
I am struggling to automatize this but not sure how this can be automated.
Should I write some custom SFDX plugin? I have seen a question about how one can execute an existing SFDX command inside a SFDX plugin but there was no definite answer, so, looks like it is impossible or I don't understand how to implement that.
Should I use jq
? I am not able to install jq
on windows and not able to run any commands from jq
. Even if I had jq
installed, I would still struggle how to use it for my case.