diff --git a/ts/daemon.ts b/ts/daemon.ts index 828c28d..95873e2 100644 --- a/ts/daemon.ts +++ b/ts/daemon.ts @@ -5,8 +5,9 @@ import { exec, execFile } from 'node:child_process'; import { promisify } from 'node:util'; import { NupstSnmp } from './snmp/manager.ts'; import type { ISnmpConfig } from './snmp/types.ts'; -import { logger } from './logger.ts'; +import { logger, type ITableColumn } from './logger.ts'; import { MigrationRunner } from './migrations/index.ts'; +import { theme, symbols, getBatteryColor, getRuntimeColor, formatPowerStatus } from './colors.ts'; const execAsync = promisify(exec); const execFileAsync = promisify(execFile); @@ -310,7 +311,6 @@ export class NupstDaemon { * Log the loaded configuration settings */ private logConfigLoaded(): void { - const { theme } = require('./colors.ts'); logger.log(''); logger.logBoxTitle('Configuration Loaded', 70, 'success'); @@ -457,7 +457,6 @@ export class NupstDaemon { // Check if power status changed if (currentStatus && currentStatus.powerStatus !== status.powerStatus) { - const { theme, formatPowerStatus } = require('./colors.ts'); logger.log(''); logger.logBoxTitle(`Power Status Change: ${ups.name}`, 60, 'warning'); logger.logBoxLine(`Previous: ${formatPowerStatus(currentStatus.powerStatus)}`); @@ -493,9 +492,6 @@ export class NupstDaemon { logger.logBoxEnd(); logger.log(''); - // Import theme and symbols for coloring - const { theme, symbols, getBatteryColor, getRuntimeColor, formatPowerStatus } = require('./colors.ts'); - // Build table data const columns: Array<{ header: string; key: string; align?: 'left' | 'right'; color?: (val: string) => string }> = [ { header: 'UPS Name', key: 'name', align: 'left', color: theme.highlight }, @@ -799,8 +795,6 @@ export class NupstDaemon { const MAX_MONITORING_TIME = 5 * 60 * 1000; // Max 5 minutes of monitoring const startTime = Date.now(); - const { theme, getBatteryColor, getRuntimeColor } = require('./colors.ts'); - logger.log(''); logger.logBoxTitle('Shutdown Monitoring Active', 60, 'warning'); logger.logBoxLine(`Emergency threshold: ${EMERGENCY_RUNTIME_THRESHOLD} minutes runtime`);