UNPKG

@vortex.so/cli

Version:

CLI to interact with Vortex.

95 lines (89 loc) 2.55 kB
'use strict'; const citty = require('citty'); const prompts = require('prompts'); require('node:process'); const c = require('chalk'); require('figures'); require('jiti'); const index = require('../../../utils/log/index.cjs'); const ship = require('../../../plugins/ship/ship.cjs'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const prompts__default = /*#__PURE__*/_interopDefaultCompat(prompts); const c__default = /*#__PURE__*/_interopDefaultCompat(c); const log = new index.Log("Ship"); const shipCommand = citty.defineCommand({ meta: { name: "ship", description: c__default.dim(`Ship 'em up!`) }, args: { command: { type: "positional", alias: "c", description: "Command to run.", required: false } }, async run({ args }) { prompts__default.override({ command: args.command }); try { const answers = await prompts__default([ { type: "select", name: "command", message: "What kind of shipment do you want to do?", choices: [ { title: "Version", value: "version", description: "Bump project version." }, { title: "Commit and tag version", value: "version:commit-tag", description: "Commit and tag project version" }, { title: "Commit version", value: "version:commit", description: "Commit project version." }, { title: "Tag version", value: "version:tag", description: "Tag project version." }, { title: "Publish", value: "publish", description: "Publish package to NPM." } ] } ]); switch (answers.command) { case "version": await ship.Ship.version(); break; case "version:commit-tag": await ship.Ship.commitTag(); break; case "version:commit": await ship.Ship.commit(); break; case "version:tag": await ship.Ship.tag(); break; case "publish": await ship.Ship.publish(); break; default: log.abort("Not shipping anything."); break; } } catch (error) { log.fail(error?.message); } } }); exports.shipCommand = shipCommand;