@constructor-io/constructorio-connect-cli
Version:
CLI tool to enable users to interface with the Constructor Connect Ecosystem
42 lines (41 loc) • 1.95 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.printExecutionWarnings = printExecutionWarnings;
const core_1 = require("@oclif/core");
const kleur_1 = __importDefault(require("kleur"));
const terminal_link_1 = __importDefault(require("terminal-link"));
/**
* Prints the warnings from the template execution, with a link to the documentation by default unless
* showDocsLink is set to false.
* @param {@link PrintExecutionWarningsArgs} args: The warnings to print and whether to show the documentation link (default true)
*/
function printExecutionWarnings({ warnings, showDocsLink = true, }) {
const originalLength = warnings.length;
if (warnings.length > 10) {
warnings = warnings.slice(0, 10);
}
core_1.ux.stdout();
core_1.ux.stdout(kleur_1.default.yellow(`⚠️ WARNINGS :`), kleur_1.default.yellow(`We found ${originalLength} warnings when validating your template!`), kleur_1.default.bold(kleur_1.default.yellow(`⬇️ Warnings ⬇️`)));
core_1.ux.stdout();
warnings.forEach((warning) => {
printSingleWarning(warning);
});
if (originalLength > 10) {
core_1.ux.stdout(`... and ${originalLength - 10} more`);
}
core_1.ux.stdout();
if (showDocsLink) {
core_1.ux.stdout(kleur_1.default.bold(`${(0, terminal_link_1.default)(kleur_1.default.bold("See documentation!"), `https://docs.constructor.com/docs/integrating-with-constructor-connect-cli-template-types-transformation-templates`)}`));
}
}
function printSingleWarning(warning) {
if (warning.critical) {
core_1.ux.stdout(kleur_1.default.red(`🚨 [${warning.type}]:`), warning.message);
}
else {
core_1.ux.stdout(kleur_1.default.yellow(`⚠️ [${warning.type}]:`), warning.message);
}
}