# @contentstack/cli-migration 中文文档

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

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

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

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

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

- 包体积（解压后）：322 kB，139 个文件
- TypeScript 类型：未声明
- Node.js 要求：\>=22\.0\.0
- 运行依赖：13 个
- 首次发布：2022-02-25T10:12:24.289Z
- 最新版本发布：2026-10-06T14:52:16.820Z
- 近 30 天下载量：44163（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：88（近 12 个月 37 个）

## 中文简介

内容tack CLI的"迁移"插件允许开发者实现内容迁移过程的自动化,并方便地将您的内容从您的系统迁移到内容tack.

## 安装

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

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

## README

# @contentstack/cli-migration (英语)

内容tack CLI的"迁移"插件允许开发者实现内容迁移过程的自动化,并方便地将您的内容从您的系统迁移到内容tack.

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io/) [![Version](https://img.shields.io/npm/v/@contentstack/cli-migration.svg)](https://npmjs.org/package/@contentstack/cli-migration) [![Downloads/week](https://img.shields.io/npm/dw/@contentstack/cli-migration.svg)](https://npmjs.org/package/@contentstack/cli-migration) [![License](https://img.shields.io/npm/l/@contentstack/cli-migration.svg)](https://github.com/contentstack/cli-plugins/blob/main/LICENSE)

-   [@contentstack/cli-migration (英语)](https://npmcn.com/package/%40contentstack/cli-migration/#readme-contentstackcli-migration)
-   [使用量](https://npmcn.com/package/%40contentstack/cli-migration/#readme-usage)
-   [图标](https://npmcn.com/package/%40contentstack/cli-migration/#readme-commands)

# 使用量

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

# 图标

-   [`csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [-c <value>] [--inline-config <value>] [--multiple]`](https://npmcn.com/package/%40contentstack/cli-migration/#readme-csdx-cmstacksmigration--k-value--a-value---file-path-value---branch-value--c-value---inline-config-value---multiple)

## `csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [-c <value>] [--inline-config <value>] [--multiple]`

内容tack 迁移脚本.

```
USAGE
  $ csdx cm:stacks:migration [-k <value>] [-a <value>] [--file-path <value>] [--branch <value>] [-c <value>]
    [--inline-config <value>] [--multiple]

FLAGS
  -a, --alias=<value>             Use this flag to add the management token alias. You must use either the --alias flag
                                  or the --stack-api-key flag.
  -c, --config=<value>            [optional] Path of the JSON configuration file.
  -k, --stack-api-key=<value>     Use this flag to add the API key of your stack. You must use either the
                                  --stack-api-key flag or the --alias flag.
      --branch=<value>            Use this flag to add the branch name where you want to perform the migration. (target
                                  branch name)
      --file-path=<value>         Use this flag to provide the path of the file of the migration script.
      --inline-config=<value>...  [optional] Inline configuration, <key1>:<value1>. Passing an external configuration
                                  makes the script re-usable.
      --multiple                  This flag helps you to migrate multiple content files in a single instance. Mention
                                  the folder path where your migration script files are stored.

DESCRIPTION
  Contentstack migration script.

EXAMPLES
  $ csdx cm:stacks:migration --file-path <migration/script/file/path> -k <api-key>

  $ csdx cm:stacks:migration --file-path <migration/script/file/path> -k <api-key> --branch <target branch name>

  $ csdx cm:migration --inline-config <key1>:<value1> <key2>:<value2> ... --file-path <migration/script/file/path>

  $ csdx cm:migration --config <path/to/json/config/file> --file-path <migration/script/file/path>

  $ csdx cm:stacks:migration --multiple --file-path <migration/scripts/dir/path> 

  $ csdx cm:stacks:migration --alias <management-token-alias> --file-path <migration/script/file/path>
```

_参见代码 : [src/commands/cm/stacks/migration.ts 互联网档案馆的存檔,存档日期2013-12-02](https://github.com/contentstack/cli-plugins/blob/main/packages/contentstack-migration/src/commands/cm/stacks/migration.ts)_

### 要记住的点

-   目前,您可以将自定义的策略传递到创建的 Field 方法来迁移组字段 .
-   您可以通过创建 SDK 实例来迁移全局字段, 并使用创建字段方法将其添加到内容类型中 .
-   目前,您可以通过创建 SDK 实例来迁移条目,为您的内容类型创建/更新/删除条目 .

## 常见问题

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

内容tack CLI的"迁移"插件允许开发者实现内容迁移过程的自动化,并方便地将您的内容从您的系统迁移到内容tack\.

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

在项目目录运行 npm install @contentstack/cli-migration，或使用 pnpm add / yarn add / bun add。

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

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/contentstack\_\_cli-migration 是否存在。

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

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

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

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

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

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

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

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

