# @currents/cmd 中文文档

规范地址：https://npmcn.com/package/%40currents/cmd/

版本：3\.0\.0
npm 元数据更新时间：2026-11-05T06:11:31.710Z
中文译文更新时间：2026-11-11T05:03:40.630Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40currents/cmd
原文对照：https://npmcn.com/package/%40currents/cmd/?lang=original
项目主页：https://github.com/currents-dev/currents-reporter#readme
源码仓库：https://github.com/currents-dev/currents-reporter

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：245 kB，14 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.13
- 运行依赖：14 个
- 首次发布：2024-07-10T20:45:35.816Z
- 最新版本发布：2026-11-05T06:11:31.316Z
- 近 30 天下载量：249411（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：87（近 12 个月 17 个）

## 中文简介

当前 CLI 工具

## 安装

```sh
npm install @currents/cmd
```

也可以使用：`pnpm add @currents/cmd`、`yarn add @currents/cmd`、`bun add @currents/cmd`

## README

# @ 当前/ cmd

用于 CLI 工具 [当前](https://currents.dev/) - 用于调试、排除故障和分析CI测试的云平台.

## 安装

要求节点js 22.13 或以后.

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

在安装的项目之外 `@currents/cmd`运行 `npx --package @currents/cmd@2 currents`没有包裹, `npx currents` 运行一个名称无关的 npm 包 `currents`。 。 。 .

从 1. x 升级: 见 [将 @ currents/ cmd 升级为 2.0](https://docs.currents.dev/resources/reporters/currents-cmd/upgrade-to-v2)。 。 。 .

## 上传测试结果

-   用其中一种生成测试结果 [支持](https://docs.currents.dev/) 记者
-   上传结果

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

JUnit XML报告, `run upload` 先将其转换为当前格式,再上传。 把引号放在周围 `--input-file` 模式,以使 CLI 扩展它而不是外壳:

```sh
npx currents run upload --project-id=xxx --key=yyy --input-format junit --input-file "reports/*.xml" --framework postman
```

`--framework` 带 `cypress`, (中文(简体) ), `postman`, (中文(简体) ), `node`, (中文(简体) ), `vitest` 或者说 `wdio`。对于 Cypress 运行结果 `after:run`,使用时 `--input-format cypress-json --input-file results.json` 无 `--framework`:它上传了每一个尝试,截图和视频. 转换后的报告被保存到 `--output-dir`,或 `--report-dir`,或者在 `.currents`。您名下的文件夹必须是空的,或不存在.

熟悉一点 [CI 构建 ID QQ](https://docs.currents.dev/guides/ci-build-id) 在使用前 `currents` 在中央情报局。 没错 **重要事项** 设置 `CI Build ID` 明确使用 `--ci-build-id` 选项,如果您正在使用 CI 硬化或多台 CI 机器来平行测试。 如果没有明确规定 `CI Build ID` 将设置为随机值.

### 页:1

获取 `--project-id` 财务报告和审定财务报表 [键](https://docs.currents.dev/guides/record-key) 从 [https://app.currents.dev (英语)](https://app.currents.dev/) 确定项目,并将结果与贵组织联系起来.

`currents` 上传结果如下:

-   使用情况 `process.env.CURRENTS_REPORT_DIR` 或者说 `--report-dir` 读取先前由一名支助记者生成的结果,否则
-   使用最近创建的名为 `.currents/[timestamp]-[uuidv4()]` 在当前工作目录中

`currents run upload` 发送运行中每次测试的列表, Curres 用来显示被压缩运行的进展 。 它从 `fullTestSuite.json`,哪个 `@currents/jest` 写给报告,或根据结果建立报告。 硬汉只有自己的测试结果 所以没有 `fullTestSuite.json` 命令运行当前文件夹中安装的 Jest 以列出每个硬度的测试。 从项目文件夹中运行,并安装了Jest 29.5或后期. `@currents/cmd` 不安装 Jest。 在Detox项目中, Jest 运行加载测试文件 `node` 测试环境,所以Detox不会启动设备. 一个在加载时使用Detox的测试文件,从运行它时的硬体结果中获得它的测试,命令打印出警告.

对于 [解毒剂](https://wix.github.io/Detox/) 运行报告 `@currents/jest`, (中文(简体) ), `currents run upload` 并附上在匹配测试尝试中录入的 Detox 的视频、截图和日志, 添加 `detox.trace.json` 作为步骤,并上传 `detox.trace.json`之后运行 `detox test` 出道: Detox 此时只写完文件.

`currents run upload` 应用 [动作](https://docs.currents.dev/guides/currents-actions) (b) 在项目交付结果之前,将结果提交项目。 测试已经进行,所以每次尝试都保留其结果,错误和文物:

-   跳过动作标记测试为跳过
-   隔离动作标志着测试失败
-   标记动作将其标记添加到测试中

仪表板显示哪个动作改变了每个测试. 尚未适用带有正则或日期条件的行动。 命令在无法获取结果时,在没有动作的情况下上传结果.

与 `--fail-on-failures`,或 `CURRENTS_FAIL_ON_FAILURES=true`,命令在测试失败时上传结果后退出1个,并列出失败的测试. 被隔离或跳伞的试验不算数 让测试命令通过,并使用上传失败CI任务,因此隔离测试不会失败:

```sh
npx detox test || true
npx currents run upload --fail-on-failures
```

### 配置

请注意,除下列备选方案外,其他所有备选方案均不包括在内: `--project-id` 财务报告和审定财务报表 `--key` 是可选的.

| 财产 | 类型 | 说明 | 环境变量 | 默认 |
| --- | --- | --- | --- | --- |
| `-k, --key` | `string` | 记录结果到Curres的记录密钥. 更多信息: [https://currents.dev/readme/guides/record-key 页面存档备份,存于互联网档案馆](https://currents.dev/readme/guides/record-key) | `CURRENTS_RECORD_KEY` | \- 说吧 |
| `-p, --project-id` | `string` | 报告项目编号 | `CURRENTS_PROJECT_ID` | \- 说吧 |
| `--machine-id` | `string` | 运行测试的机器的独特标识符 。 如果不提供,将自动生成。 见: [https://currents.dev/readme/readme?q=机器仪](https://currents.dev/readme/readme?q=machineId) | `CURRENTS_MACHINE_ID` | `[random-string]` |
| `--report-dir` | `string` | 包含测试结果的文件夹 [支持](https://docs.currents.dev/) 记者 | `CURRENTS_REPORT_DIR` | `.currents/*` |
| `--ci-build-id` | `string` | 建筑的ID来记录测试运行. 更多信息: [https://currents.dev/readme/guides/ci-building-id 页面存档备份,存于互联网档案馆](https://currents.dev/readme/guides/ci-build-id) | `CURRENTS_CI_BUILD_ID` | `auto:[random-string]` |
| `--debug` | `boolean` | 启用调试日志 | `CURRENTS_DEBUG` | `false` |
| `-t, --tag` | `string` | 用于当前记录运行的逗号分隔标签 | `CURRENTS_TAG` | \- 说吧 |
| `--environment` | `string` | 标记运行的环境, 例如 . `staging` | `CURRENTS_ENVIRONMENT` | \- 说吧 |
| `--disable-title-tags` | `boolean` | 禁用测试标题中的提取标记, 例如 . `Test name @smoke` 将不标记为 `smoke` | `CURRENTS_DISABLE_TITLE_TAGS` | `false` |
| `--remove-title-tags` | `boolean` | 从当前测试名称中删除标记, 例如 . `Test name @smoke` 变成 `Test name` 在仪表板上 | `CURRENTS_REMOVE_TITLE_TAGS` | `false` |
| `--fail-on-failures` | `boolean` | 测试失败时上传后退出 1 。 被电流动作隔离或跳过试验不算数 | `CURRENTS_FAIL_ON_FAILURES` | `false` |

命令行上的选项胜过其环境变量 。 配置也可以通过运行 CLI 命令和 `--help` 参数.

## 附加文件到运行中

`currents run attach` 上传日志或截图等文件到 CI 已经记录的运行中. 它使用记录密钥,或者在没有设定记录密钥时使用有写入访问的API密钥:

```sh
npx currents run attach --key <record-key> --project-id <id> --ci-build-id <build-id> --machine-id shard-1 docker-logs.zip
npx currents run attach --key <record-key> --project-id <id> --ci-build-id <build-id> --spec tests/cart.spec.ts --test-title "adds an item" --attempt 0 screenshot.png
```

无 `--spec`,这些档案被附于整个运行。 对于选项,运行 `npx currents run attach --help`。 。 。 .

## 共享运行

`currents run share` 打印运行的公开链接,或一个 spec 文件或测试,以及和Markdown相同的内容的链接。 它使用一个有写入权限的 API 密钥 :

```sh
npx currents run share <run-id>
npx currents run share <run-id> --instance-id <instance-id> --test-id <test-id> --purpose fix
```

`--purpose report`默认, 进行每一个测试 与它的尝试和文档, 对于一个人. `--purpose fix` 以失败为背景, 用于修复测试。 对于选项,运行 `npx currents run share --help`。 。 。 .

## 取消运行

`currents run cancel` 取消运行中, 例如其 CI 任务被取消时 。 它使用记录密钥 :

```sh
npx currents run cancel --key <record-key> --project-id <id> --ci-build-id <build-id>
```

见 [工作流取消运行](https://docs.currents.dev/getting-started/ci-setup/github-actions/cancel-runs) gitHub 动作.

## 获取会话作为证据

`currents session` 抓取代理或浏览器会话,例如修复前后的错误。 每个命令使用记录密钥,或者在没有设定记录密钥时使用具有写入权限的API密钥. 在中央情报局,在哪里 `CURRENTS_RECORD_KEY` 已设定, 不需要其他条件; 在其它地方, 设置 API 密钥一次为 `CURRENTS_API_KEY`数字 :

```sh
export CURRENTS_API_KEY=<api-key>
npx currents session start --project-id <id> --title "Checkout fails on empty cart" --status failed
npx currents session attach before.png .playwright-mcp/traces
npx currents session share --expires-in-days 7
```

`session share` 打印会话页面的公开链接,并打印与Markdown相同的内容的链接。 对于选项,运行 `npx currents session --help`。 。 。 .

## 使用当前 API

-   以JSON格式获取关于Contents资源的信息. 见 [(原始内容存档于2013-10-12) (英语). REST API](https://docs.currents.dev/api) 医生.

i️ 命令要求 `--project-id` 财务报告和审定财务报表 [`--api-key`](https://docs.currents.dev/dashboard/administration/api-keys) 从 [当前](https://app.currents.dev/) 以认证请求并提供所需数据。 或者,你可以设置 `CURRENTS_PROJECT_ID` 财务报告和审定财务报表 `CURRENTS_API_KEY` 环境变量.

**支助行动:**

-   使用 [CI 构建 ID QQ](https://docs.currents.dev/guides/ci-build-id) 运行以下命令:
    
    ```sh
    npx currents run get --ci-build-id <ci-build-id> --output path/to/save/run.json
    ```
    
-   获取上次完成的运行数据,由 `--branch` 和(或) `--tag`,通过运行以下命令:
    
    ```sh
    npx currents run get --branch <branch> --tag <tag-1,tag-2,...tag-n>
    ```
    

更多示例和使用选项,运行 `npx currents run get --help`。 。 。 .

调用 REST API 的任何其他路由, 使用 `currents api` 与路径。 它读取 API 密钥来自 `--api-key` 或者说 `CURRENTS_API_KEY`数字 :

```sh
npx currents api /v1/runs/<run-id>
npx currents api /v1/runs/<run-id>/cancel -X PUT
```

对于选项,运行 `npx currents api --help`。 。 。 .

## 缓存测试文物

这个 `currents cache` 命令允许您从指定位置归档文件,并将其保存在流星存储中的ID下。 它还存储一个带有配置数据的元文件. 您可以手动提供ID, 或由 CI 任务的变量制成 。 当未发现 CI 任务时, ID 是随机的, 命令警告: 通过 `--id` 以保存和恢复同一缓存.

要缓存文件,请使用以下命令:

```sh
npx currents cache set --key <record-key> --id <id> --path <path-1,path-2,...path-n>
```

要下载文件,请使用以下命令:

```sh
npx currents cache get --key <record-key> --id <id>
```

更多示例和使用选项,运行 `npx currents cache --help`。 。 。 .

## 代理技能

软件包包括 `currents-cli` 代理技能,它告诉编码代理如何使用这种CLI.

```sh
# Print the skill
npx currents skill

# Add it to the project for Codex and Cursor, in .agents/skills/currents-cli
npx currents skill --install

# Add it for Claude Code
npx currents skill --install --dir .claude/skills
```

该技能也在这个存储器,在 `skills/currents-cli`数字 : `npx skills add https://github.com/currents-dev/currents-reporter --skill currents-cli`。 。 。 .

## 指南

`npx currents docs` 列出载有包件的航向,例如CI设置步骤. `npx currents docs <topic>` 打印一个为 Markdown 。 这些指南是在 [文档/](https://npmcn.com/package/%40currents/cmd/docs)。 。 。 .

## 解决问题

运行 CLI 命令 `--debug` 参数或前缀 `DEBUG="currents,currents:*"` 获取关于命令执行过程的详细信息。 密钥隐藏在调试输出中 .

文件全文见 [https://docs.currents.dev/resources/reporters/currents-cmd 互联网档案馆的存檔,存档日期2013-12-20](https://docs.currents.dev/resources/reporters/currents-cmd)。 。 。 .

## 常见问题

### @currents/cmd 是什么？

当前 CLI 工具

### 如何安装 @currents/cmd？

在项目目录运行 npm install @currents/cmd，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 currents、currents-cli，可以用 npx currents 直接运行。

### @currents/cmd 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @currents/cmd 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @currents/cmd 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.13。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @currents/cmd 可以商用吗？

@currents/cmd 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @currents/cmd 的下载量有多少？

根据 npm 官方下载统计，@currents/cmd 在 2026/10/11 – 2026/11/09 这 30 天内被下载 249,411 次，日均约 8,314 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @currents/cmd 还在维护吗？

最新版本 3\.0\.0 发布于 2026/11/05（6 天前）；至今共发布 87 个版本，其中过去 12 个月发布了 17 个；首次发布于 2024/07/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

