pnpm-catalog-updates 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +15 -0
  2. package/dist/index.js +22031 -10684
  3. package/dist/index.js.map +1 -1
  4. package/package.json +7 -2
  5. package/src/cli/__tests__/commandRegistrar.test.ts +248 -0
  6. package/src/cli/commandRegistrar.ts +785 -0
  7. package/src/cli/commands/__tests__/aiCommand.test.ts +161 -0
  8. package/src/cli/commands/__tests__/analyzeCommand.test.ts +283 -0
  9. package/src/cli/commands/__tests__/checkCommand.test.ts +435 -0
  10. package/src/cli/commands/__tests__/graphCommand.test.ts +312 -0
  11. package/src/cli/commands/__tests__/initCommand.test.ts +317 -0
  12. package/src/cli/commands/__tests__/rollbackCommand.test.ts +400 -0
  13. package/src/cli/commands/__tests__/securityCommand.test.ts +467 -0
  14. package/src/cli/commands/__tests__/themeCommand.test.ts +166 -0
  15. package/src/cli/commands/__tests__/updateCommand.test.ts +720 -0
  16. package/src/cli/commands/__tests__/workspaceCommand.test.ts +286 -0
  17. package/src/cli/commands/aiCommand.ts +163 -0
  18. package/src/cli/commands/analyzeCommand.ts +219 -0
  19. package/src/cli/commands/checkCommand.ts +91 -98
  20. package/src/cli/commands/graphCommand.ts +475 -0
  21. package/src/cli/commands/initCommand.ts +64 -54
  22. package/src/cli/commands/rollbackCommand.ts +334 -0
  23. package/src/cli/commands/securityCommand.ts +165 -100
  24. package/src/cli/commands/themeCommand.ts +148 -0
  25. package/src/cli/commands/updateCommand.ts +215 -263
  26. package/src/cli/commands/workspaceCommand.ts +73 -0
  27. package/src/cli/constants/cliChoices.ts +93 -0
  28. package/src/cli/formatters/__tests__/__snapshots__/outputFormatter.test.ts.snap +557 -0
  29. package/src/cli/formatters/__tests__/ciFormatter.test.ts +526 -0
  30. package/src/cli/formatters/__tests__/outputFormatter.test.ts +448 -0
  31. package/src/cli/formatters/__tests__/progressBar.test.ts +709 -0
  32. package/src/cli/formatters/ciFormatter.ts +964 -0
  33. package/src/cli/formatters/colorUtils.ts +145 -0
  34. package/src/cli/formatters/outputFormatter.ts +615 -332
  35. package/src/cli/formatters/progressBar.ts +43 -52
  36. package/src/cli/formatters/versionFormatter.ts +132 -0
  37. package/src/cli/handlers/aiAnalysisHandler.ts +205 -0
  38. package/src/cli/handlers/changelogHandler.ts +113 -0
  39. package/src/cli/handlers/index.ts +9 -0
  40. package/src/cli/handlers/installHandler.ts +130 -0
  41. package/src/cli/index.ts +175 -726
  42. package/src/cli/interactive/InteractiveOptionsCollector.ts +387 -0
  43. package/src/cli/interactive/interactivePrompts.ts +189 -83
  44. package/src/cli/interactive/optionUtils.ts +89 -0
  45. package/src/cli/themes/colorTheme.ts +43 -16
  46. package/src/cli/utils/cliOutput.ts +118 -0
  47. package/src/cli/utils/commandHelpers.ts +249 -0
  48. package/src/cli/validators/commandValidator.ts +321 -336
  49. package/src/cli/validators/index.ts +37 -2
  50. package/src/cli/options/globalOptions.ts +0 -437
  51. package/src/cli/options/index.ts +0 -5
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Color Utilities for CLI Formatters
3
+ *
4
+ * Provides color-related utilities for terminal output formatting.
5
+ * Extracted from OutputFormatter for better maintainability.
6
+ */
7
+
8
+ import chalk from 'chalk'
9
+
10
+ // Build ANSI escape regex without literal control characters
11
+ const ANSI_ESCAPE = String.fromCharCode(27)
12
+ export const ansiRegex: RegExp = new RegExp(`${ANSI_ESCAPE}\\[[0-9;]*m`, 'g')
13
+
14
+ /**
15
+ * Color utility functions for CLI output formatting
16
+ */
17
+ export class ColorUtils {
18
+ constructor(private readonly useColor: boolean = true) {}
19
+
20
+ /**
21
+ * Apply color if color is enabled
22
+ */
23
+ colorize(colorFn: typeof chalk, text: string): string {
24
+ return this.useColor ? colorFn(text) : text
25
+ }
26
+
27
+ /**
28
+ * Strip ANSI escape codes from a string (for accurate width calculation)
29
+ */
30
+ stripAnsi(str: string): string {
31
+ return str.replace(ansiRegex, '')
32
+ }
33
+
34
+ /**
35
+ * Pad a string containing ANSI codes to a target visible width
36
+ * Returns the original string with trailing spaces to match target width
37
+ */
38
+ padAnsi(str: string, targetWidth: number): string {
39
+ const visibleWidth = this.stripAnsi(str).length
40
+ const padding = Math.max(0, targetWidth - visibleWidth)
41
+ return str + ' '.repeat(padding)
42
+ }
43
+
44
+ /**
45
+ * Colorize table headers
46
+ */
47
+ colorizeHeaders(headers: string[]): string[] {
48
+ return this.useColor ? headers.map((h) => chalk.bold.cyan(h)) : headers
49
+ }
50
+
51
+ /**
52
+ * Get color for update type
53
+ */
54
+ getUpdateTypeColor(updateType: string): typeof chalk {
55
+ switch (updateType) {
56
+ case 'major':
57
+ return chalk.red
58
+ case 'minor':
59
+ return chalk.yellow
60
+ case 'patch':
61
+ return chalk.green
62
+ default:
63
+ return chalk.gray
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Get color for severity level
69
+ */
70
+ getSeverityColor(severity: string): typeof chalk {
71
+ switch (severity.toLowerCase()) {
72
+ case 'critical':
73
+ return chalk.red
74
+ case 'high':
75
+ return chalk.yellow
76
+ case 'moderate':
77
+ return chalk.blue
78
+ case 'low':
79
+ return chalk.green
80
+ default:
81
+ return chalk.gray
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Get color for risk level
87
+ */
88
+ getRiskColor(riskLevel: string): typeof chalk {
89
+ if (!this.useColor) return chalk
90
+
91
+ switch (riskLevel) {
92
+ case 'critical':
93
+ return chalk.red.bold
94
+ case 'high':
95
+ return chalk.red
96
+ case 'medium':
97
+ return chalk.yellow
98
+ case 'low':
99
+ return chalk.green
100
+ default:
101
+ return chalk.gray
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Get color for action
107
+ */
108
+ getActionColor(action: string): typeof chalk {
109
+ if (!this.useColor) return chalk
110
+
111
+ switch (action) {
112
+ case 'update':
113
+ return chalk.green
114
+ case 'wait':
115
+ return chalk.yellow
116
+ case 'skip':
117
+ return chalk.red
118
+ case 'review':
119
+ return chalk.cyan
120
+ default:
121
+ return chalk.white
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Format confidence score with color and visual bar
127
+ */
128
+ formatConfidence(confidence: number): string {
129
+ const percentage = Math.round(confidence * 100)
130
+ const bar =
131
+ '█'.repeat(Math.floor(percentage / 10)) + '░'.repeat(10 - Math.floor(percentage / 10))
132
+
133
+ if (!this.useColor) {
134
+ return `${bar} ${percentage}%`
135
+ }
136
+
137
+ if (confidence >= 0.8) {
138
+ return chalk.green(`${bar} ${percentage}%`)
139
+ } else if (confidence >= 0.5) {
140
+ return chalk.yellow(`${bar} ${percentage}%`)
141
+ } else {
142
+ return chalk.red(`${bar} ${percentage}%`)
143
+ }
144
+ }
145
+ }