ops-toolkit 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.commitlintrc.js +25 -0
  2. package/.env.example +25 -0
  3. package/.husky/commit-msg +4 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.opencode/README.md +320 -0
  6. package/.opencode/command/add-cmd.md +38 -0
  7. package/.opencode/command/add-pkg.md +28 -0
  8. package/.opencode/command/build.md +27 -0
  9. package/.opencode/command/debug.md +36 -0
  10. package/.opencode/command/fix.md +23 -0
  11. package/.opencode/command/release.md +28 -0
  12. package/.opencode/command/review.md +36 -0
  13. package/.opencode/command/test.md +25 -0
  14. package/.prettierrc +16 -0
  15. package/.release-it.json +29 -0
  16. package/.versionrc.js +18 -0
  17. package/.vscode/extensions.json +14 -0
  18. package/.vscode/launch.json +33 -0
  19. package/.vscode/typescript.code-snippets +61 -0
  20. package/AGENTS.md +277 -0
  21. package/CHANGELOG.md +24 -0
  22. package/QUICKSTART.md +136 -0
  23. package/README.md +143 -0
  24. package/bin/ops-toolkit.ts +92 -0
  25. package/bun.lock +1921 -0
  26. package/dist/index.js +3726 -0
  27. package/docs/DEBUGGING.md +255 -0
  28. package/docs/DEVELOPMENT_GUIDE.md +538 -0
  29. package/eslint.config.js +64 -0
  30. package/package.json +90 -0
  31. package/src/commands/deploy/index.ts +97 -0
  32. package/src/commands/monitor/index.ts +60 -0
  33. package/src/commands/system/index.ts +120 -0
  34. package/src/index.ts +82 -0
  35. package/src/types/commands.ts +41 -0
  36. package/src/types/index.ts +3 -0
  37. package/src/types/system.ts +65 -0
  38. package/src/types/ui.ts +61 -0
  39. package/src/utils/config.ts +146 -0
  40. package/src/utils/index.ts +3 -0
  41. package/src/utils/logger.ts +62 -0
  42. package/src/utils/system.ts +183 -0
  43. package/tsconfig.json +48 -0
@@ -0,0 +1,97 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { DeployOptions } from '@/types/commands';
4
+
5
+ // 创建部署命令
6
+ export const DeployCommand = new Command('deploy').description('Deployment commands').alias('dep');
7
+
8
+ // 部署应用
9
+ DeployCommand.command('app')
10
+ .description('Deploy an application')
11
+ .argument('<app>', 'Application name')
12
+ .option('-e, --env <environment>', 'Target environment', 'production')
13
+ .option('-c, --config <config>', 'Configuration file')
14
+ .option('-b, --backup', 'Create backup before deployment', true)
15
+ .option('-f, --force', 'Force deployment', false)
16
+ .option('-d, --dry-run', 'Dry run (show what would be deployed)', false)
17
+ .action(async (app: string, options: DeployOptions) => {
18
+ console.log(chalk.blue('🚀 Application Deployment'));
19
+ console.log(chalk.gray(`App: ${app}`));
20
+ console.log(chalk.gray(`Environment: ${options.env}`));
21
+
22
+ if (options.dryRun) {
23
+ console.log(chalk.yellow('🔍 Dry run mode - no actual deployment'));
24
+ }
25
+
26
+ if (options.backup) {
27
+ console.log(chalk.green('💾 Backup will be created'));
28
+ }
29
+
30
+ // TODO: 实现应用部署逻辑
31
+ console.log(chalk.yellow('⚠️ Application deployment feature coming soon...'));
32
+ });
33
+
34
+ // 回滚部署
35
+ DeployCommand.command('rollback')
36
+ .description('Rollback to previous version')
37
+ .argument('<app>', 'Application name')
38
+ .option('-v, --version <version>', 'Target version (latest if not specified)')
39
+ .option('-e, --env <environment>', 'Target environment', 'production')
40
+ .option('-f, --force', 'Force rollback', false)
41
+ .action(async (app: string, options: DeployOptions) => {
42
+ console.log(chalk.blue('🔄 Rollback Deployment'));
43
+ console.log(chalk.gray(`App: ${app}`));
44
+ console.log(chalk.gray(`Environment: ${options.env}`));
45
+
46
+ if (options.version) {
47
+ console.log(chalk.gray(`Target version: ${options.version}`));
48
+ } else {
49
+ console.log(chalk.gray('Target version: latest'));
50
+ }
51
+
52
+ // TODO: 实现回滚逻辑
53
+ console.log(chalk.yellow('⚠️ Rollback feature coming soon...'));
54
+ });
55
+
56
+ // 部署状态
57
+ DeployCommand.command('status')
58
+ .description('Check deployment status')
59
+ .argument('[app]', 'Application name (optional)')
60
+ .option('-e, --env <environment>', 'Target environment', 'production')
61
+ .option('-v, --verbose', 'Show detailed status', false)
62
+ .action(async (app: string | undefined, options: DeployOptions) => {
63
+ console.log(chalk.blue('📊 Deployment Status'));
64
+
65
+ if (app) {
66
+ console.log(chalk.gray(`App: ${app}`));
67
+ } else {
68
+ console.log(chalk.gray('All applications'));
69
+ }
70
+
71
+ console.log(chalk.gray(`Environment: ${options.env}`));
72
+
73
+ // TODO: 实现状态检查逻辑
74
+ console.log(chalk.yellow('⚠️ Deployment status feature coming soon...'));
75
+ });
76
+
77
+ // 部署历史
78
+ DeployCommand.command('history')
79
+ .description('Show deployment history')
80
+ .argument('[app]', 'Application name (optional)')
81
+ .option('-e, --env <environment>', 'Target environment', 'production')
82
+ .option('-l, --limit <number>', 'Limit number of entries', '20')
83
+ .action(async (app: string | undefined, options: DeployOptions) => {
84
+ console.log(chalk.blue('📜 Deployment History'));
85
+
86
+ if (app) {
87
+ console.log(chalk.gray(`App: ${app}`));
88
+ } else {
89
+ console.log(chalk.gray('All applications'));
90
+ }
91
+
92
+ console.log(chalk.gray(`Environment: ${options.env}`));
93
+ console.log(chalk.gray(`Limit: ${options.limit} entries`));
94
+
95
+ // TODO: 实现历史查看逻辑
96
+ console.log(chalk.yellow('⚠️ Deployment history feature coming soon...'));
97
+ });
@@ -0,0 +1,60 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import type { MonitorOptions } from '@/types/commands';
4
+
5
+ // 创建监控命令
6
+ export const MonitorCommand = new Command('monitor')
7
+ .description('System monitoring commands')
8
+ .alias('mon');
9
+
10
+ // 系统资源监控
11
+ MonitorCommand.command('system')
12
+ .description('Show system resource usage')
13
+ .option('-r, --refresh <seconds>', 'Refresh interval in seconds', '5')
14
+ .option('-v, --verbose', 'Show detailed information', false)
15
+ .option('-o, --output <format>', 'Output format (table|json)', 'table')
16
+ .action(async (_options: MonitorOptions) => {
17
+ console.log(chalk.blue('📊 System Resource Monitor'));
18
+ console.log(chalk.gray(`Refresh interval: ${_options.refresh}s`));
19
+
20
+ // TODO: 实现系统监控逻辑
21
+ console.log(chalk.yellow('⚠️ System monitoring feature coming soon...'));
22
+ });
23
+
24
+ // 进程监控
25
+ MonitorCommand.command('processes')
26
+ .description('Show running processes')
27
+ .option('-s, --sort <field>', 'Sort by field (cpu|memory|name)', 'cpu')
28
+ .option('-l, --limit <number>', 'Limit number of processes', '20')
29
+ .option('-u, --user <user>', 'Filter by user')
30
+ .action(async (_options: MonitorOptions) => {
31
+ console.log(chalk.blue('🔄 Process Monitor'));
32
+ console.log(chalk.gray(`Sort by: ${_options.sort}`));
33
+
34
+ // TODO: 实现进程监控逻辑
35
+ console.log(chalk.yellow('⚠️ Process monitoring feature coming soon...'));
36
+ });
37
+
38
+ // 网络监控
39
+ MonitorCommand.command('network')
40
+ .description('Show network statistics')
41
+ .option('-i, --interface <iface>', 'Specific network interface')
42
+ .option('-r, --realtime', 'Real-time network monitoring', false)
43
+ .action(async (_options: MonitorOptions) => {
44
+ console.log(chalk.blue('🌐 Network Monitor'));
45
+
46
+ // TODO: 实现网络监控逻辑
47
+ console.log(chalk.yellow('⚠️ Network monitoring feature coming soon...'));
48
+ });
49
+
50
+ // 磁盘监控
51
+ MonitorCommand.command('disk')
52
+ .description('Show disk usage')
53
+ .option('-a, --all', 'Show all filesystems', false)
54
+ .option('-h, --human', 'Human readable format', true)
55
+ .action(async (_options: MonitorOptions) => {
56
+ console.log(chalk.blue('💾 Disk Usage Monitor'));
57
+
58
+ // TODO: 实现磁盘监控逻辑
59
+ console.log(chalk.yellow('⚠️ Disk monitoring feature coming soon...'));
60
+ });
@@ -0,0 +1,120 @@
1
+ import { Command } from 'commander';
2
+ import chalk from 'chalk';
3
+ import { SystemOptions } from '@/types/commands';
4
+
5
+ // 创建系统命令
6
+ export const SystemCommand = new Command('system')
7
+ .description('System management commands')
8
+ .alias('sys');
9
+
10
+ // 用户管理
11
+ SystemCommand.command('users')
12
+ .description('User management')
13
+ .option('-l, --list', 'List all users', true)
14
+ .option('-a, --add <user>', 'Add new user')
15
+ .option('-d, --delete <user>', 'Delete user')
16
+ .option('-m, --modify <user>', 'Modify user')
17
+ .action(async (options: SystemOptions) => {
18
+ console.log(chalk.blue('👥 User Management'));
19
+
20
+ if (options.list) {
21
+ console.log(chalk.green('📋 Listing all users...'));
22
+ }
23
+
24
+ if (options.add) {
25
+ console.log(chalk.green(`➕ Adding user: ${options.add}`));
26
+ }
27
+
28
+ if (options.delete) {
29
+ console.log(chalk.red(`🗑️ Deleting user: ${options.delete}`));
30
+ }
31
+
32
+ if (options.modify) {
33
+ console.log(chalk.yellow(`✏️ Modifying user: ${options.modify}`));
34
+ }
35
+
36
+ // TODO: 实现用户管理逻辑
37
+ console.log(chalk.yellow('⚠️ User management feature coming soon...'));
38
+ });
39
+
40
+ // 服务管理
41
+ SystemCommand.command('services')
42
+ .description('Service management')
43
+ .option('-l, --list', 'List all services', true)
44
+ .option('-s, --service <service>', 'Specific service name')
45
+ .option('-a, --action <action>', 'Action (start|stop|restart|status)', 'status')
46
+ .action(async (options: SystemOptions) => {
47
+ console.log(chalk.blue('⚙️ Service Management'));
48
+
49
+ if (options.list) {
50
+ console.log(chalk.green('📋 Listing all services...'));
51
+ }
52
+
53
+ if (options.service) {
54
+ console.log(chalk.gray(`Service: ${options.service}`));
55
+ console.log(chalk.gray(`Action: ${options.action}`));
56
+
57
+ const actionColor =
58
+ {
59
+ start: chalk.green,
60
+ stop: chalk.red,
61
+ restart: chalk.yellow,
62
+ status: chalk.blue,
63
+ }[options.action as string] || chalk.gray;
64
+
65
+ console.log(actionColor(`🔄 ${options.action} service: ${options.service}`));
66
+ }
67
+
68
+ // TODO: 实现服务管理逻辑
69
+ console.log(chalk.yellow('⚠️ Service management feature coming soon...'));
70
+ });
71
+
72
+ // 配置管理
73
+ SystemCommand.command('config')
74
+ .description('Configuration management')
75
+ .option('-l, --list', 'List configuration files', true)
76
+ .option('-e, --edit <config>', 'Edit configuration file')
77
+ .option('-v, --view <config>', 'View configuration file')
78
+ .option('-b, --backup', 'Backup configuration', false)
79
+ .action(async (options: SystemOptions) => {
80
+ console.log(chalk.blue('⚙️ Configuration Management'));
81
+
82
+ if (options.list) {
83
+ console.log(chalk.green('📋 Listing configuration files...'));
84
+ }
85
+
86
+ if (options.edit) {
87
+ console.log(chalk.yellow(`✏️ Editing config: ${options.edit}`));
88
+ }
89
+
90
+ if (options.view) {
91
+ console.log(chalk.blue(`👁️ Viewing config: ${options.view}`));
92
+ }
93
+
94
+ if (options.backup) {
95
+ console.log(chalk.green('💾 Creating configuration backup...'));
96
+ }
97
+
98
+ // TODO: 实现配置管理逻辑
99
+ console.log(chalk.yellow('⚠️ Configuration management feature coming soon...'));
100
+ });
101
+
102
+ // 系统信息
103
+ SystemCommand.command('info')
104
+ .description('Show system information')
105
+ .option('-d, --detailed', 'Show detailed information', false)
106
+ .option('-j, --json', 'Output in JSON format', false)
107
+ .action(async (options: SystemOptions) => {
108
+ console.log(chalk.blue('💻 System Information'));
109
+
110
+ if (options.detailed) {
111
+ console.log(chalk.green('📊 Showing detailed system information...'));
112
+ }
113
+
114
+ if (options.json) {
115
+ console.log(chalk.gray('📄 Output format: JSON'));
116
+ }
117
+
118
+ // TODO: 实现系统信息显示逻辑
119
+ console.log(chalk.yellow('⚠️ System information feature coming soon...'));
120
+ });
package/src/index.ts ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import { program } from 'commander';
4
+ import chalk from 'chalk';
5
+ import figlet from 'figlet';
6
+
7
+ async function main() {
8
+ const welcomeText = figlet.textSync('ops-toolkit', {
9
+ font: 'Standard',
10
+ horizontalLayout: 'default',
11
+ verticalLayout: 'default',
12
+ });
13
+
14
+ console.log(chalk.cyan(welcomeText));
15
+
16
+ program.name('ops').description('全面的DevOps CLI工具包').version('1.0.0');
17
+
18
+ program.option('-d, --debug', '启用调试模式', false);
19
+ program.option('-v, --verbose', '启用详细日志', false);
20
+
21
+ program
22
+ .command('ui', { isDefault: true })
23
+ .description('启动交互式终端界面')
24
+ .action(async () => {
25
+ console.log(chalk.green('🚀 ops-toolkit CLI正在运行!'));
26
+ console.log(chalk.blue('📋 可用命令:'));
27
+ console.log(chalk.white(' ops monitor - 系统监控'));
28
+ console.log(chalk.white(' ops logs - 日志管理'));
29
+ console.log(chalk.white(' ops deploy - 部署工具'));
30
+ console.log(chalk.white(' ops system - 系统管理'));
31
+ console.log(chalk.gray('\n🔧 UI功能即将推出...'));
32
+ });
33
+
34
+ program
35
+ .command('monitor')
36
+ .description('系统监控')
37
+ .action(async () => {
38
+ console.log(chalk.blue('📊 系统监控'));
39
+ console.log(chalk.yellow('⚠️ 监控功能即将推出...'));
40
+ });
41
+
42
+ program
43
+ .command('logs')
44
+ .description('日志管理')
45
+ .action(async () => {
46
+ console.log(chalk.blue('📋 日志管理'));
47
+ console.log(chalk.yellow('⚠️ 日志管理功能即将推出...'));
48
+ });
49
+
50
+ program
51
+ .command('deploy')
52
+ .description('部署工具')
53
+ .action(async () => {
54
+ console.log(chalk.blue('🚀 部署工具'));
55
+ console.log(chalk.yellow('⚠️ 部署功能即将推出...'));
56
+ });
57
+
58
+ program
59
+ .command('system')
60
+ .description('系统管理')
61
+ .action(async () => {
62
+ console.log(chalk.blue('⚙️ 系统管理'));
63
+ console.log(chalk.yellow('⚠️ 系统管理功能即将推出...'));
64
+ });
65
+
66
+ program.parse();
67
+ }
68
+
69
+ process.on('uncaughtException', error => {
70
+ console.error(chalk.red('❌ 未捕获异常:'), error);
71
+ process.exit(1);
72
+ });
73
+
74
+ process.on('unhandledRejection', (reason, promise) => {
75
+ console.error(chalk.red('❌ 未处理的Promise拒绝:'), promise, '原因:', reason);
76
+ process.exit(1);
77
+ });
78
+
79
+ main().catch(error => {
80
+ console.error(chalk.red('❌ 启动应用失败:'), error);
81
+ process.exit(1);
82
+ });
@@ -0,0 +1,41 @@
1
+ // 命令相关的类型定义
2
+ export interface CommandOptions {
3
+ [key: string]: string | boolean | number | undefined;
4
+ }
5
+
6
+ export interface BaseCommand {
7
+ name: string;
8
+ description: string;
9
+ options?: CommandOptions;
10
+ action?: (options?: CommandOptions) => Promise<void> | void;
11
+ }
12
+
13
+ // 监控命令选项
14
+ export interface MonitorOptions extends CommandOptions {
15
+ refresh?: number;
16
+ verbose?: boolean;
17
+ output?: 'table' | 'json';
18
+ }
19
+
20
+ // 日志命令选项
21
+ export interface LogsOptions extends CommandOptions {
22
+ follow?: boolean;
23
+ lines?: number;
24
+ pattern?: string;
25
+ level?: 'debug' | 'info' | 'warn' | 'error';
26
+ }
27
+
28
+ // 部署命令选项
29
+ export interface DeployOptions extends CommandOptions {
30
+ env?: string;
31
+ backup?: boolean;
32
+ force?: boolean;
33
+ config?: string;
34
+ }
35
+
36
+ // 系统命令选项
37
+ export interface SystemOptions extends CommandOptions {
38
+ user?: string;
39
+ service?: string;
40
+ action?: 'start' | 'stop' | 'restart' | 'status';
41
+ }
@@ -0,0 +1,3 @@
1
+ export * from './commands';
2
+ export * from './system';
3
+ export * from './ui';
@@ -0,0 +1,65 @@
1
+ // 系统相关的类型定义
2
+ export interface SystemInfo {
3
+ hostname: string;
4
+ platform: string;
5
+ arch: string;
6
+ uptime: number;
7
+ loadAverage: number[];
8
+ totalMemory: number;
9
+ freeMemory: number;
10
+ cpus: CpuInfo[];
11
+ }
12
+
13
+ export interface CpuInfo {
14
+ model: string;
15
+ speed: number;
16
+ cores: number;
17
+ usage: number;
18
+ }
19
+
20
+ export interface MemoryInfo {
21
+ total: number;
22
+ free: number;
23
+ used: number;
24
+ cached: number;
25
+ buffers: number;
26
+ percentage: number;
27
+ }
28
+
29
+ export interface DiskInfo {
30
+ filesystem: string;
31
+ size: number;
32
+ used: number;
33
+ available: number;
34
+ percentage: number;
35
+ mountpoint: string;
36
+ }
37
+
38
+ export interface NetworkInfo {
39
+ interface: string;
40
+ ip4: string;
41
+ ip6: string;
42
+ mac: string;
43
+ speed: number;
44
+ rx: number;
45
+ tx: number;
46
+ }
47
+
48
+ export interface ProcessInfo {
49
+ pid: number;
50
+ name: string;
51
+ cpu: number;
52
+ memory: number;
53
+ status: string;
54
+ user: string;
55
+ command: string;
56
+ }
57
+
58
+ export interface ServiceInfo {
59
+ name: string;
60
+ status: 'running' | 'stopped' | 'failed' | 'unknown';
61
+ enabled: boolean;
62
+ cpu: number;
63
+ memory: number;
64
+ uptime?: number;
65
+ }
@@ -0,0 +1,61 @@
1
+ // UI相关的类型定义
2
+ export interface UIComponent {
3
+ id: string;
4
+ type: 'text' | 'table' | 'chart' | 'form' | 'layout';
5
+ props?: Record<string, any>;
6
+ children?: UIComponent[];
7
+ }
8
+
9
+ export interface LayoutProps {
10
+ direction: 'horizontal' | 'vertical';
11
+ padding?: number;
12
+ border?: boolean;
13
+ title?: string;
14
+ }
15
+
16
+ export interface TableProps {
17
+ headers: string[];
18
+ rows: string[][];
19
+ sortable?: boolean;
20
+ filterable?: boolean;
21
+ }
22
+
23
+ export interface ChartProps {
24
+ type: 'line' | 'bar' | 'pie';
25
+ data: ChartData[];
26
+ title?: string;
27
+ width?: number;
28
+ height?: number;
29
+ }
30
+
31
+ export interface ChartData {
32
+ label: string;
33
+ value: number;
34
+ color?: string;
35
+ }
36
+
37
+ export interface FormField {
38
+ name: string;
39
+ label: string;
40
+ type: 'text' | 'password' | 'select' | 'checkbox' | 'radio';
41
+ required?: boolean;
42
+ options?: string[];
43
+ defaultValue?: any;
44
+ }
45
+
46
+ export interface Theme {
47
+ primary: string;
48
+ secondary: string;
49
+ success: string;
50
+ warning: string;
51
+ error: string;
52
+ background: string;
53
+ foreground: string;
54
+ }
55
+
56
+ export interface AppState {
57
+ currentPage: string;
58
+ loading: boolean;
59
+ error?: string;
60
+ data: Record<string, any>;
61
+ }
@@ -0,0 +1,146 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ import { Logger } from './logger';
5
+
6
+ // 配置管理类
7
+ export class Config {
8
+ private static configDir = path.join(os.homedir(), '.ops-toolkit');
9
+ private static configFile = path.join(Config.configDir, 'config.json');
10
+ private static defaultConfig = {
11
+ monitor: {
12
+ refreshInterval: 5000,
13
+ showProcesses: true,
14
+ maxProcesses: 20,
15
+ },
16
+ logs: {
17
+ defaultPath: '/var/log',
18
+ maxLines: 1000,
19
+ follow: false,
20
+ },
21
+ deploy: {
22
+ defaultEnv: 'production',
23
+ backupEnabled: true,
24
+ confirmBeforeDeploy: true,
25
+ },
26
+ system: {
27
+ showHiddenServices: false,
28
+ cacheTimeout: 30000,
29
+ },
30
+ ui: {
31
+ theme: 'default',
32
+ animations: true,
33
+ sound: false,
34
+ },
35
+ };
36
+
37
+ // 获取配置
38
+ static get(key?: string): any {
39
+ try {
40
+ if (!fs.existsSync(this.configFile)) {
41
+ this.createDefaultConfig();
42
+ }
43
+
44
+ const configData = fs.readFileSync(this.configFile, 'utf8');
45
+ const config = JSON.parse(configData);
46
+
47
+ if (key) {
48
+ return this.getNestedValue(config, key);
49
+ }
50
+
51
+ return config;
52
+ } catch (error) {
53
+ Logger.error(`Failed to read config: ${error}`);
54
+ return this.defaultConfig;
55
+ }
56
+ }
57
+
58
+ // 设置配置
59
+ static set(key: string, value: any): void {
60
+ try {
61
+ const config = this.get();
62
+ this.setNestedValue(config, key, value);
63
+
64
+ fs.writeFileSync(this.configFile, JSON.stringify(config, null, 2));
65
+ Logger.success(`Configuration updated: ${key}`);
66
+ } catch (error) {
67
+ Logger.error(`Failed to set config: ${error}`);
68
+ }
69
+ }
70
+
71
+ // 重置配置
72
+ static reset(): void {
73
+ try {
74
+ this.createDefaultConfig();
75
+ Logger.success('Configuration reset to defaults');
76
+ } catch (error) {
77
+ Logger.error(`Failed to reset config: ${error}`);
78
+ }
79
+ }
80
+
81
+ // 创建默认配置
82
+ private static createDefaultConfig(): void {
83
+ try {
84
+ if (!fs.existsSync(this.configDir)) {
85
+ fs.mkdirSync(this.configDir, { recursive: true });
86
+ }
87
+
88
+ fs.writeFileSync(this.configFile, JSON.stringify(this.defaultConfig, null, 2));
89
+ } catch (error) {
90
+ Logger.error(`Failed to create default config: ${error}`);
91
+ }
92
+ }
93
+
94
+ // 获取嵌套值
95
+ private static getNestedValue(obj: any, key: string): any {
96
+ return key.split('.').reduce((current, keyPart) => {
97
+ return current && current[keyPart];
98
+ }, obj);
99
+ }
100
+
101
+ // 设置嵌套值
102
+ private static setNestedValue(obj: any, key: string, value: any): void {
103
+ const keys = key.split('.');
104
+ const lastKey = keys.pop()!;
105
+
106
+ const target = keys.reduce((current, keyPart) => {
107
+ if (!current[keyPart]) {
108
+ current[keyPart] = {};
109
+ }
110
+ return current[keyPart];
111
+ }, obj);
112
+
113
+ target[lastKey] = value;
114
+ }
115
+
116
+ // 验证配置
117
+ static validate(): boolean {
118
+ try {
119
+ const config = this.get();
120
+
121
+ // 基本验证
122
+ if (!config.monitor || !config.logs || !config.deploy) {
123
+ return false;
124
+ }
125
+
126
+ // 类型验证
127
+ if (typeof config.monitor.refreshInterval !== 'number') {
128
+ return false;
129
+ }
130
+
131
+ return true;
132
+ } catch {
133
+ return false;
134
+ }
135
+ }
136
+
137
+ // 获取配置目录
138
+ static getConfigDir(): string {
139
+ return this.configDir;
140
+ }
141
+
142
+ // 获取配置文件路径
143
+ static getConfigFile(): string {
144
+ return this.configFile;
145
+ }
146
+ }
@@ -0,0 +1,3 @@
1
+ export * from './system';
2
+ export * from './logger';
3
+ export * from './config';