declapract
Version:
A tool to declaratively define best practices, maintainable evolve them, and scalably enforce them.
48 lines • 2.88 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
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 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ 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
;