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
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@serve.zone/nupst",
|
"name": "@serve.zone/nupst",
|
||||||
"version": "4.1.3",
|
"version": "4.1.4",
|
||||||
"exports": "./mod.ts",
|
"exports": "./mod.ts",
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"dev": "deno run --allow-all mod.ts",
|
"dev": "deno run --allow-all mod.ts",
|
||||||
|
@@ -134,6 +134,45 @@ WantedBy=multi-user.target
|
|||||||
* Get status of the systemd service and UPS
|
* Get status of the systemd service and UPS
|
||||||
* @param debugMode Whether to enable debug mode for SNMP
|
* @param debugMode Whether to enable debug mode for SNMP
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* Display version information and update status
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
private async displayVersionInfo(): Promise<void> {
|
||||||
|
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<void> {
|
public async getStatus(debugMode: boolean = false): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// Enable debug mode if requested
|
// Enable debug mode if requested
|
||||||
@@ -144,7 +183,10 @@ WantedBy=multi-user.target
|
|||||||
this.daemon.getNupstSnmp().enableDebug();
|
this.daemon.getNupstSnmp().enableDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if config exists first
|
// Display version and update status first
|
||||||
|
await this.displayVersionInfo();
|
||||||
|
|
||||||
|
// Check if config exists
|
||||||
try {
|
try {
|
||||||
await this.checkConfigExists();
|
await this.checkConfigExists();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Reference in New Issue
Block a user