From d14ba1dd6522c8e4f9bfa59a0b918af6bf138b18 Mon Sep 17 00:00:00 2001 From: Juergen Kunz Date: Mon, 20 Oct 2025 01:01:06 +0000 Subject: [PATCH] feat(status): display version and update status in nupst status command - Add version display at the top of status output - Check for available updates and notify user - Show "Up to date" or "Update available" with version - Display before service and UPS status information - Improves user awareness of software version and updates Bumps version to 4.1.4 --- deno.json | 2 +- test/{showcase.ts => test.showcase.ts} | 0 ts/systemd.ts | 44 +++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) rename test/{showcase.ts => test.showcase.ts} (100%) diff --git a/deno.json b/deno.json index 5ced2ea..1948998 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@serve.zone/nupst", - "version": "4.1.3", + "version": "4.1.4", "exports": "./mod.ts", "tasks": { "dev": "deno run --allow-all mod.ts", diff --git a/test/showcase.ts b/test/test.showcase.ts similarity index 100% rename from test/showcase.ts rename to test/test.showcase.ts diff --git a/ts/systemd.ts b/ts/systemd.ts index 7602342..312791e 100644 --- a/ts/systemd.ts +++ b/ts/systemd.ts @@ -134,6 +134,45 @@ WantedBy=multi-user.target * Get status of the systemd service and UPS * @param debugMode Whether to enable debug mode for SNMP */ + /** + * Display version information and update status + * @private + */ + private async displayVersionInfo(): Promise { + try { + const nupst = this.daemon.getNupstSnmp().getNupst(); + const version = nupst.getVersion(); + + // Check for updates + const updateAvailable = await nupst.checkForUpdates(); + + // Display version info + if (updateAvailable) { + const updateStatus = nupst.getUpdateStatus(); + logger.log(''); + logger.log( + `${theme.dim('NUPST')} ${theme.dim('v' + version)} ${symbols.warning} ${theme.statusWarning(`Update available: v${updateStatus.latestVersion}`)}`, + ); + logger.log(` ${theme.dim('Run')} ${theme.command('sudo nupst update')} ${theme.dim('to upgrade')}`); + } else { + logger.log(''); + logger.log( + `${theme.dim('NUPST')} ${theme.dim('v' + version)} ${symbols.success} ${theme.success('Up to date')}`, + ); + } + } catch (error) { + // If version check fails, show at least the current version + try { + const nupst = this.daemon.getNupstSnmp().getNupst(); + const version = nupst.getVersion(); + logger.log(''); + logger.log(`${theme.dim('NUPST')} ${theme.dim('v' + version)}`); + } catch (_innerError) { + // Silently fail if we can't even get the version + } + } + } + public async getStatus(debugMode: boolean = false): Promise { try { // Enable debug mode if requested @@ -144,7 +183,10 @@ WantedBy=multi-user.target this.daemon.getNupstSnmp().enableDebug(); } - // Check if config exists first + // Display version and update status first + await this.displayVersionInfo(); + + // Check if config exists try { await this.checkConfigExists(); } catch (error) {