@lawrenceloz/sfps
v6.0.2
Published
Test version of sfpowerscripts (not the official version - do not use!)
Downloads
40
Readme
sfpowerscripts
A Salesforce build system for package based development as a sfdx plugin that can be implemented in any CI/CD system of choice. Read more about the plugin and details here - https://dxatscale.gitbook.io/sfpowerscripts/
- Features
- Orchestrator, which utilizes sfdx-project.json as the source of truth for driving the build system, ensuring very low maintenance on programs often dealing with multiple number of packages
- Builds packages in parallel by respecting dependencies
- Ability to selectively build changed packages in a mono repo
- Ability to deploy only packages that are changed in repo
- Pooling commands to prepare a pool of scratch org's with pacakges pre installed for optimized Pull/Merge Request validation
- Artifacts Driven, all create commands produce an artifact or operate on an artifact
- Integrate with any CI/CD system of choice
- Support for external scripts, as hooks making integration easy
Installation
The SFDX CLI, sfpowerkit plugin, and sfdmu are required for this plugin to work. If you have not already done so, please install both of these before continuing.
To install the sfpowerscripts plugin, run the following command:
$ sfdx plugins:install sfpowerkit
$ sfdx plugins:install sfdmu
$ sfdx plugins:install @dxatscale/sfpowerscripts
For automated installations as part of a CI process or Dockerfile:
$ echo 'y' | sfdx plugins:install @dxatscale/sfpowerscripts
$ npm install -g @dxatscale/sfpowerscripts
$ sfdx COMMAND
running command...
$ sfdx (-v|--version|version)
@dxatscale/sfpowerscripts/1.4.5 win32-x64 node-v12.16.3
$ sfdx --help [COMMAND]
USAGE
$ sfdx COMMAND
...
Using sfpowerscripts
Modifiers used by Orchestrator
sfpowerscripts:orchestrator commands allow controlling attributes of a package in its stage by adding additional properties to each package as described in sfdx-project.json. This allows one to change the behaviour of the pipeline without changing any pipeline scripts
{
"path": "path--to--package",
"package": "name--of-the-package", //mandatory, when used with sfpowerscripts
"versionNumber": "X.Y.Z.[NEXT/BUILDNUMBER]",
"type":"data" //Mention the type of package, only to be used for source and data packages
"aliasfy": <boolean>, // Only for source packages, allows to deploy a subfolder whose name matches the alias of the org when using deploy command
"skipDeployOnOrgs": ["org1","org2"], // Comma seperated values of org's to mention this package should not be deployed in this org
"isOptimizedDeployment": <boolean> // default:true for source packages, Utilizes the apex classes in the package for deployment,
"skipTesting":<boolean> //default:false, skip apex testing installation of source package
"skipCoverageValidation":<boolean> //default:false, skip apex coverage validation during validation phase,
"destructiveChangePath:<path> // only for source, if enabled, this will be applied before the package is deployed
"assignPermSetsPreDeployment: ["","",]
"assignPermSetsPostDeployment: ["","",]
"preDeploymentScript":<path> //All Packages
"postDeploymentScript:<path> // All packages
"reconcileProfiles:<boolean> //default:true Source Packages
"ignoreOnStage": [ //Skip this package during the below orchestrator commands
"prepare",
"validate"
]
"alwaysDeploy": <boolean> // If true, deploys package even if already installed in org,
"buildCollection": ["packageB", "packageC"] // packages in the same build collection are always built together, as long as one package in the collection has changed
}
Enabling StatsD Metrics
Almost all the CLI commands have StatsD metrics capture enabled. This means you can setup deployment dashboards in a tool like Graphite or DataDog and capture your deployment statistics. Read more about this feature here
To enable stasd, add the following environment variable, in the format below
# Set STATSD Environment Variables for logging metrics about this build
export SFPOWERSCRIPTS_STATSD=true
export SFPOWERSCRIPTS_STATSD_HOST=172.23.95.52
export SFPOWERSCRIPTS_STATSD_PORT=8125 // Optional, defaults to 8125
export SFPOWERSCRIPTS_STATSD_PROTOCOL=UDP // Optional, defualts to UDP, Supports UDP/TCP
Output Variables
Many of the commands listed below will output variables which may be consumed as flag inputs in subsequent commands. Simply pass the variable name to the command, and it will be substituted with the corresponding value, at runtime.
Eg.
$ sfdx sfpowerscripts:package:version:increment -n <mypackage>
...
Output variable:
sfpowerscripts_incremented_project_version=1.0.0.1
$ sfdx sfpowerscripts:package:source:create -n <mypackage> --versionnumber sfpowerscripts_incremented_project_version
The following output variables are currently supported:
- sfpowerscripts_incremented_project_version
- sfpowerscripts_artifact_directory
- sfpowerscripts_artifact_metadata_directory
- sfpowerscripts_package_version_id
- sfpowerscripts_package_version_number
- sfpowerscripts_pmd_output_path
- sfpowerscripts_scratchorg_username
- sfpowerscripts_installsourcepackage_deployment_id
If you require access to the variables at the shell layer, you may do so using the readVars helper script, which is included as part of this package.
Reference name
Commands that output variables optionally accept a --refname
flag that prefixes output variables with a user-specified string. The prefix is intended as a variable namespace that allows the same command to be invoked multiple times without overwriting the output variables.
$ sfdx sfpowerscripts:package:unlocked:create --refname core -n core_package -b -x -v DevHub
Output variables:
core_sfpowerscripts_package_version_id=04t2v000007X2YRAA0
$ sfdx sfpowerscripts:CreateUnlockedPackage --refname utility -n utility_package -b -x -v Devhub
Output variables:
utility_sfpowerscripts_package_version_id=04t2v000007X2YWAA0
Commands
Orchestrator Commands
sfdx sfpowerscripts:orchestrator:prepare
sfdx sfpowerscripts:orchestrator:validate
sfdx sfpowerscripts:orchestrator:validateAgainstOrg
sfdx sfpowerscripts:orchestrator:quickbuild
sfdx sfpowerscripts:orchestrator:build
sfdx sfpowerscripts:orchestrator:deploy
sfdx sfpowerscripts:orchestrator:release
sfdx sfpowerscripts:orchestrator:promote
sfdx sfpowerscripts:orchestrator:publish
Changelog (Track Releases)
Package Commands ( Build your own workflow)
Pool Management
Static Analysis
Apex tests
Artifacts
sfdx sfpowerscripts:orchestrator:prepare
Prepare a pool of scratchorgs with all the packages upfront, so that any incoming change can be validated in an optimized manner, Please note for this feature to work the devhub should be enabled and scratchorgpool (additional fields to ScratchOrgInfo object) should be deployed to devhub. Please see the instructions here. This command also install an unlocked package to the scratch org 'sfpowerscripts-artifact' (04t1P000000ka0fQAA) for skipping unchanged packages during a validation phase. This particular package can be prebuilt against your org and the ID could be overriden by setting up the environment variable SFPOWERSCRIPTS_ARTIFACT_UNLOCKED_PACKAGE
Prepare a pool of scratchorgs with all the packages upfront, so that any incoming change can be validated in an optimized manner,
USAGE
$ sfdx sfpowerscripts:orchestrator:prepare -t <string> [-e <number>] [-m <number>] [-f <filepath>]
[--installassourcepackages --installall] [-s <filepath>] [--succeedondeploymenterrors] [--keys <string>] [-v <string>]
[--apiversion <string>]
OPTIONS
-e, --expiry=expiry [default: 2] Expiry of the scratch
org's created in the pool
-f, --config=config [default:
config/project-scratch-def.json] The
file path to the definition file for
the scratch org shape
-m, --maxallocation=maxallocation [default: 10] The size of the
scratch org pool to be created
-s, --artifactfetchscript=artifactfetchscript The path to the script file that is
used to fetch the validated
artifacts to be used in the prepare
command
-t, --tag=tag (required) The name/tag of the
scratch org pool
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
--apiversion=apiversion API version to be used
--installall Install the dependencies,along with
all the packages in the repo
--installassourcepackages Install all packages as Source
packages
--keys=keys Keys to be used while installing any
managed package dependencies.
Required format is a string of
key-value pairs separated by spaces
e.g. packageA:pw123 packageB:pw123
packageC:pw123
--succeedondeploymenterrors Do not fail the scratch orgs, if a
package failed to deploy, return the
scratch org with packages till the
last failure
--npm Fetch artifacts from a pre-authenticated
private npm registry
--scope User or Organisation scope of the NPM
packages
--npmtag The distribution tag of the package to
download. If not provided, the 'latest'
tag is used by default.
EXAMPLE
$ sfdx sfpowerscripts:orchestrator:prepare -t CI_1 -v <devhub>
See code: commands/sfpowerscripts/orchestrator/prepare.ts
sfdx sfpowerscripts:orchestrator:validate
Validate the incoming change against a prepared scratch org fetched from the provided pools (created using the prepare command). If the Sfpowerscripts Artifact package is installed in the scratch orgs, only the changed packages in the repo will be deployed by comparing against the package version installed in the fetched scratchorg.
Validate the incoming change against a prepared scratch org fetched from the provided pools.
USAGE
$ sfdx sfpowerscripts:orchestrator:validate -u <string> -p <array> -f <filepath> -i <string> [--shapefile <string>]
[--coveragepercent <integer>] [-g <array>] [-x]
OPTIONS
-f, --jwtkeyfile=jwtkeyfile (required) Path to a file containing
the private key
-g, --logsgroupsymbol=logsgroupsymbol Symbol used by CICD platform to
group/collapse logs in the console.
Provide an opening group, and an
optional closing group symbol.
-i, --clientid=clientid (required) OAuth client ID, also
known as the consumer key
-p, --pools=pools (required) Fetch scratch-org
validation environment from one of
listed pools, sequentially
-u, --devhubusername=devhubusername (required) Authentication username
for Dev Hub
-x, --deletescratchorg Delete scratch-org validation
environment, after the command has
finished running
--coveragepercent=coveragepercent [default: 75] Minimum required
percentage coverage for validating
code coverage of packages with Apex
classes
--keys=keys Keys to be used while installing any
managed package dependencies. Required
format is a string of key-value pairs
separated by spaces e.g. packageA:pw123
packageB:pw123 packageC:pw123
--shapefile=shapefile Path to .zip file of scratch org
shape / metadata to deploy
EXAMPLE
$ sfdx sfpowerscripts:orchestrator:validate -p "POOL_TAG_1,POOL_TAG_2" -u <devHubUsername> -i <clientId> -f <jwt_file>
See code: commands/sfpowerscripts/orchestrator/validate.ts
sfdx sfpowerscripts:orchestrator:validateAgainstOrg
Validate the incoming change against a target org. If the Sfpowerscripts Artifact package is installed in the target org, only changed packages in the repo will be deployed by comparing against the package version installed in the target org.
Validate the incoming change against target org
USAGE
$ sfdx sfpowerscripts:orchestrator:validateAgainstOrg -u <string> [--coveragepercent <integer>] [-g <array>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-g, --logsgroupsymbol=logsgroupsymbol Symbol used by CICD platform to group/collapse logs in the console. Provide
an opening group, and an optional closing group symbol.
-u, --targetorg=targetorg (required) Alias/User Name of the target environment
--coveragepercent=coveragepercent [default: 75] Minimum required percentage coverage for validating code
coverage of packages with Apex classes
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for this command invocation
EXAMPLE
$ sfdx sfpowerscripts:orchestrator:validateAgainstOrg -u <targetorg>
See code: commands/sfpowerscripts/orchestrator/validateAgainstOrg.ts
sfdx sfpowerscripts:orchestrator:quickbuild
Build packages (unlocked/source/data) in a repo in parallel, without validating depenencies or coverage in the case of unlocked packages. For diffcheck to work(build packages that are changed), it compares against the last know git tags, so make sure that you strategically place the tags push at the required state in your pipeline.
Build packages (unlocked/source/data) in a repo in parallel, without validating depenencies or coverage in the case of unlocked packages
USAGE
$ sfdx sfpowerscripts:orchestrator:quickbuild [--diffcheck] [--gittag] [-r <string>] [-f <filepath>] [--artifactdir
<directory>] [--waittime <number>] [--buildnumber <number>] [--executorcount <number>] [--branch <string>] [--tag
<string>] [-v <string>] [--apiversion <string>]
OPTIONS
-f, --configfilepath=configfilepath [default:
config/project-scratch-def.json]
Path in the current project
directory containing config file
for the packaging org
-r, --repourl=repourl Custom source repository URL to use
in artifact metadata, overrides
origin URL defined in git config
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
--apiversion=apiversion override the api version used for
api requests made by this command
--artifactdir=artifactdir [default: artifacts] The directory
where the generated artifact is to
be written
--branch=branch The git branch that this build is
triggered on, Useful for metrics and
general identification purposes
--buildnumber=buildnumber [default: 1] The build number to be
used for source packages, Unlocked
Packages will be assigned the
buildnumber from Saleforce directly
if using .NEXT
--diffcheck Only build the packages which have
changed by analyzing previous tags
--executorcount=executorcount [default: 5] Number of parallel
package task schedulors
--gittag This flag is deprecated, Please
utilize git tags on publish stage
--tag=tag Tag the build with a label, useful
to identify in metrics
--waittime=waittime [default: 120] Wait time for command
to finish in minutes
See code: commands/sfpowerscripts/orchestrator/quickbuild.ts
sfdx sfpowerscripts:orchestrator:build
Build all packages (unlocked/source/data) in a repo in parallel, respecting the dependency of each packages and generate artifacts to a provided directory.For diffcheck to work(build packages that are changed), it compares against the last know git tags, so make sure that you strategically place the tags push at the required state in your pipeline.
Build all packages (unlocked/source/data) in a repo in parallel, respecting the dependency of each packages and generate artifacts to a provided directory
USAGE
$ sfdx sfpowerscripts:orchestrator:build [--diffcheck] [--gittag] [-r <string>] [-f <filepath>] [--artifactdir
<directory>] [--waittime <number>] [--buildnumber <number>] [--executorcount <number>] [--branch <string>] [--tag
<string>] [-v <string>] [--apiversion <string>]
OPTIONS
-f, --configfilepath=configfilepath [default:
config/project-scratch-def.json]
Path in the current project
directory containing config file
for the packaging org
-r, --repourl=repourl Custom source repository URL to use
in artifact metadata, overrides
origin URL defined in git config
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
--apiversion=apiversion override the api version used for
api requests made by this command
--artifactdir=artifactdir [default: artifacts] The directory
where the generated artifact is to
be written
--branch=branch The git branch that this build is
triggered on, Useful for metrics and
general identification purposes
--buildnumber=buildnumber [default: 1] The build number to be
used for source packages, Unlocked
Packages will be assigned the
buildnumber from Saleforce directly
if using .NEXT
--diffcheck Only build the packages which have
changed by analyzing previous tags
--executorcount=executorcount [default: 5] Number of parallel
package task schedulors
--gittag This flag is deprecated,
Please utilize git tags on publish stage
--tag=tag Tag the build with a label, useful
to identify in metrics
--waittime=waittime [default: 120] Wait time for command
to finish in minutes
See code: commands/sfpowerscripts/orchestrator/build.ts
sfdx sfpowerscripts:orchestrator:deploy
Deploy packages from the provided aritfact directory, to a given org, using the order and configurable flags provided in sfdx-project.json
skipifalreadyinstalled
only works provide the target org has sfpowerscripts-artifact' (04t1P000000ka0fQAA) installed. Please note you can
deploy your own instance of 'sfpowerscripts-artifact' by building it from the repo and overriding using the environment variable SFPOWERSCRIPTS_ARTIFACT_UNLOCKED_PACKAGE
Deploy packages from the provided aritfact directory, to a given org, using the order and configurable flags provided in sfdx-project.json
USAGE
$ sfdx sfpowerscripts:orchestrator:deploy -u <string> [--artifactdir <directory>] [--waittime <number>] [-g <array>]
[-t <string>] [-b <string> --skipifalreadyinstalled]
OPTIONS
-b, --baselineorg=baselineorg The org against which the package skip
should be baselined
-g, --logsgroupsymbol=logsgroupsymbol Symbol used by CICD platform to
group/collapse logs in the console.
Provide an opening group, and an
optional closing group symbol.
-t, --tag=tag Tag the deploy with a label, useful
for identification in metrics
-u, --targetorg=targetorg (required) [default: scratchorg]
Alias/User Name of the target
environment
--artifactdir=artifactdir [default: artifacts] The directory
containing artifacts to be deployed
--skipifalreadyinstalled Skip the package installation if the
package is already installed in the
org
--waittime=waittime [default: 120] Wait time for command
to finish in minutes
EXAMPLE
$ sfdx sfpowerscripts:orchestrator:deploy -u <username>
See code: commands/sfpowerscripts/orchestrator/deploy.ts
sfdx sfpowerscripts:orchestrator:release
Initiate a release to an org, according to the configuration defined in a release-definition YAML file
USAGE
$ sfdx sfpowerscripts:orchestrator:release -u <string> [-p <filepath>] [--scope <string> [--npm | -f <filepath>]] [--npmrcpath <filepath> undefined] [-g <array>] [-t <string>] [--waittime <number>] [--keys <string>] [--generatechangelog]
[--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-f, --scriptpath=scriptpath (Optional: no-NPM) Path to script that authenticates and downloads artifacts from the registry
-g, --logsgroupsymbol=logsgroupsymbol Symbol used by CICD platform to group/collapse logs in the console. Provide an opening group, and an optional closing group symbol.
-p, --releasedefinition=releasedefinition Path to YAML file containing map of packages and package versions to download
-t, --tag=tag Tag the release with a label, useful for identification in metrics
-u, --targetorg=targetorg (required) [default: scratchorg] Alias/User Name of the target environment
--generatechangelog Create a release changelog
--json format output as json
--keys=keys Keys to be used while installing any managed package dependencies. Required format is a string of key-value pairs separated by spaces e.g. packageA:pw123
packageB:pw123 packageC:pw123
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for this command invocation
--npm Download artifacts from a pre-authenticated private npm registry
--npmrcpath=npmrcpath Path to .npmrc file used for authentication to registry. If left blank, defaults to home directory
--scope=scope (required for NPM) User or Organisation scope of the NPM package
--waittime=waittime [default: 120] Wait time for package installation
EXAMPLE
sfdx sfpowerscripts:orchestrator:release -p path/to/releasedefinition.yml -u myorg --npm --scope myscope --generatechangelog
See code: commands/sfpowerscripts/orchestrator/release.ts
sfdx sfpowerscripts:orchestrator:promote
Promotes validated unlocked packages with code coverage greater than 75%
Promotes validated unlocked packages with code coverage greater than 75%
USAGE
$ sfdx sfpowerscripts:orchestrator:promote -d <directory> [-v <string>]
OPTIONS
-d, --artifactdir=artifactdir (required) [default: artifacts] The
directory where artifacts are
located
-v, --devhubalias=devhubalias [default: HubOrg] Provide the alias
of the devhub previously
authenticated, default value is
HubOrg if using the Authenticate
Devhub task
EXAMPLE
$ sfdx sfpowerscripts:orchestrator:promote -d path/to/artifacts -v <org>
See code: commands/sfpowerscripts/orchestrator/promote.ts
sfdx sfpowerscripts:orchestrator:publish
Publish packages to an artifact registry, using a user-provided script that is responsible for authenticating & uploading to the registry.
Publish packages to an artifact registry, using a user-provided script that is responsible for authenticating & uploading to the registry.
USAGE
$ sfdx sfpowerscripts:orchestrator:publish -d <directory> -f <filepath> [-p -v <string>] [-t <string>]
OPTIONS
-d, --artifactdir=artifactdir (required) [default: artifacts] The
directory containing artifacts to be
published
-f, --scriptpath=scriptpath (required) Path to script that
authenticates and uploaded artifacts
to the registry
-p, --publishpromotedonly Only publish unlocked packages that
have been promoted
-t, --tag=tag Tag the publish with a label, useful
for identification in metrics
-v, --devhubalias=devhubalias Provide the alias of the devhub
previously authenticated
--gittag Tag the current commit ID with an
annotated tag containing the package
name and version - does not push tag
--pushgittag Pushes the git tags created by this
command to the repo, ensure you have
access to the repo
--npm Upload artifacts to a pre-authenticated
npm registry
--scope User or Organisation scope of the NPM
package
--npmtag Add an optional distribution tag to NPM
packages. If not provided, the 'latest'
tag is set to the published version
EXAMPLES
$ sfdx sfpowerscripts:orchestrator:publish -f path/to/script
$ sfdx sfpowerscripts:orchestrator:publish --npm
$ sfdx sfpowerscripts:orchestrator:publish -f path/to/script -p -v HubOrg
$ sfdx sfpowerscripts:orchestrator:publish -f path/to/script --gittag --pushgittag
See code: commands/sfpowerscripts/orchestrator/publish.ts
sfdx sfpowerscripts:changelog:generate
Generates release changelog, providing a summary of artifact versions, work items and commits introduced in a release. Creates a release definition based on artifacts contained in the artifact directory, and compares it to previous release definition in changelog stored on a source repository
Generates release changelog, providing a summary of artifact versions, work items and commits introduced in a release. Creates a release definition based on artifacts contained in the artifact directory, and compares it to previous release definition in changelog stored on a source repository
USAGE
$ sfdx sfpowerscripts:changelog:generate -d <directory> -n <string> -w <string> -r <string> -b <string> [--limit
<integer>] [--workitemurl <string>] [--showallartifacts]
OPTIONS
-d, --artifactdir=artifactdir (required) [default: artifacts]
Directory containing sfpowerscripts
artifacts
-n, --releasename=releasename (required) Name of the release for
which to generate changelog
-r, --repourl=repourl (required) Repository in which the
changelog files are located. Assumes
user is already authenticated.
-w, --workitemfilter=workitemfilter (required) Regular expression used
to search for work items (user
stories) introduced in release
--json format output as json
--limit=limit limit the number of releases to
display in changelog markdown
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
--showallartifacts Show all artifacts in changelog
markdown, including those that have
not changed in the release
--workitemurl=workitemurl Generic URL for work items. Each
work item ID will be appended to the
URL, providing quick access to work
items
EXAMPLE
$ sfdx sfpowerscripts:changelog:generate -n <releaseName> -d path/to/artifact/directory -w <regexp> -r <repoURL> -b
<branchName>
See code: commands/sfpowerscripts/changelog/generate.ts
sfdx sfpowerscripts:analyze:pmd
This task is used to run a static analysis of the apex classes and triggers using PMD, Please ensure that the SFDX CLI and sfpowerkit plugin are installed before using this task
This task is used to run a static analysis of the apex classes and triggers using PMD, Please ensure that the SFDX CLI and sfpowerkit plugin are installed before using this task
USAGE
$ sfdx sfpowerscripts:analyze:pmd [--sourcedir <string>] [--ruleset <string>] [--rulesetpath <string>] [--format
<string>] [-o <string>] [--version <string>] [-b] [--refname <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-b, --istobreakbuild Enable this option if the build
should be reported as failure if 1
or more critical defects are
reported during the analysis
-o, --outputpath=outputpath The file to which the output for
static analysis will be written
--format=text|textcolor|csv|emacs|summaryhtml|html|xml|xslt|yahtml|vbhtml|textpad [default: text]
https://pmd.github.io/latest/pmd_us
erdocs_cli_reference.html#available
-report-formats
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
--refname=refname Reference name to be prefixed to
output variables
--ruleset=sfpowerkit|Custom [default: sfpowerkit] Inbuilt is
the default ruleset that comes with
the task, If you choose custom,
please provide the path to the
ruleset
--rulesetpath=rulesetpath The path to the ruleset if you are
utilizing your own ruleset
--sourcedir=sourcedir The directory that is to be analzed
using PMD, If omitted default
project diretory as mentioned in
sfdx-project.json will be used
--version=version [default: 6.26.0] The version of
PMD to be used for static analysis
EXAMPLES
$ sfdx sfpowerscripts:analyze:pmd -b
Output variable:
sfpowerscripts_pmd_output_path
<refname>_sfpowerscripts_pmd_output_path
See code: commands/sfpowerscripts/analyze/pmd.ts
sfdx sfpowerscripts:apextests:trigger
Triggers Apex unit test in an org. Supports test level RunAllTestsInPackage, which optionally allows validation of individual class code coverage
Triggers Apex unit test in an org. Supports test level RunAllTestsInPackage, which optionally allows validation of individual class code coverage
USAGE
$ sfdx sfpowerscripts:apextests:trigger [-u <string>] [-l <string>] [-n <string>] [-c] [--validatepackagecoverage]
[-s] [--specifiedtests <string>] [--apextestsuite <string>] [-p <integer>] [--waittime <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-c, --validateindividualclasscoverage
Validate that individual classes have a coverage greater than the minimum required percentage coverage, only
available when test level is RunAllTestsInPackage
-l, --testlevel=RunSpecifiedTests|RunApexTestSuite|RunLocalTests|RunAllTestsInOrg|RunAllTestsInPackage
[default: RunLocalTests] The test level of the test that need to be executed when the code is to be deployed
-n, --package=package
Name of the package to run tests. Required when test level is RunAllTestsInPackage
-p, --coveragepercent=coveragepercent
[default: 75] Minimum required percentage coverage, when validating code coverage
-s, --synchronous
Select an option if the tests are to be run synchronously
-u, --targetorg=targetorg
[default: scratchorg] username or alias for the target org; overrides default target org
--apextestsuite=apextestsuite
comma-separated list of Apex test suite names to run
--json
format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL)
[default: warn] logging level for this command invocation
--specifiedtests=specifiedtests
comma-separated list of Apex test class names or IDs and, if applicable, test methods to run
--validatepackagecoverage
Validate that the package coverage is greater than the minimum required percentage coverage, only available when
test level is RunAllTestsInPackage
--waittime=waittime
[default: 60] wait time for command to finish in minutes
EXAMPLES
$ sfdx sfpowerscripts:apextests:trigger -u scratchorg -l RunLocalTests -s
$ sfdx sfpowerscripts:apextests:trigger -u scratchorg -l RunAllTestsInPackage -n <mypackage> -c
See code: commands/sfpowerscripts/apextests/trigger.ts
sfdx sfpowerscripts:apextests:validate
Validates apex test coverage in the org, Please ensure that the SFDX CLI and sfpowerkit plugin are installed before using this task.
Validates apex test coverage in the org, Please ensure that the SFDX CLI and sfpowerkit plugin are installed before using this task.
USAGE
$ sfdx sfpowerscripts:apextests:validate -t <string> [-u <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-t, --testcoverage=testcoverage (required) The percentage of test
coverage for apex clasess, that
should be as per the last test run
status
-u, --targetorg=targetorg [default: scratchorg] Alias or
username of the target org
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
EXAMPLE
$ sfdx sfpowerscripts:apextests:validate -u scratchorg -t 80
See code: commands/sfpowerscripts/apextests/validate.ts
sfdx sfpowerscripts:package:data:create
Creates a versioned artifact from a source directory containing SFDMU-based data (in csv format and export json). The artifact can be consumed by release pipelines, to deploy the data to orgs
Creates a versioned artifact from a source directory containing SFDMU-based data (in csv format and export json). The artifact can be consumed by release pipelines, to deploy the data to orgs
USAGE
$ sfdx sfpowerscripts:package:data:create -n <string> -v <string> [--artifactdir <directory>] [--diffcheck] [--branch
<string>] [--gittag] [-r <string>] [--refname <string>]
OPTIONS
-n, --package=package
(required) The name of the package
-r, --repourl=repourl
Custom source repository URL to use in artifact metadata, overrides origin URL defined in git config
-v, --versionnumber=versionnumber
(required) The format is major.minor.patch.buildnumber . This will override the build number mentioned in the
sfdx-project.json, Try considering the use of Increment Version Number task before this task
--artifactdir=artifactdir
[default: artifacts] The directory where the artifact is to be written
--branch=branch
The git branch that this build is triggered on, Useful for metrics and general identification purposes
--diffcheck
Only build when the package has changed
--gittag
Tag the current commit ID with an annotated tag containing the package name and version - does not push tag
--refname=refname
Reference name to be prefixed to output variables
EXAMPLES
$ sfdx sfpowerscripts:package:data:create -n mypackage -v <version>
$ sfdx sfpowerscripts:package:data:create -n <mypackage> -v <version> --diffcheck --gittag
Output variable:
sfpowerscripts_artifact_directory
<refname>_sfpowerscripts_artifact_directory
sfpowerscripts_package_version_number
<refname>_sfpowerscripts_package_version_number
See code: commands/sfpowerscripts/package/data/create.ts
sfdx sfpowerscripts:package:data:install
Installs a SFDMU-based data package consisting of csvfiles and export.json to a target org
Installs a SFDMU-based data package consisting of csvfiles and export.json to a target org
USAGE
$ sfdx sfpowerscripts:package:data:install -n <string> -u <string> [--artifactdir <directory>] [-s]
[--skipifalreadyinstalled] [--subdirectory <directory>]
OPTIONS
-n, --package=package (required) Name of the package to be
installed
-s, --skiponmissingartifact Skip package installation if the
build artifact is missing. Enable
this if artifacts are only being
created for modified packages
-u, --targetorg=targetorg (required) Alias/User Name of the
target environment
--artifactdir=artifactdir [default: artifacts] The directory
where the artifact is located
--skipifalreadyinstalled Skip the package installation if the
package is already installed in the
org
--subdirectory=subdirectory Install specific subdirectory in the
package. Useful when package
consists of multiple discrete
sub-packages
EXAMPLE
$ sfdx sfpowerscripts:package:data:install -n mypackage -u <org>
See code: commands/sfpowerscripts/package/data/install.ts
sfdx sfpowerscripts:package:source:create
This task simulates a packaging experience similar to unlocked packaging - creating an artifact that consists of the metadata wrapped into an artifact. The artifact can then be consumed by release tasks, to deploy the package
This task simulates a packaging experience similar to unlocked packaging - creating an artifact that consists of the metadata (e.g. commit Id), source code & an optional destructive manifest. The artifact can then be consumed by release pipelines, to deploy the package
USAGE
$ sfdx sfpowerscripts:package:source:create -n <string> -v <string> [--artifactdir <directory>] [--diffcheck]
[--branch <string>] [--gittag] [-r <string>] [--refname <string>]
OPTIONS
-n, --package=package
(required) The name of the package
-r, --repourl=repourl
Custom source repository URL to use in artifact metadata, overrides origin URL defined in git config
-v, --versionnumber=versionnumber
(required) The format is major.minor.patch.buildnumber . This will override the build number mentioned in the
sfdx-project.json, Try considering the use of Increment Version Number task before this task
--artifactdir=artifactdir
[default: artifacts] The directory where the artifact is to be written
--branch=branch
The git branch that this build is triggered on, Useful for metrics and general identification purposes
--diffcheck
Only build when the package has changed
--gittag
Tag the current commit ID with an annotated tag containing the package name and version - does not push tag
--refname=refname
Reference name to be prefixed to output variables
EXAMPLES
$ sfdx sfpowerscripts:package:source:create -n mypackage -v <version>
$ sfdx sfpowerscripts:package:source:create -n <mypackage> -v <version> --diffcheck --gittag
Output variable:
sfpowerscripts_artifact_metadata_directory
<refname>_sfpowerscripts_artifact_metadata_directory
sfpowerscripts_artifact_directory
<refname>_sfpowerscripts_artifact_directory
sfpowerscripts_package_version_number
<refname>_sfpowerscripts_package_version_number
See code: commands/sfpowerscripts/package/source/create.ts
sfdx sfpowerscripts:package:source:install
Installs a sfpowerscripts source package to the target org. skipifalreadyinstalled` only works provide the target org has sfpowerscripts-artifact' (04t1P000000ka0fQAA) installed. Please note you can deploy your own instance of 'sfpowerscripts-artifact' by building it from the repo and overriding using the environment variable SFPOWERSCRIPTS_ARTIFACT_UNLOCKED_PACKAGE
Installs a sfpowerscripts source package to the target org
USAGE
$ sfdx sfpowerscripts:package:source:install -n <string> -u <string> [--artifactdir <directory>]
[--skipifalreadyinstalled] [-s] [--subdirectory <directory>] [-o] [-t] [--waittime <string>] [--refname <string>]
OPTIONS
-n, --package=package (required) Name of the package to be
installed
-o, --optimizedeployment Optimize deployment by triggering
test classes that are in the
package, rather than using the whole
tests in the org
-s, --skiponmissingartifact Skip package installation if the
build artifact is missing. Enable
this if artifacts are only being
created for modified packages
-t, --skiptesting Skips running test when deploying to
a sandbox
-u, --targetorg=targetorg (required) Alias/User Name of the
target environment
--artifactdir=artifactdir [default: artifacts] The directory
where the artifact is located
--refname=refname Reference name to be prefixed to
output variables
--skipifalreadyinstalled Skip the package installation if the
package is already installed in the
org
--subdirectory=subdirectory Install spe