- Add action display to UPS status showing trigger mode, thresholds, and delays
- Create displayGroupsStatus() method to show group information
- Display group mode, member UPS devices, and group actions
- Integrate groups section into status command output
Major type safety improvements throughout the codebase:
- Updated DEFAULT_CONFIG version to 4.2
- Replaced 'any' with proper types in systemd.ts:
* displaySingleUpsStatus now uses IUpsConfig and NupstSnmp types
* Fixed legacy config handling to use proper IUpsConfig format
* Removed inline 'any' type annotations
- Replaced 'any' with proper types in daemon.ts:
* emergencyUps now properly typed as { ups: IUpsConfig, status: ISnmpUpsStatus }
* Exported IUpsStatus interface for reuse
* Added ISnmpUpsStatus import to disambiguate from daemon's IUpsStatus
- Replaced 'any' with Record<string, unknown> in migration system:
* Updated BaseMigration abstract class signatures
* Updated MigrationRunner.run() signature
* Updated migration-v4.0-to-v4.1.ts to use proper types
* Migrations use Record<string, unknown> because they deal with
unknown config schemas that are being upgraded
Benefits:
- TypeScript now catches type errors at compile time
- Would have caught the ups.thresholds bug earlier
- Better IDE autocomplete and type checking
- More maintainable and self-documenting code
The status command was still trying to access ups.thresholds.battery which
no longer exists in v4.1+ configs. Thresholds are now in the actions array.
Changes:
- Updated displaySingleUpsStatus() to get thresholds from actions
- Finds first action with thresholds defined for battery symbol display
- Shows success/warning symbol only if threshold is defined
This fixes 'Cannot read properties of undefined (reading battery)' error
when running nupst status on v4.1+ configs.
- 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
- Add process.stdin.destroy() after rl.close() in all interactive commands
to properly release stdin and allow process to exit cleanly
- Replace raw console.log with logger methods throughout CLI handlers
- Convert manual box drawing to logger.logBox() in daemon.ts
- Standardize menu formatting with logger.info() and logger.dim()
- Improve migration output to only show when migrations actually run
Fixes issue where process would not exit after "Setup complete!" message
due to stdin keeping the event loop alive.
Removed the last remaining ugly ASCII boxes:
- Version info box (┌─┐│└┘) that appeared at top
- Async version check box that ended randomly in middle
- Configuration error box
Now status output is 100% clean and beautiful with just colored text:
● Service: active (running)
PID: 9120 Memory: 45.7M CPU: 190ms
UPS Devices (2):
⚠ Test UPS (SNMP v1) - On Battery
Battery: 100% ✓ Runtime: 48 min
Host: 192.168.187.140:161
◯ Test UPS (SNMP v3) - Unknown
Battery: 0% ⚠ Runtime: 0 min
Host: 192.168.187.140:161
No boxes, just beautiful colored output with symbols!
Bumped to v4.1.0 to mark completion of beautiful CLI feature.
Replaced all ASCII box characters (┌─┐│└┘) with modern, clean colored
output using the existing color theme and symbols.
Changes in ts/systemd.ts:
- displayServiceStatus(): Parse systemctl output and show key info
with colored symbols (● for running, ○ for stopped)
- displaySingleUpsStatus(): Clean output with battery/runtime colors
- Green >60%, yellow 30-60%, red <30% for battery
- Power status with colored symbols and text
- Clean indented layout without boxes
Example new output:
● Service: active (running)
PID: 7606 Memory: 41.5M CPU: 279ms
UPS Devices (2):
● Test UPS (SNMP v1) - Online
Battery: 100% ✓ Runtime: 48 min
Host: 192.168.187.140:161
Much cleaner and more readable than ASCII boxes!
Critical fixes for v3→v4 migration:
1. install.sh: Auto-update systemd service file during migration
- Calls 'nupst service enable' before restarting service
- Only when migrating from v3 (OLD_NODE_INSTALL=1)
- Ensures service file has correct v4 paths
2. ts/systemd.ts: Fix hardcoded v3 paths in service template
- ExecStart: /opt/nupst/bin/nupst daemon-start (v3, broken)
→ /usr/local/bin/nupst service start-daemon (v4, correct)
- Description: Updated to 'Deno-powered UPS Monitoring Tool'
- Added RestartSec=10 (prevent rapid restart loops)
- Removed NODE_ENV=production (not needed for Deno)
- WorkingDirectory: /tmp → /opt/nupst
Without these fixes:
- Service fails to start after migration
- Service file points to non-existent /opt/nupst/bin/nupst
- Users must manually run 'nupst service enable'
Discovered via Docker migration testing in test/manualdocker/
- Remove async from functions that don't use await
- Change return types from Promise<void> to void for synchronous functions
- Fixes all 8 require-await lint warnings
- Reduces total lint warnings from 63 to 55
Comprehensive type safety improvements across all CLI handlers and daemon:
**Error handling type fixes:**
- Add 'error instanceof Error' checks before accessing error.message throughout
- Fix all error/retryError/stdError/upsError type assertions
- Replace direct error.message with proper type guards
**Switch case improvements:**
- Wrap case block declarations in braces to satisfy deno-lint
- Fix no-case-declarations warnings in CLI command handlers
**Null/undefined safety:**
- Add checks for config.snmp and config.thresholds before access
- Fix IUpsStatus lastStatusChange to handle undefined with default value
- Add proper null checks in legacy configuration paths
**Type annotations:**
- Add explicit type annotations to lambda parameters (groupId, updateAvailable, etc.)
- Add TUpsModel type cast for 'cyberpower' default
- Import and use INupstConfig type where needed
**Parameter type fixes:**
- Fix implicit 'any' type errors in array callbacks
- Add type annotations to filter/find/map parameters
Files modified:
- ts/cli.ts: config.snmp/thresholds null checks, unused error variable fixes
- ts/cli/group-handler.ts: 4 error.message fixes + 2 parameter type annotations
- ts/cli/service-handler.ts: 3 error.message fixes
- ts/cli/ups-handler.ts: 5 error.message fixes + config checks + TUpsModel import
- ts/daemon.ts: 8 error.message fixes + IUpsStatus lastStatusChange fix + updateAvailable type
- ts/nupst.ts: 1 error.message fix
- ts/systemd.ts: 5 error.message fixes + parameter type annotation
All tests passing (3/3 SNMP tests + 10/10 logger tests)
Type check: ✓ No errors
- Created deno.json configuration
- Updated all imports to use npm:net-snmp@3.20.0
- Changed all Node.js built-in imports to node: specifiers
- Updated all .js extensions to .ts in imports
- Created mod.ts as Deno entry point
- Ready for Phase 3: CLI simplification