1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const chalk_1 = require("chalk");
|
5 | const guards_1 = require("../../../guards");
|
6 | function formatAilmentMessage(ailment) {
|
7 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
8 | const treatable = guards_1.isTreatableAilment(ailment);
|
9 | return (`${yield ailment.getMessage()}\n` +
|
10 | `${yield formatAilmentSteps(ailment)}\n\n` +
|
11 | `${chalk_1.default.dim('$')} ${chalk_1.default.green(`ionic config set -g doctor.issues.${ailment.id}.ignored true`)} ${chalk_1.default.dim('(ignore this issue in the future)')}\n` +
|
12 | `${treatable ? `${chalk_1.default.dim('$')} ${chalk_1.default.green(`ionic doctor treat ${ailment.id}`)} ${chalk_1.default.dim('(attempt to fix this issue)')}\n` : ''}`);
|
13 | });
|
14 | }
|
15 | exports.formatAilmentMessage = formatAilmentMessage;
|
16 | function formatAilmentSteps(ailment) {
|
17 | return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
18 | const steps = yield ailment.getTreatmentSteps();
|
19 | if (steps.length === 0) {
|
20 | return '';
|
21 | }
|
22 | const treatable = guards_1.isTreatableAilment(ailment);
|
23 | const msg = treatable ? `To fix, the following step(s) need to be taken:` : `To fix, take the following step(s):`;
|
24 | return `\n${msg}\n\n${steps.map((step, i) => ` ${chalk_1.default.dim(String(i + 1) + ')')} ${step.message}`).join('\n')}`;
|
25 | });
|
26 | }
|