cli_pipeline

1.0.1 • Public • Published

Import

import { Pipeline } from 'cli_pipeline';

Example

Pipeline file, pipeline.js

import { Pipeline, sleep } from 'cli_pipeline';

const pipeline = new Pipeline({
  nodeVersion: 18,
  requireNodeVersion: true,
  initialQuestions: [
    {
      name: 'question',
      type: 'list',
      choices: ['serve', 'deploy'],
      message: 'Select your option'
    }
  ]
});

pipeline.init(async (initialResponse, e) => {
  pipeline.runScrip('echo 12');
  if (initialResponse.question === 'serve') {
    await pipeline.done();
    return;
  }

  if (initialResponse.question === 'deploy') {
    await pipeline.cliUpdate('Running tests');
    await sleep(1000);
    await pipeline.cliStop('stop');

    const response = await pipeline.aksOptions([
      {
        name: 'continue',
        type: 'confirm',
        choices: ['master', 'dev'],
        message: 'Select your branch to deploy',
        default: false
      }
    ]);

    if (response.continue === false) {
      await pipeline.done();
    }

    await pipeline.cliRestart('Loading...');
    await sleep(1000);
    await pipeline.cliStop('stop');
    const { environment } = await pipeline.aksOptions([
      {
        name: 'environment',
        type: 'list',
        choices: ['master', 'dev'],
        message: 'Select your branch to deploy'
      }
    ]);

    try {
      await pipeline.verifyBranch(environment);
    } catch (error) {
      pipeline.fail('wrong branch');
    }

    await pipeline.cliRestart('Loading...');
    await sleep(1000);
    await pipeline.done();
  }
});

run the cli pipeline

node ./pipeline.js

Readme

Keywords

Package Sidebar

Install

npm i cli_pipeline

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

9.95 kB

Total Files

5

Last publish

Collaborators

  • admirableyetti