@circleci/circleci-config-sdk

中文文档
0.12.5发布于 2025/05/29MITTypeScriptCommonJS近 30 天下载 9271

An SDK for building CircleCI Configuration files with JavaScript.

原始使用文档
文档目录7 节
  1. Warning ⚠️
  2. Table of Contents
  3. Getting Started
  4. Installation
  5. Example
  6. Getting Help
  7. Resources

CircleCI Config SDK

Warning ⚠️

This repo is no longer maintained, supported, or monitored by CircleCI. It will be archived in the next 90 days. It can be forked for those that would like to continue using it.

This SDK is provided on an ‘as-is’ and ‘as available’ basis without any warranties of any kind. CircleCI disclaims all warranties, express or implied, including, but not limited to, all implied warranties of merchantability, title, fitness for a particular purpose, and noninfringement.

GitHub CircleCI npm codecov npm GitHub Repo stars

Create and manage your CircleCI configuration files with JavaScript and TypeScript.

Table of Contents

Getting Started

📖 Getting Started Wiki

📖 SDK API Docs

💻 Examples


Installation

Using npm:

$ npm i @circleci/circleci-config-sdk

Using yarn:

$ yarn add @circleci/circleci-config-sdk

Usage

In Browser:

import CircleCI from '@circleci/circleci-config-sdk';

In Node.js:

const CircleCI = require('@circleci/circleci-config-sdk');

Example

Generate a CircleCI config using TypeScript/Javascript, properly typed for full IntelliSense support.

const CircleCI = require('@circleci/circleci-config-sdk');
// Instantiate new Config
const myConfig = new CircleCI.Config();
// Create new Workflow
const myWorkflow = new CircleCI.Workflow('myWorkflow');
myConfig.addWorkflow(myWorkflow);

// Create an executor instance
// Executors are used directly in jobs
// and do not need to be added to the config separately
const nodeExecutor = new CircleCI.executors.DockerExecutor('cimg/node:lts');

// Create Job and add it to the config
const nodeTestJob = new CircleCI.Job('node-test', nodeExecutor);
myConfig.addJob(nodeTestJob);

// Add steps to job
nodeTestJob
  .addStep(new CircleCI.commands.Checkout())
  .addStep(
    new CircleCI.commands.Run({
      command: 'npm install',
      name: 'NPM Install',
    }),
  )
  .addStep(
    new CircleCI.commands.Run({
      command: 'npm run test',
      name: 'Run tests',
    }),
  );

// Add Jobs to Workflow
myWorkflow.addJob(nodeTestJob);

// The `stringify()` function on `CircleCI.Config` will return the CircleCI YAML equivalent.
const MyYamlConfig = myConfig.stringify();

// Save the config to a file in Node.js or the browser. Note, use in the browser requires user interaction.
myConfig.writeFile('config.yml');

MyYamlConfig will hold the following string (A valid CircleCI Config).

version: 2.1
setup: false
jobs:
  node-test:
    docker:
      - image: cimg/node:lts
    resource_class: medium
    steps:
      - checkout: {}
      - run:
          command: npm install
          name: NPM Install
      - run:
          command: npm run test
          name: Run tests
workflows:
  myWorkflow:
    jobs:
      - node-test: {}

Getting Help

This open-source project utilized GitHub issues and project boards to manage requests and support.

If you can not find an answer to your question in an existing issue, you may open a new issue with the appropriate template. Issues are the best way for the CircleCI team and the open-source community to track and interact with your questions.

Resources

Consider checking the following common resources before opening a new issue.

Contributing

This repository welcomes community contributions! See our CONTRIBUTING.md for guidance on configuring your development environment and how to submit quality pull requests.

Related

版本与发布记录

@circleci/circleci-config-sdk 共发布 64 个版本,首次发布于 2021/04/30;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.12.5latest2025/05/291.4 年前
0.12.42025/05/281.5 年前
0.12.32023/06/133 年前
0.12.02022/11/183 年前
0.11.12022/10/134 年前
0.11.02022/09/294 年前

其他发布通道:alpha → 0.9.0-alpha.21。

关于 @circleci/circleci-config-sdk 的常见问题

@circleci/circleci-config-sdk 是什么?

An SDK for building CircleCI Configuration files with JavaScript.

如何安装 @circleci/circleci-config-sdk?

在项目目录运行 npm install @circleci/circleci-config-sdk,或使用 pnpm add / yarn add / bun add。

@circleci/circleci-config-sdk 支持 TypeScript 吗?

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

@circleci/circleci-config-sdk 支持 ESM 还是 CommonJS?

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

@circleci/circleci-config-sdk 可以商用吗?

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

@circleci/circleci-config-sdk 的下载量有多少?

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

@circleci/circleci-config-sdk 还在维护吗?

最新版本 0.12.5 发布于 2025/05/29(1.4 年前);至今共发布 64 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/04/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。