pnpm-catalog-updates 0.5.7 → 0.6.5

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 (224) hide show
  1. package/bin/pcu.js +1 -1
  2. package/dist/index.js +9559 -32
  3. package/dist/index.js.map +1 -1
  4. package/package.json +61 -103
  5. package/src/cli/commands/checkCommand.ts +227 -0
  6. package/src/cli/commands/initCommand.ts +394 -0
  7. package/src/cli/commands/securityCommand.ts +569 -0
  8. package/src/cli/commands/updateCommand.ts +245 -0
  9. package/src/cli/formatters/outputFormatter.ts +830 -0
  10. package/src/cli/formatters/progressBar.ts +700 -0
  11. package/src/cli/index.ts +565 -0
  12. package/src/cli/interactive/interactivePrompts.ts +517 -0
  13. package/src/cli/options/globalOptions.ts +380 -0
  14. package/src/cli/options/index.ts +5 -0
  15. package/src/cli/themes/colorTheme.ts +379 -0
  16. package/src/cli/validators/commandValidator.ts +395 -0
  17. package/src/cli/validators/index.ts +5 -0
  18. package/src/index.ts +4 -0
  19. package/LICENSE +0 -21
  20. package/README.ja.md +0 -587
  21. package/README.md +0 -694
  22. package/README.zh-CN.md +0 -634
  23. package/dist/application/services/CatalogUpdateService.d.ts +0 -209
  24. package/dist/application/services/CatalogUpdateService.d.ts.map +0 -1
  25. package/dist/application/services/CatalogUpdateService.js +0 -839
  26. package/dist/application/services/CatalogUpdateService.js.map +0 -1
  27. package/dist/application/services/WorkspaceService.d.ts +0 -139
  28. package/dist/application/services/WorkspaceService.d.ts.map +0 -1
  29. package/dist/application/services/WorkspaceService.js +0 -340
  30. package/dist/application/services/WorkspaceService.js.map +0 -1
  31. package/dist/cli/commands/CheckCommand.d.ts +0 -40
  32. package/dist/cli/commands/CheckCommand.d.ts.map +0 -1
  33. package/dist/cli/commands/CheckCommand.js +0 -177
  34. package/dist/cli/commands/CheckCommand.js.map +0 -1
  35. package/dist/cli/commands/InitCommand.d.ts +0 -53
  36. package/dist/cli/commands/InitCommand.d.ts.map +0 -1
  37. package/dist/cli/commands/InitCommand.js +0 -338
  38. package/dist/cli/commands/InitCommand.js.map +0 -1
  39. package/dist/cli/commands/SecurityCommand.d.ts +0 -113
  40. package/dist/cli/commands/SecurityCommand.d.ts.map +0 -1
  41. package/dist/cli/commands/SecurityCommand.js +0 -410
  42. package/dist/cli/commands/SecurityCommand.js.map +0 -1
  43. package/dist/cli/commands/UpdateCommand.d.ts +0 -44
  44. package/dist/cli/commands/UpdateCommand.d.ts.map +0 -1
  45. package/dist/cli/commands/UpdateCommand.js +0 -189
  46. package/dist/cli/commands/UpdateCommand.js.map +0 -1
  47. package/dist/cli/formatters/OutputFormatter.d.ts +0 -116
  48. package/dist/cli/formatters/OutputFormatter.d.ts.map +0 -1
  49. package/dist/cli/formatters/OutputFormatter.js +0 -664
  50. package/dist/cli/formatters/OutputFormatter.js.map +0 -1
  51. package/dist/cli/formatters/ProgressBar.d.ts +0 -195
  52. package/dist/cli/formatters/ProgressBar.d.ts.map +0 -1
  53. package/dist/cli/formatters/ProgressBar.js +0 -622
  54. package/dist/cli/formatters/ProgressBar.js.map +0 -1
  55. package/dist/cli/index.d.ts +0 -12
  56. package/dist/cli/index.d.ts.map +0 -1
  57. package/dist/cli/index.js +0 -492
  58. package/dist/cli/index.js.map +0 -1
  59. package/dist/cli/interactive/InteractivePrompts.d.ts +0 -85
  60. package/dist/cli/interactive/InteractivePrompts.d.ts.map +0 -1
  61. package/dist/cli/interactive/InteractivePrompts.js +0 -434
  62. package/dist/cli/interactive/InteractivePrompts.js.map +0 -1
  63. package/dist/cli/options/GlobalOptions.d.ts +0 -117
  64. package/dist/cli/options/GlobalOptions.d.ts.map +0 -1
  65. package/dist/cli/options/GlobalOptions.js +0 -278
  66. package/dist/cli/options/GlobalOptions.js.map +0 -1
  67. package/dist/cli/options/index.d.ts +0 -5
  68. package/dist/cli/options/index.d.ts.map +0 -1
  69. package/dist/cli/options/index.js +0 -5
  70. package/dist/cli/options/index.js.map +0 -1
  71. package/dist/cli/themes/ColorTheme.d.ts +0 -211
  72. package/dist/cli/themes/ColorTheme.d.ts.map +0 -1
  73. package/dist/cli/themes/ColorTheme.js +0 -267
  74. package/dist/cli/themes/ColorTheme.js.map +0 -1
  75. package/dist/cli/validators/CommandValidator.d.ts +0 -60
  76. package/dist/cli/validators/CommandValidator.d.ts.map +0 -1
  77. package/dist/cli/validators/CommandValidator.js +0 -319
  78. package/dist/cli/validators/CommandValidator.js.map +0 -1
  79. package/dist/cli/validators/index.d.ts +0 -5
  80. package/dist/cli/validators/index.d.ts.map +0 -1
  81. package/dist/cli/validators/index.js +0 -5
  82. package/dist/cli/validators/index.js.map +0 -1
  83. package/dist/common/config/Config.d.ts +0 -142
  84. package/dist/common/config/Config.d.ts.map +0 -1
  85. package/dist/common/config/Config.js +0 -382
  86. package/dist/common/config/Config.js.map +0 -1
  87. package/dist/common/config/ConfigLoader.d.ts +0 -49
  88. package/dist/common/config/ConfigLoader.d.ts.map +0 -1
  89. package/dist/common/config/ConfigLoader.js +0 -180
  90. package/dist/common/config/ConfigLoader.js.map +0 -1
  91. package/dist/common/config/PackageFilterConfig.d.ts +0 -56
  92. package/dist/common/config/PackageFilterConfig.d.ts.map +0 -1
  93. package/dist/common/config/PackageFilterConfig.js +0 -94
  94. package/dist/common/config/PackageFilterConfig.js.map +0 -1
  95. package/dist/common/config/index.d.ts +0 -8
  96. package/dist/common/config/index.d.ts.map +0 -1
  97. package/dist/common/config/index.js +0 -8
  98. package/dist/common/config/index.js.map +0 -1
  99. package/dist/common/error-handling/ErrorTracker.d.ts +0 -48
  100. package/dist/common/error-handling/ErrorTracker.d.ts.map +0 -1
  101. package/dist/common/error-handling/ErrorTracker.js +0 -93
  102. package/dist/common/error-handling/ErrorTracker.js.map +0 -1
  103. package/dist/common/error-handling/UserFriendlyErrorHandler.d.ts +0 -74
  104. package/dist/common/error-handling/UserFriendlyErrorHandler.d.ts.map +0 -1
  105. package/dist/common/error-handling/UserFriendlyErrorHandler.js +0 -703
  106. package/dist/common/error-handling/UserFriendlyErrorHandler.js.map +0 -1
  107. package/dist/common/error-handling/index.d.ts +0 -11
  108. package/dist/common/error-handling/index.d.ts.map +0 -1
  109. package/dist/common/error-handling/index.js +0 -9
  110. package/dist/common/error-handling/index.js.map +0 -1
  111. package/dist/common/logger/Logger.d.ts +0 -110
  112. package/dist/common/logger/Logger.d.ts.map +0 -1
  113. package/dist/common/logger/Logger.js +0 -289
  114. package/dist/common/logger/Logger.js.map +0 -1
  115. package/dist/common/logger/index.d.ts +0 -6
  116. package/dist/common/logger/index.d.ts.map +0 -1
  117. package/dist/common/logger/index.js +0 -6
  118. package/dist/common/logger/index.js.map +0 -1
  119. package/dist/common/types/cli.d.ts +0 -265
  120. package/dist/common/types/cli.d.ts.map +0 -1
  121. package/dist/common/types/cli.js +0 -5
  122. package/dist/common/types/cli.js.map +0 -1
  123. package/dist/common/types/core.d.ts +0 -270
  124. package/dist/common/types/core.d.ts.map +0 -1
  125. package/dist/common/types/core.js +0 -32
  126. package/dist/common/types/core.js.map +0 -1
  127. package/dist/common/types/index.d.ts +0 -8
  128. package/dist/common/types/index.d.ts.map +0 -1
  129. package/dist/common/types/index.js +0 -8
  130. package/dist/common/types/index.js.map +0 -1
  131. package/dist/common/utils/VersionChecker.d.ts +0 -54
  132. package/dist/common/utils/VersionChecker.d.ts.map +0 -1
  133. package/dist/common/utils/VersionChecker.js +0 -180
  134. package/dist/common/utils/VersionChecker.js.map +0 -1
  135. package/dist/common/utils/async.d.ts +0 -74
  136. package/dist/common/utils/async.d.ts.map +0 -1
  137. package/dist/common/utils/async.js +0 -228
  138. package/dist/common/utils/async.js.map +0 -1
  139. package/dist/common/utils/format.d.ts +0 -32
  140. package/dist/common/utils/format.d.ts.map +0 -1
  141. package/dist/common/utils/format.js +0 -121
  142. package/dist/common/utils/format.js.map +0 -1
  143. package/dist/common/utils/git.d.ts +0 -44
  144. package/dist/common/utils/git.d.ts.map +0 -1
  145. package/dist/common/utils/git.js +0 -147
  146. package/dist/common/utils/git.js.map +0 -1
  147. package/dist/common/utils/index.d.ts +0 -12
  148. package/dist/common/utils/index.d.ts.map +0 -1
  149. package/dist/common/utils/index.js +0 -12
  150. package/dist/common/utils/index.js.map +0 -1
  151. package/dist/common/utils/string.d.ts +0 -56
  152. package/dist/common/utils/string.d.ts.map +0 -1
  153. package/dist/common/utils/string.js +0 -134
  154. package/dist/common/utils/string.js.map +0 -1
  155. package/dist/common/utils/validation.d.ts +0 -88
  156. package/dist/common/utils/validation.d.ts.map +0 -1
  157. package/dist/common/utils/validation.js +0 -308
  158. package/dist/common/utils/validation.js.map +0 -1
  159. package/dist/domain/entities/Catalog.d.ts +0 -117
  160. package/dist/domain/entities/Catalog.d.ts.map +0 -1
  161. package/dist/domain/entities/Catalog.js +0 -240
  162. package/dist/domain/entities/Catalog.js.map +0 -1
  163. package/dist/domain/entities/Package.d.ts +0 -143
  164. package/dist/domain/entities/Package.d.ts.map +0 -1
  165. package/dist/domain/entities/Package.js +0 -272
  166. package/dist/domain/entities/Package.js.map +0 -1
  167. package/dist/domain/entities/Workspace.d.ts +0 -95
  168. package/dist/domain/entities/Workspace.d.ts.map +0 -1
  169. package/dist/domain/entities/Workspace.js +0 -173
  170. package/dist/domain/entities/Workspace.js.map +0 -1
  171. package/dist/domain/repositories/WorkspaceRepository.d.ts +0 -41
  172. package/dist/domain/repositories/WorkspaceRepository.d.ts.map +0 -1
  173. package/dist/domain/repositories/WorkspaceRepository.js +0 -8
  174. package/dist/domain/repositories/WorkspaceRepository.js.map +0 -1
  175. package/dist/domain/value-objects/CatalogCollection.d.ts +0 -106
  176. package/dist/domain/value-objects/CatalogCollection.d.ts.map +0 -1
  177. package/dist/domain/value-objects/CatalogCollection.js +0 -230
  178. package/dist/domain/value-objects/CatalogCollection.js.map +0 -1
  179. package/dist/domain/value-objects/PackageCollection.d.ts +0 -122
  180. package/dist/domain/value-objects/PackageCollection.d.ts.map +0 -1
  181. package/dist/domain/value-objects/PackageCollection.js +0 -263
  182. package/dist/domain/value-objects/PackageCollection.js.map +0 -1
  183. package/dist/domain/value-objects/Version.d.ts +0 -141
  184. package/dist/domain/value-objects/Version.d.ts.map +0 -1
  185. package/dist/domain/value-objects/Version.js +0 -268
  186. package/dist/domain/value-objects/Version.js.map +0 -1
  187. package/dist/domain/value-objects/WorkspaceConfig.d.ts +0 -144
  188. package/dist/domain/value-objects/WorkspaceConfig.d.ts.map +0 -1
  189. package/dist/domain/value-objects/WorkspaceConfig.js +0 -357
  190. package/dist/domain/value-objects/WorkspaceConfig.js.map +0 -1
  191. package/dist/domain/value-objects/WorkspaceId.d.ts +0 -51
  192. package/dist/domain/value-objects/WorkspaceId.d.ts.map +0 -1
  193. package/dist/domain/value-objects/WorkspaceId.js +0 -104
  194. package/dist/domain/value-objects/WorkspaceId.js.map +0 -1
  195. package/dist/domain/value-objects/WorkspacePath.d.ts +0 -75
  196. package/dist/domain/value-objects/WorkspacePath.d.ts.map +0 -1
  197. package/dist/domain/value-objects/WorkspacePath.js +0 -128
  198. package/dist/domain/value-objects/WorkspacePath.js.map +0 -1
  199. package/dist/index.d.ts +0 -25
  200. package/dist/index.d.ts.map +0 -1
  201. package/dist/infrastructure/cache/Cache.d.ts +0 -161
  202. package/dist/infrastructure/cache/Cache.d.ts.map +0 -1
  203. package/dist/infrastructure/cache/Cache.js +0 -398
  204. package/dist/infrastructure/cache/Cache.js.map +0 -1
  205. package/dist/infrastructure/cache/index.d.ts +0 -6
  206. package/dist/infrastructure/cache/index.d.ts.map +0 -1
  207. package/dist/infrastructure/cache/index.js +0 -6
  208. package/dist/infrastructure/cache/index.js.map +0 -1
  209. package/dist/infrastructure/external-services/NpmRegistryService.d.ts +0 -153
  210. package/dist/infrastructure/external-services/NpmRegistryService.d.ts.map +0 -1
  211. package/dist/infrastructure/external-services/NpmRegistryService.js +0 -511
  212. package/dist/infrastructure/external-services/NpmRegistryService.js.map +0 -1
  213. package/dist/infrastructure/file-system/FileSystemService.d.ts +0 -120
  214. package/dist/infrastructure/file-system/FileSystemService.d.ts.map +0 -1
  215. package/dist/infrastructure/file-system/FileSystemService.js +0 -663
  216. package/dist/infrastructure/file-system/FileSystemService.js.map +0 -1
  217. package/dist/infrastructure/repositories/FileWorkspaceRepository.d.ts +0 -57
  218. package/dist/infrastructure/repositories/FileWorkspaceRepository.d.ts.map +0 -1
  219. package/dist/infrastructure/repositories/FileWorkspaceRepository.js +0 -179
  220. package/dist/infrastructure/repositories/FileWorkspaceRepository.js.map +0 -1
  221. package/dist/infrastructure/utils/NpmrcParser.d.ts +0 -40
  222. package/dist/infrastructure/utils/NpmrcParser.d.ts.map +0 -1
  223. package/dist/infrastructure/utils/NpmrcParser.js +0 -157
  224. package/dist/infrastructure/utils/NpmrcParser.js.map +0 -1
@@ -1,664 +0,0 @@
1
- /**
2
- * Output Formatter
3
- *
4
- * Provides formatted output for CLI commands in various formats.
5
- * Supports table, JSON, YAML, and minimal output formats.
6
- */
7
- import chalk from 'chalk';
8
- import Table from 'cli-table3';
9
- import YAML from 'yaml';
10
- // Build ANSI escape regex without literal control characters
11
- const ANSI_ESCAPE = String.fromCharCode(27);
12
- const ansiRegex = new RegExp(`${ANSI_ESCAPE}\\[[0-9;]*m`, 'g');
13
- export class OutputFormatter {
14
- format;
15
- useColor;
16
- constructor(format = 'table', useColor = true) {
17
- this.format = format;
18
- this.useColor = useColor;
19
- }
20
- /**
21
- * Format outdated dependencies report
22
- */
23
- formatOutdatedReport(report) {
24
- switch (this.format) {
25
- case 'json':
26
- return JSON.stringify(report, null, 2);
27
- case 'yaml':
28
- return YAML.stringify(report);
29
- case 'minimal':
30
- return this.formatOutdatedMinimal(report);
31
- case 'table':
32
- default:
33
- return this.formatOutdatedTable(report);
34
- }
35
- }
36
- /**
37
- * Format update result
38
- */
39
- formatUpdateResult(result) {
40
- switch (this.format) {
41
- case 'json':
42
- return JSON.stringify(result, null, 2);
43
- case 'yaml':
44
- return YAML.stringify(result);
45
- case 'minimal':
46
- return this.formatUpdateMinimal(result);
47
- case 'table':
48
- default:
49
- return this.formatUpdateTable(result);
50
- }
51
- }
52
- /**
53
- * Format impact analysis
54
- */
55
- formatImpactAnalysis(analysis) {
56
- switch (this.format) {
57
- case 'json':
58
- return JSON.stringify(analysis, null, 2);
59
- case 'yaml':
60
- return YAML.stringify(analysis);
61
- case 'minimal':
62
- return this.formatImpactMinimal(analysis);
63
- case 'table':
64
- default:
65
- return this.formatImpactTable(analysis);
66
- }
67
- }
68
- /**
69
- * Format workspace validation report
70
- */
71
- formatValidationReport(report) {
72
- switch (this.format) {
73
- case 'json':
74
- return JSON.stringify(report, null, 2);
75
- case 'yaml':
76
- return YAML.stringify(report);
77
- case 'minimal':
78
- return this.formatValidationMinimal(report);
79
- case 'table':
80
- default:
81
- return this.formatValidationTable(report);
82
- }
83
- }
84
- /**
85
- * Format workspace statistics
86
- */
87
- formatWorkspaceStats(stats) {
88
- switch (this.format) {
89
- case 'json':
90
- return JSON.stringify(stats, null, 2);
91
- case 'yaml':
92
- return YAML.stringify(stats);
93
- case 'minimal':
94
- return this.formatStatsMinimal(stats);
95
- case 'table':
96
- default:
97
- return this.formatStatsTable(stats);
98
- }
99
- }
100
- /**
101
- * Format security report
102
- */
103
- formatSecurityReport(report) {
104
- switch (this.format) {
105
- case 'json':
106
- return JSON.stringify(report, null, 2);
107
- case 'yaml':
108
- return YAML.stringify(report);
109
- case 'minimal':
110
- return this.formatSecurityMinimal(report);
111
- case 'table':
112
- default:
113
- return this.formatSecurityTable(report);
114
- }
115
- }
116
- /**
117
- * Format simple message with optional styling
118
- */
119
- formatMessage(message, type = 'info') {
120
- if (!this.useColor) {
121
- return message;
122
- }
123
- switch (type) {
124
- case 'success':
125
- return chalk.green(message);
126
- case 'error':
127
- return chalk.red(message);
128
- case 'warning':
129
- return chalk.yellow(message);
130
- case 'info':
131
- default:
132
- return chalk.blue(message);
133
- }
134
- }
135
- /**
136
- * Format outdated dependencies as table
137
- */
138
- formatOutdatedTable(report) {
139
- const lines = [];
140
- // Header
141
- lines.push(this.colorize(chalk.bold, `\n📦 Workspace: ${report.workspace.name}`));
142
- lines.push(this.colorize(chalk.gray, `Path: ${report.workspace.path}`));
143
- if (!report.hasUpdates) {
144
- lines.push(this.colorize(chalk.green, '\n✅ All catalog dependencies are up to date!'));
145
- return lines.join('\n');
146
- }
147
- lines.push(this.colorize(chalk.yellow, `\n🔄 Found ${report.totalOutdated} outdated dependencies\n`));
148
- for (const catalogInfo of report.catalogs) {
149
- if (catalogInfo.outdatedCount === 0)
150
- continue;
151
- lines.push(this.colorize(chalk.bold, `📋 Catalog: ${catalogInfo.catalogName}`));
152
- const table = new Table({
153
- head: this.colorizeHeaders(['Package', 'Current', 'Latest', 'Type', 'Packages']),
154
- style: { head: [], border: [] },
155
- colWidths: [25, 15, 15, 8, 20],
156
- });
157
- for (const dep of catalogInfo.outdatedDependencies) {
158
- const typeColor = this.getUpdateTypeColor(dep.updateType);
159
- const securityIcon = dep.isSecurityUpdate ? '🔒 ' : '';
160
- // Colorize version differences
161
- const { currentColored, latestColored } = this.colorizeVersionDiff(dep.currentVersion, dep.latestVersion, dep.updateType);
162
- table.push([
163
- `${securityIcon}${dep.packageName}`,
164
- currentColored,
165
- latestColored,
166
- this.colorize(typeColor, dep.updateType),
167
- `${dep.affectedPackages.length} package(s)`,
168
- ]);
169
- }
170
- lines.push(table.toString());
171
- lines.push('');
172
- }
173
- return lines.join('\n');
174
- }
175
- /**
176
- * Format outdated dependencies minimally (npm-check-updates style)
177
- */
178
- formatOutdatedMinimal(report) {
179
- if (!report.hasUpdates) {
180
- return 'All dependencies up to date';
181
- }
182
- // Collect all dependencies first to calculate max package name width
183
- const allDeps = [];
184
- for (const catalogInfo of report.catalogs) {
185
- for (const dep of catalogInfo.outdatedDependencies) {
186
- const securityIcon = dep.isSecurityUpdate ? '🔒 ' : '';
187
- const { currentColored, latestColored } = this.colorizeVersionDiff(dep.currentVersion, dep.latestVersion, dep.updateType);
188
- allDeps.push({
189
- securityIcon,
190
- packageName: dep.packageName,
191
- currentColored,
192
- latestColored,
193
- });
194
- }
195
- }
196
- // Calculate max widths for alignment
197
- const maxNameWidth = Math.max(...allDeps.map((dep) => (dep.securityIcon + dep.packageName).length));
198
- // Calculate max version widths (need to strip color codes for accurate width calculation)
199
- const stripAnsi = (str) => str.replace(ansiRegex, '');
200
- const maxCurrentWidth = Math.max(...allDeps.map((dep) => stripAnsi(dep.currentColored).length));
201
- // Format lines with proper alignment
202
- const lines = [];
203
- for (const dep of allDeps) {
204
- const nameWithIcon = dep.securityIcon + dep.packageName;
205
- const paddedName = nameWithIcon.padEnd(maxNameWidth);
206
- // For current version alignment, we need to pad the visible text, not the colored version
207
- const currentVisible = stripAnsi(dep.currentColored);
208
- const currentPadding = maxCurrentWidth - currentVisible.length;
209
- const paddedCurrent = dep.currentColored + ' '.repeat(currentPadding);
210
- lines.push(`${paddedName} ${paddedCurrent} → ${dep.latestColored}`);
211
- }
212
- return lines.join('\n');
213
- }
214
- /**
215
- * Format update result as table
216
- */
217
- formatUpdateTable(result) {
218
- const lines = [];
219
- // Header
220
- lines.push(this.colorize(chalk.bold, `\n📦 Workspace: ${result.workspace.name}`));
221
- if (result.success) {
222
- lines.push(this.colorize(chalk.green, '✅ Update completed successfully!'));
223
- }
224
- else {
225
- lines.push(this.colorize(chalk.red, '❌ Update completed with errors'));
226
- }
227
- lines.push('');
228
- // Updated dependencies
229
- if (result.updatedDependencies.length > 0) {
230
- lines.push(this.colorize(chalk.green, `🎉 Updated ${result.totalUpdated} dependencies:`));
231
- const table = new Table({
232
- head: this.colorizeHeaders(['Catalog', 'Package', 'From', 'To', 'Type']),
233
- style: { head: [], border: [] },
234
- colWidths: [15, 25, 15, 15, 8],
235
- });
236
- for (const dep of result.updatedDependencies) {
237
- const typeColor = this.getUpdateTypeColor(dep.updateType);
238
- // Colorize version differences
239
- const { currentColored, latestColored } = this.colorizeVersionDiff(dep.fromVersion, dep.toVersion, dep.updateType);
240
- table.push([
241
- dep.catalogName,
242
- dep.packageName,
243
- currentColored,
244
- latestColored,
245
- this.colorize(typeColor, dep.updateType),
246
- ]);
247
- }
248
- lines.push(table.toString());
249
- lines.push('');
250
- }
251
- // Skipped dependencies
252
- if (result.skippedDependencies.length > 0) {
253
- lines.push(this.colorize(chalk.yellow, `⚠️ Skipped ${result.totalSkipped} dependencies:`));
254
- for (const dep of result.skippedDependencies) {
255
- lines.push(` ${dep.catalogName}:${dep.packageName} - ${dep.reason}`);
256
- }
257
- lines.push('');
258
- }
259
- // Errors
260
- if (result.errors.length > 0) {
261
- lines.push(this.colorize(chalk.red, `❌ ${result.totalErrors} errors occurred:`));
262
- for (const error of result.errors) {
263
- const prefix = error.fatal ? '💥' : '⚠️ ';
264
- lines.push(` ${prefix} ${error.catalogName}:${error.packageName} - ${error.error}`);
265
- }
266
- }
267
- return lines.join('\n');
268
- }
269
- /**
270
- * Format update result minimally (npm-check-updates style)
271
- */
272
- formatUpdateMinimal(result) {
273
- const lines = [];
274
- if (result.success) {
275
- lines.push(`Updated ${result.totalUpdated} dependencies`);
276
- }
277
- else {
278
- lines.push(`Update failed with ${result.totalErrors} errors`);
279
- }
280
- if (result.updatedDependencies.length > 0) {
281
- // Collect version info for alignment calculation
282
- const depsWithVersions = result.updatedDependencies.map((dep) => {
283
- const { currentColored, latestColored } = this.colorizeVersionDiff(dep.fromVersion, dep.toVersion, dep.updateType);
284
- return {
285
- packageName: dep.packageName,
286
- currentColored,
287
- latestColored,
288
- };
289
- });
290
- // Calculate max widths for alignment
291
- const maxNameWidth = Math.max(...depsWithVersions.map((dep) => dep.packageName.length));
292
- const stripAnsi = (str) => str.replace(ansiRegex, '');
293
- const maxCurrentWidth = Math.max(...depsWithVersions.map((dep) => stripAnsi(dep.currentColored).length));
294
- for (const dep of depsWithVersions) {
295
- const paddedName = dep.packageName.padEnd(maxNameWidth);
296
- // Pad current version for alignment
297
- const currentVisible = stripAnsi(dep.currentColored);
298
- const currentPadding = maxCurrentWidth - currentVisible.length;
299
- const paddedCurrent = dep.currentColored + ' '.repeat(currentPadding);
300
- lines.push(`${paddedName} ${paddedCurrent} → ${dep.latestColored}`);
301
- }
302
- }
303
- return lines.join('\n');
304
- }
305
- /**
306
- * Format impact analysis as table
307
- */
308
- formatImpactTable(analysis) {
309
- const lines = [];
310
- // Header
311
- lines.push(this.colorize(chalk.bold, `\n🔍 Impact Analysis: ${analysis.packageName}`));
312
- lines.push(this.colorize(chalk.gray, `Catalog: ${analysis.catalogName}`));
313
- lines.push(this.colorize(chalk.gray, `Update: ${analysis.currentVersion} → ${analysis.proposedVersion}`));
314
- lines.push(this.colorize(chalk.gray, `Type: ${analysis.updateType}`));
315
- // Risk level
316
- const riskColor = this.getRiskColor(analysis.riskLevel);
317
- lines.push(this.colorize(riskColor, `Risk Level: ${analysis.riskLevel.toUpperCase()}`));
318
- lines.push('');
319
- // Affected packages
320
- if (analysis.affectedPackages.length > 0) {
321
- lines.push(this.colorize(chalk.bold, '📦 Affected Packages:'));
322
- const table = new Table({
323
- head: this.colorizeHeaders(['Package', 'Path', 'Dependency Type', 'Risk']),
324
- style: { head: [], border: [] },
325
- colWidths: [20, 30, 15, 10],
326
- });
327
- for (const pkg of analysis.affectedPackages) {
328
- const riskColor = this.getRiskColor(pkg.compatibilityRisk);
329
- table.push([
330
- pkg.packageName,
331
- pkg.packagePath,
332
- pkg.dependencyType,
333
- this.colorize(riskColor, pkg.compatibilityRisk),
334
- ]);
335
- }
336
- lines.push(table.toString());
337
- lines.push('');
338
- }
339
- // Security impact
340
- if (analysis.securityImpact.hasVulnerabilities) {
341
- lines.push(this.colorize(chalk.bold, '🔒 Security Impact:'));
342
- if (analysis.securityImpact.fixedVulnerabilities > 0) {
343
- lines.push(this.colorize(chalk.green, ` ✅ Fixes ${analysis.securityImpact.fixedVulnerabilities} vulnerabilities`));
344
- }
345
- if (analysis.securityImpact.newVulnerabilities > 0) {
346
- lines.push(this.colorize(chalk.red, ` ⚠️ Introduces ${analysis.securityImpact.newVulnerabilities} vulnerabilities`));
347
- }
348
- lines.push('');
349
- }
350
- // Recommendations
351
- if (analysis.recommendations.length > 0) {
352
- lines.push(this.colorize(chalk.bold, '💡 Recommendations:'));
353
- for (const rec of analysis.recommendations) {
354
- lines.push(` ${rec}`);
355
- }
356
- }
357
- return lines.join('\n');
358
- }
359
- /**
360
- * Format impact analysis minimally
361
- */
362
- formatImpactMinimal(analysis) {
363
- return [
364
- `${analysis.packageName}: ${analysis.currentVersion} → ${analysis.proposedVersion}`,
365
- `Risk: ${analysis.riskLevel}`,
366
- `Affected: ${analysis.affectedPackages.length} packages`,
367
- ].join('\n');
368
- }
369
- /**
370
- * Format validation report as table
371
- */
372
- formatValidationTable(report) {
373
- const lines = [];
374
- // Header
375
- const statusIcon = report.isValid ? '✅' : '❌';
376
- const statusColor = report.isValid ? chalk.green : chalk.red;
377
- lines.push(this.colorize(chalk.bold, `\n${statusIcon} Workspace Validation`));
378
- lines.push(this.colorize(statusColor, `Status: ${report.isValid ? 'VALID' : 'INVALID'}`));
379
- lines.push('');
380
- // Workspace info
381
- lines.push(this.colorize(chalk.bold, '📦 Workspace Information:'));
382
- lines.push(` Path: ${report.workspace.path}`);
383
- lines.push(` Name: ${report.workspace.name}`);
384
- lines.push(` Packages: ${report.workspace.packageCount}`);
385
- lines.push(` Catalogs: ${report.workspace.catalogCount}`);
386
- lines.push('');
387
- // Errors
388
- if (report.errors.length > 0) {
389
- lines.push(this.colorize(chalk.red, '❌ Errors:'));
390
- for (const error of report.errors) {
391
- lines.push(` • ${error}`);
392
- }
393
- lines.push('');
394
- }
395
- // Warnings
396
- if (report.warnings.length > 0) {
397
- lines.push(this.colorize(chalk.yellow, '⚠️ Warnings:'));
398
- for (const warning of report.warnings) {
399
- lines.push(` • ${warning}`);
400
- }
401
- lines.push('');
402
- }
403
- // Recommendations
404
- if (report.recommendations.length > 0) {
405
- lines.push(this.colorize(chalk.blue, '💡 Recommendations:'));
406
- for (const rec of report.recommendations) {
407
- lines.push(` • ${rec}`);
408
- }
409
- }
410
- return lines.join('\n');
411
- }
412
- /**
413
- * Format validation report minimally
414
- */
415
- formatValidationMinimal(report) {
416
- const status = report.isValid ? 'VALID' : 'INVALID';
417
- const errors = report.errors.length;
418
- const warnings = report.warnings.length;
419
- return `${status} (${errors} errors, ${warnings} warnings)`;
420
- }
421
- /**
422
- * Format workspace statistics as table
423
- */
424
- formatStatsTable(stats) {
425
- const lines = [];
426
- lines.push(this.colorize(chalk.bold, `\n📊 Workspace Statistics`));
427
- lines.push(this.colorize(chalk.gray, `Workspace: ${stats.workspace.name}`));
428
- lines.push('');
429
- const table = new Table({
430
- head: this.colorizeHeaders(['Metric', 'Count']),
431
- style: { head: [], border: [] },
432
- colWidths: [30, 10],
433
- });
434
- table.push(['Total Packages', stats.packages.total.toString()]);
435
- table.push(['Packages with Catalog Refs', stats.packages.withCatalogReferences.toString()]);
436
- table.push(['Total Catalogs', stats.catalogs.total.toString()]);
437
- table.push(['Catalog Entries', stats.catalogs.totalEntries.toString()]);
438
- table.push(['Total Dependencies', stats.dependencies.total.toString()]);
439
- table.push(['Catalog References', stats.dependencies.catalogReferences.toString()]);
440
- table.push(['Dependencies', stats.dependencies.byType.dependencies.toString()]);
441
- table.push(['Dev Dependencies', stats.dependencies.byType.devDependencies.toString()]);
442
- table.push(['Peer Dependencies', stats.dependencies.byType.peerDependencies.toString()]);
443
- table.push([
444
- 'Optional Dependencies',
445
- stats.dependencies.byType.optionalDependencies.toString(),
446
- ]);
447
- lines.push(table.toString());
448
- return lines.join('\n');
449
- }
450
- /**
451
- * Format workspace statistics minimally
452
- */
453
- formatStatsMinimal(stats) {
454
- return [
455
- `Packages: ${stats.packages.total}`,
456
- `Catalogs: ${stats.catalogs.total}`,
457
- `Dependencies: ${stats.dependencies.total}`,
458
- ].join(', ');
459
- }
460
- /**
461
- * Format security report as table
462
- */
463
- formatSecurityTable(report) {
464
- const lines = [];
465
- // Header
466
- lines.push(this.colorize(chalk.bold, '\n🔒 Security Report'));
467
- lines.push(this.colorize(chalk.gray, `Workspace: ${report.metadata.workspacePath}`));
468
- lines.push(this.colorize(chalk.gray, `Scan Date: ${new Date(report.metadata.scanDate).toLocaleString()}`));
469
- lines.push(this.colorize(chalk.gray, `Tools: ${report.metadata.scanTools.join(', ')}`));
470
- // Summary
471
- lines.push('');
472
- lines.push(this.colorize(chalk.bold, '📊 Summary:'));
473
- const summaryTable = new Table({
474
- head: this.colorizeHeaders(['Severity', 'Count']),
475
- style: { head: [], border: [] },
476
- colWidths: [15, 10],
477
- });
478
- summaryTable.push(['Critical', this.colorize(chalk.red, report.summary.critical.toString())]);
479
- summaryTable.push(['High', this.colorize(chalk.yellow, report.summary.high.toString())]);
480
- summaryTable.push(['Moderate', this.colorize(chalk.blue, report.summary.moderate.toString())]);
481
- summaryTable.push(['Low', this.colorize(chalk.green, report.summary.low.toString())]);
482
- summaryTable.push(['Info', this.colorize(chalk.gray, report.summary.info.toString())]);
483
- summaryTable.push([
484
- 'Total',
485
- this.colorize(chalk.bold, report.summary.totalVulnerabilities.toString()),
486
- ]);
487
- lines.push(summaryTable.toString());
488
- // Vulnerabilities
489
- if (report.vulnerabilities.length > 0) {
490
- lines.push('');
491
- lines.push(this.colorize(chalk.bold, '🐛 Vulnerabilities:'));
492
- const vulnTable = new Table({
493
- head: this.colorizeHeaders(['Package', 'Severity', 'Title', 'Fix Available']),
494
- style: { head: [], border: [] },
495
- colWidths: [20, 12, 40, 15],
496
- });
497
- for (const vuln of report.vulnerabilities) {
498
- const severityColor = this.getSeverityColor(vuln.severity);
499
- const fixStatus = vuln.fixAvailable
500
- ? typeof vuln.fixAvailable === 'string'
501
- ? vuln.fixAvailable
502
- : 'Yes'
503
- : 'No';
504
- vulnTable.push([
505
- vuln.package,
506
- this.colorize(severityColor, vuln.severity.toUpperCase()),
507
- vuln.title.length > 35 ? vuln.title.substring(0, 35) + '...' : vuln.title,
508
- fixStatus,
509
- ]);
510
- }
511
- lines.push(vulnTable.toString());
512
- }
513
- // Recommendations
514
- if (report.recommendations.length > 0) {
515
- lines.push('');
516
- lines.push(this.colorize(chalk.bold, '💡 Recommendations:'));
517
- for (const rec of report.recommendations) {
518
- lines.push(` ${rec.package}: ${rec.currentVersion} → ${rec.recommendedVersion}`);
519
- lines.push(` ${rec.reason} (${rec.impact})`);
520
- }
521
- }
522
- return lines.join('\n');
523
- }
524
- /**
525
- * Format security report minimally
526
- */
527
- formatSecurityMinimal(report) {
528
- const vulnerabilities = report.summary.totalVulnerabilities;
529
- if (vulnerabilities === 0) {
530
- return 'No vulnerabilities found';
531
- }
532
- return [
533
- `${vulnerabilities} vulnerabilities found:`,
534
- ` Critical: ${report.summary.critical}`,
535
- ` High: ${report.summary.high}`,
536
- ` Moderate: ${report.summary.moderate}`,
537
- ` Low: ${report.summary.low}`,
538
- ].join('\n');
539
- }
540
- /**
541
- * Get color for severity level
542
- */
543
- getSeverityColor(severity) {
544
- switch (severity.toLowerCase()) {
545
- case 'critical':
546
- return chalk.red;
547
- case 'high':
548
- return chalk.yellow;
549
- case 'moderate':
550
- return chalk.blue;
551
- case 'low':
552
- return chalk.green;
553
- default:
554
- return chalk.gray;
555
- }
556
- }
557
- /**
558
- * Apply color if color is enabled
559
- */
560
- colorize(colorFn, text) {
561
- return this.useColor ? colorFn(text) : text;
562
- }
563
- /**
564
- * Colorize table headers
565
- */
566
- colorizeHeaders(headers) {
567
- return this.useColor ? headers.map((h) => chalk.bold.cyan(h)) : headers;
568
- }
569
- /**
570
- * Get color for update type
571
- */
572
- getUpdateTypeColor(updateType) {
573
- switch (updateType) {
574
- case 'major':
575
- return chalk.red;
576
- case 'minor':
577
- return chalk.yellow;
578
- case 'patch':
579
- return chalk.green;
580
- default:
581
- return chalk.gray;
582
- }
583
- }
584
- /**
585
- * Get color for risk level
586
- */
587
- getRiskColor(riskLevel) {
588
- switch (riskLevel) {
589
- case 'high':
590
- return chalk.red;
591
- case 'medium':
592
- return chalk.yellow;
593
- case 'low':
594
- return chalk.green;
595
- default:
596
- return chalk.gray;
597
- }
598
- }
599
- /**
600
- * Colorize version differences between current and latest
601
- */
602
- colorizeVersionDiff(current, latest, updateType) {
603
- if (!this.useColor) {
604
- return { currentColored: current, latestColored: latest };
605
- }
606
- // Parse version numbers to identify different parts
607
- const parseVersion = (version) => {
608
- // Remove leading ^ or ~ or other prefix characters
609
- const cleanVersion = version.replace(/^[\^~>=<]+/, '');
610
- const parts = cleanVersion.split('.');
611
- return {
612
- major: parts[0] || '0',
613
- minor: parts[1] || '0',
614
- patch: parts[2] || '0',
615
- extra: parts.slice(3).join('.'),
616
- prefix: version.substring(0, version.length - cleanVersion.length),
617
- };
618
- };
619
- const currentParts = parseVersion(current);
620
- const latestParts = parseVersion(latest);
621
- // Determine color based on update type for highlighting differences
622
- const diffColor = this.getUpdateTypeColor(updateType);
623
- // Build colored version strings by comparing each part
624
- const colorCurrentPart = (part, latestPart, isChanged) => {
625
- if (isChanged && part !== latestPart) {
626
- return chalk.dim.white(part); // Dim white for old version part
627
- }
628
- return chalk.white(part); // Unchanged parts in white
629
- };
630
- const colorLatestPart = (part, currentPart, isChanged) => {
631
- if (isChanged && part !== currentPart) {
632
- return diffColor(part); // Highlight the new version part with update type color
633
- }
634
- return chalk.white(part); // Unchanged parts in white
635
- };
636
- // Check which parts are different
637
- const majorChanged = currentParts.major !== latestParts.major;
638
- const minorChanged = currentParts.minor !== latestParts.minor;
639
- const patchChanged = currentParts.patch !== latestParts.patch;
640
- const extraChanged = currentParts.extra !== latestParts.extra;
641
- // Build colored current version
642
- let currentColored = currentParts.prefix;
643
- currentColored += colorCurrentPart(currentParts.major, latestParts.major, majorChanged);
644
- currentColored += '.';
645
- currentColored += colorCurrentPart(currentParts.minor, latestParts.minor, minorChanged);
646
- currentColored += '.';
647
- currentColored += colorCurrentPart(currentParts.patch, latestParts.patch, patchChanged);
648
- if (currentParts.extra) {
649
- currentColored += '.' + colorCurrentPart(currentParts.extra, latestParts.extra, extraChanged);
650
- }
651
- // Build colored latest version
652
- let latestColored = latestParts.prefix;
653
- latestColored += colorLatestPart(latestParts.major, currentParts.major, majorChanged);
654
- latestColored += '.';
655
- latestColored += colorLatestPart(latestParts.minor, currentParts.minor, minorChanged);
656
- latestColored += '.';
657
- latestColored += colorLatestPart(latestParts.patch, currentParts.patch, patchChanged);
658
- if (latestParts.extra) {
659
- latestColored += '.' + colorLatestPart(latestParts.extra, currentParts.extra, extraChanged);
660
- }
661
- return { currentColored, latestColored };
662
- }
663
- }
664
- //# sourceMappingURL=OutputFormatter.js.map