UNPKG

@code-pushup/cli

Version:

A CLI to run all kinds of code quality measurements to align your team with company goals

48 lines 1.85 kB
import { history } from '@code-pushup/core'; import { getCurrentBranchOrTag, getHashes, getSemverTags, logger, safeCheckout, } from '@code-pushup/utils'; import { yargsFilterOptionsDefinition } from '../implementation/filter.options.js'; import { printCliCommand } from '../implementation/logging.js'; import { yargsHistoryOptionsDefinition } from './history.options.js'; import { normalizeHashOptions } from './utils.js'; const command = 'history'; async function handler(args) { printCliCommand(command); const currentBranch = await getCurrentBranchOrTag(); const { targetBranch: rawTargetBranch, ...opt } = args; const { targetBranch, from, to, maxCount, onlySemverTags, ...historyOptions } = await normalizeHashOptions({ ...opt, targetBranch: rawTargetBranch ?? currentBranch, }); const filterOptions = { targetBranch, from, to, maxCount }; const results = onlySemverTags ? await getSemverTags(filterOptions) : await getHashes(filterOptions); try { // run history logic const reports = await history({ targetBranch, ...historyOptions, }, results.map(({ hash }) => hash)); logger.info(`Reports: ${reports.length}`); } finally { // go back to initial branch await safeCheckout(currentBranch); } } export function yargsHistoryCommandObject() { return { command, describe: 'Collect reports for commit history', builder: yargs => { yargs.options({ ...yargsHistoryOptionsDefinition(), ...yargsFilterOptionsDefinition(), }); yargs.group(Object.keys(yargsHistoryOptionsDefinition()), 'History Options:'); return yargs; }, handler, }; } //# sourceMappingURL=history-command.js.map