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
- 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.