File: /home/frenchy/www/french-american.org/current/node_modules/snyk/dist/lib/display-policy.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = require("chalk");
const snyk_policy_1 = require("snyk-policy");
const config = require("./config");
function display(policy) {
return __awaiter(this, void 0, void 0, function* () {
const p = snyk_policy_1.demunge(policy, config.ROOT);
let res = chalk_1.default.bold('Current Snyk policy, read from ' + policy.__filename + ' file') + '\n';
res += 'Modified: ' + policy.__modified + '\n';
res += 'Created: ' + policy.__created + '\n';
res += p.patch.map(displayRule('Patch vulnerability')).join('\n');
if (p.patch.length && p.ignore.length) {
res += '\n\n------------------------\n';
}
res += p.ignore.map(displayRule('Ignore')).join('\n');
return Promise.resolve(res);
});
}
exports.display = display;
function displayRule(title) {
return (rule, i) => {
i += 1;
return (chalk_1.default.bold('\n#' + i + ' ' + title + ' ' + rule.url) +
' in the following paths:\n' +
rule.paths
.map((p) => {
return (p.path +
(p.reason
? '\nReason: ' +
p.reason +
'\nExpires: ' +
p.expires.toUTCString() +
'\n'
: '') +
'\n');
})
.join('')
.replace(/\s*$/, ''));
};
}
//# sourceMappingURL=display-policy.js.map