Compare commits

...

10 Commits

6 changed files with 43 additions and 15 deletions

View File

@ -1,5 +1,33 @@
# Changelog # Changelog
## 2025-03-26 - 2.6.14 - fix(systemd)
Shorten closing log divider in systemd service installation output for consistent formatting.
- Replaced the overly long footer with a shorter one in ts/systemd.ts.
- This change improves log readability without affecting functionality.
## 2025-03-26 - 2.6.13 - fix(cli)
Fix CLI update output box formatting
- Adjusted the closing box line in the update process log messages for consistent visual formatting
## 2025-03-26 - 2.6.12 - fix(systemd)
Adjust logging border in systemd service installation output
- Updated the closing border line for consistent output formatting in ts/systemd.ts
## 2025-03-26 - 2.6.11 - fix(cli, systemd)
Adjust log formatting for consistent output in CLI and systemd commands
- Fixed spacing issues in service installation and status log messages in the systemd module.
- Revised output formatting in the CLI to improve message clarity.
## 2025-03-26 - 2.6.10 - fix(daemon)
Adjust console log box formatting for consistent output in daemon status messages
- Updated closing box borders to align properly in configuration error, periodic updates, and UPS status logs
- Improved visual consistency in log messages
## 2025-03-26 - 2.6.9 - fix(cli) ## 2025-03-26 - 2.6.9 - fix(cli)
Improve console output formatting for status banners and logging messages Improve console output formatting for status banners and logging messages

View File

@ -1,6 +1,6 @@
{ {
"name": "@serve.zone/nupst", "name": "@serve.zone/nupst",
"version": "2.6.9", "version": "2.6.14",
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices", "description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@serve.zone/nupst', name: '@serve.zone/nupst',
version: '2.6.9', version: '2.6.14',
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices' description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
} }

View File

@ -471,11 +471,11 @@ Options:
} }
console.log('│ Update completed successfully!'); console.log('│ Update completed successfully!');
console.log('└──────────────────────────────────────────┘'); console.log('└─────────────────────────────────────────────┘');
} catch (error) { } catch (error) {
console.error('│ Error during update process:'); console.error('│ Error during update process:');
console.error(`${error.message}`); console.error(`${error.message}`);
console.error('└──────────────────────────────────────────┘'); console.error('└─────────────────────────────────────────────┘');
process.exit(1); process.exit(1);
} }
} catch (error) { } catch (error) {
@ -919,7 +919,7 @@ Options:
if (isActive) { if (isActive) {
// Service is running, restart it // Service is running, restart it
console.log('┌─ Service Update ─────────────────────────┐'); console.log('┌─ Service Update ─────────────────────────┐');
console.log('│ Configuration has changed.'); console.log('│ Configuration has changed.');
console.log('│ Restarting NUPST service to apply changes...'); console.log('│ Restarting NUPST service to apply changes...');
@ -939,7 +939,7 @@ Options:
console.log('│ sudo systemctl restart nupst.service'); console.log('│ sudo systemctl restart nupst.service');
} }
console.log('└──────────────────────────────────────────┘'); console.log('└──────────────────────────────────────────┘');
} }
} catch (error) { } catch (error) {
// Ignore errors checking service status // Ignore errors checking service status

View File

@ -125,7 +125,7 @@ export class NupstDaemon {
console.error('┌─ Configuration Error ─────────────────────┐'); console.error('┌─ Configuration Error ─────────────────────┐');
console.error(`${message}`); console.error(`${message}`);
console.error('│ Please run \'nupst setup\' first to create a configuration.'); console.error('│ Please run \'nupst setup\' first to create a configuration.');
console.error('└──────────────────────────────────────────┘'); console.error('└──────────────────────────────────────────┘');
} }
/** /**
@ -196,7 +196,7 @@ export class NupstDaemon {
console.log(`│ Battery: ${this.config.thresholds.battery}%`); console.log(`│ Battery: ${this.config.thresholds.battery}%`);
console.log(`│ Runtime: ${this.config.thresholds.runtime} minutes`); console.log(`│ Runtime: ${this.config.thresholds.runtime} minutes`);
console.log(`│ Check Interval: ${this.config.checkInterval / 1000} seconds`); console.log(`│ Check Interval: ${this.config.checkInterval / 1000} seconds`);
console.log('└──────────────────────────────────────────┘'); console.log('└────────────────────────────────────────────┘');
} }
/** /**
@ -228,7 +228,7 @@ export class NupstDaemon {
if (status.powerStatus !== lastStatus) { if (status.powerStatus !== lastStatus) {
console.log('┌─ Power Status Change ─────────────────────┐'); console.log('┌─ Power Status Change ─────────────────────┐');
console.log(`│ Status changed: ${lastStatus}${status.powerStatus}`); console.log(`│ Status changed: ${lastStatus}${status.powerStatus}`);
console.log('└──────────────────────────────────────────┘'); console.log('└──────────────────────────────────────────┘');
lastStatus = status.powerStatus; lastStatus = status.powerStatus;
lastLogTime = currentTime; // Reset log timer when status changes lastLogTime = currentTime; // Reset log timer when status changes
} }
@ -239,7 +239,7 @@ export class NupstDaemon {
console.log(`│ Timestamp: ${timestamp}`); console.log(`│ Timestamp: ${timestamp}`);
console.log(`│ Power Status: ${status.powerStatus}`); console.log(`│ Power Status: ${status.powerStatus}`);
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`); console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
console.log('└──────────────────────────────────────────┘'); console.log('└──────────────────────────────────────────┘');
lastLogTime = currentTime; lastLogTime = currentTime;
} }
@ -267,7 +267,7 @@ export class NupstDaemon {
batteryCapacity: number, batteryCapacity: number,
batteryRuntime: number batteryRuntime: number
}): Promise<void> { }): Promise<void> {
console.log('┌─ UPS Status ────────────────────────────┐'); console.log('┌─ UPS Status ────────────────────────────┐');
console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`); console.log(`│ Battery: ${status.batteryCapacity}% | Runtime: ${status.batteryRuntime} min`);
console.log('└──────────────────────────────────────────┘'); console.log('└──────────────────────────────────────────┘');

View File

@ -66,7 +66,7 @@ WantedBy=multi-user.target
// Write the service file // Write the service file
await fs.writeFile(this.serviceFilePath, this.serviceTemplate); await fs.writeFile(this.serviceFilePath, this.serviceTemplate);
console.log('┌─ Service Installation ─────────────────────┐'); console.log('┌─ Service Installation ─────────────────────┐');
console.log(`│ Service file created at ${this.serviceFilePath}`); console.log(`│ Service file created at ${this.serviceFilePath}`);
// Reload systemd daemon // Reload systemd daemon
@ -76,7 +76,7 @@ WantedBy=multi-user.target
// Enable the service // Enable the service
execSync('systemctl enable nupst.service'); execSync('systemctl enable nupst.service');
console.log('│ Service enabled to start on boot'); console.log('│ Service enabled to start on boot');
console.log('└──────────────────────────────────────────┘'); console.log('└─────────────────────────────────────────────┘');
} catch (error) { } catch (error) {
if (error.message === 'Configuration not found') { if (error.message === 'Configuration not found') {
// Just rethrow the error as the message has already been displayed // Just rethrow the error as the message has already been displayed
@ -97,9 +97,9 @@ WantedBy=multi-user.target
await this.checkConfigExists(); await this.checkConfigExists();
execSync('systemctl start nupst.service'); execSync('systemctl start nupst.service');
console.log('┌─ Service Status ─────────────────────────┐'); console.log('┌─ Service Status ───────────────────────────┐');
console.log('│ NUPST service started successfully'); console.log('│ NUPST service started successfully');
console.log('└──────────────────────────────────────────┘'); console.log('└────────────────────────────────────────────┘');
} catch (error) { } catch (error) {
if (error.message === 'Configuration not found') { if (error.message === 'Configuration not found') {
// Exit with error code since configuration is required // Exit with error code since configuration is required