> For the complete documentation index, see [llms.txt](https://docs.currents.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.currents.dev/~/changes/TYKBeqcc7WyqjmgOzWzB/resources/reporters/currents-cmd.md).

# @currents/cmd

The package has CLI commands and tools for Currents platform

### Requirements

* Create an account at <https://app.currents.dev>
* Obtain the Project Id (see [Project Settings](/~/changes/TYKBeqcc7WyqjmgOzWzB/dashboard/projects/project-settings.md)) and the [Record Key](/~/changes/TYKBeqcc7WyqjmgOzWzB/guides/record-key.md)&#x20;

### Setup

```sh
npm install @currents/cmd --save-dev
```

### Usage

```sh
npx currents upload --project-id=xxx --key=yyy
```

`currents` will upload the results, as follows:

* use `process.env.CURRENTS_REPORT_DIR` or `--reportDir` to read the results previously generated by one of supported reporters, otherwise
* use the most recently created directory named `.currents-report-[timestamp]-[uuidv4()]` in the current working directory

{% hint style="info" %}
Get familiar with  [CI Build ID](/~/changes/TYKBeqcc7WyqjmgOzWzB/guides/ci-build-id.md) before using `currents` in CI.&#x20;

It is <mark style="color:yellow;">**important**</mark> to set the `CI Build ID` explicitly using `--ci-build-id` option, if you are using CI sharding or multiple CI machines to parallelize your tests.&#x20;

If not set explicitly, the `CI Build ID` will be set to a random value and it will affect your reporting.
{% endhint %}

### Example

```sh
# Generate jest results 
$ npx jest --reporters=@currents/jest --reporters=default
[currents]: Run started
[currents]: Report directory is set to - /Users/agoldis/immer/.currents-report-2024-07-16T20-33-12-555Z-478913e1-1916-499b-8d8d-c08043d50f3d
# ....
[currents]: [__tests__/base.js] - spec results written to file: /Users/agoldis/immer/.currents-report-2024-07-16T20-33-12-555Z-478913e1-1916-499b-8d8d-c08043d50f3d/instances/Aql-q2CM.json
[currents]: Run completed

# Upload the results to Currents
$ npx currents upload --key=XXX --project-id=C3lBM6
Currents config: {
  projectId: 'C3lBM6',
  recordKey: '*****',
  removeTitleTags: false,
  disableTitleTags: false,
  debug: false
}
Report directory: '.currents-report-2024-07-16T20-33-12-555Z-478913e1-1916-499b-8d8d-c08043d50f3d'
[root] Run created: 'https://app.currents.dev/run/8466c149d9bbf745'
Script execution finished
✨  Done in 17.96s.
```

### Configuration

All options apart from `--project-id` and `--key` are optional. Use `--help` flag to list the available options.

* `-k, --key`
  * The record key to record the results to Currents. Read more: [Record Key](/~/changes/TYKBeqcc7WyqjmgOzWzB/guides/record-key.md)
  * Environment variable: `CURRENTS_RECORD_KEY`
  * Type: `string`

* `-p, --project-id`
  * The id of the project for reporting
  * Environment variable: `CURRENTS_PROJECT_ID`
  * Type: `string`

* `--ci-build-id`
  * The id of the build to record the test run. Read more [CI Build ID](/~/changes/TYKBeqcc7WyqjmgOzWzB/guides/ci-build-id.md)
  * Environment variable: `CURRENTS_CI_BUILD_ID`
  * Type: `string`
  * Default value: `auto:[random-string]`

* `--report-dir`
  * Directory with the test results generated by one of currents reporters
  * Environment variable: `CURRENTS_REPORT_DIR`
  * Type: `string`
  * Default value: `.currents-report-[timestamp]-[uuidv4]`

* `-t, --tag`
  * Comma-separated tag(s) to attach to the recorded run
  * Environment variable: `CURRENTS_TAG`
  * Type: `string`

* `--disable-title-tags`
  * Disable extracting tags from test title, e.g. `Test name @smoke` would not be tagged with `smoke`
  * Environment variable: `CURRENTS_DISABLE_TITLE_TAGS`
  * Type: `boolean`
  * Default value: `false`

* `--remove-title-tags`
  * Remove tags from test names in Currents, e.g. `Test name @smoke` becomes `Test name` in the dashboard
  * Environment variable: `CURRENTS_REMOVE_TITLE_TAGS`
  * Type: `boolean`
  * Default value: `false`

* `--debug`
  * Enable debug logs
  * Environment variable: `DEBUG=currents*`
  * Type: `boolean`

### Troubleshooting

Run the CLI command with the `--debug` argument or prefix it with `DEBUG="currents*"` to obtain detailed information about the command execution process.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.currents.dev/~/changes/TYKBeqcc7WyqjmgOzWzB/resources/reporters/currents-cmd.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
