npm package: @mysf/plugin-sf-data-export
Description: Plugin to export data from salesforce
Author: Salesforce
Latest version: 1.0.12

**NOTE: This template for sf plugins is not yet official. Please consult with the Platform CLI team before using this template.**

# plugin-sf-data-export

[![NPM](https://img.shields.io/npm/v/@salesforce/plugin-sf-data-export.svg?label=@salesforce/plugin-sf-data-export)](https://www.npmjs.com/package/@salesforce/plugin-sf-data-export) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/plugin-sf-data-export.svg)](https://npmjs.org/package/@salesforce/plugin-sf-data-export) [![License](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/license/apache-2-0)

## Using the template

This repository provides a template for creating a plugin for the Salesforce CLI. To convert this template to a working plugin:

1. Please get in touch with the Platform CLI team. We want to help you develop your plugin.
2. Generate your plugin:

   ```
   sf plugins install dev
   sf dev generate plugin

   git init -b main
   git add . && git commit -m "chore: initial commit"
   ```

3. Create your plugin's repo in the salesforcecli github org
4. When you're ready, replace the contents of this README with the information you want.

## Learn about `sf` plugins

Salesforce CLI plugins are based on the [oclif plugin framework](https://oclif.io/docs/introduction). Read the [plugin developer guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_plugins.meta/sfdx_cli_plugins/cli_plugins_architecture_sf_cli.htm) to learn about Salesforce CLI plugin development.

This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the [node developer packages](#tooling) used by Salesforce. There is also a default circleci config using the [release management orb](https://github.com/forcedotcom/npm-release-management-orb) standards.

Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the `posttest` script and it is required to keep these tests active in your plugin if you plan to have it bundled.

### Tooling

- [@salesforce/core](https://github.com/forcedotcom/sfdx-core)
- [@salesforce/kit](https://github.com/forcedotcom/kit)
- [@salesforce/sf-plugins-core](https://github.com/salesforcecli/sf-plugins-core)
- [@salesforce/ts-types](https://github.com/forcedotcom/ts-types)
- [@salesforce/ts-sinon](https://github.com/forcedotcom/ts-sinon)
- [@salesforce/dev-config](https://github.com/forcedotcom/dev-config)
- [@salesforce/dev-scripts](https://github.com/forcedotcom/dev-scripts)

# Everything past here is only a suggestion as to what should be in your specific plugin's description

This plugin is bundled with the [Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli). For more information on the CLI, read the [getting started guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm).

We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.

## Install

```bash
sf plugins install @salesforce/plugin-sf-data-export@x.y.z
```

## Issues

Please report any issues at https://github.com/forcedotcom/cli/issues

## Contributing

1. Please read our [Code of Conduct](CODE_OF_CONDUCT.md)
2. Create a new issue before starting your project so that we can keep track of
   what you are trying to add/fix. That way, we can also offer suggestions or
   let you know if there is already an effort in progress.
3. Fork this repository.
4. [Build the plugin locally](#build)
5. Create a _topic_ branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
6. Edit the code in your fork.
7. Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
8. Sign CLA (see [CLA](#cla) below).
9. Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.

### CLA

External contributors will be required to sign a Contributor's License
Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.

### Build

To build the plugin locally, make sure to have yarn installed and run the following commands:

```bash
# Clone the repository
git clone git@github.com:salesforcecli/plugin-sf-data-export

# Install the dependencies and compile
yarn && yarn build
```

To use your plugin, run using the local `./bin/dev` or `./bin/dev.cmd` file.

```bash
# 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.

```bash
# Link your plugin to the sf cli
sf plugins link .
# To verify
sf plugins
```

## Commands

<!-- commands -->
* [`sf data bulk`](#sf-data-bulk)
* [`sf data caseCreationController`](#sf-data-casecreationcontroller)
* [`sf data compare`](#sf-data-compare)
* [`sf data export`](#sf-data-export)
* [`sf data gitDifferencePlugin`](#sf-data-gitdifferenceplugin)
* [`sf data restDeploy`](#sf-data-restdeploy)
* [`sf data restExport`](#sf-data-restexport)
* [`sf data restImport`](#sf-data-restimport)
* [`sf restDeploy`](#sf-restdeploy)

## `sf data bulk`

Export all fields from a specific object.

```
USAGE
  $ sf data bulk -o <value> -s <value> [--json] [--flags-dir <value>] [-t <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.
  -s, --object=<value>      (required) The API name of the object.
  -t, --output=<value>      [default: bulkExport.json] The file path to save the results.

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

EXAMPLES
  $ sf data bulk --object Account --target-org my-org

  $ sf data bulk --object Contact --target-org my-org
```

_See code: [src/commands/data/bulk.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/bulk.ts)_

## `sf data caseCreationController`

Calling a specific method of the Apex class present in the target org.

```
USAGE
  $ sf data caseCreationController -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.

EXAMPLES
  $ sf data export --soql "SELECT Name FROM Account" --target-org my-org

  $ sf data export --soql "SELECT Id, Status FROM Case" --output results.json
```

_See code: [src/commands/data/caseCreationController.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/caseCreationController.ts)_

## `sf data compare`

Compare fields of an object between two orgs.

```
USAGE
  $ sf data compare -s <value> -a <value> -b <value> [--json] [--flags-dir <value>]

FLAGS
  -a, --source-org=<value>  (required) The first org (Source)
  -b, --target-org=<value>  (required) The second org (Target)
  -s, --object=<value>      (required) The API name of the object.

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

EXAMPLES
  $ sf data compare --object Account --source-org "DevOrg" --target-org "ProdOrg"
```

_See code: [src/commands/data/compare.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/compare.ts)_

## `sf data export`

Export data from an org in JSON format.

```
USAGE
  $ sf data export -o <value> -q <value> [--json] [--flags-dir <value>] [-f <value>]

FLAGS
  -f, --output=<value>      [default: export.json] The file path to save the results.
  -o, --target-org=<value>  (required) Username or alias of the target org. Not required if the `target-org`
                            configuration variable is already set.
  -q, --soql=<value>        (required) The SOQL query to execute.

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

EXAMPLES
  $ sf data export --soql "SELECT Name FROM Account" --target-org my-org

  $ sf data export --soql "SELECT Id, Status FROM Case" --output results.json
```

_See code: [src/commands/data/export.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/export.ts)_

## `sf data gitDifferencePlugin`

Detects changed files using Git

```
USAGE
  $ sf data gitDifferencePlugin [--json] [--flags-dir <value>] [-b <value>]

FLAGS
  -b, --base-sha=<value>  [default: HEAD~1] The commit SHA to compare against

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

EXAMPLES
  $ sf data export --soql "SELECT Name FROM Account" --target-org my-org

  $ sf data export --soql "SELECT Id, Status FROM Case" --output results.json
```

_See code: [src/commands/data/gitDifferencePlugin.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/gitDifferencePlugin.ts)_

## `sf data restDeploy`

Deploy data to the Org B via Apex REST for Git versioning.

```
USAGE
  $ sf data restDeploy -o <value> -s validate|get-auth|authenticate|deploy [--json] [--flags-dir <value>] [-f
    <value>] [-l <value>] [-a <value>]

FLAGS
  -a, --auth-id=<value>     Authentication ID for the authenticate stage
  -f, --input-file=<value>  [default: ./data/restExport.json] The file path to be taken as an input for the import.
  -l, --log-file=<value>    [default: ./logs/error.log] Path to the error log file
  -o, --target-org=<value>  (required) The second org (Target)
  -s, --stage=<option>      (required) Stage of the import process
                            <options: validate|get-auth|authenticate|deploy>

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

EXAMPLES
  $ sf data restDeploy --target-org TargetOrg --input-file ./data/restExport.json --stage validate

  $ sf data restDeploy --target-org TargetOrg --stage get-auth

  $ sf data restDeploy --target-org TargetOrg --auth-id "a01BH00000XYZabc" --stage authenticate

  $ sf data restDeploy --target-org TargetOrg --input-file ./data/restExport.json --auth-id "a01BH00000XYZabc" --stage deploy
```

_See code: [src/commands/data/restDeploy.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/restDeploy.ts)_

## `sf data restExport`

Exports data from Org A via Apex REST for Git versioning.

```
USAGE
  $ sf data restExport [--json] [--flags-dir <value>] [-o <value>] [-f <value>] [-l <value>]

FLAGS
  -f, --output=<value>      [default: ./data/restExport.json] The file path to save the results.
  -l, --log-file=<value>    [default: ./logs/error.log] Path to the error log file
  -o, --target-org=<value>  The second org (Target)

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

EXAMPLES
  $ sf data restExport --target-org OrgA

  $ sf data restExport --target-org OrgA --output ./custom/path.json
```

_See code: [src/commands/data/restExport.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/restExport.ts)_

## `sf data restImport`

Import data to the Org B via Apex REST for Git versioning.

```
USAGE
  $ sf data restImport -o <value> [--json] [--flags-dir <value>] [-f <value>] [-l <value>]

FLAGS
  -f, --input-file=<value>  [default: ./data/restExport.json] The file path to be taken as an input for the import.
  -l, --log-file=<value>    [default: ./logs/error.log] Path to the error log file
  -o, --target-org=<value>  (required) The second org (Target)

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

EXAMPLES
  $ sf data restImport --target-org OrgB --input-file ./data/contact.json
```

_See code: [src/commands/data/restImport.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/data/restImport.ts)_

## `sf restDeploy`

Deploy data to the Org B via Apex REST for Git versioning.

```
USAGE
  $ sf restDeploy -o <value> -s validate|get-auth|authenticate|deploy [--json] [--flags-dir <value>] [-f
    <value>] [-l <value>] [-a <value>]

FLAGS
  -a, --auth-id=<value>     Authentication ID for the authenticate stage
  -f, --input-file=<value>  [default: ./data/restExport.json] The file path to be taken as an input for the import.
  -l, --log-file=<value>    [default: ./logs/error.log] Path to the error log file
  -o, --target-org=<value>  (required) The second org (Target)
  -s, --stage=<option>      (required) Stage of the import process
                            <options: validate|get-auth|authenticate|deploy>

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

EXAMPLES
  $ sf data restDeploy --target-org TargetOrg --input-file ./data/restExport.json --stage validate

  $ sf data restDeploy --target-org TargetOrg --stage get-auth

  $ sf data restDeploy --target-org TargetOrg --auth-id "a01BH00000XYZabc" --stage authenticate

  $ sf data restDeploy --target-org TargetOrg --input-file ./data/restExport.json --auth-id "a01BH00000XYZabc" --stage deploy
```

_See code: [src/commands/restDeploy.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/v1.0.12/src/commands/restDeploy.ts)_
<!-- commandsstop -->

- [`sf hello world`](#sf-hello-world)

## `sf hello world`

Say hello.

```
USAGE
  $ sf hello world [--json] [--flags-dir <value>] [-n <value>]

FLAGS
  -n, --name=<value>  [default: World] The name of the person you'd like to say hello to.

GLOBAL FLAGS
  --flags-dir=<value>  Import flag values from a directory.
  --json               Format output as json.

DESCRIPTION
  Say hello.

  Say hello either to the world or someone you know.

EXAMPLES
  Say hello to the world:

    $ sf hello world

  Say hello to someone you know:

    $ sf hello world --name Astro

FLAG DESCRIPTIONS
  -n, --name=<value>  The name of the person you'd like to say hello to.

    This person can be anyone in the world!
```

_See code: [src/commands/hello/world.ts](https://github.com/salesforcecli/plugin-sf-data-export/blob/1.1.76/src/commands/hello/world.ts)_

<!-- commandsstop -->