File tree Expand file tree Collapse file tree 5 files changed +107
-2
lines changed
Expand file tree Collapse file tree 5 files changed +107
-2
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+ const path = require ( 'path' ) ;
3+
4+ const packageJson = require ( '../package.json' ) ;
5+ const versionInfo = {
6+ version : packageJson . version ,
7+ buildTime : new Date ( ) . toISOString ( ) ,
8+ source : 'release'
9+ } ;
10+
11+ // Read the current version.ts file
12+ const versionTsPath = path . join ( __dirname , '../src/config/version.ts' ) ;
13+ let versionTsContent = fs . readFileSync ( versionTsPath , 'utf8' ) ;
14+
15+ // Replace the versionData object
16+ const newVersionData = `let versionData: VersionInfo = {
17+ version: '${ versionInfo . version } ',
18+ buildTime: '${ versionInfo . buildTime } ',
19+ source: '${ versionInfo . source } '
20+ };` ;
21+
22+ // Use regex to replace the versionData assignment
23+ versionTsContent = versionTsContent . replace (
24+ / l e t v e r s i o n D a t a : V e r s i o n I n f o = \{ [ \s \S ] * ?\} ; / ,
25+ newVersionData
26+ ) ;
27+
28+ // Write the updated file
29+ fs . writeFileSync ( versionTsPath , versionTsContent ) ;
30+ console . log ( `Updated version.ts to version ${ versionInfo . version } ` ) ;
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ export { registerStartCommand } from './start';
44export { registerStopCommand } from './stop' ;
55export { registerStatusCommand } from './status' ;
66export { registerConfigCommand } from './config' ;
7+ export { registerVersionCommand } from './version' ;
Original file line number Diff line number Diff line change 1+ import { Command } from 'commander' ;
2+ import chalk from 'chalk' ;
3+ import { getGatewayVersion } from '../config/version' ;
4+
5+ export function registerVersionCommand ( program : Command ) {
6+ program
7+ . command ( 'version' )
8+ . description ( 'Display DeployStack Gateway version information' )
9+ . action ( async ( ) => {
10+ try {
11+ const versionInfo = getGatewayVersion ( ) ;
12+
13+ console . log ( chalk . cyan ( 'DeployStack Gateway' ) ) ;
14+ console . log ( chalk . green ( `Version: ${ versionInfo . version } ` ) ) ;
15+ console . log ( chalk . gray ( `Build Time: ${ versionInfo . buildTime } ` ) ) ;
16+ console . log ( chalk . gray ( `Source: ${ versionInfo . source } ` ) ) ;
17+
18+ // Add some additional info
19+ console . log ( ) ;
20+ console . log ( chalk . yellow ( 'Environment:' ) ) ;
21+ console . log ( chalk . gray ( `Node.js: ${ process . version } ` ) ) ;
22+ console . log ( chalk . gray ( `Platform: ${ process . platform } ${ process . arch } ` ) ) ;
23+
24+ } catch ( error ) {
25+ console . error ( chalk . red ( 'Error getting version information:' ) , error ) ;
26+ process . exit ( 1 ) ;
27+ }
28+ } ) ;
29+ }
Original file line number Diff line number Diff line change 1+ import * as fs from 'fs' ;
2+ import * as path from 'path' ;
3+
4+ export interface VersionInfo {
5+ version : string ;
6+ buildTime : string ;
7+ source : string ;
8+ }
9+
10+ // This will be replaced by the build script
11+ let versionData : VersionInfo = {
12+ version : '0.1.0' ,
13+ buildTime : '2025-07-26T14:30:00.000Z' ,
14+ source : 'development'
15+ } ;
16+
17+ // Try to read from package.json as fallback for development
18+ try {
19+ const packageJsonPath = path . join ( __dirname , '../../package.json' ) ;
20+ if ( fs . existsSync ( packageJsonPath ) ) {
21+ const packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf8' ) ) ;
22+ versionData = {
23+ version : packageJson . version || '0.1.0' ,
24+ buildTime : new Date ( ) . toISOString ( ) ,
25+ source : 'package.json'
26+ } ;
27+ }
28+ } catch {
29+ // Use static fallback if package.json can't be read
30+ }
31+
32+ export const getGatewayVersion = ( ) : VersionInfo => {
33+ return {
34+ version : versionData . version || '0.1.0' ,
35+ buildTime : versionData . buildTime ,
36+ source : versionData . source
37+ } ;
38+ } ;
39+
40+ export const getVersionString = ( ) : string => {
41+ return getGatewayVersion ( ) . version ;
42+ } ;
Original file line number Diff line number Diff line change 22
33import { Command } from 'commander' ;
44import chalk from 'chalk' ;
5+ import { getVersionString } from './config/version' ;
56import {
67 registerLoginCommand ,
78 registerLogoutCommand ,
89 registerStartCommand ,
910 registerStopCommand ,
1011 registerStatusCommand ,
11- registerConfigCommand
12+ registerConfigCommand ,
13+ registerVersionCommand
1214} from './commands' ;
1315
1416const program = new Command ( ) ;
1517
1618program
1719 . name ( 'deploystack' )
1820 . description ( 'DeployStack Gateway - Local secure proxy for MCP servers' )
19- . version ( '0.1.0' ) ;
21+ . version ( getVersionString ( ) ) ;
2022
2123// Register all commands
2224registerLoginCommand ( program ) ;
@@ -25,6 +27,7 @@ registerStartCommand(program);
2527registerStopCommand ( program ) ;
2628registerStatusCommand ( program ) ;
2729registerConfigCommand ( program ) ;
30+ registerVersionCommand ( program ) ;
2831
2932// Show help if no command is provided
3033if ( process . argv . length <= 2 ) {
You can’t perform that action at this time.
0 commit comments