UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

56 lines 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.versionReplString = versionReplString; exports.printVersionRepl = printVersionRepl; const version_1 = require("../../util/version"); const manifest_1 = require("../../project/sigdb/manifest"); const ansi_1 = require("../../util/text/ansi"); const url_1 = require("url"); /** * Returns a version string for the REPL including flowR, R, and the engine in use. */ async function versionReplString(parser) { const version = await (0, version_1.retrieveVersionInformation)(parser); const rVersion = version.r === 'none' ? '' : version.r === 'unknown' ? ', R version unknown' : `, R v${version.r}`; const treeSitterVer = parser.name === 'tree-sitter' ? `, R grammar v${parser.treeSitterVersion()}` : ''; return `flowR repl v${version.flowr}${rVersion}${treeSitterVer} (${version.engine} engine)`; } /** * Compact, dimmed note on the bundled signature databases (merged into the engine parenthesis): one linked ref per * scope present on disk (`current`, `base`, `full-history`) with its last update. * The full history is on disk as `history.*` (mounted alongside `current.*`), or a merged `full.*` in a baked container. */ function sigDbSummaryString() { const it = (s) => (0, ansi_1.italic)(s, ansi_1.formatter); const entries = []; const add = (label, file) => { if (file === undefined) { return; } let date; try { date = (0, manifest_1.readManifestDate)(file); } catch { /* a corrupt/unreadable manifest must not break --version */ } entries.push({ label, file, date }); }; add('current', (0, manifest_1.defaultSigDbPath)('current')); add('base', (0, manifest_1.defaultSigDbPath)('base')); add('full-history', (0, manifest_1.defaultSigDbPath)('full') ?? (0, manifest_1.defaultSigDbPath)('history')); if (entries.length === 0) { return it('no sigdb'); } const link = (text, file) => it(ansi_1.formatter.hyperlink(text, (0, url_1.pathToFileURL)(file).href, true)); // if every ref shares the same date, print it once const shared = entries.every(e => e.date !== undefined && e.date === entries[0].date) ? entries[0].date : undefined; const refs = entries.map(e => link(shared === undefined && e.date !== undefined ? `${e.label} ${e.date}` : e.label, e.file)); return it('sigdb: ') + refs.join(it(', ')) + (shared !== undefined ? it(` ${shared}`) : ''); } /** * Prints the version information for the REPL including flowR, R, and the bundled signature databases. */ async function printVersionRepl(parser) { const sigdb = sigDbSummaryString(); console.log((await versionReplString(parser)).replace(/\)$/, () => `, ${sigdb})`)); } //# sourceMappingURL=print-version.js.map