dsh-brain/lib/version.js

25 lines
988 B
JavaScript

/**
* Single source of truth for the package version.
*
* The compiled file lives in `lib/`, so `../package.json` resolves to this
* package's manifest both in the repo and inside node_modules. Every surface
* that reports a version (status card, capabilities, Mnemon manifest) reads it
* from here, so a release bump is one edit in package.json.
*/
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
const FALLBACK_VERSION = '0.10.1';
function readVersion() {
try {
const manifest = JSON.parse(readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf8'));
if (typeof manifest.version === 'string' && manifest.version !== '')
return manifest.version;
}
catch {
// A missing or broken manifest must not take the plugin down.
}
return FALLBACK_VERSION;
}
/** Version reported by the status card, capabilities and the Mnemon manifest. */
export const VERSION = readVersion();