Sometimes ... Salesforce tools are delivered without the mandatory capabilities allowing the advanced developments of partners and clients to survive.
Sometimes ... Salesforce R&D team shows some understanding, but sometimes ... not at all, even when a new SFDC Platform version prevents to generate a managed package.
So after the third plugin I needed to create during a few weeks (not for fun, but to allow our managed package to survive!) , I decided to join them on a single plugin: SFDX Essentials , and to publish it as open source , by solidarity with fellow victims of savage platform upgrades :)
Contributions are welcome, please run npm run lint:fix before making a new PR
A revamping of the plugin sources to be more typescript oriented has been performed for version 1.0.0. Please create an issue if you have any problem
Command list
Command | Description |
---|---|
essentials:filter-metadatas | Filter metadatas generated from a SFDX Project in order to be able to deploy only part of them on an org |
essentials:filter-xml-content | Filter content of metadatas (XML) in order to be able to deploy only part of them on an org |
essentials:change-dependency-version | Replace other managed packages dependency version number ( very useful when you build a managed package over another managed package, like Financial Services Cloud ) |
essentials:fix-lightning-attributes-names | Replace reserved lightning attribute names in lightning components and apex classes ( if you named a lightning attribute like a custom apex class, since Summer 18 you simply can not generate a managed package again) |
essentials:uncomment | Uncomment lines in sfdx/md files (useful to manage @Deprecated annotations with managed packages) |
essentials:check-sfdx-project-consistency | Check consistency between a SFDX project files and package.xml files |
Please contribute :)
sfdx plugins:install sfdx-essentials
- Windows users: sfdx plugin generator is bugged on windows (hardcode call of linux rm instruction) , so you may use Git Bash to run this code ( at least while it installs the plugin dependencies )
Its seems that sfdx plugins:update and sfdx update does not always work, in that case , uninstall then reinstall the plugin
sfdx plugins:uninstall sfdx-essentials
sfdx plugins:install sfdx-essentials
- Fork the repo and clone it on your computer
- run $ sfdx plugins:link
- Now your calls to sfdx essentials are performed on your local sources
- Once your code is ready and documented, please make a pull request :)
Allows to filter metadatas folder generated by sfdx force:source:convert , using your own package.xml file
This can help if you need to deploy only part of the result of sfdx force:source:convert into a org, by filtering the result (usually in mdapi_output_dir) to keep only the items referenced in your own package.xml file
WARNING: This version does not support all the metadata types yet, please contribute if you are in a hurry :)
USAGE
$ sfdx essentials:filter-metadatas OPTIONS
OPTIONS
-i, --inputfolder=inputfolder Input folder (default: "." )
-o, --outputfolder=outputfolder Output folder (default: filteredMetadatas)
-p, --packagexml=packagexml package.xml file path
DESCRIPTION
Package.xml types currently managed:
- ApexClass
- ApexComponent
- ApexPage
- ApexTrigger
- ApprovalProcess
- AuraDefinitionBundle
- BusinessProcess
- ContentAsset
- CustomApplication
- CustomField
- CustomLabel
- CustomMetadata
- CustomObject
- CustomObjectTranslation
- CustomSite
- CustomTab
- Document
- EmailTemplate
- EscalationRules
- FlexiPage
- Flow
- FieldSet
- GlobalValueSet
- GlobalValueSetTranslation
- HomePageLayout
- ListView
- LightningComponentBundle
- Layout
- NamedCredential
- Network
- PermissionSet
- Profile
- Queue
- QuickAction
- RecordType
- RemoteSiteSetting
- Report
- SiteDotCom
- StandardValueSet
- StandardValueSetTranslation
- StaticResource
- Translations
- ValidationRule
- WebLink
- Workflow
EXAMPLES
$ sfdx essentials:filter-metadatas -p myPackage.xml
$ sfdx essentials:filter-metadatas -i md_api_output_dir -p myPackage.xml -o md_api_filtered_output_dir
$ sfdx force:source:convert -d tmp/deployDemoQuali/
$ sfdx essentials:filter-metadatas -i tmp/deployDemoQuali/ -p myPackage.xml -o tmp/deployDemoQualiFiltered/
$ sfdx force:mdapi:deploy -d tmp/deployDemoQualiFiltered/ -w 60 -u DemoQuali
See code: src/commands/essentials/filter-metadatas.ts
When you perform deployments from one org to another, the features activated in the target org may not fit the content of the sfdx/metadata files extracted from the source org.
You may need to filter some elements in the XML files, for example in the Profiles
This script requires a filter-config.json file following this example
{
"filters" : [
{
"name" : "ProfileFiltering",
"description" :"Remove unwanted stuff in profiles",
"folders": [
"profiles"
],
"file_extensions": [
"profile"
],
"exclude_list" : [
{
"type_tag":"userPermissions",
"identifier_tag" : "name",
"values" : [
"AllowUniversalSearch",
"EnableNotifications"
]
},
{
"type_tag":"tabVisibilities",
"identifier_tag" : "tab",
"values" : [
"TabExportScripts",
"TabInstallScripts"
]
}
]
}
]
}
USAGE
$ sfdx essentials:filter-xml-content OPTIONS
OPTIONS
-i, --inputfolder=inputfolder Input folder (default: "." )
-o, --outputfolder=outputfolder Output folder (default: Input Folder + _xml_content_filtered)
-p, --configFile=configFile JSON file containing configuration. Default: filter-config.json
EXAMPLE
$ sfdx essentials:filter-xml-content -i "retrieveUnpackaged"
See code: src/commands/essentials/filter-xml-content.ts
Allows to change an external package dependency version
USAGE
$ sfdx essentials:change-dependency-version OPTIONS
OPTIONS
-f, --folder=folder SFDX project folder containing files
-j, --majorversion=majorversion Major version
-m, --minorversion=minorversion Minor version
-n, --namespace=namespace Namespace of the managed package
EXAMPLE
$ sfdx essentials:change-dependency-version -n FinServ -j 214 -m 7
See code: src/commands/essentials/change-dependency-version.ts
If you named a lightning attribute like a custom apex class, since Summer 18 you simply can not generate a managed package again.
This command lists all custom apex classes and custom objects names , then replaces all their references in lightning components and also in apex classes with their camelCase version.
Ex : MyClass_x attribute would be renamed myClassX
USAGE
$ sfdx essentials:fix-lightning-attributes-names OPTIONS
OPTIONS
-f, --folder=folder SFDX project folder containing files (usually 'force-app/main/default'). Default : '.'
EXAMPLE
$ sfdx essentials:fix-lightning-attributes-names
See code: src/commands/essentials/fix-lightning-attributes-names.ts
Once you flagged a packaged method as @Deprecated , you can not deploy it in an org not used for generating a managed package
This commands allows to uncomment desired lines just before making a deployment
Before :
// @Deprecated SFDX_ESSENTIALS_UNCOMMENT
global static List<OrgDebugOption__c> setDebugOption() {
return null;
}
After :
@Deprecated // Uncommented by sfdx essentials:uncomment (https://github.com/nvuillam/sfdx-essentials)
global static List<OrgDebugOption__c> setDebugOption() {
return null;
}
USAGE
$ sfdx essentials:uncomment OPTIONS
OPTIONS
-f, --folder=folder SFDX project folder containing files (usually 'force-app/main/default'). Default : '.'
-k, --uncommentKey=someString Uncomment key. Default : 'SFDX_ESSENTIALS_UNCOMMENT'
EXAMPLE
$ sfdx essentials:uncomment --folder "./Projects/DevRootSource/tmp/deployPackagingDxcDevFiltered" --uncommentKey "SFDX_ESSENTIALS_UNCOMMENT_DxcDev_"
See code: src/commands/essentials/uncomment.ts
Allows to compare the content of a SFDX and the content of one or several package.xml files ( append, if several )
USAGE
$ sfdx essentials:check-sfdx-project-consistency OPTIONS
OPTIONS
-p, --folder=folder List of package.xml files path
-i, --inputfolder=someString SFDX Project folder . Default : '.'
EXAMPLE
$ sfdx essentials:check-sfdx-project-consistency -p "./Config/packageXml/package_DevRoot_Managed.xml,./Config/packageXml/package_DevRoot_xDemo.xml" -i "./Projects/DevRootSource/force-app/main/default"
See code: src/commands/essentials/check-sfdx-project-consistency.ts