UNPKG

savory

Version:

A command-line interface for operating your Codefresh account

28 lines (26 loc) 1.03 kB
const fp = require('lodash/fp'), chalk = require('chalk'), { middleware: httpClientMiddleware } = require('../../lib/api_client'), { errorFormatter } = require('../style'); module.exports = { command: "version <component>", description: "Retrieves the version of components in Codefresh", builder: (yargs)=> { return yargs .usage(`Specify the component for which a version is required.`) .example('$0 version api') .example('$0 version nomios') .positional('component', { choices: ["api", "hermes"] }) }, handler: fp.pipe(httpClientMiddleware, ({ _httpClient, component })=> { ({ "api": ()=> _httpClient('version').then(fp.pipe(fp.get('current_commit.0'), (commitHash)=> `Latest API commit is ${ chalk.whiteBright(commitHash) }`)), "hermes": ()=> _httpClient('hermes/version') })[component]() .then(console.log) .catch(errorFormatter); }) };