Merge pull request #210 from IrvanFza/feat/version-display

feat: display version prominently in CLI banner and WebUI navbar
This commit is contained in:
Badri Narayanan S
2026-02-01 16:14:40 +05:30
committed by GitHub
5 changed files with 42 additions and 20 deletions

View File

@@ -8,9 +8,12 @@ import { DEFAULT_PORT } from './constants.js';
import { logger } from './utils/logger.js';
import { config } from './config.js';
import { getStrategyLabel, STRATEGY_NAMES, DEFAULT_STRATEGY } from './account-manager/strategies/index.js';
import { getPackageVersion } from './utils/helpers.js';
import path from 'path';
import os from 'os';
const packageVersion = getPackageVersion();
// Parse command line arguments
const args = process.argv.slice(2);
const isDebug = args.includes('--debug') || process.env.DEBUG === 'true';
@@ -100,7 +103,7 @@ const server = app.listen(PORT, HOST, () => {
logger.log(`
╔══════════════════════════════════════════════════════════════╗
║ Antigravity Claude Proxy Server
Antigravity Claude Proxy Server v${packageVersion}
╠══════════════════════════════════════════════════════════════╣
║ ║
${border} ${align(`Server and WebUI running at: http://${HOST === '0.0.0.0' ? 'localhost' : HOST}:${PORT}`)}${border}

View File

@@ -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

View File

@@ -13,8 +13,6 @@
*/
import path from 'path';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import express from 'express';
import { getPublicConfig, saveConfig, config } from '../config.js';
import { DEFAULT_PORT, ACCOUNT_CONFIG_PATH, MAX_ACCOUNTS } from '../constants.js';
@@ -22,18 +20,10 @@ import { readClaudeConfig, updateClaudeConfig, replaceClaudeConfig, getClaudeCon
import { logger } from '../utils/logger.js';
import { getAuthorizationUrl, completeOAuthFlow, startCallbackServer } from '../auth/oauth.js';
import { loadAccounts, saveAccounts } from '../account-manager/storage.js';
import { getPackageVersion } from '../utils/helpers.js';
// Get package version
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
let packageVersion = '1.0.0';
try {
const packageJsonPath = path.join(__dirname, '../../package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
packageVersion = packageJson.version;
} catch (error) {
logger.warn('[WebUI] Could not read package.json version, using default');
}
const packageVersion = getPackageVersion();
// OAuth state storage (state -> { server, verifier, state, timestamp })
// Maps state ID to active OAuth flow data