> 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/resources/reporters/currents-cmd/upgrade-to-v2.md).

# Upgrade to 2.0

Upgrade @currents/cmd from 1.x to 2.0: the breaking changes and the commands to change in scripts and CI jobs

`@currents/cmd` 2.0.0 groups the commands by resource: `currents upload` is `currents run upload`, `currents cancel` is `currents run cancel`, and `currents api get-run` is `currents run get`. This page lists the breaking changes and what to change in scripts and CI jobs. The full list is in the [changelog](https://github.com/currents-dev/currents-reporter/blob/main/packages/cmd/CHANGELOG.md).

## Steps

{% stepper %}
{% step %}

### Use Node.js 20 or later

`@currents/cmd` 2.0.0 requires Node.js 20 or later. In GitHub Actions, set `node-version` in `actions/setup-node` to `20` or later.
{% endstep %}

{% step %}

### Install 2.0.0

```bash
npm install @currents/cmd@2 --save-dev
```

{% endstep %}

{% step %}

### Install Jest where you upload sharded Jest results

`@currents/cmd` 2.0.1 and later do not install Jest. To upload the results of a sharded `@currents/jest` run (`--shard`), `currents run upload` runs the Jest installed in the current folder to list every test of the suite: one shard's results do not hold the tests of the other shards.

Run the upload of a shard in a folder where Jest 29.5 or later is installed, usually the project folder after `npm ci`. Without it, the upload fails:

```
Jest discovery needs the "jest" package, and it is not installed in /home/runner/work/app. Run the command from the folder of the project that ran the tests, or install Jest 29.5 or later: npm install --save-dev jest
```

Other uploads do not need Jest with `@currents/cmd` 2.0.2 or later. A run that is not sharded, also one filtered with `-t` or a test path, or stopped by `--bail`, takes the list of tests from its results. The upload of a Detox shard runs Jest without booting a device. With 2.0.1, filtered runs also need Jest in the current folder.
{% endstep %}

{% step %}

### Rename the commands

| 1.x                                                  | 2.0                                                                                                                                    |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `currents --key ...` (no command)                    | `currents run upload --key ...`                                                                                                        |
| `currents upload`                                    | `currents run upload`                                                                                                                  |
| `currents convert ...` followed by `currents upload` | `currents run upload --input-format junit ...`. See [Upload JUnit XML reports](/resources/reporters/currents-cmd/currents-convert.md). |
| `currents cancel`                                    | `currents run cancel`                                                                                                                  |
| `currents api get-run`                               | `currents run get`                                                                                                                     |

The renamed commands take the same options, environment variables and exit codes.

`currents upload`, `currents convert` and `currents api get-run` still work in 2.0 but are not listed in the help. `currents cancel` still works and prints a deprecation warning. It will be removed in the next major version.
{% endstep %}

{% step %}

### Check the options you also set as environment variables

A command-line option wins over its environment variable. In 1.x, the environment variable won. When both are set to different values, the command prints a warning:

```
WARNING  --project-id and CURRENTS_PROJECT_ID are set to different values; using --project-id
```

Remove the option or the variable you do not want the command to use.
{% endstep %}

{% step %}

### Convert reports into an empty folder

`currents run upload --input-format` and `currents convert` fail when `--output-dir` or `--report-dir` names a folder that holds other files:

```
ERROR  The folder "out" is not empty. Reports already in it would be uploaded with the converted ones. Remove the folder, or leave out --output-dir to convert into a new folder in .currents.
```

In 1.x, the reports already in the folder were uploaded with the converted ones. Leave out `--output-dir` and `--report-dir` to convert into a new folder in `.currents`, or name a folder that is empty or does not exist.
{% endstep %}
{% endstepper %}

## What changes without a breaking error

* `currents` without a command prints the help and exits with `1`. In 1.x, it ran `upload`. With upload options or their environment variables set, it prints `upload is no longer the default command. Run 'currents run upload ...' instead.`
* [`currents api`](/resources/reporters/currents-cmd/currents-api.md) takes a REST API route and sends a request to it, such as `currents api /v1/runs/<run-id>`.
* The commit and branch come from [`@currents/commit-info`](https://www.npmjs.com/package/@currents/commit-info) 2.0.0. When git cannot read the repository, for example in a container that runs as another user, they come from the CI provider's variables. The repository URL is stored without the user name and password it can hold on CI, such as the job token in GitLab's `CI_REPOSITORY_URL`.
* `currents cache set` and `cache get` without `--id` make the cache ID from the CI job on every CI provider they detect, not only GitHub Actions and GitLab CI. When they detect no CI job, they warn that the ID is random. See [currents cache](/resources/reporters/currents-cmd/currents-cache.md).
* `--debug` output replaces keys with `*****`.

## New commands

* [`currents run attach`](/resources/reporters/currents-cmd/currents-run-attach.md): upload files, such as logs, to a run recorded in CI
* [`currents session`](/resources/reporters/currents-cmd/currents-session.md): capture an agent or browser session as evidence, attach screenshots and traces, and share a link
* [`currents skill`](/resources/reporters/currents-cmd/currents-skill.md): install the agent skill that tells coding agents how to use the CLI


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.currents.dev/resources/reporters/currents-cmd/upgrade-to-v2.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
