UNPKG

@yolkai/nx-workspace

Version:

Extensible Dev Tools for Monorepos

61 lines (60 loc) 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const output_1 = require("../utils/output"); class DefaultReporter { beforeRun(affectedProjectNames, affectedArgs, taskOverrides) { if (affectedProjectNames.length <= 0) { let description = `with "${affectedArgs.target}"`; if (affectedArgs.configuration) { description += ` that are configured for "${affectedArgs.configuration}"`; } output_1.output.logSingleLine(`No projects ${description} were run`); return; } const bodyLines = affectedProjectNames.map(affectedProject => `${output_1.output.colors.gray('-')} ${affectedProject}`); if (Object.keys(taskOverrides).length > 0) { bodyLines.push(''); bodyLines.push(`${output_1.output.colors.gray('With flags:')}`); Object.entries(taskOverrides) .map(([flag, value]) => ` --${flag}=${value}`) .forEach(arg => bodyLines.push(arg)); } output_1.output.log({ title: `${output_1.output.colors.gray('Running target')} ${affectedArgs.target} ${output_1.output.colors.gray('for projects:')}`, bodyLines }); output_1.output.addVerticalSeparator(); } printResults(affectedArgs, failedProjectNames, startedWithFailedProjects) { output_1.output.addNewline(); output_1.output.addVerticalSeparator(); if (failedProjectNames.length === 0) { output_1.output.success({ title: `Running target "${affectedArgs.target}" succeeded` }); if (affectedArgs.onlyFailed && startedWithFailedProjects) { output_1.output.warn({ title: `Only projects ${output_1.output.underline('which had previously failed')} were run`, bodyLines: [ `You should verify by running ${output_1.output.underline('without')} ${output_1.output.bold('--only-failed')}` ] }); } return; } const bodyLines = [ output_1.output.colors.gray('Failed projects:'), '', ...failedProjectNames.map(project => `${output_1.output.colors.gray('-')} ${project}`) ]; if (!affectedArgs.onlyFailed && !startedWithFailedProjects) { bodyLines.push(''); bodyLines.push(`${output_1.output.colors.gray('You can isolate the above projects by passing:')} ${output_1.output.bold('--only-failed')}`); } output_1.output.error({ title: `Running target "${affectedArgs.target}" failed`, bodyLines }); } } exports.DefaultReporter = DefaultReporter;