@code-pushup/cli
Version:
A CLI to run all kinds of code quality measurements to align your team with company goals
43 lines • 1.74 kB
JavaScript
import { bold, gray } from 'ansis';
import { collectAndPersistReports, upload, } from '@code-pushup/core';
import { ui } from '@code-pushup/utils';
import { CLI_NAME } from '../constants.js';
import { collectSuccessfulLog, renderConfigureCategoriesHint, renderIntegratePortalHint, uploadSuccessfulLog, } from '../implementation/logging.js';
export function yargsAutorunCommandObject() {
const command = 'autorun';
return {
command,
describe: 'Shortcut for running collect followed by upload',
handler: async (args) => {
ui().logger.log(bold(CLI_NAME));
ui().logger.info(gray(`Run ${command}...`));
const options = args;
// we need to ensure `json` is part of the formats as we want to upload
const optionsWithFormat = {
...options,
persist: {
...options.persist,
format: [
...new Set([...options.persist.format, 'json']),
],
},
};
await collectAndPersistReports(optionsWithFormat);
collectSuccessfulLog();
if (!options.categories || options.categories.length === 0) {
renderConfigureCategoriesHint();
}
if (options.upload) {
const report = await upload(options);
if (report?.url) {
uploadSuccessfulLog(report.url);
}
}
else {
ui().logger.warning('Upload skipped because configuration is not set.');
renderIntegratePortalHint();
}
},
};
}
//# sourceMappingURL=autorun-command.js.map