npm package: @pieriandx/case-report
Description: Generates a CGW case report in PDF format
Author: David Atchley,
Latest version: 1.0.1

# case-report - create PDF, HTML reports from CGW JSON output

## Feature

- Takes the CGW JSON output file via standard input or specifying the file on the command line
- Can output both PDF and HTML version of the generated report
- When outputing the HTML version, all assets copied along with the html file
- Can create a copy of the default HTML and web assets to create customized versions of the report
- Let's you specify which templates and assets to use on the command line to override the defaults

## Getting Started

You can install with both `npm` and `yarn`.

```
npm install -g @pierian/case-report
```

```
yarn global add @pierian/case-report
```

## Usage

`case-report` is built to work with the CGW application prepared for use on appliance sequencers, like Illumina. The command
can be part of a pipe-line, taking the standard CGW JSON output via standard input to generate the report.

```
$ cgw | case-report
```

### Commands and Options

There are two commands available to use with `case-report`. You can always type `case-report --help` to see the
available commands, and `case-report [command] --help` to see specific options available for each command.

```
Usage: case-report [command] [options]

Commands:
  copy [options]    copy the default templates/assets for customization
  create [options]  generate PDF case report output                 [aliases: c]

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]
```

_create_ - this is the default command, and will run by default if no command is given on the command line
_copy_ - this is used to create a local copy of the html templates and web related assets to create custom reports

#### create

The `create` command has the following command specific options.

```
case-report create [options]

generate PDF case report output

Options:
  --input, -i      path to CGW JSON data input file to process [defaults to
                   stdin]                                               [string]
  --output-path    path to folder to write output files
                                                      [string] [default: "/tmp"]
  --output-prefix  prefix to prepend to all generated output files
                                                          [string] [default: ""]
  --pdf            output PDF format report            [boolean] [default: true]
  --html           output HTML format report (folder, files and assets)
                                                      [boolean] [default: false]
  --template-path  path to custom HTML report template(s)               [string]
```

#### copy

The `copy` command will copy the HTML templates and default assets to the current working
directory (ie, `./`, the directory you run the command from). It has the following command
specific options.

```
case-report copy [options]

copy the default templates/assets for customization

Options:
  --version    Show version number                                     [boolean]
  --help       Show help                                               [boolean]
  --templates  copy the template html files            [boolean] [default: true]
  --assets     copy the default assets (css, images, fonts)
                                                       [boolean] [default: true]
```

## Configuring

`case-report` can be configure via command line options or through a `.casereportrc` file. The
`.casereportrc` file is a JSON configuration file. The command will look for this file in the current
working directory and then traverse up the directory path until it finds one.

If it doesn't find it while traversing it will then look to see if you've configured a path to the
configuration file in the `CASE_REPORT_CFG` environment variable. Barring that not being defined, it
will lastly look in your current user's home directory (`~/`).

All command line options are settable in the `.casereportrc` configuration file. Here's an example
configuration file.

```
{
  "input": "./test/cgw-output.json",
  "template-path": "./data",
  "assets-path": "./data/assets",
  "output-path": "./output",
  "output-prefix": "pierian-"
}
```