@aws-cdk/cli-lib-alpha

中文文档
2.1029.4-alpha.0发布于 2025/10/02Apache-2.0TypeScriptCommonJS零依赖构建来源已验证近 30 天下载 3946

AWS CDK Programmatic CLI library

此软件包已被标记为弃用

Deprecated in favor of @aws-cdk/toolkit-lib, a newer approach providing similar functionality to this package. Please migrate.

原始使用文档
文档目录12 节
  1. ⚠️ Deprecated module
  2. Overview
  3. Known issues
  4. Setup
  5. AWS CDK app directory
  6. Cloud Assembly Directory Producer
  7. Commands
  8. list
  9. synth
  10. bootstrap
  11. deploy
  12. destroy

AWS CDK CLI Library (deprecated)


@aws-cdk/cli-lib-lpha: Deprecated

This package has been deprecated in favor of @aws-cdk/toolkit-lib, a newer approach providing similar functionality to what this package offered. Please migrate as soon as possible. For any migration problems, please open an issue. We are committed to supporting the same feature set that this package offered.


⚠️ Deprecated module

This package is has been deprecated. Already published versions can be used, but no support is provided whatsoever and we will soon stop publishing new versions.

Instead, please use @aws-cdk/toolkit-lib.

Overview

Provides a library to interact with the AWS CDK CLI programmatically from jsii supported languages. Currently the package includes implementations for:

  • cdk deploy
  • cdk synth
  • cdk bootstrap
  • cdk destroy
  • cdk list

Known issues

  • JavaScript/TypeScript only
    The jsii packages are currently not in a working state.
  • No useful return values
    All output is currently printed to stdout/stderr
  • Missing or Broken options
    Some CLI options might not be available in this package or broken

Due to the deprecation of the package, this issues will not be resolved.

Setup

AWS CDK app directory

Obtain an AwsCdkCli class from an AWS CDK app directory (containing a cdk.json file):

const cli = AwsCdkCli.fromCdkAppDirectory("/path/to/cdk/app");

Cloud Assembly Directory Producer

You can also create AwsCdkCli from a class implementing ICloudAssemblyDirectoryProducer. AWS CDK apps might need to be synthesized multiple times with additional context values before they are ready.

The produce() method of the ICloudAssemblyDirectoryProducer interface provides this multi-pass ability. It is invoked with the context values of the current iteration and should use these values to synthesize a Cloud Assembly. The return value is the path to the assembly directory.

A basic implementation would look like this:

class MyProducer implements ICloudAssemblyDirectoryProducer {
  async produce(context: Record<string, any>) {
    const app = new cdk.App({ context });
    const stack = new cdk.Stack(app);
    return app.synth().directory;
  }
}

For all features (e.g. lookups) to work correctly, cdk.App() must be instantiated with the received context values. Since it is not possible to update the context of an app, it must be created as part of the produce() method.

The producer can than be used like this:

const cli = AwsCdkCli.fromCloudAssemblyDirectoryProducer(new MyProducer());

Commands

list

// await this asynchronous method call using a language feature
cli.list();

synth

// await this asynchronous method call using a language feature
cli.synth({
  stacks: ['MyTestStack'],
});

bootstrap

// await this asynchronous method call using a language feature
cli.bootstrap();

deploy

// await this asynchronous method call using a language feature
cli.deploy({
  stacks: ['MyTestStack'],
});

destroy

// await this asynchronous method call using a language feature
cli.destroy({
  stacks: ['MyTestStack'],
});

版本与发布记录

@aws-cdk/cli-lib-alpha 共发布 214 个版本,首次发布于 2023/01/19;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1029.4-alpha.0latest2025/10/021.1 年前
2.1029.3-alpha.02025/09/241.1 年前
2.1029.2-alpha.02025/09/171.1 年前
2.1029.1-alpha.02025/09/121.2 年前
2.1029.0-alpha.02025/09/051.2 年前
2.1028.0-alpha.02025/09/041.2 年前

关于 @aws-cdk/cli-lib-alpha 的常见问题

@aws-cdk/cli-lib-alpha 是什么?

AWS CDK Programmatic CLI library注意:该包已被作者标记为弃用——Deprecated in favor of @aws-cdk/toolkit-lib, a newer approach providing similar functionality to this package. Please migrate.

如何安装 @aws-cdk/cli-lib-alpha?

在项目目录运行 npm install @aws-cdk/cli-lib-alpha,或使用 pnpm add / yarn add / bun add。

@aws-cdk/cli-lib-alpha 支持 TypeScript 吗?

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

@aws-cdk/cli-lib-alpha 支持 ESM 还是 CommonJS?

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

@aws-cdk/cli-lib-alpha 需要什么版本的 Node.js?

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

@aws-cdk/cli-lib-alpha 可以商用吗?

@aws-cdk/cli-lib-alpha 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aws-cdk/cli-lib-alpha 的下载量有多少?

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

@aws-cdk/cli-lib-alpha 还在维护吗?

最新版本 2.1029.4-alpha.0 发布于 2025/10/02(1.1 年前);至今共发布 214 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/01/19。作者已将其标记为弃用,新项目建议寻找替代方案。