npm package: @slalom-salesforce/sf-pr-comments
Description: post review comments generated from salesforce scanner to repos like github bitbucket azure repo
Author: Fayas Mansoor @fayas-mansoor-slalom
Latest version: 0.2.8

**NOTE: This template for sf plugins is not yet official. Please consult with the Platform CLI team before using this template.**

# sf-pr-comments

[![NPM](https://img.shields.io/npm/v/@salesforce/sf-pr-comments.svg?label=@salesforce/sf-pr-comments)](https://www.npmjs.com/package/@salesforce/sf-pr-comments) [![Downloads/week](https://img.shields.io/npm/dw/@salesforce/sf-pr-comments.svg)](https://npmjs.org/package/@salesforce/sf-pr-comments) [![License](https://img.shields.io/badge/License-BSD%203--Clause-brightgreen.svg)](https://raw.githubusercontent.com/salesforcecli/sf-pr-comments/main/LICENSE.txt)

## 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.html)>). 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)

### Hooks

For cross clouds commands, e.g. `sf env list`, we utilize [oclif hooks](https://oclif.io/docs/hooks) to get the relevant information from installed plugins.

This plugin includes sample hooks in the [src/hooks directory](src/hooks). You'll just need to add the appropriate logic. You can also delete any of the hooks if they aren't required for your plugin.

# 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/sf-pr-comments@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/sf-pr-comments

# 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 azure postcomments`](#sf-azure-postcomments)
* [`sf bitbucket postcomments`](#sf-bitbucket-postcomments)
* [`sf github postcomments`](#sf-github-postcomments)

## `sf azure postcomments`

This helps post code review comments from a JSON file to azure repo pull request.

```
USAGE
  $ sf azure postcomments -t <value> -o <value> -p <value> -r <value> -i <value> -d <value> -F <value> -g <value>
    [--json]

FLAGS
  -F, --reviewresultjsonfile=<value>  (required) Path to file where code review results are stored in JSON format
  -d, --foldernamefordiff=<value>     (required) Name of the folder where diff files will be stored
  -g, --gitfoldername=<value>         (required) Path to base project folder where git is initialized
  -i, --azureprid=<value>             (required) Pull request id to post the comments to
  -o, --azureorguri=<value>           (required) Name of Azure Organization where the project resides
  -p, --azureprojectname=<value>      (required) Name of Azure Project where the repo resides
  -r, --azurereponame=<value>         (required) Name of Azure Repo where the PR is being raised
  -t, --authtoken=<value>             (required) Azure Devops personal access token used to authenicate to repo, ensure
                                      this token has write / post permission of repo

GLOBAL FLAGS
  --json  Format output as json.

EXAMPLES
  $ sfdx azure:postcomments --authtoken asdasczxccxc --azureorgname 'organization-name' --azureprojectname 'ProjectName' --azurereponame 'RepoName' --foldernamefordiff '/path/to/diff/folder/' --gitfoldername '/path/to/git/folder' --reviewresultjsonfile '/path/to/code/review/comment/output/in/json/from/sfdx/scanner/staticCodeAnalyzerResults.json' --azureprid 1
```

## `sf bitbucket postcomments`

This helps post code review comments from a JSON file to bitbucket pull request.

```
USAGE
  $ sf bitbucket postcomments -N <value> -t <value> -w <value> -r <value> -i <value> -d <value> -g <value> -F <value>
    [--json]

FLAGS
  -F, --reviewresultjsonfile=<value>  (required) Path to file where code review results are stored in JSON format
  -N, --username=<value>              (required) Bitbucket username used to authenicate to repo
  -d, --foldernamefordiff=<value>     (required) Path of the folder where diff files will be stored
  -g, --gitfoldername=<value>         (required) Path to base project folder where git is initialized
  -i, --bitbucketprid=<value>         (required) Pull request id to post the comments to
  -r, --bitbucketreposlug=<value>     (required) Name of Bitbucket repo slug where the PR is being raised
  -t, --authtoken=<value>             (required) Bitbucket personal access token used to authenicate to repo, ensure
                                      this token has write / post permission of repo
  -w, --bitbucketworkspace=<value>    (required) Name of Bitbucket workspace where the repo resides

GLOBAL FLAGS
  --json  Format output as json.

EXAMPLES
  $ sfdx bitbucket:postcomments --username 'ci_user' --authtoken 'mybitbucketpersonaltoken' --bitbucketworkspace 'slalom' --bitbucketreposlug 'sfdx_poc' --bitbucketprid 1 --foldernamefordiff './srcDiff' --reviewresultjsonfile './codereviewvoilations.json' --gitfoldername './'
```

## `sf github postcomments`

Summary of a command.

```
USAGE
  $ sf github postcomments [--json] [-n <value>]

FLAGS
  -n, --name=<value>  Description of a flag.

GLOBAL FLAGS
  --json  Format output as json.

DESCRIPTION
  Summary of a command.

  Description of a command.

EXAMPLES
  $ sf github postcomments
```
<!-- commandsstop -->