mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 14:16:43 +00:00
27 lines
660 B
TypeScript
27 lines
660 B
TypeScript
/**
|
|
* Version Utility
|
|
*
|
|
* Centralized version management for CCS.
|
|
* Reads version from package.json at runtime.
|
|
*/
|
|
|
|
import * as path from 'path';
|
|
import * as fs from 'fs';
|
|
|
|
// Get version from package.json (relative to dist/ at runtime)
|
|
let cachedVersion: string | null = null;
|
|
|
|
export function getVersion(): string {
|
|
if (cachedVersion) return cachedVersion;
|
|
|
|
try {
|
|
const packageJsonPath = path.join(__dirname, '../../package.json');
|
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
cachedVersion = packageJson.version || '0.0.0';
|
|
} catch {
|
|
cachedVersion = '0.0.0';
|
|
}
|
|
|
|
return cachedVersion ?? '0.0.0';
|
|
}
|