UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

148 lines 7.64 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.flowrVersion = flowrVersion; exports.retrieveVersionInformation = retrieveVersionInformation; exports.printVersionInformation = printVersionInformation; const ansi_1 = require("./text/ansi"); const semver_1 = require("semver"); const assert_1 = require("./assert"); const sigdb_download_1 = require("../project/sigdb/sigdb-download"); const doc_files_1 = require("../documentation/doc-util/doc-files"); // this is automatically replaced with the current version by release-it const version = '2.14.0'; // this is automatically replaced with the release date by release-it (regex-bumper, see package.json) const versionDate = '2026-07-15T07:13:44Z'; /** * Retrieves the current flowR version as a new {@link SemVer} object. */ function flowrVersion() { return new semver_1.SemVer(version); } const versionRegex = /^\d+\.\d+\.\d+/m; /** * Retrieves the version information for flowR and the given parser or analysis provider. */ async function retrieveVersionInformation(input) { const flowr = flowrVersion().toString(); let r; let name; if ('name' in input) { r = await input.rVersion(); name = input.name; } else { const parserInformation = input.parserInformation(); r = parserInformation.name === 'r-shell' ? (await parserInformation.rVersion()) : 'unknown'; name = parserInformation.name; } (0, assert_1.guard)(versionRegex.test(flowr), `flowR version ${flowr} does not match the expected format!`); (0, assert_1.guard)(r === 'unknown' || r === 'none' || versionRegex.test(r), `R version ${r} does not match the expected format!`); return { flowr: flowr, r: r, engine: name }; } /** * Displays the version information to the given output. */ async function printVersionInformation(output, input, engineOnly = false) { const { flowr, r, engine } = await retrieveVersionInformation(input); const dim = (s) => (0, ansi_1.faint)(s, output.formatter); const rReason = r === 'none' ? ' (no R interpreter available)' : r === 'unknown' ? (engine === 'tree-sitter' ? ' (not queried, using the tree-sitter engine)' : ' (could not be determined)') : ''; const flowrValue = versionRegex.test(flowr) ? output.formatter.hyperlink(flowr, `https://github.com/flowr-analysis/flowr/releases/tag/v${flowr}`, true) : flowr; const rows = []; const pluginLines = []; if (!engineOnly) { rows.push(['flowR', `${flowrValue} ${dim(`(${versionDate})`)}`]); } rows.push(['engine', engine], ['R', `${r}${rReason}`, r === 'none' || r === 'unknown']); if (typeof input !== 'function' && 'inspectContext' in input) { // reads the current analyzer, so it reflects the databases in use (and adapts to config changes) const ctx = input.inspectContext(); const setting = ctx.config.solver.sigdb.assumedRVersion ?? 'auto'; rows.push(['assumed R', `${ctx.resolvedRVersion} ${dim(`(solver.sigdb.assumedRVersion = "${setting}")`)}`]); const dbs = ctx.deps.loadedSignatureDatabases(); const sigDbUrl = (0, sigdb_download_1.sigDbRemoteRelease)()?.url; const describe = (d) => { const entry = `${d.scope} (v${d.version}, ${d.date}${d.format ? `, ${d.format}` : ''})`; return sigDbUrl ? output.formatter.hyperlink(entry, sigDbUrl, true) : entry; }; rows.push(['databases', dbs.length === 0 ? 'none' : dbs.map(describe).join(', '), dbs.length === 0]); // the registered plugins, grouped by prefix; collected here and printed after the table (below) so the // longer labels do not widen the version rows. The header links (once) to the plugin wiki section const wiki = `${doc_files_1.FlowrWikiBaseRef}/Analyzer#plugins`; const osc8 = (0, ansi_1.supportsHyperlinks)(); const names = ctx.config.defaultPlugins.map(x => typeof x === 'string' ? x : x[0]); const byPrefix = new Map(); for (const p of names) { const at = p.indexOf(':'); const [prefix, suffix] = at < 0 ? [p, ''] : [p.slice(0, at), p.slice(at + 1)]; byPrefix.set(prefix, [...(byPrefix.get(prefix) ?? []), suffix]); } const trace = ctx.config.repl.showPlugins; // loaded lazily so this presentation util does not statically pull the plugin registry (and the whole // plugin/dataflow graph) into `util/version`, which `util/assert` depends on const { BuiltInPlugins } = await Promise.resolve().then(() => __importStar(require('../project/plugins/plugin-registry'))); const keyByClass = new Map(BuiltInPlugins.map(([key, producer]) => [producer.name, key])); const activated = new Set(); for (const cls of ctx.activatedPlugins) { const key = keyByClass.get(cls); if (key !== undefined) { activated.add(key); } } const render = (full, suffix) => trace && !activated.has(full) ? dim(suffix) : suffix; const labelWidth = Math.max(...[...byPrefix.keys()].map(p => p.length)); const header = `registered plugins (${names.length})`; const hint = trace ? ' (faint = did not activate)' : ' (set +repl.showPlugins=true to track activation)'; pluginLines.push(`${(0, ansi_1.bold)(output.formatter.hyperlink(header, wiki, true), output.formatter)}:${dim(hint)}`); for (const [prefix, suffixes] of [...byPrefix].sort((a, b) => a[0].localeCompare(b[0]))) { pluginLines.push(` ${(0, ansi_1.bold)(prefix, output.formatter)}:${' '.repeat(labelWidth - prefix.length)} ${[...suffixes].sort((a, b) => a.localeCompare(b)).map(s => render(`${prefix}:${s}`, s)).join(', ')}`); } if (!osc8) { pluginLines.push(` ${dim('docs: ' + wiki)}`); } } const width = Math.max(...rows.map(([label]) => label.length)); for (const [label, value, faded] of rows) { const padding = ' '.repeat(width - label.length); const line = `${label}:${padding} ${value}`; output.stdout(faded ? dim(line) : line); } for (const line of pluginLines) { output.stdout(line); } } //# sourceMappingURL=version.js.map