# @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 中文文档

规范地址：https://npmcn.com/package/%40amazon-web-services-cloudformation/cloudformation-cli-typescript-lib/

版本：1\.0\.6
npm 元数据更新时间：2025-05-22T20:56:33.288Z
中文译文更新时间：2026-11-05T23:57:54.807Z
软件包许可：Apache License 2\.0

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

原始 npm 页面：https://www.npmjs.com/package/%40amazon-web-services-cloudformation/cloudformation-cli-typescript-lib
原文对照：https://npmcn.com/package/%40amazon-web-services-cloudformation/cloudformation-cli-typescript-lib/?lang=original
项目主页：https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin#readme
源码仓库：https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin

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

- 包体积（解压后）：119 kB，21 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=20\.0\.0
- 运行依赖：6 个
- peer 依赖：aws-sdk ^2\.712\.0
- 首次发布：2021-04-08T22:04:03.237Z
- 最新版本发布：2024-07-19T00:36:16.204Z
- 近 30 天下载量：10925（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：7（近 12 个月 0 个）

## 中文简介

CloudFormation 资源提供方开发 Kit(RPDK) 允许您撰写您自己的资源提供方, 供 CloudFormation 使用 。 此插件库有助于通过 CloudFormation 为您的提供者的执行提供运行时间绑定 .

## 安装

```sh
npm install @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib
```

也可以使用：`pnpm add @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib`、`yarn add @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib`、`bun add @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib`

## README

# AWS 云格式资源提供者打字插件

我们兴奋地分享我们的进步,在"云阵CLI"中加入新的语言!

## AWS 云格式资源提供者类型脚本插件

[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/aws-cloudformation/cloudformation-cli-typescript-plugin/ci/master)](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin/actions?query=branch%3Amaster+workflow%3Aci) [![Codecov](https://img.shields.io/codecov/c/gh/aws-cloudformation/cloudformation-cli-typescript-plugin)](https://codecov.io/gh/aws-cloudformation/cloudformation-cli-typescript-plugin) [![PyPI version](https://img.shields.io/pypi/v/cloudformation-cli-typescript-plugin)](https://pypi.org/project/cloudformation-cli-typescript-plugin) [![NPM version](https://img.shields.io/npm/v/@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib)](https://www.npmjs.com/package/@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib) [![Node.js version](https://img.shields.io/badge/dynamic/json?color=brightgreen&url=https://raw.githubusercontent.com/aws-cloudformation/cloudformation-cli-typescript-plugin/master/package.json&query=$.engines.node&label=nodejs)](https://nodejs.org/)

CloudFormation CLI (cfn) 允许您编写自己的可供 CloudFormation 使用的资源提供者 .

此插件库帮助提供 TypeScript 运行时间绑定, 通过 CloudFormation 执行您的提供者 .

## 使用量

如果您正在使用此软件包为 CloudFormation 构建资源提供者, 请安装 [云格式 CLI 类型脚本插件](https://github.com/aws-cloudformation/cloudformation-cli-typescript-plugin) - 这将自动安装 [云阵 CLI](https://github.com/aws-cloudformation/cloudformation-cli)推荐 Python 虚拟环境 .

**先决条件**

-   Python 版本 3.6 或以上
-   [萨姆CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
-   您选择类型脚本 IDE

**安装**

```shell
pip3 install cloudformation-cli-typescript-plugin
```

参见 [云格式 CLI 用户指南](https://docs.aws.amazon.com/cloudformation-cli/latest/userguide/resource-types.html) 联 合 国 [云阵 CLI](https://github.com/aws-cloudformation/cloudformation-cli) 用于使用指令.

**怎么样**

示例运行 :

```
$ cfn init
Initializing new project
What's the name of your resource type?
(Organization::Service::Resource)
>> Foo::Bar::Baz
Select a language for code generation:
[1] java
[2] typescript
(enter an integer):
>> 2
Use docker for platform-independent packaging (Y/n)?
This is highly recommended unless you are experienced
with cross-platform Typescript packaging.
>> y
Initialized a new project in <>
$ cfn submit --dry-run
$ sam local invoke --event sam-tests/create.json TestEntrypoint
```

## 发展

对于插件的修改,推荐一个Python虚拟环境. 检查并安装可编辑模式的插件 :

```shell
python3 -m venv env
source env/bin/activate
pip3 install -e /path/to/cloudformation-cli-typescript-plugin
```

你也许也想看看 [云阵 CLI](https://github.com/aws-cloudformation/cloudformation-cli) 如果您想要编辑此内容。 在这种情况下,将它们安装在一次操作中效果良好:

```shell
pip3 install \
  -e /path/to/cloudformation-cli \
  -e /path/to/cloudformation-cli-typescript-plugin
```

这可以确保两个都无意中从PyPI安装.

对于打字机库"@amazon-web- services-cloudform/cloudform-cli-typescript-lib"的修改,将所编译的Javascript:

```shell
npm run build
npm pack
```

您可以在 Cfn 资源工程中安装 :

```shell
npm install ../path/to/cloudformation-cli-typescript-plugin/amazon-web-services-cloudformation-cloudformation-cli-typescript-lib-1.0.1.tgz
```

固定和运行单元测试通过 [承诺前](https://pre-commit.com/),在安装后自动执行(`pre-commit install`) (中文(简体) ). 持续整合还进行这些检查。 手动选项可供选择,所以不需要执行:

```shell
# run all hooks on all files, mirrors what the CI runs
pre-commit run --all-files
# run unit tests only. can also be used for other hooks, e.g. black, flake8, pylint-local
pre-commit run pytest-local
```

## 许可证

这个库根据Apache 2.0许可证获得许可.

## 常见问题

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 是什么？

CloudFormation 资源提供方开发 Kit\(RPDK\) 允许您撰写您自己的资源提供方, 供 CloudFormation 使用 。 此插件库有助于通过 CloudFormation 为您的提供者的执行提供运行时间绑定 \.

### 如何安装 @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib？

在项目目录运行 npm install @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib，或使用 pnpm add / yarn add / bun add。

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 支持 TypeScript 吗？

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

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 支持 ESM 还是 CommonJS？

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

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 需要什么版本的 Node\.js？

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

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 可以商用吗？

@amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 使用 Apache License 2\.0 许可。声明的许可为 Apache License 2\.0，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 的下载量有多少？

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

### @amazon-web-services-cloudformation/cloudformation-cli-typescript-lib 还在维护吗？

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

