feat: add version display to CLI banner and WebUI
- Add getPackageVersion() utility function in src/utils/helpers.js - Display version in CLI startup banner (e.g., "v2.4.2") - Display version in WebUI navbar next to "CLAUDE PROXY SYSTEM" - Refactor WebUI to use shared getPackageVersion() utility - Update footer with GitHub icon and link
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import path from 'path';
|
||||
|
||||
/**
|
||||
* Shared Utility Functions
|
||||
*
|
||||
* General-purpose helper functions used across multiple modules.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the package version from package.json
|
||||
* @param {string} [defaultVersion='1.0.0'] - Default version if package.json cannot be read
|
||||
* @returns {string} The package version
|
||||
*/
|
||||
export function getPackageVersion(defaultVersion = '1.0.0') {
|
||||
try {
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const packageJsonPath = path.join(__dirname, '../../package.json');
|
||||
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
||||
return packageJson.version || defaultVersion;
|
||||
} catch {
|
||||
return defaultVersion;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format duration in milliseconds to human-readable string
|
||||
* @param {number} ms - Duration in milliseconds
|
||||
|
||||
Reference in New Issue
Block a user