devkill 0.12.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/LICENSE +21 -0
- package/README.es.md +253 -0
- package/README.id.md +238 -0
- package/README.md +377 -0
- package/README.pt.md +241 -0
- package/README.tr.md +242 -0
- package/lib/cli/cli.controller.d.ts +81 -0
- package/lib/cli/cli.controller.js +760 -0
- package/lib/cli/cli.controller.js.map +1 -0
- package/lib/cli/interfaces/cli-options.interface.d.ts +5 -0
- package/lib/cli/interfaces/cli-options.interface.js +2 -0
- package/lib/cli/interfaces/cli-options.interface.js.map +1 -0
- package/lib/cli/interfaces/command-keys.interface.d.ts +17 -0
- package/lib/cli/interfaces/command-keys.interface.js +2 -0
- package/lib/cli/interfaces/command-keys.interface.js.map +1 -0
- package/lib/cli/interfaces/config.interface.d.ts +17 -0
- package/lib/cli/interfaces/config.interface.js +2 -0
- package/lib/cli/interfaces/config.interface.js.map +1 -0
- package/lib/cli/interfaces/index.d.ts +11 -0
- package/lib/cli/interfaces/index.js +12 -0
- package/lib/cli/interfaces/index.js.map +1 -0
- package/lib/cli/interfaces/json-output.interface.d.ts +30 -0
- package/lib/cli/interfaces/json-output.interface.js +2 -0
- package/lib/cli/interfaces/json-output.interface.js.map +1 -0
- package/lib/cli/interfaces/key-press.interface.d.ts +7 -0
- package/lib/cli/interfaces/key-press.interface.js +2 -0
- package/lib/cli/interfaces/key-press.interface.js.map +1 -0
- package/lib/cli/interfaces/node-version.interface.d.ts +5 -0
- package/lib/cli/interfaces/node-version.interface.js +2 -0
- package/lib/cli/interfaces/node-version.interface.js.map +1 -0
- package/lib/cli/interfaces/stats.interface.d.ts +15 -0
- package/lib/cli/interfaces/stats.interface.js +2 -0
- package/lib/cli/interfaces/stats.interface.js.map +1 -0
- package/lib/cli/interfaces/ui-positions.interface.d.ts +5 -0
- package/lib/cli/interfaces/ui-positions.interface.js +2 -0
- package/lib/cli/interfaces/ui-positions.interface.js.map +1 -0
- package/lib/cli/interfaces/version.interface.d.ts +5 -0
- package/lib/cli/interfaces/version.interface.js +2 -0
- package/lib/cli/interfaces/version.interface.js.map +1 -0
- package/lib/cli/models/start-parameters.model.d.ts +7 -0
- package/lib/cli/models/start-parameters.model.js +25 -0
- package/lib/cli/models/start-parameters.model.js.map +1 -0
- package/lib/cli/services/console.service.d.ts +23 -0
- package/lib/cli/services/console.service.js +87 -0
- package/lib/cli/services/console.service.js.map +1 -0
- package/lib/cli/services/https.service.d.ts +4 -0
- package/lib/cli/services/https.service.js +32 -0
- package/lib/cli/services/https.service.js.map +1 -0
- package/lib/cli/services/index.d.ts +7 -0
- package/lib/cli/services/index.js +8 -0
- package/lib/cli/services/index.js.map +1 -0
- package/lib/cli/services/json-output.service.d.ts +20 -0
- package/lib/cli/services/json-output.service.js +101 -0
- package/lib/cli/services/json-output.service.js.map +1 -0
- package/lib/cli/services/results.service.d.ts +13 -0
- package/lib/cli/services/results.service.js +61 -0
- package/lib/cli/services/results.service.js.map +1 -0
- package/lib/cli/services/scan.service.d.ts +13 -0
- package/lib/cli/services/scan.service.js +79 -0
- package/lib/cli/services/scan.service.js.map +1 -0
- package/lib/cli/services/spinner.service.d.ts +9 -0
- package/lib/cli/services/spinner.service.js +27 -0
- package/lib/cli/services/spinner.service.js.map +1 -0
- package/lib/cli/services/ui.service.d.ts +17 -0
- package/lib/cli/services/ui.service.js +59 -0
- package/lib/cli/services/ui.service.js.map +1 -0
- package/lib/cli/services/update.service.d.ts +15 -0
- package/lib/cli/services/update.service.js +37 -0
- package/lib/cli/services/update.service.js.map +1 -0
- package/lib/cli/ui/base.ui.d.ts +28 -0
- package/lib/cli/ui/base.ui.js +49 -0
- package/lib/cli/ui/base.ui.js.map +1 -0
- package/lib/cli/ui/components/general.ui.d.ts +7 -0
- package/lib/cli/ui/components/general.ui.js +13 -0
- package/lib/cli/ui/components/general.ui.js.map +1 -0
- package/lib/cli/ui/components/header/header-ui.constants.d.ts +7 -0
- package/lib/cli/ui/components/header/header-ui.constants.js +7 -0
- package/lib/cli/ui/components/header/header-ui.constants.js.map +1 -0
- package/lib/cli/ui/components/header/header.ui.d.ts +18 -0
- package/lib/cli/ui/components/header/header.ui.js +96 -0
- package/lib/cli/ui/components/header/header.ui.js.map +1 -0
- package/lib/cli/ui/components/header/stats.ui.d.ts +25 -0
- package/lib/cli/ui/components/header/stats.ui.js +198 -0
- package/lib/cli/ui/components/header/stats.ui.js.map +1 -0
- package/lib/cli/ui/components/header/status.ui.d.ts +33 -0
- package/lib/cli/ui/components/header/status.ui.js +188 -0
- package/lib/cli/ui/components/header/status.ui.js.map +1 -0
- package/lib/cli/ui/components/help/help-command.ui.d.ts +9 -0
- package/lib/cli/ui/components/help/help-command.ui.js +61 -0
- package/lib/cli/ui/components/help/help-command.ui.js.map +1 -0
- package/lib/cli/ui/components/help/help.constants.d.ts +8 -0
- package/lib/cli/ui/components/help/help.constants.js +270 -0
- package/lib/cli/ui/components/help/help.constants.js.map +1 -0
- package/lib/cli/ui/components/help/help.ui.d.ts +30 -0
- package/lib/cli/ui/components/help/help.ui.js +176 -0
- package/lib/cli/ui/components/help/help.ui.js.map +1 -0
- package/lib/cli/ui/components/logs.ui.d.ts +24 -0
- package/lib/cli/ui/components/logs.ui.js +132 -0
- package/lib/cli/ui/components/logs.ui.js.map +1 -0
- package/lib/cli/ui/components/options.ui.d.ts +29 -0
- package/lib/cli/ui/components/options.ui.js +327 -0
- package/lib/cli/ui/components/options.ui.js.map +1 -0
- package/lib/cli/ui/components/profile-picker.ui.d.ts +25 -0
- package/lib/cli/ui/components/profile-picker.ui.js +117 -0
- package/lib/cli/ui/components/profile-picker.ui.js.map +1 -0
- package/lib/cli/ui/components/result-details.ui.d.ts +23 -0
- package/lib/cli/ui/components/result-details.ui.js +182 -0
- package/lib/cli/ui/components/result-details.ui.js.map +1 -0
- package/lib/cli/ui/components/results.ui.d.ts +86 -0
- package/lib/cli/ui/components/results.ui.js +620 -0
- package/lib/cli/ui/components/results.ui.js.map +1 -0
- package/lib/cli/ui/components/warning.ui.d.ts +12 -0
- package/lib/cli/ui/components/warning.ui.js +30 -0
- package/lib/cli/ui/components/warning.ui.js.map +1 -0
- package/lib/cli/ui/heavy.ui.d.ts +18 -0
- package/lib/cli/ui/heavy.ui.js +37 -0
- package/lib/cli/ui/heavy.ui.js.map +1 -0
- package/lib/cli/ui/index.d.ts +14 -0
- package/lib/cli/ui/index.js +15 -0
- package/lib/cli/ui/index.js.map +1 -0
- package/lib/constants/cli.constants.d.ts +14 -0
- package/lib/constants/cli.constants.js +138 -0
- package/lib/constants/cli.constants.js.map +1 -0
- package/lib/constants/index.d.ts +8 -0
- package/lib/constants/index.js +9 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/main.constants.d.ts +96 -0
- package/lib/constants/main.constants.js +79 -0
- package/lib/constants/main.constants.js.map +1 -0
- package/lib/constants/messages.constants.d.ts +31 -0
- package/lib/constants/messages.constants.js +37 -0
- package/lib/constants/messages.constants.js.map +1 -0
- package/lib/constants/options.constants.d.ts +6 -0
- package/lib/constants/options.constants.js +8 -0
- package/lib/constants/options.constants.js.map +1 -0
- package/lib/constants/os-service-map.constants.d.ts +10 -0
- package/lib/constants/os-service-map.constants.js +11 -0
- package/lib/constants/os-service-map.constants.js.map +1 -0
- package/lib/constants/result-descriptions.constants.d.ts +142 -0
- package/lib/constants/result-descriptions.constants.js +203 -0
- package/lib/constants/result-descriptions.constants.js.map +1 -0
- package/lib/constants/sort.result.d.ts +6 -0
- package/lib/constants/sort.result.js +22 -0
- package/lib/constants/sort.result.js.map +1 -0
- package/lib/constants/spinner.constants.d.ts +5 -0
- package/lib/constants/spinner.constants.js +88 -0
- package/lib/constants/spinner.constants.js.map +1 -0
- package/lib/constants/status.constants.d.ts +7 -0
- package/lib/constants/status.constants.js +9 -0
- package/lib/constants/status.constants.js.map +1 -0
- package/lib/constants/update.constants.d.ts +2 -0
- package/lib/constants/update.constants.js +3 -0
- package/lib/constants/update.constants.js.map +1 -0
- package/lib/constants/workers.constants.d.ts +14 -0
- package/lib/constants/workers.constants.js +16 -0
- package/lib/constants/workers.constants.js.map +1 -0
- package/lib/core/constants/global-ignored.constants.d.ts +1 -0
- package/lib/core/constants/global-ignored.constants.js +44 -0
- package/lib/core/constants/global-ignored.constants.js.map +1 -0
- package/lib/core/constants/index.d.ts +1 -0
- package/lib/core/constants/index.js +2 -0
- package/lib/core/constants/index.js.map +1 -0
- package/lib/core/constants/profiles.constants.d.ts +8 -0
- package/lib/core/constants/profiles.constants.js +138 -0
- package/lib/core/constants/profiles.constants.js.map +1 -0
- package/lib/core/devkill.d.ts +25 -0
- package/lib/core/devkill.js +129 -0
- package/lib/core/devkill.js.map +1 -0
- package/lib/core/index.d.ts +4 -0
- package/lib/core/index.js +5 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/interfaces/devkill.interface.d.ts +78 -0
- package/lib/core/interfaces/devkill.interface.js +2 -0
- package/lib/core/interfaces/devkill.interface.js.map +1 -0
- package/lib/core/interfaces/devkillrc-config.interface.d.ts +87 -0
- package/lib/core/interfaces/devkillrc-config.interface.js +12 -0
- package/lib/core/interfaces/devkillrc-config.interface.js.map +1 -0
- package/lib/core/interfaces/file-service.interface.d.ts +76 -0
- package/lib/core/interfaces/file-service.interface.js +2 -0
- package/lib/core/interfaces/file-service.interface.js.map +1 -0
- package/lib/core/interfaces/folder.interface.d.ts +89 -0
- package/lib/core/interfaces/folder.interface.js +2 -0
- package/lib/core/interfaces/folder.interface.js.map +1 -0
- package/lib/core/interfaces/index.d.ts +6 -0
- package/lib/core/interfaces/index.js +7 -0
- package/lib/core/interfaces/index.js.map +1 -0
- package/lib/core/interfaces/logger-service.interface.d.ts +59 -0
- package/lib/core/interfaces/logger-service.interface.js +2 -0
- package/lib/core/interfaces/logger-service.interface.js.map +1 -0
- package/lib/core/interfaces/npkill.interface.d.ts +78 -0
- package/lib/core/interfaces/npkill.interface.js +2 -0
- package/lib/core/interfaces/npkill.interface.js.map +1 -0
- package/lib/core/interfaces/npkillrc-config.interface.d.ts +87 -0
- package/lib/core/interfaces/npkillrc-config.interface.js +12 -0
- package/lib/core/interfaces/npkillrc-config.interface.js.map +1 -0
- package/lib/core/interfaces/profile.interface.d.ts +9 -0
- package/lib/core/interfaces/profile.interface.js +2 -0
- package/lib/core/interfaces/profile.interface.js.map +1 -0
- package/lib/core/interfaces/search-status.model.d.ts +35 -0
- package/lib/core/interfaces/search-status.model.js +48 -0
- package/lib/core/interfaces/search-status.model.js.map +1 -0
- package/lib/core/interfaces/services.interface.d.ts +26 -0
- package/lib/core/interfaces/services.interface.js +2 -0
- package/lib/core/interfaces/services.interface.js.map +1 -0
- package/lib/core/npkill.d.ts +25 -0
- package/lib/core/npkill.js +129 -0
- package/lib/core/npkill.js.map +1 -0
- package/lib/core/services/config/config-merger.d.ts +17 -0
- package/lib/core/services/config/config-merger.js +57 -0
- package/lib/core/services/config/config-merger.js.map +1 -0
- package/lib/core/services/config/config-validator.d.ts +3 -0
- package/lib/core/services/config/config-validator.js +43 -0
- package/lib/core/services/config/config-validator.js.map +1 -0
- package/lib/core/services/config/index.d.ts +4 -0
- package/lib/core/services/config/index.js +5 -0
- package/lib/core/services/config/index.js.map +1 -0
- package/lib/core/services/config/profile-validator.d.ts +6 -0
- package/lib/core/services/config/profile-validator.js +68 -0
- package/lib/core/services/config/profile-validator.js.map +1 -0
- package/lib/core/services/config/property-validators.d.ts +33 -0
- package/lib/core/services/config/property-validators.js +125 -0
- package/lib/core/services/config/property-validators.js.map +1 -0
- package/lib/core/services/config.service.d.ts +37 -0
- package/lib/core/services/config.service.js +100 -0
- package/lib/core/services/config.service.js.map +1 -0
- package/lib/core/services/files/files.service.d.ts +28 -0
- package/lib/core/services/files/files.service.js +207 -0
- package/lib/core/services/files/files.service.js.map +1 -0
- package/lib/core/services/files/files.worker.d.ts +1 -0
- package/lib/core/services/files/files.worker.js +286 -0
- package/lib/core/services/files/files.worker.js.map +1 -0
- package/lib/core/services/files/files.worker.service.d.ts +90 -0
- package/lib/core/services/files/files.worker.service.js +216 -0
- package/lib/core/services/files/files.worker.service.js.map +1 -0
- package/lib/core/services/files/index.d.ts +4 -0
- package/lib/core/services/files/index.js +5 -0
- package/lib/core/services/files/index.js.map +1 -0
- package/lib/core/services/files/unix-files.service.d.ts +9 -0
- package/lib/core/services/files/unix-files.service.js +28 -0
- package/lib/core/services/files/unix-files.service.js.map +1 -0
- package/lib/core/services/files/windows-files.service.d.ts +9 -0
- package/lib/core/services/files/windows-files.service.js +16 -0
- package/lib/core/services/files/windows-files.service.js.map +1 -0
- package/lib/core/services/index.d.ts +5 -0
- package/lib/core/services/index.js +6 -0
- package/lib/core/services/index.js.map +1 -0
- package/lib/core/services/logger.service.d.ts +22 -0
- package/lib/core/services/logger.service.js +84 -0
- package/lib/core/services/logger.service.js.map +1 -0
- package/lib/core/services/profiles.service.d.ts +54 -0
- package/lib/core/services/profiles.service.js +86 -0
- package/lib/core/services/profiles.service.js.map +1 -0
- package/lib/core/services/stream.service.d.ts +12 -0
- package/lib/core/services/stream.service.js +39 -0
- package/lib/core/services/stream.service.js.map +1 -0
- package/lib/dirname.d.ts +2 -0
- package/lib/dirname.js +6 -0
- package/lib/dirname.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/main.d.ts +2 -0
- package/lib/main.js +19 -0
- package/lib/main.js.map +1 -0
- package/lib/utils/get-file-content.d.ts +1 -0
- package/lib/utils/get-file-content.js +6 -0
- package/lib/utils/get-file-content.js.map +1 -0
- package/lib/utils/is-safe-to-delete.d.ts +1 -0
- package/lib/utils/is-safe-to-delete.js +9 -0
- package/lib/utils/is-safe-to-delete.js.map +1 -0
- package/lib/utils/unit-conversions.d.ts +11 -0
- package/lib/utils/unit-conversions.js +54 -0
- package/lib/utils/unit-conversions.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/* eslint-disable quotes */
|
|
2
|
+
import pc from 'picocolors';
|
|
3
|
+
export const HELP_SECTIONS = [
|
|
4
|
+
{
|
|
5
|
+
id: 'welcome',
|
|
6
|
+
title: 'Welcome',
|
|
7
|
+
icon: '👋',
|
|
8
|
+
content: [
|
|
9
|
+
pc.bold('Welcome to devkill!'),
|
|
10
|
+
'',
|
|
11
|
+
'Devkill helps you find and manage "junk" directories',
|
|
12
|
+
'left behind by development tools.',
|
|
13
|
+
'',
|
|
14
|
+
'These folders are essential while working on projects,',
|
|
15
|
+
'but over time they pile up, eating tons of space long',
|
|
16
|
+
"after you've moved on.",
|
|
17
|
+
'',
|
|
18
|
+
'Devkill scans your directories, lists these folders with',
|
|
19
|
+
'their sizes, and shows when you last touched each project,',
|
|
20
|
+
'so you can quickly decide what to keep and what to clean.',
|
|
21
|
+
'',
|
|
22
|
+
pc.green(pc.bold('Multi-language. Easy. Powerful.')),
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'shortcuts',
|
|
27
|
+
title: 'Quick Reference',
|
|
28
|
+
icon: '⌨️',
|
|
29
|
+
content: [
|
|
30
|
+
pc.cyan(pc.bold('Navigation')),
|
|
31
|
+
` ${pc.green('↑/↓ or j/k')} Move cursor.`,
|
|
32
|
+
` ${pc.green('←/→ or h/l')} Switch panels.`,
|
|
33
|
+
` ${pc.green('PgUp/PgDown')} Fast scroll.`,
|
|
34
|
+
` ${pc.green('Home/End')} Jump to first/last.`,
|
|
35
|
+
'',
|
|
36
|
+
pc.cyan(pc.bold('Actions (normal mode)')),
|
|
37
|
+
` ${pc.green('SPACE / DEL')} Delete folder.`,
|
|
38
|
+
` ${pc.green('o')} Open parent folder.`,
|
|
39
|
+
` ${pc.green('/')} Search (Regex supported).`,
|
|
40
|
+
` ${pc.green('t')} Enter ${pc.green('multi-select mode')}.`,
|
|
41
|
+
'',
|
|
42
|
+
pc.cyan(pc.bold('Actions (multi-select mode)')),
|
|
43
|
+
` ${pc.green('t')} Back to ${pc.green('normal mode')} without delete.`,
|
|
44
|
+
` ${pc.green('v')} Range selection.`,
|
|
45
|
+
` ${pc.green('a')} Select/deselect all.`,
|
|
46
|
+
` ${pc.green('SPACE')} Select/deselect current.`,
|
|
47
|
+
` ${pc.green('ENTER')} Delete selected folders.`,
|
|
48
|
+
'',
|
|
49
|
+
pc.cyan(pc.bold('Others')),
|
|
50
|
+
` ${pc.green('e')} Show errors.`,
|
|
51
|
+
` ${pc.green('q / ESC')} Quit devkill.`,
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'header',
|
|
56
|
+
title: 'Header Info',
|
|
57
|
+
icon: '📊',
|
|
58
|
+
content: [
|
|
59
|
+
pc.bold('Understanding the header'),
|
|
60
|
+
'',
|
|
61
|
+
pc.bold(pc.green('Potential Space')),
|
|
62
|
+
'The total size of all detected directories.',
|
|
63
|
+
'This represents the maximum possible space you could',
|
|
64
|
+
'free if you deleted everything.',
|
|
65
|
+
'',
|
|
66
|
+
pc.bold(pc.green('Freed Space')),
|
|
67
|
+
'The space actually recovered in this session.',
|
|
68
|
+
'',
|
|
69
|
+
pc.bold(pc.green('Last Modified (age)')),
|
|
70
|
+
'Shows when the last file in the parent workspace was',
|
|
71
|
+
'modified. This helps identify abandoned projects.',
|
|
72
|
+
'',
|
|
73
|
+
pc.dim('Note: This checks the entire parent directory,'),
|
|
74
|
+
pc.dim('not just the target folder itself.'),
|
|
75
|
+
'',
|
|
76
|
+
pc.bold(pc.green('Progress Bar')),
|
|
77
|
+
'The progress bar has 3 color-coded parts:',
|
|
78
|
+
'',
|
|
79
|
+
` ${pc.green('▀▀▀▀')} Green → Results ready (stats calculated)`,
|
|
80
|
+
` ${pc.white('▀▀▀▀')} White → Directories examined`,
|
|
81
|
+
` ${pc.gray('▀▀▀▀')} Gray → Pending to be analyzed`,
|
|
82
|
+
'',
|
|
83
|
+
'Full bar example:',
|
|
84
|
+
` ${pc.green('▀▀▀▀▀▀▀')}${pc.white('▀▀▀▀')}${pc.gray('▀▀▀▀▀▀▀▀▀▀▀')}`,
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'warnings',
|
|
89
|
+
title: 'Warnings',
|
|
90
|
+
icon: '⚠️',
|
|
91
|
+
content: [
|
|
92
|
+
pc.bold(pc.yellow('Important: Not all results are safe to delete!')),
|
|
93
|
+
'',
|
|
94
|
+
'Some applications (VSCode, Discord, Slack, etc.) need',
|
|
95
|
+
'their dependencies to work. If their directory is deleted,',
|
|
96
|
+
'the application will probably break until dependencies',
|
|
97
|
+
'are reinstalled.',
|
|
98
|
+
'',
|
|
99
|
+
'Devkill will try to detect this folders and show "⚠️"',
|
|
100
|
+
'alongside the result and mark it as "sensitive".',
|
|
101
|
+
'',
|
|
102
|
+
'',
|
|
103
|
+
pc.bold(pc.green('Pro tip')),
|
|
104
|
+
'Use the Info panel (→) to see more information',
|
|
105
|
+
'about why a folder is flagged.',
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'panels',
|
|
110
|
+
title: 'Panels',
|
|
111
|
+
icon: '📋',
|
|
112
|
+
content: [
|
|
113
|
+
pc.bold('Understanding the interface'),
|
|
114
|
+
'',
|
|
115
|
+
pc.bold(pc.cyan('Delete Panel (Main)')),
|
|
116
|
+
'Lists all found directories with their sizes.',
|
|
117
|
+
'Navigate with arrow keys or j/k.',
|
|
118
|
+
'Press SPACE to delete a folder.',
|
|
119
|
+
'Press → to see details.',
|
|
120
|
+
'',
|
|
121
|
+
pc.bold(pc.cyan('Info Panel')),
|
|
122
|
+
'Shows details of the selected result. Plus notes',
|
|
123
|
+
'that might be useful to you.',
|
|
124
|
+
'',
|
|
125
|
+
pc.bold(pc.cyan('Options Panel')),
|
|
126
|
+
'Configure devkill settings on the fly.',
|
|
127
|
+
'',
|
|
128
|
+
pc.bold(pc.cyan('Help Panel (You are here!)')),
|
|
129
|
+
'Navigate through help sections.',
|
|
130
|
+
'Use ↑/↓ to change sections.',
|
|
131
|
+
'Scroll content with j/k or arrow keys.',
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
// { // TODO pending to add .npkillrc support
|
|
135
|
+
// id: 'config',
|
|
136
|
+
// title: 'Configuration',
|
|
137
|
+
// icon: '⚙️',
|
|
138
|
+
// content: [
|
|
139
|
+
// colors.bold('Customizing npkill with .npkillrc'),
|
|
140
|
+
// '',
|
|
141
|
+
// colors.bold.cyan('What is .npkillrc?'),
|
|
142
|
+
// 'A configuration file where you can set your default',
|
|
143
|
+
// 'preferences, custom profiles, and target folders.',
|
|
144
|
+
// '',
|
|
145
|
+
// colors.bold.cyan('Location'),
|
|
146
|
+
// '',
|
|
147
|
+
// 'Place it in your home directory:',
|
|
148
|
+
// colors.dim(' ~/.npkillrc'),
|
|
149
|
+
// '',
|
|
150
|
+
// 'Or load from a custom location:',
|
|
151
|
+
// colors.green(' npkill --config /path/to/config'),
|
|
152
|
+
// '',
|
|
153
|
+
// colors.bold.cyan('Example Configuration'),
|
|
154
|
+
// '',
|
|
155
|
+
// colors.dim('{'),
|
|
156
|
+
// colors.dim(' "targets": ["node_modules", ".venv", "target"],'),
|
|
157
|
+
// colors.dim(' "exclude": [".git", "important-project"],'),
|
|
158
|
+
// colors.dim(' "sortBy": "size",'),
|
|
159
|
+
// colors.dim(' "excludeSensitiveResults": true,'),
|
|
160
|
+
// colors.dim(' "profiles": {'),
|
|
161
|
+
// colors.dim(' "mystack": {'),
|
|
162
|
+
// colors.dim(' "targets": ["node_modules", "venv", "target"]'),
|
|
163
|
+
// colors.dim(' }'),
|
|
164
|
+
// colors.dim(' }'),
|
|
165
|
+
// colors.dim('}'),
|
|
166
|
+
// '',
|
|
167
|
+
// colors.bold.cyan('Available Options'),
|
|
168
|
+
// `${colors.green('targets')} Target folder names to search`,
|
|
169
|
+
// `${colors.green('exclude')} Directories to skip`,
|
|
170
|
+
// `${colors.green('sortBy')} Default sort (size/path/age)`,
|
|
171
|
+
// `${colors.green('sizeUnit')} Display unit (auto/mb/gb)`,
|
|
172
|
+
// `${colors.green('profiles')} Custom profile definitions`,
|
|
173
|
+
// ],
|
|
174
|
+
// },
|
|
175
|
+
{
|
|
176
|
+
id: 'profiles',
|
|
177
|
+
title: 'Profiles',
|
|
178
|
+
icon: '📦',
|
|
179
|
+
content: [
|
|
180
|
+
pc.bold('Working with profiles'),
|
|
181
|
+
'',
|
|
182
|
+
pc.bold(pc.cyan('What are profiles?')),
|
|
183
|
+
'Profiles are presets of target folders for different',
|
|
184
|
+
'programming languages and tools.',
|
|
185
|
+
'',
|
|
186
|
+
pc.bold(pc.cyan('Usage')),
|
|
187
|
+
'List available profiles:',
|
|
188
|
+
pc.green(' devkill -p'),
|
|
189
|
+
'',
|
|
190
|
+
'Single profile:',
|
|
191
|
+
pc.green(' devkill -p node'),
|
|
192
|
+
'',
|
|
193
|
+
'Multiple profiles:',
|
|
194
|
+
pc.green(' devkill -p node,python,java'),
|
|
195
|
+
'',
|
|
196
|
+
// colors.bold.cyan('Custom Profiles'),
|
|
197
|
+
// 'Define your own in .npkillrc:',
|
|
198
|
+
// '',
|
|
199
|
+
// colors.dim('"profiles": {'),
|
|
200
|
+
// colors.dim(' "webdev": {'),
|
|
201
|
+
// colors.dim(' "targets": ["node_modules", "dist", ".next"]'),
|
|
202
|
+
// colors.dim(' }'),
|
|
203
|
+
// colors.dim('}'),
|
|
204
|
+
// '',
|
|
205
|
+
// 'Then use:',
|
|
206
|
+
// colors.green(' npkill -p webdev'),
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: 'tips',
|
|
211
|
+
title: 'Tips & Tricks',
|
|
212
|
+
icon: '💡',
|
|
213
|
+
content: [
|
|
214
|
+
pc.bold('Get the most out of devkill'),
|
|
215
|
+
'',
|
|
216
|
+
pc.bold(pc.cyan('1. Use profiles')),
|
|
217
|
+
' Start with profiles for common tools:',
|
|
218
|
+
` ${pc.green('devkill -p node,python,java')}.`,
|
|
219
|
+
'',
|
|
220
|
+
pc.bold(pc.cyan('2. Sort intelligently')),
|
|
221
|
+
' Sort by size to find the biggest space hogs:',
|
|
222
|
+
` ${pc.green('devkill --sort size')}`,
|
|
223
|
+
' Or by age to find abandoned projects.',
|
|
224
|
+
'',
|
|
225
|
+
pc.bold(pc.cyan('3. Exclude what you need')),
|
|
226
|
+
' Protect important directories:',
|
|
227
|
+
` ${pc.green('devkill -E ".git,important_project"')}`,
|
|
228
|
+
'',
|
|
229
|
+
pc.bold(pc.cyan('4. Try dry-run mode')),
|
|
230
|
+
' Test without risk using --dry-run.',
|
|
231
|
+
' Nothing is deleted! (simulated with delay).',
|
|
232
|
+
'',
|
|
233
|
+
pc.bold(pc.cyan('5. Multi-select workflow')),
|
|
234
|
+
' Press "t" to enter selection mode.',
|
|
235
|
+
' Mark folders with SPACE.',
|
|
236
|
+
' Press ENTER to delete all at once.',
|
|
237
|
+
'',
|
|
238
|
+
' Press "v" on first item.',
|
|
239
|
+
' Move to last item and press "v" again.',
|
|
240
|
+
' All items in between are selected!',
|
|
241
|
+
'',
|
|
242
|
+
pc.bold(pc.cyan('6. Check details first')),
|
|
243
|
+
' Unsure about a result? Press → to see',
|
|
244
|
+
' more details.',
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: 'about',
|
|
249
|
+
title: 'About',
|
|
250
|
+
icon: 'ℹ️',
|
|
251
|
+
content: [
|
|
252
|
+
pc.bold('About devkill'),
|
|
253
|
+
'',
|
|
254
|
+
'Devkill, a tool designed to help developers',
|
|
255
|
+
'reclaim disk space by finding and removing',
|
|
256
|
+
'unnecessary dependency folders.',
|
|
257
|
+
'',
|
|
258
|
+
pc.bold(pc.cyan('Get Involved')),
|
|
259
|
+
'GitHub: github.com/arupbasak/devkill',
|
|
260
|
+
'Report bugs, request features, contribute!',
|
|
261
|
+
'',
|
|
262
|
+
pc.bold(pc.cyan('License')),
|
|
263
|
+
'MIT License - Free and open source.',
|
|
264
|
+
'',
|
|
265
|
+
'',
|
|
266
|
+
pc.dim('Made with ❤️'),
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
];
|
|
270
|
+
//# sourceMappingURL=help.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.constants.js","sourceRoot":"","sources":["../../../../../src/cli/ui/components/help/help.constants.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EAAE,MAAM,YAAY,CAAC;AAS5B,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C;QACE,EAAE,EAAE,SAAS;QACb,KAAK,EAAE,SAAS;QAChB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC;YAC9B,EAAE;YACF,sDAAsD;YACtD,mCAAmC;YACnC,EAAE;YACF,wDAAwD;YACxD,uDAAuD;YACvD,wBAAwB;YACxB,EAAE;YACF,0DAA0D;YAC1D,4DAA4D;YAC5D,2DAA2D;YAC3D,EAAE;YACF,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;SACrD;KACF;IACD;QACE,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,iBAAiB;QACxB,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC9B,KAAK,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,qBAAqB;YAChD,KAAK,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,uBAAuB;YAClD,KAAK,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,oBAAoB;YAChD,KAAK,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,8BAA8B;YACvD,EAAE;YACF,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACzC,KAAK,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,sBAAsB;YAClD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uC;YACvC,gDAAgD;YAChD,EAAE;YACF,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YAC5C,uCAAuC;YACvC,6BAA6B;YAC7B,uCAAuC;YACvC,EAAE;YACF,6BAA6B;YAC7B,2CAA2C;YAC3C,uCAAuC;YACvC,EAAE;YACF,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAC1C,0CAA0C;YAC1C,kBAAkB;SACnB;KACF;IACD;QACE,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,IAAI;QACV,OAAO,EAAE;YACP,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC;YACxB,EAAE;YACF,6CAA6C;YAC7C,4CAA4C;YAC5C,iCAAiC;YACjC,EAAE;YACF,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAChC,sCAAsC;YACtC,4CAA4C;YAC5C,EAAE;YACF,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC3B,qCAAqC;YACrC,EAAE;YACF,EAAE;YACF,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC;SACvB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Subject } from 'rxjs';
|
|
2
|
+
import type { IKeyPress } from '../../../interfaces/key-press.interface.js';
|
|
3
|
+
import { BaseUi, type InteractiveUi } from '../../base.ui.js';
|
|
4
|
+
export declare class HelpUi extends BaseUi implements InteractiveUi {
|
|
5
|
+
resultIndex: number;
|
|
6
|
+
readonly goToOptions$: Subject<null>;
|
|
7
|
+
private selectedSection;
|
|
8
|
+
private scrollOffset;
|
|
9
|
+
private readonly INDEX_WIDTH;
|
|
10
|
+
private readonly SCROLL_STEP;
|
|
11
|
+
private readonly KEYS;
|
|
12
|
+
private previousSection;
|
|
13
|
+
private nextSection;
|
|
14
|
+
private selectSection;
|
|
15
|
+
private scrollUp;
|
|
16
|
+
private scrollDown;
|
|
17
|
+
private scrollPageUp;
|
|
18
|
+
private scrollPageDown;
|
|
19
|
+
private scrollToTop;
|
|
20
|
+
private scrollToBottom;
|
|
21
|
+
private goToOptions;
|
|
22
|
+
private getContentAreaHeight;
|
|
23
|
+
onKeyInput({ name }: IKeyPress): void;
|
|
24
|
+
render(): void;
|
|
25
|
+
private drawIndex;
|
|
26
|
+
private drawContent;
|
|
27
|
+
/** Get real width, removing ANSI color codes. */
|
|
28
|
+
private getStringWidth;
|
|
29
|
+
clear(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import { MARGINS } from '../../../../constants/main.constants.js';
|
|
4
|
+
import { BaseUi } from '../../base.ui.js';
|
|
5
|
+
import { HELP_SECTIONS } from './help.constants.js';
|
|
6
|
+
export class HelpUi extends BaseUi {
|
|
7
|
+
resultIndex = 0;
|
|
8
|
+
goToOptions$ = new Subject();
|
|
9
|
+
selectedSection = 0;
|
|
10
|
+
scrollOffset = 0;
|
|
11
|
+
INDEX_WIDTH = 23;
|
|
12
|
+
SCROLL_STEP = 2;
|
|
13
|
+
KEYS = {
|
|
14
|
+
up: () => this.previousSection(),
|
|
15
|
+
down: () => this.nextSection(),
|
|
16
|
+
k: () => this.scrollUp(),
|
|
17
|
+
j: () => this.scrollDown(),
|
|
18
|
+
u: () => this.scrollPageUp(),
|
|
19
|
+
d: () => this.scrollPageDown(),
|
|
20
|
+
pageup: () => this.scrollPageUp(),
|
|
21
|
+
pagedown: () => this.scrollPageDown(),
|
|
22
|
+
home: () => this.scrollToTop(),
|
|
23
|
+
end: () => this.scrollToBottom(),
|
|
24
|
+
right: () => this.goToOptions(),
|
|
25
|
+
l: () => this.goToOptions(),
|
|
26
|
+
q: () => this.goToOptions(),
|
|
27
|
+
escape: () => this.goToOptions(),
|
|
28
|
+
return: () => this.selectSection(),
|
|
29
|
+
};
|
|
30
|
+
previousSection() {
|
|
31
|
+
if (this.selectedSection > 0) {
|
|
32
|
+
this.selectedSection--;
|
|
33
|
+
this.scrollOffset = 0;
|
|
34
|
+
this.render();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
nextSection() {
|
|
38
|
+
if (this.selectedSection < HELP_SECTIONS.length - 1) {
|
|
39
|
+
this.selectedSection++;
|
|
40
|
+
this.scrollOffset = 0;
|
|
41
|
+
this.render();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
selectSection() {
|
|
45
|
+
this.scrollOffset = 0;
|
|
46
|
+
this.render();
|
|
47
|
+
}
|
|
48
|
+
scrollUp() {
|
|
49
|
+
if (this.scrollOffset > 0) {
|
|
50
|
+
this.scrollOffset = Math.max(0, this.scrollOffset - this.SCROLL_STEP);
|
|
51
|
+
this.render();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
scrollDown() {
|
|
55
|
+
const currentSection = HELP_SECTIONS[this.selectedSection];
|
|
56
|
+
const contentHeight = this.getContentAreaHeight();
|
|
57
|
+
const maxScroll = Math.max(0, currentSection.content.length - contentHeight);
|
|
58
|
+
if (this.scrollOffset < maxScroll) {
|
|
59
|
+
this.scrollOffset = Math.min(maxScroll, this.scrollOffset + this.SCROLL_STEP);
|
|
60
|
+
this.render();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
scrollPageUp() {
|
|
64
|
+
const pageSize = this.getContentAreaHeight() - 2;
|
|
65
|
+
this.scrollOffset = Math.max(0, this.scrollOffset - pageSize);
|
|
66
|
+
this.render();
|
|
67
|
+
}
|
|
68
|
+
scrollPageDown() {
|
|
69
|
+
const currentSection = HELP_SECTIONS[this.selectedSection];
|
|
70
|
+
const contentHeight = this.getContentAreaHeight();
|
|
71
|
+
const pageSize = contentHeight - 2;
|
|
72
|
+
const maxScroll = Math.max(0, currentSection.content.length - contentHeight);
|
|
73
|
+
this.scrollOffset = Math.min(maxScroll, this.scrollOffset + pageSize);
|
|
74
|
+
this.render();
|
|
75
|
+
}
|
|
76
|
+
scrollToTop() {
|
|
77
|
+
this.scrollOffset = 0;
|
|
78
|
+
this.render();
|
|
79
|
+
}
|
|
80
|
+
scrollToBottom() {
|
|
81
|
+
const currentSection = HELP_SECTIONS[this.selectedSection];
|
|
82
|
+
const contentHeight = this.getContentAreaHeight();
|
|
83
|
+
this.scrollOffset = Math.max(0, currentSection.content.length - contentHeight);
|
|
84
|
+
this.render();
|
|
85
|
+
}
|
|
86
|
+
goToOptions() {
|
|
87
|
+
this.clear();
|
|
88
|
+
this.goToOptions$.next(null);
|
|
89
|
+
}
|
|
90
|
+
getContentAreaHeight() {
|
|
91
|
+
return this.terminal.rows - MARGINS.ROW_RESULTS_START - 4;
|
|
92
|
+
}
|
|
93
|
+
onKeyInput({ name }) {
|
|
94
|
+
const action = this.KEYS[name];
|
|
95
|
+
if (action === undefined) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
action();
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
this.clear();
|
|
102
|
+
const startRow = MARGINS.ROW_RESULTS_START;
|
|
103
|
+
const contentAreaHeight = this.getContentAreaHeight();
|
|
104
|
+
// Header hint
|
|
105
|
+
this.printAt(pc.dim('Use ') +
|
|
106
|
+
pc.green('↑/↓') +
|
|
107
|
+
pc.dim(' to change section, ') +
|
|
108
|
+
pc.green('j/k') +
|
|
109
|
+
pc.dim(' to scroll.'), { x: 2, y: startRow });
|
|
110
|
+
this.drawIndex(startRow + 2);
|
|
111
|
+
this.drawContent(startRow + 2, contentAreaHeight);
|
|
112
|
+
}
|
|
113
|
+
drawIndex(startRow) {
|
|
114
|
+
const indexHeight = this.terminal.rows - startRow - 1;
|
|
115
|
+
this.printAt(pc.gray(`╭${'─'.repeat(this.INDEX_WIDTH - 2)}╮`), {
|
|
116
|
+
x: 2,
|
|
117
|
+
y: startRow - 1,
|
|
118
|
+
});
|
|
119
|
+
for (let i = 0; i < Math.min(HELP_SECTIONS.length, indexHeight); i++) {
|
|
120
|
+
const section = HELP_SECTIONS[i];
|
|
121
|
+
const isSelected = i === this.selectedSection;
|
|
122
|
+
const padding = ' '.repeat(Math.max(0, this.INDEX_WIDTH - section.title.length - 6));
|
|
123
|
+
const line = ` ${section.icon} ${section.title}${padding}`;
|
|
124
|
+
if (isSelected) {
|
|
125
|
+
this.printAt(pc.gray('│') + pc.bgCyan(pc.black(line)) + pc.gray('│'), {
|
|
126
|
+
x: 2,
|
|
127
|
+
y: startRow + i,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.printAt(pc.gray('│') + pc.white(line) + pc.gray('│'), {
|
|
132
|
+
x: 2,
|
|
133
|
+
y: startRow + i,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const bottomRow = startRow + Math.min(HELP_SECTIONS.length, indexHeight);
|
|
138
|
+
this.printAt(pc.gray(`╰${'─'.repeat(this.INDEX_WIDTH - 2)}╯`), {
|
|
139
|
+
x: 2,
|
|
140
|
+
y: bottomRow,
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
drawContent(startRow, contentHeight) {
|
|
144
|
+
const currentSection = HELP_SECTIONS[this.selectedSection];
|
|
145
|
+
const contentStartX = this.INDEX_WIDTH + 2;
|
|
146
|
+
const contentWidth = Math.max(20, this.terminal.columns - contentStartX - 4);
|
|
147
|
+
this.printAt(pc.gray(`╭${'─'.repeat(contentWidth)}╮`), {
|
|
148
|
+
x: contentStartX,
|
|
149
|
+
y: startRow - 1,
|
|
150
|
+
});
|
|
151
|
+
const visibleContent = currentSection.content.slice(this.scrollOffset, this.scrollOffset + contentHeight);
|
|
152
|
+
for (let i = 0; i < contentHeight; i++) {
|
|
153
|
+
const line = visibleContent[i] || '';
|
|
154
|
+
const padding = ' '.repeat(Math.max(0, contentWidth - this.getStringWidth(line) - 1));
|
|
155
|
+
this.printAt(pc.gray('│ ') + line + padding + pc.gray('│'), {
|
|
156
|
+
x: contentStartX,
|
|
157
|
+
y: startRow + i,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
this.printAt(pc.gray(`╰${'─'.repeat(contentWidth)}╯`), {
|
|
161
|
+
x: contentStartX,
|
|
162
|
+
y: startRow + contentHeight,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/** Get real width, removing ANSI color codes. */
|
|
166
|
+
getStringWidth(str) {
|
|
167
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ANSI escape code stripping
|
|
168
|
+
return str.replace(/\u001b\[[0-9;]*m/g, '').length;
|
|
169
|
+
}
|
|
170
|
+
clear() {
|
|
171
|
+
for (let row = MARGINS.ROW_RESULTS_START; row < this.terminal.rows; row++) {
|
|
172
|
+
this.clearLine(row);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=help.ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.ui.js","sourceRoot":"","sources":["../../../../../src/cli/ui/components/help/help.ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAElE,OAAO,EAAE,MAAM,EAAsB,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,OAAO,MAAO,SAAQ,MAAM;IAChC,WAAW,GAAG,CAAC,CAAC;IAEP,YAAY,GAAG,IAAI,OAAO,EAAQ,CAAC;IAEpC,eAAe,GAAG,CAAC,CAAC;IACpB,YAAY,GAAG,CAAC,CAAC;IACR,WAAW,GAAG,EAAE,CAAC;IACjB,WAAW,GAAG,CAAC,CAAC;IAEhB,IAAI,GAAG;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C,EAAE;YACrD,CAAC,EAAE,aAAa;YAChB,CAAC,EAAE,QAAQ,GAAG,aAAa;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,iDAAiD;IACzC,cAAc,CAAC,GAAW;QAChC,kGAAkG;QAClG,OAAO,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;IACrD,CAAC;IAED,KAAK;QACH,KAAK,IAAI,GAAG,GAAG,OAAO,CAAC,iBAAiB,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YAC1E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LoggerService } from '@core/services/logger.service.js';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import type { IKeyPress } from '../../interfaces/key-press.interface.js';
|
|
4
|
+
import { BaseUi, type InteractiveUi } from '../base.ui.js';
|
|
5
|
+
export declare class LogsUi extends BaseUi implements InteractiveUi {
|
|
6
|
+
private readonly logger;
|
|
7
|
+
readonly close$: Subject<null>;
|
|
8
|
+
private size;
|
|
9
|
+
private errors;
|
|
10
|
+
private pages;
|
|
11
|
+
private actualPage;
|
|
12
|
+
private readonly KEYS;
|
|
13
|
+
constructor(logger: LoggerService);
|
|
14
|
+
onKeyInput({ name }: IKeyPress): void;
|
|
15
|
+
render(): void;
|
|
16
|
+
private cyclePages;
|
|
17
|
+
private close;
|
|
18
|
+
private renderPopup;
|
|
19
|
+
private printHeader;
|
|
20
|
+
private stylizeText;
|
|
21
|
+
private chunkString;
|
|
22
|
+
private chunkArray;
|
|
23
|
+
private calculatePosition;
|
|
24
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
import { BaseUi } from '../base.ui.js';
|
|
4
|
+
export class LogsUi extends BaseUi {
|
|
5
|
+
logger;
|
|
6
|
+
close$ = new Subject();
|
|
7
|
+
size;
|
|
8
|
+
errors = 0;
|
|
9
|
+
pages = [];
|
|
10
|
+
actualPage = 0;
|
|
11
|
+
KEYS = {
|
|
12
|
+
e: () => this.cyclePages(),
|
|
13
|
+
escape: () => this.close(),
|
|
14
|
+
};
|
|
15
|
+
constructor(logger) {
|
|
16
|
+
super();
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
this.setVisible(false, false);
|
|
19
|
+
}
|
|
20
|
+
onKeyInput({ name }) {
|
|
21
|
+
const action = this.KEYS[name];
|
|
22
|
+
if (action === undefined) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
action();
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
this.renderPopup();
|
|
29
|
+
}
|
|
30
|
+
cyclePages() {
|
|
31
|
+
this.actualPage++;
|
|
32
|
+
if (this.actualPage >= this.pages.length) {
|
|
33
|
+
this.actualPage = 0;
|
|
34
|
+
this.close();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.render();
|
|
38
|
+
}
|
|
39
|
+
close() {
|
|
40
|
+
this.close$.next(null);
|
|
41
|
+
}
|
|
42
|
+
renderPopup() {
|
|
43
|
+
this.calculatePosition();
|
|
44
|
+
for (let x = this.position.x; x < this.size.x; x++) {
|
|
45
|
+
for (let y = this.position.y; y < this.size.y; y++) {
|
|
46
|
+
let char = ' ';
|
|
47
|
+
if (x === this.position.x || x === this.size.x - 1) {
|
|
48
|
+
char = '│';
|
|
49
|
+
}
|
|
50
|
+
if (y === this.position.y) {
|
|
51
|
+
char = '═';
|
|
52
|
+
}
|
|
53
|
+
if (y === this.size.y - 1) {
|
|
54
|
+
char = '─';
|
|
55
|
+
}
|
|
56
|
+
if (x === this.position.x && y === this.position.y) {
|
|
57
|
+
char = '╒';
|
|
58
|
+
}
|
|
59
|
+
if (x === this.size.x - 1 && y === this.position.y) {
|
|
60
|
+
char = '╕';
|
|
61
|
+
}
|
|
62
|
+
if (x === this.position.x && y === this.size.y - 1) {
|
|
63
|
+
char = '╰';
|
|
64
|
+
}
|
|
65
|
+
if (x === this.size.x - 1 && y === this.size.y - 1) {
|
|
66
|
+
char = '╯';
|
|
67
|
+
}
|
|
68
|
+
this.printAt(pc.bgBlack(char), { x, y });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const width = this.size.x - this.position.x - 2;
|
|
72
|
+
const maxEntries = this.size.y - this.position.y - 2;
|
|
73
|
+
const messagesByLine = this.logger
|
|
74
|
+
.get('error')
|
|
75
|
+
.map((entry, index) => `${index}. ${entry.message}`)
|
|
76
|
+
.reduce((acc, line) => {
|
|
77
|
+
acc.push(...this.chunkString(line, width));
|
|
78
|
+
return acc;
|
|
79
|
+
}, []);
|
|
80
|
+
this.pages = this.chunkArray(messagesByLine, maxEntries);
|
|
81
|
+
this.errors = this.logger.get('error').length;
|
|
82
|
+
if (messagesByLine.length === 0) {
|
|
83
|
+
this.printAt(this.stylizeText('No errors!'), {
|
|
84
|
+
x: this.position.x + 1,
|
|
85
|
+
y: this.position.y + 1,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this.pages[this.actualPage].forEach((entry, index) => {
|
|
89
|
+
this.printAt(this.stylizeText(entry, 'error'), {
|
|
90
|
+
x: this.position.x + 1,
|
|
91
|
+
y: this.position.y + 1 + index,
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
this.printHeader();
|
|
95
|
+
}
|
|
96
|
+
printHeader() {
|
|
97
|
+
const titleText = ' Errors ';
|
|
98
|
+
this.printAt(this.stylizeText(titleText), {
|
|
99
|
+
x: Math.floor((this.size.x + titleText.length / 2) / 2) - this.position.x,
|
|
100
|
+
y: this.position.y,
|
|
101
|
+
});
|
|
102
|
+
const rightText = ` ${this.errors} errors | Page ${this.actualPage + 1}/${this.pages.length} `;
|
|
103
|
+
this.printAt(this.stylizeText(rightText), {
|
|
104
|
+
x: Math.floor(this.size.x + this.position.x - 4 - (rightText.length + 2)),
|
|
105
|
+
y: this.position.y,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
stylizeText(text, style = 'normal') {
|
|
109
|
+
const styles = { normal: 'white', error: 'red' };
|
|
110
|
+
const color = styles[style];
|
|
111
|
+
return pc[color](pc.bgBlack(text));
|
|
112
|
+
}
|
|
113
|
+
chunkString(str, length) {
|
|
114
|
+
const matches = str.match(new RegExp(`.{1,${length}}`, 'g'));
|
|
115
|
+
return matches !== null ? [...matches] : [];
|
|
116
|
+
}
|
|
117
|
+
chunkArray(arr, size) {
|
|
118
|
+
return arr.length > size
|
|
119
|
+
? [arr.slice(0, size), ...this.chunkArray(arr.slice(size), size)]
|
|
120
|
+
: [arr];
|
|
121
|
+
}
|
|
122
|
+
calculatePosition() {
|
|
123
|
+
const posX = 5;
|
|
124
|
+
const posY = 4;
|
|
125
|
+
this.setPosition({ x: posX, y: posY }, false);
|
|
126
|
+
this.size = {
|
|
127
|
+
x: this.terminal.columns - posX,
|
|
128
|
+
y: this.terminal.rows - 3,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=logs.ui.js.map
|