UNPKG

declapract

Version:

A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.

39 lines 2.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.displayPlan = void 0; const chalk_1 = __importDefault(require("chalk")); const indent_string_1 = __importDefault(require("indent-string")); const domain_1 = require("../../../../domain"); const sortFileCheckEvaluationsByPracticeRef_1 = require("../sortFileCheckEvaluationsByPracticeRef"); const getColoredPlanTitle_1 = require("./color/getColoredPlanTitle"); const displayPlan = async ({ plan }) => { // print out the title for this file const title = (0, getColoredPlanTitle_1.getColoredPlanTitle)({ plan }); console.log(` * ${title}`); // tslint:disable-line: no-console // if there is nothing to do, then don't show more details for this file if (plan.action === domain_1.RequiredAction.NO_CHANGE) return; // if there was any failed evaluations, display each practice and show each practice that failed and why plan.evaluations.filter(domain_1.hasFailed).forEach((evaluation) => { // display the reasons of the practices that failed evaluation.checks .filter(domain_1.hasFailed) .sort(sortFileCheckEvaluationsByPracticeRef_1.sortFileCheckEvaluationsByPracticeRef) .forEach((failedCheck) => { const statusToken = (0, domain_1.isFixableCheck)(failedCheck) ? chalk_1.default.yellow('✕') : chalk_1.default.red('✕'); const fixabilityToken = (0, domain_1.isFixableCheck)(failedCheck) ? chalk_1.default.gray('(fix:appliable)') : ''; console.log((0, indent_string_1.default)(`${statusToken} practice:${failedCheck.practiceRef} ${fixabilityToken}`, 4)); // tslint:disable-line: no-console if (failedCheck.reason) console.log((0, indent_string_1.default)(failedCheck.reason, 6), '\n'); // tslint:disable-line: no-console }); }); }; exports.displayPlan = displayPlan; //# sourceMappingURL=displayPlan.js.map