@jayree/sfdx-plugin-source
A Salesforce CLI plugin containing commands to generate and compare sfdx source snapshot files.
Install
sfdx plugins:install @jayree/sfdx-plugin-source
Commands
sfdx jayree:project:fix
Fix retrieved metadata.
USAGE
$ sfdx jayree:project:fix [--json] [-o <value>] [-t <value>]
FLAGS
-o, --target-org=<value>
-t, --task=<value>... Comma-separated list of task names listed in sfdx-project.json.
GLOBAL FLAGS
--json Format output as json.
ALIASES
$ sfdx jayree:source:fix
See code: src/commands/jayree/project/fix.ts
sfdx jayree:source:snapshot:compare
compares sfdx source snapshot files
USAGE
$ sfdx jayree:source:snapshot:compare [--json] [--filepath <value>]
FLAGS
--filepath=<value> [default: ./sfdx-source-snapshot.json] path of the generated snapshot file
GLOBAL FLAGS
--json Format output as json.
See code: src/commands/jayree/source/snapshot/compare.ts
sfdx jayree:source:snapshot:generate
generates sfdx source snapshot files
USAGE
$ sfdx jayree:source:snapshot:generate [--json] [--filepath <value>]
FLAGS
--filepath=<value> [default: ./sfdx-source-snapshot.json] path to save the generated snapshot file
GLOBAL FLAGS
--json Format output as json.
See code: src/commands/jayree/source/snapshot/generate.ts
sfdx jayree:source:tracking:list
list changes in a scratch org by remote revision counter number
USAGE
$ sfdx jayree:source:tracking:list -o <value> [--json] [--api-version <value>] [-r <value>]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org.
-r, --revision=<value> start at a specific revision counter number
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ sfdx jayree:source:tracking:list
$ sfdx jayree:source:tracking:list -u me@my.org
$ sfdx jayree:source:tracking:list -u me@my.org -r 101
See code: src/commands/jayree/source/tracking/list.ts
sfdx jayree:source:tracking:store:get
get stored revision counter number
USAGE
$ sfdx jayree:source:tracking:store:get -o <value> [--json]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org.
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ sfdx jayree:source:tracking:store:get
$ sfdx jayree:source:tracking:store:get -u me@my.org
See code: src/commands/jayree/source/tracking/store/get.ts
sfdx jayree:source:tracking:store:set
store revision counter number
USAGE
$ sfdx jayree:source:tracking:store:set -o <value> [--json] [--api-version <value>] [-r <value>]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org.
-r, --revision=<value> revision counter number (default: remote revision counter number)
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--json Format output as json.
EXAMPLES
$ sfdx jayree:source:tracking:store:set
$ sfdx jayree:source:tracking:store:set -u me@my.org
$ sfdx jayree:source:tracking:store:set -u MyTestOrg1 -r 101
See code: src/commands/jayree/source/tracking/store/set.ts
Hooks
prerun
- Resets source tracking using
force:source:tracking:reset
before executing force:source:pull
or project:retrieve:start
.
IMPORTANT: This hook will only run if SFDX_ENABLE_JAYREE_HOOKS_RESET_BEFORE_PULL=true
is set. It uses the stored serverMaxRevisionCounter
as revision counter number (see: jayree:source:tracking:store:set
). If the hook doesn't find a stored value it asks if the current local revision counter number should be stored and used.
scopedPreRetrieve
scopedPostRetrieve (plugin-source plugin) / postsourceupdate (legacy salesforce-alm plugin)
- Applies source fixes of the
jayree project fix
command, deletes and moves source files to separate package directories. See the configuration file sfdx-project.json for examples. Set "isActive": true,´ to apply this fix during
scopedPostRetrieve` hook.
IMPORTANT: Since the hook is not able to update the (JSON) output of the command, an additional output is generated. Set the environment variable SFDX_ENABLE_JAYREE_HOOKS_JSON_OUTPUT=true
and additional comma-separated JSON output will be appended, where the output must be parsed as an array, e.g. JSON.parse(`[${stdout}]`)
. See an example below:
import execa from "execa";
import { CliUx } from "@oclif/core";
async function run() {
const { stdout } = await execa("sfdx", [
"force:source:retrieve",
"--metadata",
"Group:*",
"--json"
]);
const parsedStdout = JSON.parse(`[${stdout}]`);
CliUx.ux.styledJSON(
parsedStdout.length > 1
? {
...parsedStdout[0],
result: {
...parsedStdout[0].result,
fixedFiles: parsedStdout[1].fixedFiles
}
}
: parsedStdout[0]
);
}
run();