# @contentstack/cli-audit 中文文档

规范地址：https://npmcn.com/package/%40contentstack/cli-audit/

版本：2\.0\.2
npm 元数据更新时间：2026-10-06T14:56:25.424Z
中文译文更新时间：2026-11-10T16:42:13.413Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40contentstack/cli-audit
原文对照：https://npmcn.com/package/%40contentstack/cli-audit/?lang=original
项目主页：https://github.com/contentstack/cli
源码仓库：https://github.com/contentstack/cli-plugins

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

- 包体积（解压后）：497 kB，74 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.0\.0
- 运行依赖：9 个
- 首次发布：2023-10-13T09:46:08.408Z
- 最新版本发布：2026-10-06T14:56:24.998Z
- 近 30 天下载量：51088（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：77（近 12 个月 38 个）

## 中文简介

内容ack 审计插件

## 安装

```sh
npm install @contentstack/cli-audit
```

也可以使用：`pnpm add @contentstack/cli-audit`、`yarn add @contentstack/cli-audit`、`bun add @contentstack/cli-audit`

## README

# @contentstack/ cli- 审计

审计插件

## 如何安装此插件

```shell
$ csdx plugins:install @contentstack/cli-audit
```

## 如何使用此插件

```sh-session
$ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/2.0.2 linux-x64 node-v22.23.3
$ csdx --help [COMMAND]
USAGE
  $ csdx COMMAND
...
```

# 图标

-   [`csdx cm:stacks:audit`](https://npmcn.com/package/%40contentstack/cli-audit/#readme-csdx-cmstacksaudit)
-   [`csdx cm:stacks:audit:fix`](https://npmcn.com/package/%40contentstack/cli-audit/#readme-csdx-cmstacksauditfix)

## `csdx cm:stacks:audit`

执行审计并发现导出的内容tack数据中可能的错误

```
USAGE
  $ csdx cm:stacks:audit [-c <value>] [-d <value>] [--show-console-output] [--report-path <value>] [--modules
    content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules|composable-studio...]
    [--columns <value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output
    csv|json|yaml]

FLAGS
  --modules=<option>...  Provide the list of modules to be audited
                         <options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-ru
                         les|composable-studio>
  --report-path=<value>  Path to store the audit reports

COMMON FLAGS
  -c, --config=<value>       Path of the external config
  -d, --data-dir=<value>     Path where the data is stored
      --show-console-output  Display the audit and audit fix result for individual modules

TABLE FLAGS
  --columns=<value>  Specify columns to display, comma-separated.
  --csv              Output results in CSV format.
  --filter=<value>   Filter rows by a column value (e.g., name=foo).
  --no-header        Hide table headers in output.
  --no-truncate      Prevent truncation of long text in columns.
  --output=<option>  Specify output format: csv, json, or yaml.
                     <options: csv|json|yaml>
  --sort=<value>     Sort the table by a column. Use "-" for descending.

DESCRIPTION
  Perform audits and find possible errors in the exported Contentstack data

EXAMPLES
  $ csdx cm:stacks:audit

  $ csdx cm:stacks:audit --report-path=<path>

  $ csdx cm:stacks:audit --report-path=<path> --csv

  $ csdx cm:stacks:audit --report-path=<path> --filter="name=<filter-value>"

  $ csdx cm:stacks:audit --report-path=<path> --modules=content-types --filter="name="<filter-value>"
```

_参见代码 : [src/commands/cm/stacks/audit/index.ts (中文(简体) )](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-audit/src/commands/cm/stacks/audit/index.ts)_

## `csdx cm:stacks:audit:fix`

进行审核,并纠正导出的内容tack数据中可能出现的错误.

```
USAGE
  $ csdx cm:stacks:audit:fix [-c <value>] [-d <value>] [--show-console-output] [--report-path <value>] [--modules
    content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-rules|composable-studio...]
    [--copy-path <value> --copy-dir] [--fix-only
    reference|global_field|json:rte|json:extension|blocks|group|content_types...] [--columns <value>] [--sort <value>]
    [--filter <value>] [--csv] [--no-truncate] [--no-header] [--output csv|json|yaml]

FLAGS
  --copy-dir              Create backup from the original data.
  --copy-path=<value>     Provide the path to backup the copied data
  --fix-only=<option>...  Provide the list of fix options
                          <options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
  --modules=<option>...   Provide the list of modules to be audited
                          <options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets|field-r
                          ules|composable-studio>
  --report-path=<value>   Path to store the audit reports

COMMON FLAGS
  -c, --config=<value>       Path of the external config
  -d, --data-dir=<value>     Path where the data is stored
      --show-console-output  Display the audit and audit fix result for individual modules

TABLE FLAGS
  --columns=<value>  Specify columns to display, comma-separated.
  --csv              Output results in CSV format.
  --filter=<value>   Filter rows by a column value (e.g., name=foo).
  --no-header        Hide table headers in output.
  --no-truncate      Prevent truncation of long text in columns.
  --output=<option>  Specify output format: csv, json, or yaml.
                     <options: csv|json|yaml>
  --sort=<value>     Sort the table by a column. Use "-" for descending.

DESCRIPTION
  Perform audits and fix possible errors in the exported Contentstack data.

EXAMPLES
  $ csdx cm:stacks:audit:fix --copy-dir

  $ csdx cm:stacks:audit:fix --report-path=<path> --copy-dir

  $ csdx cm:stacks:audit:fix --report-path=<path> --copy-dir --csv

  $ csdx cm:stacks:audit:fix --fix-only=reference,global_field --copy-dir

  $ csdx cm:stacks:audit:fix --report-path=<path> --filter="name=<filter-value>"

  $ csdx cm:stacks:audit:fix --report-path=<path> --modules=content-types --filter="name="<filter-value>" --copy-dir --copy-path=<path>
```

_参见代码 : [src/commands/cm/stacks/ 审计/固定](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-audit/src/commands/cm/stacks/audit/fix.ts)_

## 常见问题

### @contentstack/cli-audit 是什么？

内容ack 审计插件

### 如何安装 @contentstack/cli-audit？

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

### @contentstack/cli-audit 支持 TypeScript 吗？

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

### @contentstack/cli-audit 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @contentstack/cli-audit 需要什么版本的 Node\.js？

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

### @contentstack/cli-audit 可以商用吗？

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

### @contentstack/cli-audit 的下载量有多少？

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

### @contentstack/cli-audit 还在维护吗？

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

