/sfdx-essentials

Commands to fix lack of capabilities or bugs of SFDC platform

Primary LanguageTypeScript

Salesforce DX Essentials

Version Downloads/week License

PLUGIN

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 :)

For the moments, this plugin capabilities are :

  • Filtering metadatas generated from a SFDX Project in order to be able to deploy only part of them on an org

  • Replace other managed packages dependency version number ( very useful when you build a managed package over another managed package, like Financial Services Cloud )

  • 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)

Please contribute :)

INSTALLATION

    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 )

UPGRADE

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

COMMANDS

essentials:filter-metadatas

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
     - AuraDefinitionBundle
     - BusinessProcess
     - ContentAsset
     - CustomApplication
     - CustomField
     - CustomLabel
     - CustomMetadata
     - CustomObject
     - CustomObjectTranslation
     - CustomTab
     - Document
     - EmailTemplate
     - EscalationRules
     - FlexiPage
     - GlobalValueSet
     - GlobalValueSetTranslation
     - HomePageLayout
     - ListView
     - Layout
     - NamedCredential
     - PermissionSet
     - Profile
     - QuickAction
     - RecordType
     - RemoteSiteSetting
     - Report
     - StandardValueSet
     - StaticResource
     - Translations
     - WebLink
     - Workflow

See conversion tables

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

essentials:change-dependency-version

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

essentials:fix-lightning-attributes-names

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

essentials:uncomment

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

essentials:check-sfdx-project-consistency

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