ci-sf-plugin

0.0.18 • Public • Published

ci-sf-plugin

Set of commands making CI and dev's life easier.

NPM Downloads/week License

Intro
Configuration
Commands
Development

Intro

# installation
$ sf plugins install ci-sf-plugin@x.y.z

# get info
$ sf plugins inspect ci-sf-plugin
$ sf (-h|--help) [COMMAND]

Configuration

  • Complete example of ciconfig.json file which should be placed in the root of your DX project.
    {
        "projectName": "my-project",
        "packageIds": [
            {
                "id": "04t1W000000aaa4QAK"
            },
            {
                "id": "04t2E000000bbbxQAA",
                "name": "name of this package",
                "versionNumber": "2.14"
            }
        ],
        "apexPrePush": [
            "scripts/anonymous-apex/enableMarketingUser.apex"
        ],
        "apexPostPush": [
            "scripts/anonymous-apex/insertCustomSettings.apex"
        ],
        "profile": "My Admin Profile",
        "permsetGroups": [
            "Admin_Application_Access",
            "Admin_Accounts_Access"
        ],
        "postCreateManualSteps": {
            "apexOrgVerification": "scripts/anonymous-apex/verifyOrgFeatures.apex",
            "continueInstruction": "Please, continue by running '...' command.",
            "features": [
                {
                    "name": "ContactsToMultipleAccounts",
                    "manualStepDescription": "Open the new scratch org, go to Setup/Account Settings and enable 'Allow users to relate a contact to multiple accounts'."
                },
                {
                    "manualStepDescription": "Open the new scratch org, go to Setup/Asset Settings and turn on 'Enable Asset Sharing'."
                }
            ],
            "settings": {
                "accountSettings": {
                    "enableRelateContactToMultipleAccounts": true
                }
            }
        }
    }

Commands

sf ci apex test run

Run unit tests in an org.

USAGE
  $ sf ci apex test run -o <value> [--json] [--flags-dir <value>] [-l RunLocalTests|RunAllTestsInOrg]

FLAGS
  -l, --test-level=<option>  [default: RunLocalTests] specifies which tests to run
                             <options: RunLocalTests|RunAllTestsInOrg>
  -o, --target-org=<value>   (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Run unit tests in an org.

EXAMPLES
  $ sf ci apex test run -o orgAlias

  $ sf ci apex test run -o orgAlias --test-level RunLocalTests

sf ci apex execute

Executes Apex in an org. Either 'pre-push' or 'post-push' flag must be provided.

USAGE
  $ sf ci apex execute -o <value> [--json] [--flags-dir <value>] [--pre-push] [--post-push] [-x <value>]

FLAGS
  -o, --target-org=<value>      (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.
  -x, --ci-config-file=<value>  [default: ciconfig.json] path to a 'ciconfig.json' file with 'apexPrePush' or 'apexPostPush' property
      --post-push               executes post-push scripts.
      --pre-push                executes pre-push scripts.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Executes Apex in an org. Either 'pre-push' or 'post-push' flag must be provided.

EXAMPLES
  $ sf ci apex execute -o orgAlias --pre-push

  $ sf ci apex execute --post-push

sf ci limits api display

Display org's limits.

USAGE
  $ sf ci limits api display -o <value> [--json] [--flags-dir <value>]

FLAGS
  -o, --target-org=<value>  (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Display org's limits.

EXAMPLES
  $ sf ci limits api limits -o orgAlias

sf ci org create

Creates a scratch org from your default dev hub. User can be also notified about possibly needed post-org-create manual steps together with instructions how to continue. Different behaviour can be configured for CI environment.

USAGE
  $ sf ci org create -v <value> [--json] [--flags-dir <value>] [-a <value>] [-d <value>] [-f <value>] [--ci] [-t <value>] [-x <value>] [-w <value>]

FLAGS
  -a, --set-alias=<value>           alias for the created org
  -d, --duration-days=<value>       [default: 30] duration of the scratch org (in days) (min:1, max:30)
  -f, --definition-file=<value>     [default: config/project-scratch-def.json] path to an org definition file
  -t, --validation-timeout=<value>  [default: 30] timeout in seconds before org validation happens
  -v, --target-dev-hub=<value>      (required) [default: kamil.malecek@durrgroup.com] Username or alias of the Dev Hub org. Not required if the `target-dev-hub` configuration variable is already
                                    set.
  -w, --wait=<value>                [default: 60] number of minutes to wait for the scratch org to be ready
  -x, --ci-config-file=<value>      [default: ciconfig.json] path to a 'ciconfig.json' file with 'projectName' property
      --ci                          set for CI environment

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Creates a scratch org from your default dev hub. User can be also notified about possibly needed post-org-create manual steps together with instructions how to continue. Different behaviour can
  be configured for CI environment.

EXAMPLES
  $ sf ci org create -a orgAlias

  $ sf ci org create --set-alias orgAlias --definition-file config/project-scratch-def.json

  $ sf ci org create --set-alias orgAlias --ci --validation-timeout 60

sf ci org delete

Delete a scratch org. Either explicitly specified org or the default one, if any.

USAGE
  $ sf ci org delete -o <value> [--json] [--flags-dir <value>]

FLAGS
  -o, --target-org=<value>  (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Delete a scratch org. Either explicitly specified org or the default one, if any.

EXAMPLES
  $ sf ci org delete -o orgAlias

sf ci org printurl

Display navigation URL for either specified org or the default one, if any, but don’t launch browser.

USAGE
  $ sf ci org printurl -o <value> [--json] [--flags-dir <value>]

FLAGS
  -o, --target-org=<value>  (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Display navigation URL for either specified org or the default one, if any, but don’t launch browser.

EXAMPLES
  $ sf ci org printurl -o orgAlias

sf ci package install

Installs packages into an org.

USAGE
  $ sf ci package install -o <value> [--json] [--flags-dir <value>] [-s AllUsers|AdminsOnly] [-p <value>] [-x <value>]

FLAGS
  -o, --target-org=<value>      (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.
  -p, --package=<value>         ID (starts with 04t) or alias of the package version to install, overrides 'ciconfig.json' configuration
  -s, --security-type=<option>  [default: AdminsOnly] security access type for the installed package
                                <options: AllUsers|AdminsOnly>
  -x, --ci-config-file=<value>  [default: ciconfig.json] path to a 'ciconfig.json' file with 'packageIds' array property

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Installs packages into an org.

EXAMPLES
  $ sf ci package install -o orgAlias

  $ sf ci package install --target-org orgAlias --package 04t0W000001MRQIQA4

sf ci source push

Pushes DX source into an org.

USAGE
  $ sf ci source push -o <value> [--json] [--flags-dir <value>] [--ci] [-x <value>]

FLAGS
  -o, --target-org=<value>      (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.
  -x, --ci-config-file=<value>  [default: ciconfig.json] path to a 'ciconfig.json' file with 'ciForceignore' property
      --ci                      set for CI environment

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Pushes DX source into an org.

EXAMPLES
  $ sf ci source push -o orgAlias

  $ sf ci source push -o orgAlias --ci

sf ci source sort

Sort selected metadata. Profiles, permission sets, muting permission sets and permission set groups are sorted by default.

USAGE
  $ sf ci source sort [--json] [--flags-dir <value>] [-d <value>]

FLAGS
  -d, --directory=<value>  [default: src/main/default] relative path to the parent folder of metadata ('profiles' etc. folders inside)

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Sort selected metadata. Profiles, permission sets, muting permission sets and permission set groups are sorted by default.

EXAMPLES
  $ sf ci source sort

  $ sf ci source sort -d '~/projects/project-dx/src/main/default'

sf ci user assign permsetgroup

Assigns permission set groups to an authenticated user.

USAGE
  $ sf ci user assign permsetgroup -o <value> [--json] [--flags-dir <value>] [-n <value>] [-x <value>]

FLAGS
  -n, --permset-group-name=<value>  permission set group name to assign
  -o, --target-org=<value>          (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.
  -x, --ci-config-file=<value>      [default: ciconfig.json] path to a 'ciconfig.json' file with 'permsetGroups' array property

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Assigns permission set groups to an authenticated user.

EXAMPLES
  $ sf ci user assign permsetgroup -o orgAlias

  $ sf ci user assign permsetgroup --target-org orgAlias --permset-group-name PermsetGroup_DevName

sf ci user assign profile

Assigns profile to the currently authenticated user.

USAGE
  $ sf ci user assign profile -o <value> [--json] [--flags-dir <value>] [-n <value>] [-x <value>]

FLAGS
  -n, --profile-name=<value>    profile name to assign
  -o, --target-org=<value>      (required) Username or alias of the target org. Not required if the `target-org` configuration variable is already set.
  -x, --ci-config-file=<value>  [default: ciconfig.json] path to a 'ciconfig.json' file with 'profile' property

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Assigns profile to the currently authenticated user.

EXAMPLES
  $ sf ci user assign profile -o orgAlias

  $ sf ci user assign profile --target-org orgAlias --profile-name "Custom Admin Profile"

Development

  • Install the dependencies and compile
yarn && yarn build

To use your plugin, run using the local ./bin/dev or ./bin/dev.cmd file.

# Run using local run file.
./bin/dev hello world

There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.

# Link your plugin to the sf cli
sf plugins link .
# To verify
sf plugins

Package Sidebar

Install

npm i ci-sf-plugin

Weekly Downloads

36

Version

0.0.18

License

MIT

Unpacked Size

491 kB

Total Files

52

Last publish

Collaborators

  • malecka1