UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

76 lines 3.79 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProjectQueryDefinition = void 0; const project_query_executor_1 = require("./project-query-executor"); const ansi_1 = require("../../../util/text/ansi"); const time_1 = require("../../../util/text/time"); const joi_1 = __importDefault(require("joi")); const r_author_1 = require("../../../util/r-author"); const r_license_1 = require("../../../util/r-license"); function addSuffix(count, singular = '', plural = 's') { return `${count === 1 ? singular : plural}`; } exports.ProjectQueryDefinition = { executor: project_query_executor_1.executeProjectQuery, asciiSummarizer: (formatter, analyzer, queryResults, result) => { const out = queryResults; result.push(`Query: ${(0, ansi_1.bold)('project', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`); if (out.name) { result.push(` ╰ Project Name: ${out.name}`); } if (out.version) { result.push(` ╰ Version: ${out.version}`); } if (out.encoding) { result.push(` ╰ Encoding: ${out.encoding}`); } if (out.authors && out.authors.length > 0) { result.push(` ╰ Author${addSuffix(out.authors.length)}:`); for (const author of out.authors) { result.push(` ╰ ${(0, r_author_1.rAuthorInfoToReadable)(author)}`); } } if (out.licenses && out.licenses.length > 0) { result.push(` ╰ License${addSuffix(out.licenses.length)}:`); for (const license of out.licenses) { result.push(` ╰ ${(0, r_license_1.stringifyRLicense)(license)}`); } } if (out.roleCounts) { const entries = Object.entries(out.roleCounts).filter(([, count]) => count > 0); if (entries.length > 0) { result.push(' ╰ File Role Counts:'); const longestRole = Math.max(...entries.map(([r]) => r.length)); const longestCount = Math.max(...entries.map(([, c]) => String(c).length)); for (const [role, count] of entries) { result.push(` ╰ ${(role + ':').padEnd(longestRole + 1, ' ')} ${formatter.format(String(count).padStart(longestCount, ' '), { effect: ansi_1.ColorEffect.Foreground, color: 6 /* Colors.Cyan */ })}`); } } } if (analyzer.peekDataflow() === undefined) { result.push(formatter.format(' ╰ Dataflow Analysis not performed', { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground })); } else { result.push(` ╰ Dataflow Analysis considered ${out.files.length} file${out.files.length === 1 ? '' : 's'}`); for (const file of out.files.slice(0, 20)) { result.push(` ╰ \`${file}\``); } if (out.files.length > 20) { result.push(` ╰ ... and ${out.files.length - 20} more files`); } } return true; }, schema: joi_1.default.object({ type: joi_1.default.string().valid('project').required().description('The type of the query.'), withDf: joi_1.default.boolean().optional().default(false).description('Whether to include Dataflow information in the result.') }).description('The project query provides information on the analyzed project.'), flattenInvolvedNodes: () => [] }; //# sourceMappingURL=project-query-format.js.map