@mks2508/better-logger 0.0.2-alpha.2 â 0.3.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.
- package/.claude/settings.local.json +18 -2
- package/.github/workflows/ci-quality.yml +357 -0
- package/.github/workflows/docs-demo.yml +119 -0
- package/.github/workflows/releases-core.yml +512 -0
- package/.github/workflows/releases-full.yml +582 -0
- package/.github/{workflows â workflows-backup}/ci.yml +12 -110
- package/.github/workflows-backup/nightly.yml +196 -0
- package/.github/workflows-backup/release-optimized.yml +373 -0
- package/.release-notes-0.2.0.md +129 -0
- package/.yamllint +28 -0
- package/CHANGELOG.json +783 -0
- package/CLAUDE.md +92 -1
- package/README.md +198 -490
- package/bun.lock +323 -0
- package/demo.html +9 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/Logger.d.ts +272 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/Logger.js +680 -0
- package/dist/ScopedLogger.d.ts +126 -0
- package/dist/ScopedLogger.d.ts.map +1 -0
- package/dist/ScopedLogger.js +234 -0
- package/dist/chunks/Logger-BpeuYIxR.js +2 -0
- package/dist/chunks/Logger-BpeuYIxR.js.map +1 -0
- package/dist/chunks/Logger-Didxtr23.js +3275 -0
- package/dist/chunks/Logger-Didxtr23.js.map +1 -0
- package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
- package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
- package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
- package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
- package/dist/chunks/environment-Bxbnw4pd.js +544 -0
- package/dist/chunks/environment-Bxbnw4pd.js.map +1 -0
- package/dist/chunks/environment-Dm66zOML.js +4 -0
- package/dist/chunks/environment-Dm66zOML.js.map +1 -0
- package/dist/chunks/formatting-C0riPC5_.js +95 -0
- package/dist/chunks/formatting-C0riPC5_.js.map +1 -0
- package/dist/chunks/formatting-DNCAV66-.js +2 -0
- package/dist/chunks/formatting-DNCAV66-.js.map +1 -0
- package/dist/cli/CommandProcessor.d.ts +103 -0
- package/dist/cli/CommandProcessor.d.ts.map +1 -0
- package/dist/cli/CommandProcessor.js +184 -0
- package/dist/cli/commands/ConfigCommand.d.ts +17 -0
- package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/cli/commands/ConfigCommand.js +88 -0
- package/dist/cli/commands/ExportCommand.d.ts +51 -0
- package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
- package/dist/cli/commands/ExportCommand.js +243 -0
- package/dist/cli/commands/HistoryCommand.d.ts +50 -0
- package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
- package/dist/cli/commands/HistoryCommand.js +96 -0
- package/dist/cli/commands/StatusCommand.d.ts +33 -0
- package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
- package/dist/cli/commands/StatusCommand.js +93 -0
- package/dist/cli/commands/ThemeCommand.d.ts +33 -0
- package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
- package/dist/cli/commands/ThemeCommand.js +79 -0
- package/dist/cli/help.d.ts +15 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +118 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +46 -0
- package/dist/constants.d.ts +122 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +159 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +134 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +315 -242
- package/dist/core.js.map +1 -1
- package/dist/example.d.ts +18 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +154 -0
- package/dist/exports-module.d.ts +203 -0
- package/dist/exports-module.d.ts.map +1 -0
- package/dist/exports-module.js +260 -0
- package/dist/exports.cjs +1 -1
- package/dist/exports.cjs.map +1 -1
- package/dist/exports.js +5 -4
- package/dist/exports.js.map +1 -1
- package/dist/handlers/AnalyticsLogHandler.d.ts +11 -0
- package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
- package/dist/handlers/AnalyticsLogHandler.js +19 -0
- package/dist/handlers/ExportLogHandler.d.ts +103 -0
- package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
- package/dist/handlers/ExportLogHandler.js +516 -0
- package/dist/handlers/FileLogHandler.d.ts +36 -0
- package/dist/handlers/FileLogHandler.d.ts.map +1 -0
- package/dist/handlers/FileLogHandler.js +156 -0
- package/dist/handlers/RemoteLogHandler.d.ts +14 -0
- package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
- package/dist/handlers/RemoteLogHandler.js +37 -0
- package/dist/handlers/index.d.ts +8 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -103
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +139 -0
- package/dist/styling/LogStyleBuilder.d.ts +149 -0
- package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
- package/dist/styling/LogStyleBuilder.js +289 -0
- package/dist/styling/SemanticStyles.d.ts +181 -0
- package/dist/styling/SemanticStyles.d.ts.map +1 -0
- package/dist/styling/SemanticStyles.js +339 -0
- package/dist/styling/SmartPresets.d.ts +25 -0
- package/dist/styling/SmartPresets.d.ts.map +1 -0
- package/dist/styling/SmartPresets.js +276 -0
- package/dist/styling/StyleBuilder.d.ts +140 -0
- package/dist/styling/StyleBuilder.d.ts.map +1 -0
- package/dist/styling/StyleBuilder.js +280 -0
- package/dist/styling/banners.d.ts +45 -0
- package/dist/styling/banners.d.ts.map +1 -0
- package/dist/styling/banners.js +155 -0
- package/dist/styling/index.d.ts +10 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/index.js +9 -0
- package/dist/styling/themes.d.ts +10 -0
- package/dist/styling/themes.d.ts.map +1 -0
- package/dist/styling/themes.js +231 -0
- package/dist/styling-module.d.ts +185 -0
- package/dist/styling-module.d.ts.map +1 -0
- package/dist/styling-module.js +199 -0
- package/dist/styling.cjs +1 -1
- package/dist/styling.cjs.map +1 -1
- package/dist/styling.js +6 -6
- package/dist/styling.js.map +1 -1
- package/dist/types/Logger.d.ts +268 -0
- package/dist/types/Logger.d.ts.map +1 -0
- package/dist/types/ScopedLogger.d.ts +123 -0
- package/dist/types/ScopedLogger.d.ts.map +1 -0
- package/dist/types/cli/CommandProcessor.d.ts +100 -0
- package/dist/types/cli/CommandProcessor.d.ts.map +1 -0
- package/dist/types/cli/commands/ConfigCommand.d.ts +14 -0
- package/dist/types/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/ExportCommand.d.ts +48 -0
- package/dist/types/cli/commands/ExportCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/HistoryCommand.d.ts +47 -0
- package/dist/types/cli/commands/HistoryCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/StatusCommand.d.ts +30 -0
- package/dist/types/cli/commands/StatusCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/ThemeCommand.d.ts +30 -0
- package/dist/types/cli/commands/ThemeCommand.d.ts.map +1 -0
- package/dist/types/cli/help.d.ts +12 -0
- package/dist/types/cli/help.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +15 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/constants.d.ts +119 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/core.d.ts +125 -211
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +13 -0
- package/dist/types/example.d.ts +18 -0
- package/dist/types/example.d.ts.map +1 -0
- package/dist/types/exports-module.d.ts +196 -0
- package/dist/types/exports-module.d.ts.map +1 -0
- package/dist/types/handlers/AnalyticsLogHandler.d.ts +8 -0
- package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/ExportLogHandler.d.ts +100 -0
- package/dist/types/handlers/ExportLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/FileLogHandler.d.ts +33 -0
- package/dist/types/handlers/FileLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/RemoteLogHandler.d.ts +11 -0
- package/dist/types/handlers/RemoteLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/index.d.ts +8 -0
- package/dist/types/handlers/index.d.ts.map +1 -0
- package/dist/types/handlers.d.ts +88 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +4 -0
- package/dist/types/index.d.ts +7 -675
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/main.d.ts +2 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/styling/LogStyleBuilder.d.ts +146 -0
- package/dist/types/styling/LogStyleBuilder.d.ts.map +1 -0
- package/dist/types/styling/SemanticStyles.d.ts +178 -0
- package/dist/types/styling/SemanticStyles.d.ts.map +1 -0
- package/dist/types/styling/SmartPresets.d.ts +22 -0
- package/dist/types/styling/SmartPresets.d.ts.map +1 -0
- package/dist/types/styling/StyleBuilder.d.ts +140 -0
- package/dist/types/styling/StyleBuilder.d.ts.map +1 -0
- package/dist/types/styling/banners.d.ts +42 -0
- package/dist/types/styling/banners.d.ts.map +1 -0
- package/dist/types/styling/index.d.ts +10 -0
- package/dist/types/styling/index.d.ts.map +1 -0
- package/dist/types/styling/themes.d.ts +7 -0
- package/dist/types/styling/themes.d.ts.map +1 -0
- package/dist/types/styling-module.d.ts +178 -0
- package/dist/types/styling-module.d.ts.map +1 -0
- package/dist/types/types/core.d.ts +125 -0
- package/dist/types/types/core.d.ts.map +1 -0
- package/dist/types/types/handlers.d.ts +85 -0
- package/dist/types/types/handlers.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/environment.d.ts +47 -0
- package/dist/types/utils/environment.d.ts.map +1 -0
- package/dist/types/utils/formatting.d.ts +37 -0
- package/dist/types/utils/formatting.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/opentui-detection.d.ts +34 -0
- package/dist/types/utils/opentui-detection.d.ts.map +1 -0
- package/dist/types/utils/output.d.ts +41 -0
- package/dist/types/utils/output.d.ts.map +1 -0
- package/dist/types/utils/stackTrace.d.ts +6 -0
- package/dist/types/utils/stackTrace.d.ts.map +1 -0
- package/dist/types/utils/timestamps.d.ts +20 -0
- package/dist/types/utils/timestamps.d.ts.map +1 -0
- package/dist/utils/environment.d.ts +47 -0
- package/dist/utils/environment.d.ts.map +1 -0
- package/dist/utils/environment.js +85 -0
- package/dist/utils/formatting.d.ts +40 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +117 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/opentui-detection.d.ts +34 -0
- package/dist/utils/opentui-detection.d.ts.map +1 -0
- package/dist/utils/opentui-detection.js +116 -0
- package/dist/utils/output.d.ts +44 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +150 -0
- package/dist/utils/stackTrace.d.ts +9 -0
- package/dist/utils/stackTrace.d.ts.map +1 -0
- package/dist/utils/stackTrace.js +81 -0
- package/dist/utils/timestamps.d.ts +20 -0
- package/dist/utils/timestamps.d.ts.map +1 -0
- package/dist/utils/timestamps.js +71 -0
- package/docs/API.md +691 -0
- package/docs/CORE.md +10 -10
- package/docs/DEVELOPMENT.md +731 -0
- package/docs/PACKAGES.md +244 -0
- package/docs/_config.yml +36 -0
- package/docs/index.md +179 -0
- package/examples/README.md +208 -0
- package/examples/basic-logging.js +75 -0
- package/examples/data-export.js +234 -0
- package/examples/package.json +16 -0
- package/examples/performance-timing.js +170 -0
- package/examples/simplified-api.js +124 -0
- package/examples/styling-themes.js +207 -0
- package/package.json +37 -21
- package/packages/core/package.json +57 -0
- package/packages/exports/package.json +41 -0
- package/packages/nodejs-opentui/README.md +232 -0
- package/packages/nodejs-opentui/package.json +72 -0
- package/packages/nodejs-opentui/src/LogRenderer.ts +171 -0
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +178 -0
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +131 -0
- package/packages/nodejs-opentui/src/index.ts +133 -0
- package/packages/nodejs-opentui/src/types.ts +158 -0
- package/packages/nodejs-opentui/tsconfig.json +20 -0
- package/packages/styling/package.json +41 -0
- package/project-utils/README.md +172 -0
- package/project-utils/auto-release-gemini.ts +1193 -0
- package/project-utils/auto-release-ui.ts +1329 -0
- package/project-utils/commit-generator.ts +1385 -0
- package/project-utils/commit-ui.ts +264 -0
- package/project-utils/git-utils.ts +199 -0
- package/project-utils/github-release-manager.ts +466 -0
- package/project-utils/project-config.ts +260 -0
- package/project-utils/prompt-templates.js +345 -0
- package/project-utils/prompt-templates.ts +422 -0
- package/project-utils/version-manager.ts +1078 -0
- package/src/Logger.ts +251 -16
- package/src/ScopedLogger.ts +262 -0
- package/src/cli/CommandProcessor.ts +173 -2
- package/src/cli/commands/HistoryCommand.ts +117 -0
- package/src/cli/index.ts +12 -0
- package/src/constants.ts +84 -2
- package/src/core.ts +119 -46
- package/src/example.ts +4 -4
- package/src/exports-module.ts +1 -1
- package/src/handlers/ExportLogHandler.ts +141 -0
- package/src/handlers/FileLogHandler.ts +144 -5
- package/src/index.ts +1 -1
- package/src/main.ts +3 -3
- package/src/styling/LogStyleBuilder.ts +355 -0
- package/src/styling/SemanticStyles.ts +380 -0
- package/src/styling/SmartPresets.ts +288 -0
- package/src/styling/StyleBuilder.ts +14 -0
- package/src/styling/index.ts +16 -1
- package/src/styling-module.ts +1 -1
- package/src/types/core.ts +60 -0
- package/src/types/index.ts +6 -0
- package/src/utils/environment.ts +94 -0
- package/src/utils/formatting.ts +142 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/opentui-detection.ts +138 -0
- package/src/utils/output.ts +66 -8
- package/test-core-browser.html +237 -0
- package/test-core-node.js +63 -0
- package/tests/test-conflict-resolution.ts +391 -0
- package/tests/validate-workflows.sh +131 -0
- package/tests/yaml-autofix.sh +146 -0
- package/vite.config.ts +189 -50
- package/.npmrc.bak +0 -1
- package/dist/chunks/Logger-BQhMKy_T.js +0 -2
- package/dist/chunks/Logger-BQhMKy_T.js.map +0 -1
- package/dist/chunks/Logger-BrFKFZcD.js +0 -978
- package/dist/chunks/Logger-BrFKFZcD.js.map +0 -1
- package/dist/chunks/core-2opW4Pi3.js +0 -194
- package/dist/chunks/core-2opW4Pi3.js.map +0 -1
- package/dist/chunks/core-DyugwSYZ.js +0 -4
- package/dist/chunks/core-DyugwSYZ.js.map +0 -1
- package/dist/chunks/exports-BNP3R7dp.js +0 -421
- package/dist/chunks/exports-BNP3R7dp.js.map +0 -1
- package/dist/chunks/exports-U1xLBXrY.js +0 -2
- package/dist/chunks/exports-U1xLBXrY.js.map +0 -1
- package/dist/chunks/styling-DhUDzwlE.js +0 -654
- package/dist/chunks/styling-DhUDzwlE.js.map +0 -1
- package/dist/chunks/styling-tmRDI28D.js +0 -2
- package/dist/chunks/styling-tmRDI28D.js.map +0 -1
- package/dist/types/exports.d.ts +0 -600
- package/dist/types/styling.d.ts +0 -751
- package/src/Logger.ts.backup +0 -1684
- /package/.github/{workflows â workflows-backup}/release.yml +0 -0
|
@@ -11,20 +11,101 @@ export interface ICommand {
|
|
|
11
11
|
name: string;
|
|
12
12
|
description: string;
|
|
13
13
|
usage: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
aliases?: string[];
|
|
14
16
|
execute(args: string, logger: Logger): void | Promise<void>;
|
|
15
17
|
}
|
|
16
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Plugin interface for extending CLI functionality
|
|
21
|
+
*/
|
|
22
|
+
export interface ICLIPlugin {
|
|
23
|
+
name: string;
|
|
24
|
+
version: string;
|
|
25
|
+
description: string;
|
|
26
|
+
commands: ICommand[];
|
|
27
|
+
initialize?(processor: CommandProcessor, logger: Logger): void;
|
|
28
|
+
cleanup?(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Command history entry
|
|
33
|
+
*/
|
|
34
|
+
interface HistoryEntry {
|
|
35
|
+
command: string;
|
|
36
|
+
timestamp: Date;
|
|
37
|
+
success: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
17
40
|
/**
|
|
18
41
|
* CLI command processor
|
|
19
42
|
*/
|
|
20
43
|
export class CommandProcessor {
|
|
21
44
|
private commands: Map<string, ICommand> = new Map();
|
|
45
|
+
private aliases: Map<string, string> = new Map();
|
|
46
|
+
private plugins: Map<string, ICLIPlugin> = new Map();
|
|
47
|
+
private history: HistoryEntry[] = [];
|
|
48
|
+
private maxHistorySize: number = 100;
|
|
49
|
+
private isInteractiveMode: boolean = false;
|
|
22
50
|
|
|
23
51
|
/**
|
|
24
52
|
* Register a command
|
|
25
53
|
*/
|
|
26
54
|
registerCommand(command: ICommand): void {
|
|
27
55
|
this.commands.set(command.name, command);
|
|
56
|
+
|
|
57
|
+
// Register aliases
|
|
58
|
+
if (command.aliases) {
|
|
59
|
+
for (const alias of command.aliases) {
|
|
60
|
+
this.aliases.set(alias, command.name);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Register a plugin
|
|
67
|
+
*/
|
|
68
|
+
registerPlugin(plugin: ICLIPlugin, logger?: Logger): void {
|
|
69
|
+
if (this.plugins.has(plugin.name)) {
|
|
70
|
+
throw new Error(`Plugin ${plugin.name} is already registered`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.plugins.set(plugin.name, plugin);
|
|
74
|
+
|
|
75
|
+
// Register plugin commands
|
|
76
|
+
for (const command of plugin.commands) {
|
|
77
|
+
this.registerCommand(command);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Initialize plugin
|
|
81
|
+
if (plugin.initialize && logger) {
|
|
82
|
+
plugin.initialize(this, logger);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Unregister a plugin
|
|
88
|
+
*/
|
|
89
|
+
unregisterPlugin(pluginName: string): void {
|
|
90
|
+
const plugin = this.plugins.get(pluginName);
|
|
91
|
+
if (!plugin) return;
|
|
92
|
+
|
|
93
|
+
// Remove plugin commands
|
|
94
|
+
for (const command of plugin.commands) {
|
|
95
|
+
this.commands.delete(command.name);
|
|
96
|
+
if (command.aliases) {
|
|
97
|
+
for (const alias of command.aliases) {
|
|
98
|
+
this.aliases.delete(alias);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Cleanup plugin
|
|
104
|
+
if (plugin.cleanup) {
|
|
105
|
+
plugin.cleanup();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.plugins.delete(pluginName);
|
|
28
109
|
}
|
|
29
110
|
|
|
30
111
|
/**
|
|
@@ -38,7 +119,70 @@ export class CommandProcessor {
|
|
|
38
119
|
* Get a specific command
|
|
39
120
|
*/
|
|
40
121
|
getCommand(name: string): ICommand | undefined {
|
|
41
|
-
|
|
122
|
+
// Check direct command name
|
|
123
|
+
let command = this.commands.get(name);
|
|
124
|
+
if (command) return command;
|
|
125
|
+
|
|
126
|
+
// Check aliases
|
|
127
|
+
const aliasTarget = this.aliases.get(name);
|
|
128
|
+
if (aliasTarget) {
|
|
129
|
+
return this.commands.get(aliasTarget);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get command history
|
|
137
|
+
*/
|
|
138
|
+
getHistory(): HistoryEntry[] {
|
|
139
|
+
return [...this.history];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Clear command history
|
|
144
|
+
*/
|
|
145
|
+
clearHistory(): void {
|
|
146
|
+
this.history = [];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Get registered plugins
|
|
151
|
+
*/
|
|
152
|
+
getPlugins(): ICLIPlugin[] {
|
|
153
|
+
return Array.from(this.plugins.values());
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Enter interactive mode
|
|
158
|
+
*/
|
|
159
|
+
enterInteractiveMode(logger: Logger): void {
|
|
160
|
+
this.isInteractiveMode = true;
|
|
161
|
+
logger.info('đ§ Interactive CLI mode activated. Type /exit to quit, /help for commands.');
|
|
162
|
+
|
|
163
|
+
// Set up browser console listener for interactive commands
|
|
164
|
+
if (typeof window !== 'undefined') {
|
|
165
|
+
this.setupBrowserInteractiveMode(logger);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Exit interactive mode
|
|
171
|
+
*/
|
|
172
|
+
exitInteractiveMode(): void {
|
|
173
|
+
this.isInteractiveMode = false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Setup browser interactive mode
|
|
178
|
+
*/
|
|
179
|
+
private setupBrowserInteractiveMode(logger: Logger): void {
|
|
180
|
+
// Add global CLI function for browser usage
|
|
181
|
+
(window as any).cli = (commandString: string) => {
|
|
182
|
+
return this.processCommand(`/${commandString}`, logger);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
logger.info('đĄ Use cli("command") to execute CLI commands in browser console.');
|
|
42
186
|
}
|
|
43
187
|
|
|
44
188
|
/**
|
|
@@ -47,6 +191,7 @@ export class CommandProcessor {
|
|
|
47
191
|
async processCommand(commandString: string, logger: Logger): Promise<void> {
|
|
48
192
|
if (!commandString.startsWith('/')) {
|
|
49
193
|
logger.error('Invalid command. Commands must start with /');
|
|
194
|
+
this.addToHistory(commandString, false);
|
|
50
195
|
return;
|
|
51
196
|
}
|
|
52
197
|
|
|
@@ -54,16 +199,42 @@ export class CommandProcessor {
|
|
|
54
199
|
const commandName = parts[0] || '';
|
|
55
200
|
const args = parts.slice(1).join(' ');
|
|
56
201
|
|
|
57
|
-
const command = this.
|
|
202
|
+
const command = this.getCommand(commandName);
|
|
58
203
|
if (!command) {
|
|
59
204
|
logger.error(`Unknown command: ${commandName}. Type /help for available commands.`);
|
|
205
|
+
|
|
206
|
+
// Suggest similar commands
|
|
207
|
+
const suggestions = this.getSuggestions(commandName);
|
|
208
|
+
if (suggestions.length > 0) {
|
|
209
|
+
logger.info(`đ Did you mean: ${suggestions.slice(0, 3).join(', ')}?`);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
this.addToHistory(commandString, false);
|
|
60
213
|
return;
|
|
61
214
|
}
|
|
62
215
|
|
|
63
216
|
try {
|
|
64
217
|
await command.execute(args || '', logger);
|
|
218
|
+
this.addToHistory(commandString, true);
|
|
65
219
|
} catch (error) {
|
|
66
220
|
logger.error(`Command '${commandName}' failed:`, error);
|
|
221
|
+
this.addToHistory(commandString, false);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Add command to history
|
|
227
|
+
*/
|
|
228
|
+
private addToHistory(command: string, success: boolean): void {
|
|
229
|
+
this.history.unshift({
|
|
230
|
+
command,
|
|
231
|
+
timestamp: new Date(),
|
|
232
|
+
success
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Limit history size
|
|
236
|
+
if (this.history.length > this.maxHistorySize) {
|
|
237
|
+
this.history = this.history.slice(0, this.maxHistorySize);
|
|
67
238
|
}
|
|
68
239
|
}
|
|
69
240
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview History management commands for CLI
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { ICommand } from '../CommandProcessor.js';
|
|
6
|
+
import type { Logger } from '../../Logger.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Show command history
|
|
10
|
+
*/
|
|
11
|
+
export class HistoryCommand implements ICommand {
|
|
12
|
+
name = 'history';
|
|
13
|
+
description = 'Show command execution history';
|
|
14
|
+
usage = '/history [limit] - Show recent commands (default: 10)';
|
|
15
|
+
category = 'system';
|
|
16
|
+
aliases = ['hist', 'h'];
|
|
17
|
+
|
|
18
|
+
execute(args: string, logger: Logger): void {
|
|
19
|
+
const processor = (logger as any).cliProcessor;
|
|
20
|
+
if (!processor) {
|
|
21
|
+
logger.error('CLI processor not available');
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const limit = parseInt(args) || 10;
|
|
26
|
+
const history = processor.getHistory().slice(0, limit);
|
|
27
|
+
|
|
28
|
+
if (history.length === 0) {
|
|
29
|
+
logger.info('đ No command history available');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
logger.info(`đ Last ${history.length} commands:`);
|
|
34
|
+
|
|
35
|
+
history.forEach((entry: any, index: number) => {
|
|
36
|
+
const status = entry.success ? 'â
' : 'â';
|
|
37
|
+
const time = entry.timestamp.toLocaleTimeString();
|
|
38
|
+
logger.info(`${status} [${time}] ${entry.command}`);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Clear command history
|
|
45
|
+
*/
|
|
46
|
+
export class ClearHistoryCommand implements ICommand {
|
|
47
|
+
name = 'clearhistory';
|
|
48
|
+
description = 'Clear command execution history';
|
|
49
|
+
usage = '/clearhistory - Remove all command history';
|
|
50
|
+
category = 'system';
|
|
51
|
+
aliases = ['clrhist'];
|
|
52
|
+
|
|
53
|
+
execute(args: string, logger: Logger): void {
|
|
54
|
+
const processor = (logger as any).cliProcessor;
|
|
55
|
+
if (!processor) {
|
|
56
|
+
logger.error('CLI processor not available');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
processor.clearHistory();
|
|
61
|
+
logger.success('đī¸ Command history cleared');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Interactive mode command
|
|
67
|
+
*/
|
|
68
|
+
export class InteractiveCommand implements ICommand {
|
|
69
|
+
name = 'interactive';
|
|
70
|
+
description = 'Enter interactive CLI mode';
|
|
71
|
+
usage = '/interactive - Start interactive command mode';
|
|
72
|
+
category = 'system';
|
|
73
|
+
aliases = ['i', 'repl'];
|
|
74
|
+
|
|
75
|
+
execute(args: string, logger: Logger): void {
|
|
76
|
+
const processor = (logger as any).cliProcessor;
|
|
77
|
+
if (!processor) {
|
|
78
|
+
logger.error('CLI processor not available');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
processor.enterInteractiveMode(logger);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Plugin management command
|
|
88
|
+
*/
|
|
89
|
+
export class PluginsCommand implements ICommand {
|
|
90
|
+
name = 'plugins';
|
|
91
|
+
description = 'List loaded CLI plugins';
|
|
92
|
+
usage = '/plugins - Show all registered plugins';
|
|
93
|
+
category = 'system';
|
|
94
|
+
aliases = ['plug'];
|
|
95
|
+
|
|
96
|
+
execute(args: string, logger: Logger): void {
|
|
97
|
+
const processor = (logger as any).cliProcessor;
|
|
98
|
+
if (!processor) {
|
|
99
|
+
logger.error('CLI processor not available');
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const plugins = processor.getPlugins();
|
|
104
|
+
|
|
105
|
+
if (plugins.length === 0) {
|
|
106
|
+
logger.info('đ No plugins registered');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
logger.info(`đ Loaded plugins (${plugins.length}):`);
|
|
111
|
+
|
|
112
|
+
plugins.forEach((plugin: any) => {
|
|
113
|
+
logger.info(` đĻ ${plugin.name} v${plugin.version} - ${plugin.description}`);
|
|
114
|
+
logger.info(` Commands: ${plugin.commands.map((c: any) => c.name).join(', ')}`);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/cli/index.ts
CHANGED
|
@@ -33,6 +33,12 @@ import {
|
|
|
33
33
|
ClearBufferCommand,
|
|
34
34
|
BufferInfoCommand
|
|
35
35
|
} from './commands/ExportCommand.js';
|
|
36
|
+
import {
|
|
37
|
+
HistoryCommand,
|
|
38
|
+
ClearHistoryCommand,
|
|
39
|
+
InteractiveCommand,
|
|
40
|
+
PluginsCommand
|
|
41
|
+
} from './commands/HistoryCommand.js';
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Create and configure default CLI processor
|
|
@@ -55,5 +61,11 @@ export function createDefaultCLI(): CommandProcessor {
|
|
|
55
61
|
processor.registerCommand(new ClearBufferCommand());
|
|
56
62
|
processor.registerCommand(new BufferInfoCommand());
|
|
57
63
|
|
|
64
|
+
// Register new enhanced commands
|
|
65
|
+
processor.registerCommand(new HistoryCommand());
|
|
66
|
+
processor.registerCommand(new ClearHistoryCommand());
|
|
67
|
+
processor.registerCommand(new InteractiveCommand());
|
|
68
|
+
processor.registerCommand(new PluginsCommand());
|
|
69
|
+
|
|
58
70
|
return processor;
|
|
59
71
|
}
|
package/src/constants.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @fileoverview Global constants for Advanced Logger
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import type { LogLevel } from './types/index.js';
|
|
5
|
+
import type { LogLevel, AdaptiveColors } from './types/index.js';
|
|
6
|
+
import type { LevelStyleConfig } from './utils/index.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Default configuration values
|
|
@@ -15,6 +16,61 @@ export const DEFAULT_CONFIG = {
|
|
|
15
16
|
theme: 'default' as const,
|
|
16
17
|
bannerType: 'simple' as const,
|
|
17
18
|
bufferSize: 1000,
|
|
19
|
+
autoDetectTheme: true,
|
|
20
|
+
} as const;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Basic level styles for core module (minimal CSS styling)
|
|
24
|
+
*/
|
|
25
|
+
export const LEVEL_STYLES: Record<LogLevel | 'success', LevelStyleConfig> = {
|
|
26
|
+
debug: {
|
|
27
|
+
emoji: 'đ',
|
|
28
|
+
label: 'DEBUG',
|
|
29
|
+
background: 'linear-gradient(90deg, #6c757d, #495057)',
|
|
30
|
+
color: '#ffffff',
|
|
31
|
+
border: '1px solid #6c757d',
|
|
32
|
+
shadow: '0 2px 4px rgba(108, 117, 125, 0.3)'
|
|
33
|
+
},
|
|
34
|
+
info: {
|
|
35
|
+
emoji: 'âšī¸',
|
|
36
|
+
label: 'INFO',
|
|
37
|
+
background: 'linear-gradient(90deg, #007bff, #0056b3)',
|
|
38
|
+
color: '#ffffff',
|
|
39
|
+
border: '1px solid #007bff',
|
|
40
|
+
shadow: '0 2px 4px rgba(0, 123, 255, 0.3)'
|
|
41
|
+
},
|
|
42
|
+
warn: {
|
|
43
|
+
emoji: 'â ī¸',
|
|
44
|
+
label: 'WARN',
|
|
45
|
+
background: 'linear-gradient(90deg, #ffc107, #e0a800)',
|
|
46
|
+
color: '#000000',
|
|
47
|
+
border: '1px solid #ffc107',
|
|
48
|
+
shadow: '0 2px 4px rgba(255, 193, 7, 0.3)'
|
|
49
|
+
},
|
|
50
|
+
error: {
|
|
51
|
+
emoji: 'â',
|
|
52
|
+
label: 'ERROR',
|
|
53
|
+
background: 'linear-gradient(90deg, #dc3545, #c82333)',
|
|
54
|
+
color: '#ffffff',
|
|
55
|
+
border: '1px solid #dc3545',
|
|
56
|
+
shadow: '0 2px 4px rgba(220, 53, 69, 0.3)'
|
|
57
|
+
},
|
|
58
|
+
critical: {
|
|
59
|
+
emoji: 'đ¨',
|
|
60
|
+
label: 'CRITICAL',
|
|
61
|
+
background: 'linear-gradient(90deg, #8B0000, #FF0000)',
|
|
62
|
+
color: '#ffffff',
|
|
63
|
+
border: '2px solid #FF0000',
|
|
64
|
+
shadow: '0 4px 8px rgba(255, 0, 0, 0.4)'
|
|
65
|
+
},
|
|
66
|
+
success: {
|
|
67
|
+
emoji: 'â
',
|
|
68
|
+
label: 'SUCCESS',
|
|
69
|
+
background: 'linear-gradient(90deg, #28a745, #1e7e34)',
|
|
70
|
+
color: '#ffffff',
|
|
71
|
+
border: '1px solid #28a745',
|
|
72
|
+
shadow: '0 2px 4px rgba(40, 167, 69, 0.3)'
|
|
73
|
+
}
|
|
18
74
|
} as const;
|
|
19
75
|
|
|
20
76
|
/**
|
|
@@ -86,4 +142,30 @@ export const LEVEL_PRIORITIES: Record<LogLevel, number> = {
|
|
|
86
142
|
warn: 2,
|
|
87
143
|
error: 3,
|
|
88
144
|
critical: 4,
|
|
89
|
-
} as const;
|
|
145
|
+
} as const;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Adaptive color configurations for DevTools theme compatibility
|
|
149
|
+
*/
|
|
150
|
+
export const ADAPTIVE_COLORS = {
|
|
151
|
+
timestamp: {
|
|
152
|
+
light: '#666666',
|
|
153
|
+
dark: '#a0a0a0',
|
|
154
|
+
},
|
|
155
|
+
messageText: {
|
|
156
|
+
light: '#2d3748',
|
|
157
|
+
dark: '#f7fafc',
|
|
158
|
+
},
|
|
159
|
+
prefix: {
|
|
160
|
+
light: '#2d3748',
|
|
161
|
+
dark: '#e2e8f0',
|
|
162
|
+
},
|
|
163
|
+
prefixBackground: {
|
|
164
|
+
light: '#2d3748',
|
|
165
|
+
dark: '#4a5568',
|
|
166
|
+
},
|
|
167
|
+
location: {
|
|
168
|
+
light: '#718096',
|
|
169
|
+
dark: '#a0aec0',
|
|
170
|
+
},
|
|
171
|
+
} as const satisfies Record<string, AdaptiveColors>;
|