126 Commits

Author SHA1 Message Date
88ad16c638 chore: bump version to 4.0.3
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 6s
Release / build-and-release (push) Successful in 46s
CI / Build All Platforms (push) Successful in 51s
v4.0.3
2025-10-19 20:41:39 +00:00
016681b77b feat(migrations): add migration system for v3→v4 config format
- Create abstract BaseMigration class with order, shouldRun(), migrate()
- Add MigrationRunner to execute migrations in order
- Add Migration v1→v2 (snmp → upsDevices)
- Add Migration v3→v4 (upsList → upsDevices)
- Update INupstConfig with version field
- Update loadConfig() to run migrations automatically
- Update saveConfig() to ensure version field and remove legacy fields
- Update Docker test scripts to use real UPS data from .nogit/env.json
- Remove colors.bright (not available in @std/fmt/colors)

Config migrations allow users to jump versions (e.g., v1→v4) with all
intermediate migrations running automatically. Version field tracks
config format for future migrations.
2025-10-19 20:41:09 +00:00
49f7a7da8b Merge pull request 'migration/deno-v4' (#1) from migration/deno-v4 into main
Some checks failed
CI / Type Check & Lint (push) Failing after 6s
CI / Build Test (Current Platform) (push) Successful in 6s
CI / Build All Platforms (push) Successful in 47s
Reviewed-on: #1
2025-10-19 15:14:03 +00:00
f8269a1cb7 feat(cli): add beautiful colored output and fix daemon exit bug
Some checks failed
CI / Type Check & Lint (push) Failing after 6s
CI / Build Test (Current Platform) (push) Successful in 6s
Release / build-and-release (push) Successful in 44s
CI / Build All Platforms (push) Successful in 50s
CI / Type Check & Lint (pull_request) Failing after 5s
CI / Build Test (Current Platform) (pull_request) Successful in 5s
CI / Build All Platforms (pull_request) Successful in 49s
Major improvements:
- Created color theme system (ts/colors.ts) with ANSI colors
- Enhanced logger with colors, table formatting, and styled boxes
- Fixed daemon exit bug - now stays running when no UPS configured
- Added config hot-reload with file watcher for live updates
- Beautified CLI help output with color-coded commands
- Added showcase test demonstrating all output features
- Fixed ANSI code handling for perfect table/box alignment

Features:
- Color-coded messages (success=green, error=red, warning=yellow, info=cyan)
- Status symbols (●○◐◯ for running/stopped/starting/unknown)
- Battery level colors (green>60%, yellow 30-60%, red<30%)
- Table formatting with auto-sizing and column alignment
- Styled boxes (success, error, warning, info styles)
- Hot-reload: daemon watches config file and reloads automatically
- Idle mode: daemon stays alive when no devices, checks periodically

Daemon improvements:
- No longer exits when no UPS devices configured
- Enters idle monitoring loop waiting for config
- File watcher detects config changes in real-time
- Auto-reloads and starts monitoring when devices added
- Logs warnings instead of errors for missing devices

Technical fixes:
- Strip ANSI codes when calculating text width for alignment
- Use visible length for padding calculations in tables and boxes
- Properly handle colored text in table cells and box lines

Breaking changes: None (backward compatible)
v4.0.2
2025-10-19 15:08:30 +00:00
b37e1aae6c chore(release): bump version to 4.0.1
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 5s
Release / build-and-release (push) Successful in 43s
CI / Build All Platforms (push) Successful in 51s
v4.0.1
2025-10-19 14:50:39 +00:00
7076829747 fix(install): detect enabled services even when failed/stopped during migration
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 49s
Previously only checked 'is-active' which missed failed/stopped services.
Now checks 'is-enabled' OR 'is-active' to ensure service file gets updated
during v3→v4 migration regardless of service state.
2025-10-19 14:43:44 +00:00
1387ca262b fix(migration): update systemd service file during v3→v4 migration
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 47s
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/
2025-10-19 14:37:32 +00:00
684f034aee ci(release): auto-delete existing release before creating new one
All checks were successful
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 46s
- Checks if release already exists for the tag
- Automatically deletes conflicting release if found
- Prevents duplicate/stale releases when recreating tags
- Ensures fresh binaries when tag is recreated

This fixes the issue where recreating a tag would keep old
release with outdated binaries.
2025-10-19 14:33:58 +00:00
a63ec16d63 fix(version): make version programmatic by reading from deno.json
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 8s
CI / Build All Platforms (push) Successful in 48s
Release / build-and-release (push) Successful in 37s
- Replace hardcoded version in 00_commitinfo_data.ts
- Now dynamically imports deno.json and reads version
- Version will auto-update when deno.json is changed
- Fixes version showing 3.1.2 instead of 4.0.0

test: add Docker test scripts for v3→v4 migration
- 01-setup-v3-container.sh: Creates systemd container with v3
- 02-test-v3-to-v4-migration.sh: Tests migration (now fixed)
- 03-cleanup.sh: Removes test container
- README.md: Complete documentation

Tested: Version now correctly shows 4.0.0
v4.0.0
2025-10-19 14:26:53 +00:00
85f34cf96a ci: revert to single artifact with .zip extension in name
All checks were successful
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 6s
CI / Build All Platforms (push) Successful in 50s
- Changed back to single artifact containing all binaries
- Named 'nupst-binaries.zip' to clarify it's a ZIP container
- Contains all 5 platform binaries + SHA256SUMS.txt
2025-10-19 14:09:23 +00:00
4d28614e08 ci: upload each binary as separate artifact for easier download
All checks were successful
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 6s
CI / Build All Platforms (push) Successful in 1m5s
- Split single 'nupst-binaries' artifact into 6 individual artifacts
- Each platform binary now shows as separate downloadable item in UI
- Artifacts: nupst-linux-x64, nupst-linux-arm64, nupst-macos-x64,
  nupst-macos-arm64, nupst-windows-x64.exe, SHA256SUMS.txt
2025-10-19 14:05:01 +00:00
567c7be7c5 fix(ci): downgrade upload-artifact from v4 to v3 for Gitea compatibility
All checks were successful
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 5s
CI / Build All Platforms (push) Successful in 59s
- actions/upload-artifact@v4 not supported on Gitea
- Error: GHES (GitHub Enterprise Server) compatibility issue
- Using v3 which is compatible with Gitea Actions
2025-10-19 14:01:25 +00:00
a897a7c780 ci: enable artifact builds for all commits on all branches
Some checks failed
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 6s
CI / Build All Platforms (push) Failing after 24s
- Remove conditional from build-all job in ci.yml
- Previously only ran on main branch and tags
- Now runs on every commit to any branch
- Allows testing binaries from feature branches via artifacts API
2025-10-19 13:59:27 +00:00
accf137216 update readme 2025-10-19 13:54:45 +00:00
c3441946cb fix(ci): replace non-existent gitea-release-action with Gitea API calls
All checks were successful
CI / Build All Platforms (Tag/Main only) (push) Has been skipped
CI / Type Check & Lint (push) Successful in 7s
CI / Build Test (Current Platform) (push) Successful in 6s
Release / build-and-release (push) Successful in 37s
- Use curl to directly call Gitea API for release creation
- Upload binaries as release assets using API
- Fixes authentication error in CI workflow
2025-10-19 13:38:24 +00:00
37ccbf58fd fix(lint): remove unnecessary async keywords from synchronous functions
Some checks failed
CI / Build All Platforms (Tag/Main only) (push) Has been skipped
CI / Type Check & Lint (push) Successful in 5s
CI / Build Test (Current Platform) (push) Successful in 5s
Release / build-and-release (push) Failing after 2s
- 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
2025-10-19 13:25:01 +00:00
071ded9c41 style: configure deno fmt to use single quotes
All checks were successful
CI / Build All Platforms (Tag/Main only) (push) Has been skipped
CI / Type Check & Lint (push) Successful in 6s
CI / Build Test (Current Platform) (push) Successful in 6s
- Add singleQuote: true to deno.json fmt configuration
- Reformat all files with single quotes using deno fmt
2025-10-19 13:14:18 +00:00
b935087d50 ci(release): add automatic cleanup of old binaries and releases
- Clean old binaries from dist/binaries before each build
- Automatically delete old releases, keeping only the last 3
- Prevents accumulation of stale binaries and release storage bloat
2025-10-19 13:12:18 +00:00
e1383097b2 fix: update migration references in installer and README 2025-10-19 13:05:51 +00:00
dff0ea610b fix types
All checks were successful
CI / Build All Platforms (Tag/Main only) (push) Has been skipped
CI / Type Check & Lint (push) Successful in 7s
CI / Build Test (Current Platform) (push) Successful in 7s
2025-10-19 12:57:17 +00:00
4faa10c494 feat(install): add proper update/migration support for existing installations
Some checks failed
CI / Build All Platforms (Tag/Main only) (push) Has been skipped
CI / Type Check & Lint (push) Failing after 41s
CI / Build Test (Current Platform) (push) Successful in 40s
Enhanced install.sh to properly handle updates and migrations:

**Update Detection & Service Management:**
- Detect old Node.js-based installations (v3.x) via package.json/node_modules
- Stop running service before updating binary
- Restart service after successful update if it was running
- Preserve /etc/nupst/config.json during updates

**Migration from v3.x to v4.0:**
- Clean up old Node.js installation files:
  - node_modules/, vendor/, dist_ts/ directories
  - package.json, package-lock.json, pnpm-lock.yaml
  - tsconfig.json, setup.sh, bin/ directory
- Inform user about migration with helpful feedback
- Link to migration guide documentation

**User Experience Improvements:**
- Show different messages for new installs vs updates
- Inform about v3.x → v4.0 migration when detected
- Display migration guide link for old installations
- Show service restart status
- Provide context-aware next steps based on config presence

**Safety Features:**
- Ask for confirmation before replacing existing installation (interactive mode)
- Preserve user configuration in /etc/nupst/
- Handle service state properly (stop → update → restart)
- Graceful cleanup with error suppression (|| true)

This ensures seamless updates from any version (including v3.x Node.js installs)
to v4.0+ Deno-based binaries without manual intervention or data loss.
2025-10-19 10:23:14 +00:00
c2d39cc19a fix: resolve all TypeScript type errors across codebase for Deno strict mode
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
2025-10-18 21:07:57 +00:00
9ccbbbdc37 fix(snmp): resolve TypeScript type errors for Deno strict mode
- Add Buffer import from node:buffer to manager.ts and types.ts
- Fix error handling type assertions (error/retryError/stdError as unknown)
- Add explicit type annotation to byte parameter in isPrintableAscii check
- All tests now passing (3 SNMP tests + 10 logger tests)
2025-10-18 16:17:01 +00:00
1705ffe2be test: switch to Deno native testing framework
- Remove tapbundle and @git.zone/tstest dependency
- Use Deno.test() and @std/assert for all tests
- Update test imports to use jsr:@std/assert
- All 10 logger tests passing with native Deno test runner
- Simplified test configuration in deno.json
- Tests are now completely dependency-free (only standard library)
2025-10-18 16:01:38 +00:00
968cbbd8fc test: update tests for Deno with @git.zone/tstest/tapbundle
- Update tapbundle imports from @push.rocks to @git.zone/tstest
- Change all test file imports from .js to .ts extensions
- Tests verified working with Deno runtime
- All 10 logger tests passing
- SNMP tests ready for Deno execution
2025-10-18 15:58:20 +00:00
a2ae9960b6 docs: update documentation for v4.0.0 release
- Rewrite README.md for Deno-based binary distribution
  - Update installation instructions for binary downloads
  - Document new subcommand CLI structure
  - Add troubleshooting, security, and development sections
  - Remove Node.js references, add Deno information

- Add comprehensive v4.0.0 changelog entry
  - Document all breaking changes
  - List new features and technical improvements
  - Provide migration guide and command mapping
  - Include technical details and benefits

- Create MIGRATION.md guide for v3.x to v4.0 upgrade
  - Step-by-step migration instructions
  - Configuration compatibility information
  - Troubleshooting common migration issues
  - Rollback procedures
  - Post-migration best practices
2025-10-18 13:33:46 +00:00
df6a44d5d9 feat: complete migration to Deno with automated releases
- Remove old Node.js infrastructure (package.json, tsconfig.json, bin/nupst launcher, setup.sh)
- Update install.sh to download pre-compiled binaries from Gitea releases
- Add Gitea Actions CI/CD workflows:
  - ci.yml: Type checking, linting, and build verification
  - release.yml: Automated binary compilation and release on tags
- Update .gitignore for Deno-focused project structure
- Binary-based distribution requires no dependencies or build steps
2025-10-18 13:20:23 +00:00
9efcc4b437 Phase 3: Reorganize CLI with subcommand structure
Major Changes:
- Reorganized commands into logical groups (service, ups, group)
- Added new subcommand structure:
  - nupst service <enable|disable|start|stop|restart|status|logs|start-daemon>
  - nupst ups <add|edit|remove|list|test>
  - nupst group <add|edit|remove|list>
  - nupst config [show]
- Added --version/-v flag support
- Added restart subcommand for service
- Added command aliases (ls, rm)
- Renamed delete() to remove() in handlers
- Maintained backward compatibility with deprecation warnings
- Updated all help messages to reflect new structure
- Added showVersion(), showServiceHelp(), showUpsHelp() methods
- Fixed readline imports to use node:readline

Breaking Changes:
- Old command format (e.g. 'nupst add') is deprecated
- Users should migrate to new format (e.g. 'nupst ups add')
- Backward compatibility maintained with warnings for now
2025-10-18 12:36:35 +00:00
5903ae71be Phase 4: Add compilation scripts and successful cross-platform build
- Created scripts/compile-all.sh for all 5 platforms
- Successfully compiled binaries for:
  - Linux x64 (345MB)
  - Linux ARM64 (340MB)
  - macOS x64 (337MB)
  - macOS ARM64 (334MB)
  - Windows x64 (345MB)
- Added --no-check flag to bypass npm:net-snmp type issues
- Updated .gitignore for Deno artifacts
- Tested compiled binary - working successfully

Note: Binaries embed npm:net-snmp with native bindings
Warning from Deno about cross-platform node_modules compatibility noted
2025-10-18 12:25:16 +00:00
a649c598ad Phase 1-2: Migrate to Deno with npm: and node: specifiers
- 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
2025-10-18 11:59:55 +00:00
5f4f3ecbc3 start migration to deno v3.1.2-pre-deno-migration 2025-10-18 09:14:41 +00:00
806f81c6a0 3.1.2 v3.1.2 2025-03-28 22:30:01 +00:00
88e353eec6 fix(cli/ups-handler): Improve UPS device listing table formatting for better column alignment 2025-03-28 22:30:01 +00:00
80ff1b1230 3.1.1 v3.1.1 2025-03-28 22:27:21 +00:00
1075335497 fix(cli): Improve table header formatting in group and UPS listings 2025-03-28 22:27:21 +00:00
eafb5207a4 3.1.0 v3.1.0 2025-03-28 22:12:01 +00:00
9969e0f703 feat(cli): Refactor CLI commands to use dedicated handlers for UPS, group, and service management 2025-03-28 22:12:01 +00:00
ac4b2c95f3 3.0.1 v3.0.1 2025-03-28 16:32:08 +00:00
c593d76ead fix(cli): Simplify UPS ID generation by removing the redundant promptForUniqueUpsId function in the CLI module and replacing it with the shortId helper. 2025-03-28 16:32:08 +00:00
01ccf2d080 3.0.0 v3.0.0 2025-03-28 16:19:43 +00:00
0e55f22dad BREAKING CHANGE(core): Add multi-UPS support and group management; update CLI, configuration and documentation to support multiple UPS devices with group modes 2025-03-28 16:19:43 +00:00
bd3042de25 2.6.17 v2.6.17 2025-03-26 22:43:19 +00:00
456351ca34 fix(logger): Preserve logbox width after logBoxEnd so that subsequent logBoxLine calls continue using the set width. 2025-03-26 22:43:18 +00:00
00afa317ef 2.6.16 v2.6.16 2025-03-26 22:38:24 +00:00
45ee8208b5 fix(cli): Improve CLI logging consistency by replacing direct console output with unified logger calls. 2025-03-26 22:38:24 +00:00
39bf3e2239 2.6.15 v2.6.15 2025-03-26 22:28:38 +00:00
f3de3f0618 fix(logger): Replace direct console logging with unified logger interface for consistent formatting 2025-03-26 22:28:38 +00:00
03056d279d update 2025-03-26 22:19:24 +00:00
f860f39e59 2.6.14 v2.6.14 2025-03-26 18:15:17 +00:00
fa4516de3b fix(systemd): Shorten closing log divider in systemd service installation output for consistent formatting. 2025-03-26 18:15:17 +00:00