@mks2508/better-logger 5.0.0 → 5.0.2
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/dist/chunks/{Logger-Cbi1f10o.js → Logger-CKqzXDh3.js} +2 -2
- package/dist/chunks/{Logger-Cbi1f10o.js.map → Logger-CKqzXDh3.js.map} +1 -1
- package/dist/chunks/{Logger-BZ7B7OXE.js → Logger-D_vuKP4l.js} +2 -2
- package/dist/chunks/{Logger-BZ7B7OXE.js.map → Logger-D_vuKP4l.js.map} +1 -1
- package/dist/chunks/cli-module-B-njrTWb.js +2 -0
- package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
- package/dist/chunks/{cli-module-ClIJmaT8.js → cli-module-Cx7qotPY.js} +16 -9
- package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +2 -2
- package/dist/terminal/formatter.d.ts.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -48
- package/.github/workflows/ci-quality.yml +0 -357
- package/.github/workflows/docs-demo.yml +0 -119
- package/.github/workflows/releases-core.yml +0 -512
- package/.github/workflows/releases-full.yml +0 -582
- package/.github/workflows-backup/ci.yml +0 -221
- package/.github/workflows-backup/nightly.yml +0 -196
- package/.github/workflows-backup/release-optimized.yml +0 -373
- package/.github/workflows-backup/release.yml +0 -269
- package/.release-notes-0.2.0.md +0 -129
- package/.yamllint +0 -28
- package/CHANGELOG.json +0 -1076
- package/CHANGELOG.md +0 -209
- package/CLAUDE.md +0 -217
- package/bun.lock +0 -333
- package/demo.html +0 -847
- package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
- package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
- package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
- package/docs/API.md +0 -918
- package/docs/CORE.md +0 -264
- package/docs/DEVELOPMENT.md +0 -731
- package/docs/EXPORTS.md +0 -467
- package/docs/PACKAGES.md +0 -244
- package/docs/STYLING.md +0 -405
- package/docs/_config.yml +0 -36
- package/docs/index.md +0 -179
- package/examples/README.md +0 -208
- package/examples/basic-logging.js +0 -75
- package/examples/data-export.js +0 -234
- package/examples/package.json +0 -16
- package/examples/performance-timing.js +0 -170
- package/examples/simplified-api.js +0 -124
- package/examples/styling-themes.js +0 -207
- package/index.html +0 -358
- package/packages/core/package.json +0 -57
- package/packages/exports/package.json +0 -41
- package/packages/nodejs-opentui/README.md +0 -232
- package/packages/nodejs-opentui/package.json +0 -72
- package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
- package/packages/nodejs-opentui/src/index.ts +0 -133
- package/packages/nodejs-opentui/src/types.ts +0 -158
- package/packages/nodejs-opentui/tsconfig.json +0 -20
- package/packages/styling/package.json +0 -41
- package/playground/demo-all.ts +0 -95
- package/playground/demo-box.ts +0 -85
- package/playground/demo-levels.ts +0 -56
- package/playground/demo-real-world.ts +0 -98
- package/playground/demo-spinner.ts +0 -77
- package/playground/demo-steps.ts +0 -72
- package/playground/demo-table.ts +0 -83
- package/project-utils/README.md +0 -172
- package/project-utils/auto-release-gemini.ts +0 -1193
- package/project-utils/auto-release-ui.ts +0 -1329
- package/project-utils/commit-generator.ts +0 -1385
- package/project-utils/commit-ui.ts +0 -264
- package/project-utils/git-utils.ts +0 -199
- package/project-utils/github-release-manager.ts +0 -466
- package/project-utils/project-config.ts +0 -260
- package/project-utils/prompt-templates.js +0 -345
- package/project-utils/prompt-templates.ts +0 -422
- package/project-utils/version-manager.ts +0 -1078
- package/public/vite.svg +0 -1
- package/src/Logger.ts +0 -1858
- package/src/ScopedLogger.ts +0 -256
- package/src/cli/CommandProcessor.ts +0 -248
- package/src/cli/commands/ConfigCommand.ts +0 -93
- package/src/cli/commands/ExportCommand.ts +0 -276
- package/src/cli/commands/HistoryCommand.ts +0 -117
- package/src/cli/commands/StatusCommand.ts +0 -112
- package/src/cli/commands/ThemeCommand.ts +0 -88
- package/src/cli/help.ts +0 -127
- package/src/cli/index.ts +0 -71
- package/src/cli-module.ts +0 -21
- package/src/cli-primitives/box.ts +0 -86
- package/src/cli-primitives/cli-table.ts +0 -62
- package/src/cli-primitives/divider.ts +0 -17
- package/src/cli-primitives/header.ts +0 -18
- package/src/cli-primitives/index.ts +0 -13
- package/src/cli-primitives/server-fallback.ts +0 -54
- package/src/cli-primitives/spinner.ts +0 -133
- package/src/cli-primitives/step.ts +0 -22
- package/src/constants.ts +0 -313
- package/src/core.ts +0 -397
- package/src/example.ts +0 -210
- package/src/exports-module.ts +0 -311
- package/src/handlers/AnalyticsLogHandler.ts +0 -22
- package/src/handlers/ExportLogHandler.ts +0 -610
- package/src/handlers/FileLogHandler.ts +0 -169
- package/src/handlers/RemoteLogHandler.ts +0 -42
- package/src/handlers/index.ts +0 -8
- package/src/hooks/HookManager.ts +0 -177
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -395
- package/src/main.ts +0 -196
- package/src/serializers/SerializerRegistry.ts +0 -173
- package/src/serializers/index.ts +0 -1
- package/src/style.css +0 -96
- package/src/styling/LogStyleBuilder.ts +0 -355
- package/src/styling/SemanticStyles.ts +0 -380
- package/src/styling/SmartPresets.ts +0 -288
- package/src/styling/StyleBuilder.ts +0 -319
- package/src/styling/StyleCache.ts +0 -131
- package/src/styling/banners.ts +0 -168
- package/src/styling/index.ts +0 -27
- package/src/styling/themes.ts +0 -235
- package/src/styling-module.ts +0 -244
- package/src/terminal/color-converter.ts +0 -315
- package/src/terminal/formatter.ts +0 -236
- package/src/terminal/terminal-renderer.ts +0 -342
- package/src/transports/ConsoleTransport.ts +0 -28
- package/src/transports/FileTransport.ts +0 -53
- package/src/transports/HttpTransport.ts +0 -56
- package/src/transports/TransportManager.ts +0 -130
- package/src/transports/index.ts +0 -4
- package/src/types/core.ts +0 -417
- package/src/types/handlers.ts +0 -95
- package/src/types/hooks.ts +0 -45
- package/src/types/index.ts +0 -83
- package/src/types/serializers.ts +0 -30
- package/src/types/transports.ts +0 -52
- package/src/typescript.svg +0 -1
- package/src/utils/adapter.ts +0 -291
- package/src/utils/ansi-colors.ts +0 -333
- package/src/utils/environment-detector.ts +0 -170
- package/src/utils/environment.ts +0 -94
- package/src/utils/formatting.ts +0 -332
- package/src/utils/index.ts +0 -33
- package/src/utils/opentui-detection.ts +0 -138
- package/src/utils/output.ts +0 -227
- package/src/utils/stackTrace.ts +0 -144
- package/src/utils/timestamps.ts +0 -80
- package/src/vite-env.d.ts +0 -1
- package/src/writers/BufferWriter.ts +0 -157
- package/src/writers/index.ts +0 -6
- package/test-core-browser.html +0 -237
- package/test-core-node.js +0 -63
- package/tests/test-conflict-resolution.ts +0 -391
- package/tests/validate-workflows.sh +0 -131
- package/tests/yaml-autofix.sh +0 -146
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -256
package/src/cli/help.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Help system for Advanced Logger CLI
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ICommand } from './CommandProcessor.js';
|
|
6
|
-
import type { Logger } from '../Logger.js';
|
|
7
|
-
import { StyleBuilder } from '../styling/index.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Help command - show comprehensive CLI help
|
|
11
|
-
*/
|
|
12
|
-
export class HelpCommand implements ICommand {
|
|
13
|
-
name = 'help';
|
|
14
|
-
description = 'Show CLI help and available commands';
|
|
15
|
-
usage = '/help [command]';
|
|
16
|
-
|
|
17
|
-
execute(_args: string, logger: Logger): void {
|
|
18
|
-
const helpStyle = new StyleBuilder()
|
|
19
|
-
.bg('linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)')
|
|
20
|
-
.color('#495057')
|
|
21
|
-
.padding('15px 20px')
|
|
22
|
-
.rounded('8px')
|
|
23
|
-
.border('1px solid #dee2e6')
|
|
24
|
-
.font('Monaco, Consolas, monospace')
|
|
25
|
-
.size('13px')
|
|
26
|
-
.build();
|
|
27
|
-
|
|
28
|
-
const helpText = `
|
|
29
|
-
╭─────────────── ADVANCED LOGGER CLI COMMANDS ─────────────────╮
|
|
30
|
-
│ │
|
|
31
|
-
│ CONFIGURATION │
|
|
32
|
-
│ /config Show current configuration │
|
|
33
|
-
│ /config {json} Apply JSON configuration │
|
|
34
|
-
│ /config key=val Apply key-value configuration │
|
|
35
|
-
│ /themes Show available themes │
|
|
36
|
-
│ /banners Show available banner types │
|
|
37
|
-
│ /banner [type] Change/show banner type │
|
|
38
|
-
│ /status Show logger status & buffer stats │
|
|
39
|
-
│ /demo Show feature demonstration │
|
|
40
|
-
│ /reset Reset to default configuration │
|
|
41
|
-
│ │
|
|
42
|
-
│ EXPORT & CLIPBOARD │
|
|
43
|
-
│ /export <format> Export logs (json|csv|md|plain|html) │
|
|
44
|
-
│ /copy <format> Copy logs to clipboard │
|
|
45
|
-
│ /buffer-size N Set log buffer size │
|
|
46
|
-
│ /buffer-info Show buffer statistics │
|
|
47
|
-
│ /clear-buffer Clear stored logs │
|
|
48
|
-
│ │
|
|
49
|
-
│ EXPORT FILTERS (for export/copy commands) │
|
|
50
|
-
│ --level error,warn Filter by log levels │
|
|
51
|
-
│ --since 2h Logs from last 2 hours │
|
|
52
|
-
│ --until 1h Logs until 1 hour ago │
|
|
53
|
-
│ --prefix API,DB Filter by prefixes │
|
|
54
|
-
│ --exclude-prefix INT Exclude prefixes │
|
|
55
|
-
│ --last 50 Last 50 logs only │
|
|
56
|
-
│ --first 25 First 25 logs only │
|
|
57
|
-
│ --search "error" Search in log messages │
|
|
58
|
-
│ --with-stack Only logs with stack traces │
|
|
59
|
-
│ --errors-only Only error + critical logs │
|
|
60
|
-
│ --group-by level Group by level/prefix/hour │
|
|
61
|
-
│ │
|
|
62
|
-
│ EXPORT OPTIONS │
|
|
63
|
-
│ --minimal Minimal output format │
|
|
64
|
-
│ --compact Remove extra whitespace │
|
|
65
|
-
│ --styled Include styling (HTML format) │
|
|
66
|
-
│ │
|
|
67
|
-
├──────────────────── CONFIGURATION OPTIONS ─────────────────┤
|
|
68
|
-
│ │
|
|
69
|
-
│ theme: default | dark | light | neon | minimal | cyberpunk│
|
|
70
|
-
│ bannerType: simple | ascii | unicode | svg | animated │
|
|
71
|
-
│ verbosity: debug | info | warn | error | critical | silent│
|
|
72
|
-
│ enableColors: true | false │
|
|
73
|
-
│ enableTimestamps: true | false │
|
|
74
|
-
│ enableStackTrace: true | false │
|
|
75
|
-
│ globalPrefix: "string" │
|
|
76
|
-
│ bufferSize: number (50-10000) │
|
|
77
|
-
│ │
|
|
78
|
-
├──────────────────────── EXAMPLES ──────────────────────────┤
|
|
79
|
-
│ │
|
|
80
|
-
│ Basic Configuration: │
|
|
81
|
-
│ /config {"theme":"dark","verbosity":"debug"} │
|
|
82
|
-
│ /config theme=neon,bufferSize=2000 │
|
|
83
|
-
│ /banner animated Change to animated banner │
|
|
84
|
-
│ │
|
|
85
|
-
│ Export Examples: │
|
|
86
|
-
│ /export json --level=error,warn --last=25 │
|
|
87
|
-
│ /export csv --since=2h --prefix=API │
|
|
88
|
-
│ /export markdown --group-by=level --errors-only │
|
|
89
|
-
│ /export html --styled --since=1h │
|
|
90
|
-
│ │
|
|
91
|
-
│ Clipboard Examples: │
|
|
92
|
-
│ /copy plain --minimal --last=10 │
|
|
93
|
-
│ /copy json --search="authentication" --compact │
|
|
94
|
-
│ /copy csv --since=30m --exclude-prefix=DEBUG │
|
|
95
|
-
│ │
|
|
96
|
-
│ Buffer Management: │
|
|
97
|
-
│ /buffer-size 5000 Increase buffer to 5000 logs │
|
|
98
|
-
│ /buffer-info Show detailed buffer statistics │
|
|
99
|
-
│ /clear-buffer Clear all stored logs │
|
|
100
|
-
│ │
|
|
101
|
-
│ Time Formats: │
|
|
102
|
-
│ --since=2h 2 hours ago │
|
|
103
|
-
│ --since=30m 30 minutes ago │
|
|
104
|
-
│ --since=1d 1 day ago │
|
|
105
|
-
│ --since="2024-01-01T10:00:00Z" Specific ISO date │
|
|
106
|
-
│ │
|
|
107
|
-
╰─────────────────────────────────────────────────────────────╯`;
|
|
108
|
-
|
|
109
|
-
console.log(`%c${helpText}`, helpStyle);
|
|
110
|
-
|
|
111
|
-
// Show quick tips
|
|
112
|
-
logger.group('💡 Quick Tips');
|
|
113
|
-
const tips = [
|
|
114
|
-
'Use /demo to see all logger features in action',
|
|
115
|
-
'Logs are automatically stored in a circular buffer for export',
|
|
116
|
-
'Export formats: JSON (structured), CSV (Excel), Markdown (readable), Plain (simple), HTML (styled)',
|
|
117
|
-
'Time filters support relative (2h, 30m) and absolute (ISO) formats',
|
|
118
|
-
'Combine multiple filters: /export json --level=error --since=1h --search="auth"',
|
|
119
|
-
'Use /copy for quick clipboard access instead of /export'
|
|
120
|
-
];
|
|
121
|
-
|
|
122
|
-
tips.forEach(tip => {
|
|
123
|
-
logger.info(`• ${tip}`);
|
|
124
|
-
});
|
|
125
|
-
logger.groupEnd();
|
|
126
|
-
}
|
|
127
|
-
}
|
package/src/cli/index.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI system exports for Advanced Logger
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Core CLI system
|
|
6
|
-
export { CommandProcessor, type ICommand } from './CommandProcessor.js';
|
|
7
|
-
import { CommandProcessor } from './CommandProcessor.js';
|
|
8
|
-
|
|
9
|
-
// Commands
|
|
10
|
-
export { ConfigCommand } from './commands/ConfigCommand.js';
|
|
11
|
-
export { ThemesCommand, BannersCommand, BannerCommand } from './commands/ThemeCommand.js';
|
|
12
|
-
export { StatusCommand, ResetCommand, DemoCommand } from './commands/StatusCommand.js';
|
|
13
|
-
export {
|
|
14
|
-
ExportCommand,
|
|
15
|
-
CopyCommand,
|
|
16
|
-
BufferSizeCommand,
|
|
17
|
-
ClearBufferCommand,
|
|
18
|
-
BufferInfoCommand
|
|
19
|
-
} from './commands/ExportCommand.js';
|
|
20
|
-
|
|
21
|
-
// Help system
|
|
22
|
-
export { HelpCommand } from './help.js';
|
|
23
|
-
|
|
24
|
-
// Import all commands
|
|
25
|
-
import { HelpCommand } from './help.js';
|
|
26
|
-
import { ConfigCommand } from './commands/ConfigCommand.js';
|
|
27
|
-
import { ThemesCommand, BannersCommand, BannerCommand } from './commands/ThemeCommand.js';
|
|
28
|
-
import { StatusCommand, ResetCommand, DemoCommand } from './commands/StatusCommand.js';
|
|
29
|
-
import {
|
|
30
|
-
ExportCommand,
|
|
31
|
-
CopyCommand,
|
|
32
|
-
BufferSizeCommand,
|
|
33
|
-
ClearBufferCommand,
|
|
34
|
-
BufferInfoCommand
|
|
35
|
-
} from './commands/ExportCommand.js';
|
|
36
|
-
import {
|
|
37
|
-
HistoryCommand,
|
|
38
|
-
ClearHistoryCommand,
|
|
39
|
-
InteractiveCommand,
|
|
40
|
-
PluginsCommand
|
|
41
|
-
} from './commands/HistoryCommand.js';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Create and configure default CLI processor
|
|
45
|
-
*/
|
|
46
|
-
export function createDefaultCLI(): CommandProcessor {
|
|
47
|
-
const processor = new CommandProcessor();
|
|
48
|
-
|
|
49
|
-
// Register all default commands
|
|
50
|
-
processor.registerCommand(new HelpCommand());
|
|
51
|
-
processor.registerCommand(new ConfigCommand());
|
|
52
|
-
processor.registerCommand(new ThemesCommand());
|
|
53
|
-
processor.registerCommand(new BannersCommand());
|
|
54
|
-
processor.registerCommand(new BannerCommand());
|
|
55
|
-
processor.registerCommand(new StatusCommand());
|
|
56
|
-
processor.registerCommand(new ResetCommand());
|
|
57
|
-
processor.registerCommand(new DemoCommand());
|
|
58
|
-
processor.registerCommand(new ExportCommand());
|
|
59
|
-
processor.registerCommand(new CopyCommand());
|
|
60
|
-
processor.registerCommand(new BufferSizeCommand());
|
|
61
|
-
processor.registerCommand(new ClearBufferCommand());
|
|
62
|
-
processor.registerCommand(new BufferInfoCommand());
|
|
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
|
-
|
|
70
|
-
return processor;
|
|
71
|
-
}
|
package/src/cli-module.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI-only entry point for @mks2508/better-logger/cli
|
|
3
|
-
* Exports only CLI primitives for minimal bundle size in CLI tools.
|
|
4
|
-
* @version 5.0.0
|
|
5
|
-
* @since 5.0.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export { renderStep } from './cli-primitives/step.js';
|
|
9
|
-
export { renderHeader } from './cli-primitives/header.js';
|
|
10
|
-
export { renderDivider } from './cli-primitives/divider.js';
|
|
11
|
-
export { renderBox } from './cli-primitives/box.js';
|
|
12
|
-
export { renderTable } from './cli-primitives/cli-table.js';
|
|
13
|
-
export { SpinnerManager, NoopSpinner } from './cli-primitives/spinner.js';
|
|
14
|
-
export { ServerFallback } from './cli-primitives/server-fallback.js';
|
|
15
|
-
|
|
16
|
-
export type {
|
|
17
|
-
CLILogLevel,
|
|
18
|
-
ISpinnerHandle,
|
|
19
|
-
IBoxOptions,
|
|
20
|
-
ITableOptions,
|
|
21
|
-
} from './types/index.js';
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Box renderer for CLI primitives
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { IBoxOptions } from '../types/core.js';
|
|
7
|
-
import type { ColorCapability } from '../terminal/color-converter.js';
|
|
8
|
-
import { getANSIForeground, ANSI } from '../terminal/color-converter.js';
|
|
9
|
-
import { getTerminalWidth } from '../utils/environment-detector.js';
|
|
10
|
-
import { stripAnsi, getVisibleLength } from '../terminal/formatter.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Border character sets for different styles
|
|
14
|
-
*/
|
|
15
|
-
const BORDER_CHARS = {
|
|
16
|
-
single: { tl: '\u250c', tr: '\u2510', bl: '\u2514', br: '\u2518', h: '\u2500', v: '\u2502' },
|
|
17
|
-
rounded: { tl: '\u256d', tr: '\u256e', bl: '\u2570', br: '\u256f', h: '\u2500', v: '\u2502' },
|
|
18
|
-
double: { tl: '\u2554', tr: '\u2557', bl: '\u255a', br: '\u255d', h: '\u2550', v: '\u2551' },
|
|
19
|
-
bold: { tl: '\u250f', tr: '\u2513', bl: '\u2517', br: '\u251b', h: '\u2501', v: '\u2503' },
|
|
20
|
-
} as const;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Renders content inside a bordered box
|
|
24
|
-
* @param content - Content string (may contain newlines)
|
|
25
|
-
* @param options - Box rendering options
|
|
26
|
-
* @param colorCap - Terminal color capability
|
|
27
|
-
* @returns Formatted box string with border
|
|
28
|
-
*/
|
|
29
|
-
export function renderBox(content: string, options: IBoxOptions = {}, colorCap: ColorCapability = 'full'): string {
|
|
30
|
-
const {
|
|
31
|
-
title,
|
|
32
|
-
borderColor,
|
|
33
|
-
borderStyle = 'rounded',
|
|
34
|
-
padding = 0,
|
|
35
|
-
} = options;
|
|
36
|
-
|
|
37
|
-
const chars = BORDER_CHARS[borderStyle] ?? BORDER_CHARS.rounded;
|
|
38
|
-
const lines = content.split('\n');
|
|
39
|
-
const maxTermWidth = Math.min(getTerminalWidth() - 4, 80);
|
|
40
|
-
|
|
41
|
-
// Calculate content width from visible text
|
|
42
|
-
const contentWidths = lines.map(l => getVisibleLength(l));
|
|
43
|
-
const titleWidth = title ? stripAnsi(title).length + 2 : 0; // +2 for spaces around title
|
|
44
|
-
const maxContentWidth = Math.max(...contentWidths, titleWidth);
|
|
45
|
-
const innerWidth = Math.min(maxContentWidth + 2, maxTermWidth); // +2 for horizontal padding
|
|
46
|
-
|
|
47
|
-
// Color wrapper for border chars
|
|
48
|
-
const bc = borderColor && colorCap !== 'none'
|
|
49
|
-
? getANSIForeground(borderColor, colorCap)
|
|
50
|
-
: '';
|
|
51
|
-
const reset = bc ? ANSI.reset : '';
|
|
52
|
-
|
|
53
|
-
const wrap = (char: string) => `${bc}${char}${reset}`;
|
|
54
|
-
|
|
55
|
-
// Build top border (with optional title)
|
|
56
|
-
let topBorder: string;
|
|
57
|
-
if (title) {
|
|
58
|
-
const titleStr = ` ${title} `;
|
|
59
|
-
const afterTitle = innerWidth - stripAnsi(titleStr).length;
|
|
60
|
-
topBorder = ` ${wrap(chars.tl)}${wrap(chars.h)}${wrap(titleStr)}${wrap(chars.h.repeat(Math.max(0, afterTitle - 1)))}${wrap(chars.tr)}`;
|
|
61
|
-
} else {
|
|
62
|
-
topBorder = ` ${wrap(chars.tl)}${wrap(chars.h.repeat(innerWidth))}${wrap(chars.tr)}`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Build bottom border
|
|
66
|
-
const bottomBorder = ` ${wrap(chars.bl)}${wrap(chars.h.repeat(innerWidth))}${wrap(chars.br)}`;
|
|
67
|
-
|
|
68
|
-
// Build padding lines
|
|
69
|
-
const emptyLine = ` ${wrap(chars.v)}${' '.repeat(innerWidth)}${wrap(chars.v)}`;
|
|
70
|
-
const paddingLines = padding > 0 ? Array(padding).fill(emptyLine) : [];
|
|
71
|
-
|
|
72
|
-
// Build content lines
|
|
73
|
-
const contentLines = lines.map(line => {
|
|
74
|
-
const visible = getVisibleLength(line);
|
|
75
|
-
const pad = innerWidth - visible - 1; // -1 for left space
|
|
76
|
-
return ` ${wrap(chars.v)} ${line}${' '.repeat(Math.max(0, pad))}${wrap(chars.v)}`;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return [
|
|
80
|
-
topBorder,
|
|
81
|
-
...paddingLines,
|
|
82
|
-
...contentLines,
|
|
83
|
-
...paddingLines,
|
|
84
|
-
bottomBorder,
|
|
85
|
-
].join('\n');
|
|
86
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI table renderer for CLI primitives
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ITableOptions } from '../types/core.js';
|
|
7
|
-
import type { ColorCapability } from '../terminal/color-converter.js';
|
|
8
|
-
import { getANSIForeground, ANSI } from '../terminal/color-converter.js';
|
|
9
|
-
import { getVisibleLength, padToWidth } from '../terminal/formatter.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Renders an array of objects as a formatted ASCII table
|
|
13
|
-
* @param rows - Array of row objects
|
|
14
|
-
* @param options - Table rendering options
|
|
15
|
-
* @param colorCap - Terminal color capability
|
|
16
|
-
* @returns Formatted table string
|
|
17
|
-
*/
|
|
18
|
-
export function renderTable(
|
|
19
|
-
rows: Record<string, unknown>[],
|
|
20
|
-
options: ITableOptions = {},
|
|
21
|
-
colorCap: ColorCapability = 'full'
|
|
22
|
-
): string {
|
|
23
|
-
if (rows.length === 0) return '';
|
|
24
|
-
|
|
25
|
-
// Determine columns from options or first row's keys
|
|
26
|
-
const columns = options.columns ?? Object.keys(rows[0]!);
|
|
27
|
-
const headers = options.head ?? columns;
|
|
28
|
-
|
|
29
|
-
// Calculate column widths (max of header and all values)
|
|
30
|
-
const colWidths = columns.map((col, i) => {
|
|
31
|
-
const headerLen = getVisibleLength(headers[i] ?? col);
|
|
32
|
-
const maxValueLen = rows.reduce((max, row) => {
|
|
33
|
-
const val = String(row[col] ?? '');
|
|
34
|
-
return Math.max(max, getVisibleLength(val));
|
|
35
|
-
}, 0);
|
|
36
|
-
return Math.max(headerLen, maxValueLen) + 2; // +2 for padding
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Color helpers
|
|
40
|
-
const cyan = colorCap !== 'none' ? getANSIForeground('#00bcd4', colorCap) : '';
|
|
41
|
-
const dim = colorCap !== 'none' ? ANSI.dim : '';
|
|
42
|
-
const reset = colorCap !== 'none' ? ANSI.reset : '';
|
|
43
|
-
|
|
44
|
-
// Build header row
|
|
45
|
-
const headerRow = ' ' + columns.map((col, i) => {
|
|
46
|
-
const label = headers[i] ?? col;
|
|
47
|
-
return cyan + ANSI.bold + padToWidth(` ${label}`, colWidths[i]!) + reset;
|
|
48
|
-
}).join('');
|
|
49
|
-
|
|
50
|
-
// Build separator
|
|
51
|
-
const separator = ' ' + dim + colWidths.map(w => '\u2500'.repeat(w)).join('\u2500') + reset;
|
|
52
|
-
|
|
53
|
-
// Build data rows
|
|
54
|
-
const dataRows = rows.map(row => {
|
|
55
|
-
return ' ' + columns.map((col, i) => {
|
|
56
|
-
const val = String(row[col] ?? '');
|
|
57
|
-
return padToWidth(` ${val}`, colWidths[i]!);
|
|
58
|
-
}).join('');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return [headerRow, separator, ...dataRows].join('\n');
|
|
62
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Divider renderer for CLI primitives
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ANSI } from '../terminal/color-converter.js';
|
|
7
|
-
import { getTerminalWidth } from '../utils/environment-detector.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Renders a horizontal divider line
|
|
11
|
-
* @param width - Optional explicit width (defaults to terminal width capped at 60)
|
|
12
|
-
* @returns Formatted divider string
|
|
13
|
-
*/
|
|
14
|
-
export function renderDivider(width?: number): string {
|
|
15
|
-
const w = width ?? Math.min(getTerminalWidth() - 4, 60);
|
|
16
|
-
return ANSI.dim + ' ' + '\u2500'.repeat(w) + ANSI.reset;
|
|
17
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Header renderer for CLI primitives
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { ANSI } from '../terminal/color-converter.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Renders a styled header with optional subtitle
|
|
10
|
-
* @param title - Main title text
|
|
11
|
-
* @param subtitle - Optional subtitle (rendered dimmed)
|
|
12
|
-
* @returns Formatted header string
|
|
13
|
-
*/
|
|
14
|
-
export function renderHeader(title: string, subtitle?: string): string {
|
|
15
|
-
const t = ANSI.bold + title + ANSI.reset;
|
|
16
|
-
const s = subtitle ? ANSI.dim + ` ${subtitle}` + ANSI.reset : '';
|
|
17
|
-
return ` ${t}${s}`;
|
|
18
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview CLI Primitives - Built-in terminal UI components for better-logger
|
|
3
|
-
* @version 5.0.0
|
|
4
|
-
* @since 5.0.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export { renderStep } from './step.js';
|
|
8
|
-
export { renderHeader } from './header.js';
|
|
9
|
-
export { renderDivider } from './divider.js';
|
|
10
|
-
export { renderBox } from './box.js';
|
|
11
|
-
export { renderTable } from './cli-table.js';
|
|
12
|
-
export { SpinnerManager, NoopSpinner } from './spinner.js';
|
|
13
|
-
export { ServerFallback } from './server-fallback.js';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Server/JSON fallback for CLI primitives in non-TTY environments
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { IBoxOptions, ITableOptions } from '../types/core.js';
|
|
7
|
-
import type { Logger } from '../Logger.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Server-mode fallback: outputs CLI primitives as plain logger calls
|
|
11
|
-
* when not running in an interactive terminal.
|
|
12
|
-
*
|
|
13
|
-
* @since 5.0.0
|
|
14
|
-
*/
|
|
15
|
-
export class ServerFallback {
|
|
16
|
-
private logger: Logger;
|
|
17
|
-
|
|
18
|
-
constructor(logger: Logger) {
|
|
19
|
-
this.logger = logger;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** Render step as plain info log */
|
|
23
|
-
step(current: number, total: number, msg: string): void {
|
|
24
|
-
this.logger.info(`[${current}/${total}] ${msg}`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** Render header as plain info log */
|
|
28
|
-
header(title: string, subtitle?: string): void {
|
|
29
|
-
const text = subtitle ? `${title} ${subtitle}` : title;
|
|
30
|
-
this.logger.info(text);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** Divider is a no-op in server mode */
|
|
34
|
-
divider(): void {
|
|
35
|
-
// No-op in server/JSON mode
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Blank line is a no-op in server mode */
|
|
39
|
-
blank(): void {
|
|
40
|
-
// No-op in server/JSON mode
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Render box content as plain info log */
|
|
44
|
-
box(content: string, _options?: IBoxOptions): void {
|
|
45
|
-
this.logger.info(content);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Render table rows as plain info logs */
|
|
49
|
-
cliTable(rows: Record<string, unknown>[], _options?: ITableOptions): void {
|
|
50
|
-
for (const row of rows) {
|
|
51
|
-
this.logger.info(JSON.stringify(row));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Built-in spinner implementation for CLI primitives
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { ISpinnerHandle, LoggerConfig } from '../types/core.js';
|
|
7
|
-
import type { Logger } from '../Logger.js';
|
|
8
|
-
import { ANSI } from '../terminal/color-converter.js';
|
|
9
|
-
|
|
10
|
-
/** Braille-based spinner animation frames */
|
|
11
|
-
const SPINNER_FRAMES = ['\u280b', '\u2819', '\u2839', '\u2838', '\u283c', '\u2834', '\u2826', '\u2827', '\u2807', '\u280f'];
|
|
12
|
-
|
|
13
|
-
/** Spinner frame interval in milliseconds */
|
|
14
|
-
const FRAME_INTERVAL = 80;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Interactive terminal spinner with in-place line updates.
|
|
18
|
-
* Writes to stderr to avoid polluting piped stdout.
|
|
19
|
-
*
|
|
20
|
-
* @implements {ISpinnerHandle}
|
|
21
|
-
* @since 5.0.0
|
|
22
|
-
*/
|
|
23
|
-
export class SpinnerManager implements ISpinnerHandle {
|
|
24
|
-
private message: string;
|
|
25
|
-
private frameIndex = 0;
|
|
26
|
-
private interval: ReturnType<typeof setInterval> | null = null;
|
|
27
|
-
private _logger: Logger;
|
|
28
|
-
|
|
29
|
-
constructor(message: string, _config: LoggerConfig, logger: Logger) {
|
|
30
|
-
this.message = message;
|
|
31
|
-
this._logger = logger;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** Start the spinner animation */
|
|
35
|
-
start(): void {
|
|
36
|
-
if (this.interval) return; // Already running
|
|
37
|
-
|
|
38
|
-
// Switch logger to buffer mode to prevent garbled output
|
|
39
|
-
this._logger.updateConfig({ outputMode: 'silent' });
|
|
40
|
-
|
|
41
|
-
this.frameIndex = 0;
|
|
42
|
-
this.render();
|
|
43
|
-
this.interval = setInterval(() => {
|
|
44
|
-
this.frameIndex = (this.frameIndex + 1) % SPINNER_FRAMES.length;
|
|
45
|
-
this.render();
|
|
46
|
-
}, FRAME_INTERVAL);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Stop the spinner without a status message */
|
|
50
|
-
stop(): void {
|
|
51
|
-
this.clearInterval();
|
|
52
|
-
this.clearLine();
|
|
53
|
-
// Restore logger output
|
|
54
|
-
this._logger.updateConfig({ outputMode: 'console' });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** Stop with a success indicator */
|
|
58
|
-
succeed(msg?: string): void {
|
|
59
|
-
this.clearInterval();
|
|
60
|
-
this.clearLine();
|
|
61
|
-
const text = msg ?? this.message;
|
|
62
|
-
process.stderr.write(` ${ANSI.fg.green}\u2713${ANSI.reset} ${text}\n`);
|
|
63
|
-
this._logger.updateConfig({ outputMode: 'console' });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Stop with a failure indicator */
|
|
67
|
-
fail(msg?: string): void {
|
|
68
|
-
this.clearInterval();
|
|
69
|
-
this.clearLine();
|
|
70
|
-
const text = msg ?? this.message;
|
|
71
|
-
process.stderr.write(` ${ANSI.fg.red}\u2717${ANSI.reset} ${text}\n`);
|
|
72
|
-
this._logger.updateConfig({ outputMode: 'console' });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Update the spinner text while running */
|
|
76
|
-
text(msg: string): void {
|
|
77
|
-
this.message = msg;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
private render(): void {
|
|
81
|
-
const frame = SPINNER_FRAMES[this.frameIndex] ?? SPINNER_FRAMES[0];
|
|
82
|
-
const line = ` ${ANSI.fg.cyan}${frame}${ANSI.reset} ${this.message}`;
|
|
83
|
-
process.stderr.write(`\r\x1b[K${line}`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
private clearLine(): void {
|
|
87
|
-
process.stderr.write('\r\x1b[K');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
private clearInterval(): void {
|
|
91
|
-
if (this.interval) {
|
|
92
|
-
clearInterval(this.interval);
|
|
93
|
-
this.interval = null;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* No-op spinner for non-TTY environments or silent mode.
|
|
100
|
-
* Logs start/succeed/fail as plain log messages.
|
|
101
|
-
*
|
|
102
|
-
* @implements {ISpinnerHandle}
|
|
103
|
-
* @since 5.0.0
|
|
104
|
-
*/
|
|
105
|
-
export class NoopSpinner implements ISpinnerHandle {
|
|
106
|
-
private message: string;
|
|
107
|
-
private _logger: Logger;
|
|
108
|
-
|
|
109
|
-
constructor(message: string, logger: Logger) {
|
|
110
|
-
this.message = message;
|
|
111
|
-
this._logger = logger;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
start(): void {
|
|
115
|
-
this._logger.info(this.message);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
stop(): void {
|
|
119
|
-
// No-op
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
succeed(msg?: string): void {
|
|
123
|
-
this._logger.success(msg ?? this.message);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
fail(msg?: string): void {
|
|
127
|
-
this._logger.error(msg ?? this.message);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
text(msg: string): void {
|
|
131
|
-
this.message = msg;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Step progress renderer for CLI primitives
|
|
3
|
-
* @since 5.0.0
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { getANSIForeground, ANSI, type ColorCapability } from '../terminal/color-converter.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Renders a step progress indicator like ` [2/5] Analyzing repository...`
|
|
10
|
-
* @param current - Current step number
|
|
11
|
-
* @param total - Total number of steps
|
|
12
|
-
* @param msg - Step description message
|
|
13
|
-
* @param colorCap - Terminal color capability
|
|
14
|
-
* @returns Formatted step string
|
|
15
|
-
*/
|
|
16
|
-
export function renderStep(current: number, total: number, msg: string, colorCap: ColorCapability): string {
|
|
17
|
-
const label = `[${current}/${total}]`;
|
|
18
|
-
const colored = colorCap !== 'none'
|
|
19
|
-
? getANSIForeground('#00bcd4', colorCap) + ANSI.bold + label + ANSI.reset
|
|
20
|
-
: label;
|
|
21
|
-
return ` ${colored} ${msg}`;
|
|
22
|
-
}
|