@contentstack/cli-bulk-operations

中文文档
2.1.1发布于 2026/10/06MITTypeScript近 30 天下载 3.4万

用于批量操作的内存 CLI 插件

中文使用文档
文档目录18 节
  1. 特征
  2. 使用量
  3. 图标
  4. csdx cm:stacks:bulk-assets
  5. csdx cm:stacks:bulk-entries
  6. csdx cm:stacks:bulk-taxonomies
  7. 所需资源
  8. 发展
  9. 设置
  10. 可用的脚本
  11. 测试
  12. 代码质量
  13. 线性
  14. 格式化
  15. 巨钩
  16. 排雷中心/发改委
  17. GitHub 动作工作流程
  18. 更改日志

真相来源: 插头 —— 说 packages/contentstack-bulk-operations从 cli-bulk-操作。命令迁移指南: BULK-操作-模拟.md。 。 。 .

@contentstack/cli-bulk-操作

用于执行您内容上的批量操作的内存 CLI 插件 .

特征

  • 在内容上执行批量操作
  • 为类型安全而使用类型脚本所建
  • 综合测试覆盖率
  • 用 ESLint 和 Pretier 执行代码质量
  • 自动计算机/光盘工作流程

使用量

$ npm install -g @contentstack/cli-bulk-operations
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-bulk-operations/2.1.1 linux-x64 node-v22.23.3
$ csdx --help [COMMAND]
USAGE
  $ csdx COMMAND
...

图标

csdx cm:stacks:bulk-assets

资产散装业务:发布/不发布/交叉发布(CMS)并删除/移动(CS资产). 从 JSON 文件删除/移动载入资产 UID { "uids": [...] }; 通过组织 --org-uid。 。 。 .

USAGE
  $ csdx cm:stacks:bulk-assets [-a <value>] [-k <value>] [--operation publish|unpublish|delete|move] [--source-alias
    <value>] [--publish-mode bulk|single] [--branch <value>] [-c <value>] [-y] [--retry-failed <value>] [--revert
    <value>] [--bulk-operation-file <value>] [--backup-dir <value> | --source-env <value> | --folder-uid <value> |
    --environments <value>... | --locales <value>...] [--dry-run] [--space-uid <value>] [--org-uid <value>] [--workspace
    <value>] [--asset-uids-file <value>] [--locale <value>] [--target-folder-uid <value>]

FLAGS
  -a, --alias=<value>                Uses the name of a saved Management Token to authenticate the command. The command
                                     can only access the branches allowed for that token. This option can be used as an
                                     alternative to` --stack-api-key.`
  -c, --config=<value>               (optional) Specifies the path to a JSON configuration file that defines the options
                                     for the command. Use this file instead of passing multiple CLI flags for a single
                                     run.
  -k, --stack-api-key=<value>        API key of the source stack. You must use either the --stack-api-key flag or the
                                     --alias flag.
  -y, --yes                          Skips interactive confirmation prompts and runs the command immediately using the
                                     provided options. Useful for automation and scripts.
      --asset-uids-file=<value>      Path to UTF-8 JSON file: exactly `{ "uids": ["uid1", "uid2"] }` (non-empty string
                                     array, no trimming; large lists: see docs for NODE_OPTIONS)
      --backup-dir=<value>           Path to the import backup directory. Each imported asset is published only to the
                                     environments and locales it was published to in the source stack (read from the
                                     backup publish details and asset UID mapping), with asset-scan gating applied.
                                     Intended for the post-import publish flow.
      --branch=<value>               [default: main] The name of the branch where you want to perform the bulk publish
                                     operation. If you don't mention the branch name, then by default the content from
                                     main branch will be published.
      --bulk-operation-file=<value>  [default: bulk-operation] (optional) Folder path to store operation logs. Creates
                                     separate files for success and failed operations. Default: bulk-operation
      --dry-run                      Preview the publish plan without making any API calls.
      --environments=<value>...      Specifies one or more environments where the entries or assets should be published.
                                     Separate multiple environments with spaces.
      --folder-uid=<value>           (optional) The UID of the Assets' folder from which the assets need to be
                                     published. The default value is cs_root.
      --locale=<value>               Locale code for bulk delete only (single locale per run). Not applicable for move —
                                     move always relocates all locale variants of an asset.
      --locales=<value>...           Specifies one or more locale codes for which the entries or assets should be
                                     published. Separate multiple locales with spaces.
      --operation=<option>           Operation to perform: `publish`/`unpublish` (CMS, requires stack API key or alias)
                                     or `delete`/`move` (CS Assets, requires OAuth/Token and --space-uid/--org-uid)
                                     <options: publish|unpublish|delete|move>
      --org-uid=<value>              Organization UID for CS Assets API (organization_uid header)
      --publish-mode=<option>        [default: bulk] Publish mode: bulk (uses Bulk Publish API) or single (individual
                                     API calls)
                                     <options: bulk|single>
      --retry-failed=<value>         (optional) Use this option to retry publishing the failed entries/assets from the
                                     logfile. Specify the name of the logfile that lists failed publish calls. If this
                                     option is used, it will override all other flags.
      --revert=<value>               (optional) Revert publish operations from a log folder. Specify the folder path
                                     containing success logs. Works similar to retry-failed.
      --source-alias=<value>         Alias name for source environment delivery token (required for cross-publish). Add
                                     delivery token using: csdx auth:tokens:add
      --source-env=<value>           Source environment for cross-publish
      --space-uid=<value>            CS Assets space UID
      --target-folder-uid=<value>    Destination CS Assets folder UID for bulk move. Use "root" to move assets to the
                                     root folder.
      --workspace=<value>            [default: main] CS Assets workspace query parameter (default: main)

DESCRIPTION
  Bulk operations for assets: publish/unpublish/cross-publish (CMS) and delete/move (CS Assets). Delete/move load asset
  UIDs from a JSON file `{ "uids": [...] }`; pass organization via `--org-uid`.

EXAMPLES
  $ csdx cm:stacks:bulk-assets --operation publish --environments dev,staging --locales en-us -k blt123

  $ csdx cm:stacks:bulk-assets --operation unpublish --environments prod --locales en-us -a myAlias

  $ csdx cm:stacks:bulk-assets --operation publish --folder-uid cs_root --environments prod --locales en-us -k blt123

  $ csdx cm:stacks:bulk-assets --operation publish --environments prod --locales en-us --publish-mode bulk -k blt123

  $ csdx cm:stacks:bulk-assets --operation publish --source-env production --source-alias prod-delivery --environments staging,dev --locales en-us -a myAlias

  $ csdx cm:stacks:bulk-assets --retry-failed ./bulk-operation -a myAlias

  $ csdx cm:stacks:bulk-assets --revert ./bulk-operation -a myAlias

  $ csdx cm:stacks:bulk-assets --backup-dir ./content --operation publish -k blt123

  $ csdx cm:stacks:bulk-assets --operation delete --space-uid am123 --org-uid bltOrg --locale en-us --asset-uids-file ./assets.json

  $ csdx cm:stacks:bulk-assets --operation move --space-uid am123 --org-uid bltOrg --target-folder-uid amFolder --asset-uids-file ./assets.json

参见代码 : src/commands/cm/stacks/bulk-assets.ts (中文(简体) )

csdx cm:stacks:bulk-entries

条目批量操作( publish/ unpublish/ cross- pullish)

USAGE
  $ csdx cm:stacks:bulk-entries [-a <value>] [-k <value>] [--operation publish|unpublish] [--environments <value>...]
    [--locales <value>...] [--source-env <value>] [--source-alias <value>] [--publish-mode bulk|single] [--branch
    <value>] [-c <value>] [-y] [--retry-failed <value>] [--revert <value>] [--bulk-operation-file <value>]
    [--content-types <value>...] [--filter draft|modified|non-localized|unpublished] [--include-variants]

FLAGS
  -a, --alias=<value>                Uses the name of a saved Management Token to authenticate the command. The command
                                     can only access the branches allowed for that token. This option can be used as an
                                     alternative to` --stack-api-key.`
  -c, --config=<value>               (optional) Specifies the path to a JSON configuration file that defines the options
                                     for the command. Use this file instead of passing multiple CLI flags for a single
                                     run.
  -k, --stack-api-key=<value>        API key of the source stack. You must use either the --stack-api-key flag or the
                                     --alias flag.
  -y, --yes                          Skips interactive confirmation prompts and runs the command immediately using the
                                     provided options. Useful for automation and scripts.
      --branch=<value>               [default: main] The name of the branch where you want to perform the bulk publish
                                     operation. If you don't mention the branch name, then by default the content from
                                     main branch will be published.
      --bulk-operation-file=<value>  [default: bulk-operation] (optional) Folder path to store operation logs. Creates
                                     separate files for success and failed operations. Default: bulk-operation
      --content-types=<value>...     Content type UIDs to perform operation on. If not provided, operates on all content
                                     types.
      --environments=<value>...      Specifies one or more environments where the entries or assets should be published.
                                     Separate multiple environments with spaces.
      --filter=<option>              Filter entries by status
                                     <options: draft|modified|non-localized|unpublished>
      --include-variants             Includes entry variants (alternate versions of a base entry) in the bulk operation.
                                     By default, only base entries are processed.
      --locales=<value>...           Specifies one or more locale codes for which the entries or assets should be
                                     published. Separate multiple locales with spaces.
      --operation=<option>           Specifies whether to `publish` or `unpublish` content.
                                     <options: publish|unpublish>
      --publish-mode=<option>        [default: bulk] Publish mode: bulk (uses Bulk Publish API) or single (individual
                                     API calls)
                                     <options: bulk|single>
      --retry-failed=<value>         (optional) Use this option to retry publishing the failed entries/assets from the
                                     logfile. Specify the name of the logfile that lists failed publish calls. If this
                                     option is used, it will override all other flags.
      --revert=<value>               (optional) Revert publish operations from a log folder. Specify the folder path
                                     containing success logs. Works similar to retry-failed.
      --source-alias=<value>         Alias name for source environment delivery token (required for cross-publish). Add
                                     delivery token using: csdx auth:tokens:add
      --source-env=<value>           Source environment for cross-publish

DESCRIPTION
  Bulk operations for entries (publish/unpublish/cross-publish)

EXAMPLES
  $ csdx cm:stacks:bulk-entries --operation publish --environments dev --locales en-us -k blt123

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog,article --environments dev --locales en-us -k blt123

  $ csdx cm:stacks:bulk-entries --operation unpublish --content-types blog --environments prod --locales en-us -a myAlias

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --source-env production --source-alias prod-delivery --environments staging --locales en-us -a myAlias

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --environments prod --locales en-us --publish-mode bulk -k blt123

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --environments prod --locales en-us --filter modified -k blt123

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --environments prod --locales en-us --filter draft -k blt123

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --environments prod --locales en-us --filter unpublished -k blt123

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --environments prod --filter non-localized -k blt123

  $ csdx cm:stacks:bulk-entries --operation publish --content-types blog --environments prod --locales en-us --include-variants -k blt123

  $ csdx cm:stacks:bulk-entries --retry-failed ./bulk-operation

  $ csdx cm:stacks:bulk-entries --revert ./bulk-operation

参见代码 : src/commands/cm/stacks/bulk-entrys.ts (中文(简体) )

csdx cm:stacks:bulk-taxonomies

向环境和地方发布分类(CMA POST/v3/taxonomies/publish;启动出版工作)

USAGE
  $ csdx cm:stacks:bulk-taxonomies [-a <value>] [-k <value>] [--operation publish|unpublish] [--environments <value>...]
    [--locales <value>...] [--source-env <value>] [--source-alias <value>] [--publish-mode bulk|single] [--branch
    <value>] [-c <value>] [-y] [--retry-failed <value>] [--revert <value>] [--bulk-operation-file <value>] [--taxonomies
    <value>]

FLAGS
  -a, --alias=<value>                Uses the name of a saved Management Token to authenticate the command. The command
                                     can only access the branches allowed for that token. This option can be used as an
                                     alternative to` --stack-api-key.`
  -c, --config=<value>               (optional) Specifies the path to a JSON configuration file that defines the options
                                     for the command. Use this file instead of passing multiple CLI flags for a single
                                     run.
  -k, --stack-api-key=<value>        API key of the source stack. You must use either the --stack-api-key flag or the
                                     --alias flag.
  -y, --yes                          Skips interactive confirmation prompts and runs the command immediately using the
                                     provided options. Useful for automation and scripts.
      --branch=<value>               [default: main] The name of the branch where you want to perform the bulk publish
                                     operation. If you don't mention the branch name, then by default the content from
                                     main branch will be published.
      --bulk-operation-file=<value>  [default: bulk-operation] (optional) Folder path to store operation logs. Creates
                                     separate files for success and failed operations. Default: bulk-operation
      --environments=<value>...      Specifies one or more environments where the entries or assets should be published.
                                     Separate multiple environments with spaces.
      --locales=<value>...           Specifies one or more locale codes for which the entries or assets should be
                                     published. Separate multiple locales with spaces.
      --operation=<option>           Specifies whether to `publish` or `unpublish` content.
                                     <options: publish|unpublish>
      --publish-mode=<option>        [default: bulk] Publish mode: bulk (uses Bulk Publish API) or single (individual
                                     API calls)
                                     <options: bulk|single>
      --retry-failed=<value>         (optional) Use this option to retry publishing the failed entries/assets from the
                                     logfile. Specify the name of the logfile that lists failed publish calls. If this
                                     option is used, it will override all other flags.
      --revert=<value>               (optional) Revert publish operations from a log folder. Specify the folder path
                                     containing success logs. Works similar to retry-failed.
      --source-alias=<value>         Alias name for source environment delivery token (required for cross-publish). Add
                                     delivery token using: csdx auth:tokens:add
      --source-env=<value>           Source environment for cross-publish
      --taxonomies=<value>           Comma-separated taxonomy UIDs to include in the job. If omitted, all taxonomies in
                                     the stack (current branch) are included. Example: products_tax,brands_tax

DESCRIPTION
  Publish taxonomies to environments and locales (CMA POST /v3/taxonomies/publish; initiates a publish job)

EXAMPLES
  $ csdx cm:stacks:bulk-taxonomies --operation publish --environments dev,staging --locales en-us --taxonomies products_tax,brands_tax -k blt123

  $ csdx cm:stacks:bulk-taxonomies --operation publish --environments development --locales en-us,hi-in -k blt123

  $ csdx cm:stacks:bulk-taxonomies --operation unpublish --environments prod --locales en-us --taxonomies my_taxonomy -a myAlias

  $ csdx cm:stacks:bulk-taxonomies --operation publish --environments staging --locales en-us,fr-fr --taxonomies taxonomy_a -a myAlias

  $ csdx cm:stacks:bulk-taxonomies --operation publish --branch feature --environments development --locales en-us --taxonomies brands_tax -k blt123

参见代码 : src/com/stacks/bulk-taxonomies.ts (中文(简体) )

所需资源

  • 节点.js 22
  • 有 API 证书的链接账户

发展

设置

# Clone the repository
git clone https://github.com/contentstack/cli-plugins.git
cd cli-plugins/packages/contentstack-bulk-operations

# Install dependencies
npm install

# Build the project
npm run build

可用的脚本

  • npm run build - 构建 TypeScript 项目
  • npm run lint - 运行ESLint检查
  • npm run lint:fix - 自动解决ESLint问题
  • npm run format - 有Pretier格式代码
  • npm run format:check - 检查代码格式
  • npm test - 运行测试
  • npm run test:coverage - 进行覆盖测试
  • npm run clean - 清洁建筑文物

测试

该项目利用Mocha进行全面覆盖报告测试.

# Run all tests
npm test

# Run tests with coverage
npm run test:coverage

# Run tests with detailed coverage report
npm run test:coverage:report

代码质量

线性

该项目使用带有TypeScript特定规则的ESLint:

npm run lint

格式化

代码格式化由 Pretier 处理 :

npm run format

巨钩

Husky被配置为先检查后再执行和推:

  • 承诺前: 运行已分级检查和格式化已分级的文件
  • 预推: 运行和测试以确保代码质量

排雷中心/发改委

GitHub 动作工作流程

  1. 公关检查 (单位:千美元)pr-checks.yml: 按拉出请求运行

    • 林特检查
    • 测试覆盖的执行
    • 构建验证
  2. 测试 (单位:千美元)test.yml: 推和公关运行

    • 跨越多节点.js版本的测试(18,20,22)
    • 向Codecov报告覆盖范围
  3. 释放 (单位:千美元)release.yml: 主分支运行

    • 自动 npm 出版
    • GitHub 发布创建
    • 语义版本

更改日志

见 变动情况 为释放历史.

版本与发布记录

@contentstack/cli-bulk-operations 共发布 20 个版本,首次发布于 2026/01/29;过去 12 个月发布了 20 个版本。

版本发布日期距今
2.1.1latest2026/10/061 个月前
1.2.6v1-x2026/10/061 个月前
2.1.02026/09/151 个月前
1.2.52026/08/132 个月前
2.0.02026/08/122 个月前
1.2.42026/08/053 个月前

其他发布通道:beta → 2.0.0-beta.5,v1-x → 1.2.6。

关于 @contentstack/cli-bulk-operations 的常见问题

@contentstack/cli-bulk-operations 是什么?

用于批量操作的内存 CLI 插件

如何安装 @contentstack/cli-bulk-operations?

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

@contentstack/cli-bulk-operations 支持 TypeScript 吗?

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

@contentstack/cli-bulk-operations 需要什么版本的 Node.js?

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

@contentstack/cli-bulk-operations 可以商用吗?

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

@contentstack/cli-bulk-operations 的下载量有多少?

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

@contentstack/cli-bulk-operations 还在维护吗?

最新版本 2.1.1 发布于 2026/10/06(1 个月前);至今共发布 20 个版本,其中过去 12 个月发布了 20 个;首次发布于 2026/01/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。