Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/doodle-node-cli / src / prompts / deployment-dashboard.js
Size: Mime:
const chalk = require('chalk');
const inquirer = require('inquirer');
const { table } = require('table');

const { TAGFLOW_PROJECTS, CONFIG_DEBUG_MODE_KEY, CONFIG_GITHUB_TOKEN_KEY } = require('../constants');
const { getRecentDeploymentTags } = require('../apis/github');

module.exports = async config => {
  if (!config[CONFIG_GITHUB_TOKEN_KEY]) {
    console.log(chalk.red('You need to have a PAT in your configuration file'));
    console.log(`Run ${chalk.yellow('doodle init')} to save your PAT`);
    process.exit(1);
  }

  const repositoryAnswer = await inquirer.prompt([
    {
      type: 'list',
      name: 'repository',
      message: 'From which repository do you want to see the last deployments?:',
      choices: config[CONFIG_DEBUG_MODE_KEY] ? [...TAGFLOW_PROJECTS, 'doodle-node-cli'] : TAGFLOW_PROJECTS,
    },
  ]);

  const tableHeader = ['Tag name', 'Tag commit SHA'];
  const recentTags = await getRecentDeploymentTags(config[CONFIG_GITHUB_TOKEN_KEY], repositoryAnswer.repository);

  const preparedData = [tableHeader, ...recentTags];

  console.log(table(preparedData));
};