@circleci/circleci-config-sdk
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.0 • Public • Published

    CircleCI Config SDK

    GitHub License CircleCI npm codecov npm

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

    Table of Contents

    Getting Started

    Installation

    Using npm:

    $ npm i @circleci/circleci-config-sdk

    Using yarn:

    $ yarn add @circleci/circleci-config-sdk

    Usage

    In Node.js:

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

    In Browser:

    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.executor.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();

    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

    Keywords

    Install

    npm i @circleci/circleci-config-sdk

    DownloadsWeekly Downloads

    112

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    969 kB

    Total Files

    139

    Last publish

    Collaborators

    • icodeokay
    • domparfitt
    • nathanrp
    • stuart133
    • dcarley
    • elainek5
    • jonwebs
    • aaylacci
    • asaroya
    • schurchleycci
    • christian-stephen
    • olivierbacs
    • afranco07
    • lewang_npm
    • mitz418
    • projectfrank
    • paranoidmonoid
    • sds0307
    • brivu
    • glivas
    • jleadbetter-circleci
    • lavin-ds
    • zelabedeen
    • dcerezoi
    • pma-cci
    • danmux
    • rithu
    • avalcepina
    • am-bui
    • h42zhu
    • teesloane
    • roman731
    • forbsey1
    • bentodevbox
    • rdmcmillan
    • liene
    • cci-npm-al
    • liam.clarke
    • sandro_jaya
    • bardan-circleci
    • seth-taylor
    • etcci
    • yoheikoyama
    • emilmilanov
    • royvandewater
    • yundt
    • zzakjs
    • circleci-deploy
    • circleci-bear
    • circleci-ops
    • tsorel
    • taxonomic-blackfish
    • breon
    • aengelberg
    • amandadyson
    • jr-circle
    • bostonou
    • veravera
    • pnhcci
    • miller_cci
    • heug_cci
    • michael_webster
    • dsayling
    • janedotbiz
    • pete-woods
    • andrewwelton
    • ganezasan
    • musab
    • kira-m
    • jrwdunham
    • nibrasohin
    • joelthompson
    • epgui
    • nbialostosky
    • polymeris
    • vlin7
    • jaryt
    • rcasto92
    • cnwobi
    • teka23
    • npmjoel321
    • camillelawrence
    • enoshanwar
    • techsquidtv
    • sulami
    • roncodingenthusiast
    • ralphda54
    • spoontstr
    • jennmillercircle
    • mzalimeni-cci
    • katiecircle
    • sashal
    • ruben.vicario
    • reifying
    • stigbra
    • briceicle
    • wydee
    • gabiterateur
    • lindabyrne
    • tanya-coding
    • ryanbarkley
    • sskangg
    • sanajaved7
    • circlecai
    • christinanguyen
    • lelau
    • bryansayson
    • avinashcircleci
    • jeffreyfriedman
    • markl121
    • azizamagerramova
    • elimt
    • anthonycircleci
    • nivl
    • fernandoabreu2
    • pjadhav
    • katia7
    • graemerharvey
    • rrakin
    • ade_adesokan
    • moratod
    • dcdavid
    • nicolechung
    • marcdel
    • hamzanaqi
    • dotatcircleci
    • bjohnso5
    • semanticallynull
    • brentmmarks
    • tiak
    • jrahme-cci
    • isnotprimary
    • kkim-sh
    • jtmcg
    • melanieseltzer-cci
    • atw-cci
    • da.jiang
    • rsylvian
    • zakizaki
    • keatonus
    • nramabad
    • tshen815
    • sudocurse
    • halie-kastl
    • hoodr
    • ccgeller
    • marcomorain
    • jacquegarcia
    • stevegr33n