mo-dx-plugin
A plugin for Salesforce DX CLI that provides ability to save Apex Classes, Apex Triggers, Visualforce Page, Visualforce Components ,AuraBundle(Lightning Components) and Static Resource to Salesforce org (Scratch/Non-Scratch orgs) using Tooling API.
Plugin also provides a retrieve command that can retrieve metadata in salesforceDx and traditional source format from salesforce unmanaged/managed package or changesets.
The commands in this plugin are used within the DX Code Companion extension (https://marketplace.visualstudio.com/items?itemName=MohithShrivastava.dx-code-companion).
If you are Visual Studio Code user then recommend installing the extension along with the plugin to avoid having to remember the commands.
Setup
Install as plugin (Recommended approach for Installing)
Install plugin using command : sfdx plugins:install mo-dx-plugin
Install from source(Preferred approach for debugging and enhancing the plugin)
-
Install the SDFX CLI.
-
Clone the repository:
git clone git@github.com:msrivastav13/mo-dx-plugin.git
-
Install using yarn:
yarn install
-
Link the plugin:
sfdx plugins:link
.
Commands
sfdx retrieve:dxsource
sfdx retrieve:pkgsource
sfdx deploy:apex
sfdx deploy:trigger
sfdx deploy:vf
sfdx deploy:vfcomponent
sfdx deploy:aura
sfdx deploy:lwc
sfdx deploy:staticresource
sfdx metadata:rename
sfdx retrieve:dxsource
Retrieves soure code from Managed/Unmamaged package or Changesets.This command works for only Non-scratch orgs .If you are trying to convert a traditional project in Managed/Unmanaged package , this command can help convert the sourcecode to DX format.
USAGE
$ sfdx retrieve:dxsource
OPTIONS
-n, --packagename=packagename (required) the name of the package you want to retrieve.The package parameter value must be enclosed in double quotes.Example if you have a package named HR App the command would be sfdx retrieve:dxsource -n "HR App"
-p, --pathname=pathname [default: force-app] where to convert the result to...defaults to
force-app
-u, --targetusername=targetusername username or alias for the target org; overrides default target org
-m, --retainmetadata provide a random string to retain the mdapiout folder that has source code in mdapi format
--apiversion=apiversion override the api version used for api requests made by this command
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal) logging level for this command invocation
EXAMPLES
$ sfdx retrieve:dxsource -n <package/changeset> // Default authorized org is used as username or org alias
$ sfdx retrieve:dxsource -u myOrg@example.com -n <package/changeset> -p <[pathName]>
See code: src/commands/retrieve/dxsource.ts
sfdx retrieve:pkgsource
Retrieves soure code from Managed/Unmamaged package or Changesets.This command works for only Non-scratch orgs.This retrieves metadata in traditional source format.
USAGE
$ sfdx retrieve:pkgsource
OPTIONS
-n, --packagename=packagename (required) the name of the package you want to retrieve.The package parameter value must be enclosed in double quotes.Example if you have a package named HR App the command would be sfdx retrieve:pkgsource -n "HR App"
EXAMPLES
$ sfdx retrieve:pkgsource -n <package/changeset> // Default authorized org is used as username or org alias
See code: src/commands/retrieve/pkgsource.ts
sfdx deploy:apex
Deploys apex code to the Salesforce Org using Tooling API.
USAGE
$ sfdx deploy:apex
OPTIONS
--p, --pathname=pathname (required) the file path of the apex class you want to save to salesforce. Note you can run pwd command on terminal to obtain the path easily.
EXAMPLES
$ sfdx deploy:apex -p <pathname> // Default authorized org is used for the deploy .The pathname parameter must be enclosed in double quotes. Example if your path is /Users/mohith/Desktop/ForceProjects/TestApp/force-app/main/default/classes/Constants.cls then the command to save this class will be sfdx deploy:apex -p "/Users/mohith/Desktop/ForceProjects/TestApp/force-app/main/default/classes/Constants.cls"
See code: src/commands/deploy/apex.ts
sfdx deploy:trigger
Deploys apex trigger code to the Salesforce Org using Tooling API.
USAGE
$ sfdx deploy:trigger
OPTIONS
--p, --pathname=pathname (required) the file path of the apex trigger you want to save to salesforce. Note you can run pwd command on terminal to obtain the path easily
EXAMPLES
$ sfdx deploy:trigger -p <pathname> // Default authorized org is used for the deploy
See code: src/commands/deploy/trigger.ts
sfdx deploy:vf
Deploys visualforce page to the Salesforce Org using Tooling API.
USAGE
$ sfdx deploy:vf
OPTIONS
--p, --pathname=pathname (required) the file path of the vf page you want to save to salesforce . Note you can run pwd command on terminal to obtain the path.
EXAMPLES
$ sfdx deploy:vf -p <pathname> // Default authorized org is used for the deploy
See code: src/commands/deploy/vf.ts
sfdx deploy:vfcomponent
Deploys visualforce components to the Salesforce Org using Tooling API.
USAGE
$ sfdx deploy:vfcomponent
OPTIONS
--p, --pathname=pathname (required) the file path of the vf component you want to save
EXAMPLES
$ sfdx deploy:vfcomponent -p <pathname> // file path used to save the component to Salesforce.
See code: src/commands/deploy/vfcomponent.ts
sfdx deploy:aura
Deploys aura lightning bundle to the Salesforce Org using Tooling API.
Supports deploying whole aura bundle as well individual files .To deploy the AuraBundle provide the directory path in path(p) parameter
USAGE
$ sfdx deploy:aura
OPTIONS
--p, --pathname=pathname (required) the file path of the aura bundle you want to save to Salesforce.
EXAMPLES
$ sfdx deploy:aura -p <pathname> // Default authorized org is used for the deploy
See code: src/commands/deploy/aura.ts
sfdx deploy:lwc
Deploys lighnting web component bundle to the Salesforce Org using Tooling API.
Supports deploying lwc bundle as well individual files in lwc bundle .To deploy the Lightning Bundle as a whole provide the directory path in path(p) parameter
USAGE
$ sfdx deploy:lwc
OPTIONS
--p, --pathname=pathname (required) the file path of the lightning web components bundle you want to save to Salesforce.
EXAMPLES
$ sfdx deploy:lwc -p <pathname> // Default authorized org is used for the deploy
See code: src/commands/deploy/lwc.ts
sfdx deploy:staticresource
Deploys Static Resources to the Salesforce Org using Tooling API.
Supports deploying staticresource folder (It zips it up) as well individual files in staticresource folder.
USAGE
$ sfdx deploy:staticresource
OPTIONS
--p, --pathname=pathname (required) the file path of the lightning web components bundle you want to save to Salesforce.
EXAMPLES
$ sfdx deploy:staticresource -p <pathname> // Default authorized org is used for the deploy
$ sfdx deploy:staticresource -p <pathname> --resourcefolder <name of the folder where you have app>' // Default authorized org is used for the deploy
$ sfdx deploy:staticresource -p <pathname> --resourcefolder <name of the folder where you have app>' --cachecontrol public //makes the cache control of static resource public
See code: src/commands/deploy/staticresource.ts
sfdx metadata:rename
Renames a single metadata using the salesforce Metadata API.
Salesforce allows to rename some types of metadata (CRUD based) using the Metadata API.This commands provides sfdx version
USAGE
$ sfdx metadata:rename
OPTIONS
-t, --metadatatype=metadatatype (required) the type of the metadata (Ex CustomObject for customobject, CustomField for custom field)
-o, --oldfullname=oldfullname (required) Full API name of the current component that will be overriden with the new name
-n, --newfullname=newfullname (required) Full API name that will override the existing component name
EXAMPLES
'$ sfdx metadata:rename -t <metadatatype> -n <newname> -o <oldname>',
'$ sfdx metadata:rename -t CustomObject -n MyCustomObject1New__c -o MyCustomObject1__c' // here Custom Object MyCustomObject1__c is renamed to MyCustomObject1New__c
See code: src/commands/metadata/rename.ts
Important Note When Using these Commands With Non-Scratch Org
These commands do not maintain history and files are overriden on server .Make sure you have source control for the project setup so you can recover code if you accidently overwrite anything