pnpm-catalog-updates 1.0.3 ā 1.1.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/README.md +15 -0
- package/dist/index.js +22031 -10684
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
- package/src/cli/__tests__/commandRegistrar.test.ts +248 -0
- package/src/cli/commandRegistrar.ts +785 -0
- package/src/cli/commands/__tests__/aiCommand.test.ts +161 -0
- package/src/cli/commands/__tests__/analyzeCommand.test.ts +283 -0
- package/src/cli/commands/__tests__/checkCommand.test.ts +435 -0
- package/src/cli/commands/__tests__/graphCommand.test.ts +312 -0
- package/src/cli/commands/__tests__/initCommand.test.ts +317 -0
- package/src/cli/commands/__tests__/rollbackCommand.test.ts +400 -0
- package/src/cli/commands/__tests__/securityCommand.test.ts +467 -0
- package/src/cli/commands/__tests__/themeCommand.test.ts +166 -0
- package/src/cli/commands/__tests__/updateCommand.test.ts +720 -0
- package/src/cli/commands/__tests__/workspaceCommand.test.ts +286 -0
- package/src/cli/commands/aiCommand.ts +163 -0
- package/src/cli/commands/analyzeCommand.ts +219 -0
- package/src/cli/commands/checkCommand.ts +91 -98
- package/src/cli/commands/graphCommand.ts +475 -0
- package/src/cli/commands/initCommand.ts +64 -54
- package/src/cli/commands/rollbackCommand.ts +334 -0
- package/src/cli/commands/securityCommand.ts +165 -100
- package/src/cli/commands/themeCommand.ts +148 -0
- package/src/cli/commands/updateCommand.ts +215 -263
- package/src/cli/commands/workspaceCommand.ts +73 -0
- package/src/cli/constants/cliChoices.ts +93 -0
- package/src/cli/formatters/__tests__/__snapshots__/outputFormatter.test.ts.snap +557 -0
- package/src/cli/formatters/__tests__/ciFormatter.test.ts +526 -0
- package/src/cli/formatters/__tests__/outputFormatter.test.ts +448 -0
- package/src/cli/formatters/__tests__/progressBar.test.ts +709 -0
- package/src/cli/formatters/ciFormatter.ts +964 -0
- package/src/cli/formatters/colorUtils.ts +145 -0
- package/src/cli/formatters/outputFormatter.ts +615 -332
- package/src/cli/formatters/progressBar.ts +43 -52
- package/src/cli/formatters/versionFormatter.ts +132 -0
- package/src/cli/handlers/aiAnalysisHandler.ts +205 -0
- package/src/cli/handlers/changelogHandler.ts +113 -0
- package/src/cli/handlers/index.ts +9 -0
- package/src/cli/handlers/installHandler.ts +130 -0
- package/src/cli/index.ts +175 -726
- package/src/cli/interactive/InteractiveOptionsCollector.ts +387 -0
- package/src/cli/interactive/interactivePrompts.ts +189 -83
- package/src/cli/interactive/optionUtils.ts +89 -0
- package/src/cli/themes/colorTheme.ts +43 -16
- package/src/cli/utils/cliOutput.ts +118 -0
- package/src/cli/utils/commandHelpers.ts +249 -0
- package/src/cli/validators/commandValidator.ts +321 -336
- package/src/cli/validators/index.ts +37 -2
- package/src/cli/options/globalOptions.ts +0 -437
- package/src/cli/options/index.ts +0 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Handlers
|
|
3
|
+
*
|
|
4
|
+
* Handler classes extracted from commands to reduce complexity.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export { AIAnalysisHandler, type AIAnalysisOptions } from './aiAnalysisHandler.js'
|
|
8
|
+
export { ChangelogHandler } from './changelogHandler.js'
|
|
9
|
+
export { InstallHandler } from './installHandler.js'
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install Handler
|
|
3
|
+
*
|
|
4
|
+
* Handles package manager install operations for the update command.
|
|
5
|
+
* Extracted from UpdateCommand to reduce class complexity (ARCH-002).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { IPackageManagerService } from '@pcu/core'
|
|
9
|
+
import { logger, t } from '@pcu/utils'
|
|
10
|
+
import chalk from 'chalk'
|
|
11
|
+
import { ProgressBar } from '../formatters/progressBar.js'
|
|
12
|
+
import { cliOutput } from '../utils/cliOutput.js'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Handles package manager install operations after catalog updates
|
|
16
|
+
*/
|
|
17
|
+
export class InstallHandler {
|
|
18
|
+
private readonly packageManagerService: IPackageManagerService
|
|
19
|
+
|
|
20
|
+
constructor(packageManagerService: IPackageManagerService) {
|
|
21
|
+
this.packageManagerService = packageManagerService
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Run package manager install to update lock file after catalog updates
|
|
26
|
+
* Uses injected package manager service for testability
|
|
27
|
+
* Enhanced error handling with detailed feedback
|
|
28
|
+
*/
|
|
29
|
+
async runInstall(workspacePath: string, verbose?: boolean): Promise<void> {
|
|
30
|
+
const pmName = this.packageManagerService.getName()
|
|
31
|
+
const progressBar = new ProgressBar({
|
|
32
|
+
text: t('command.update.runningPnpmInstall'),
|
|
33
|
+
total: 1,
|
|
34
|
+
})
|
|
35
|
+
progressBar.start(t('command.update.runningPnpmInstall'))
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
const result = await this.packageManagerService.install({
|
|
39
|
+
cwd: workspacePath,
|
|
40
|
+
verbose,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
if (result.success) {
|
|
44
|
+
progressBar.succeed(t('command.update.pnpmInstallSuccess'))
|
|
45
|
+
} else {
|
|
46
|
+
this.handleInstallFailure(result, pmName, progressBar, verbose)
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// Handle unexpected errors (e.g., spawn errors, permission issues)
|
|
50
|
+
progressBar.fail(t('command.update.pnpmInstallFailed'))
|
|
51
|
+
this.logInstallError(error, pmName)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Handle install command failure with detailed feedback
|
|
57
|
+
*/
|
|
58
|
+
private handleInstallFailure(
|
|
59
|
+
result: Awaited<ReturnType<IPackageManagerService['install']>>,
|
|
60
|
+
pmName: string,
|
|
61
|
+
progressBar: ProgressBar,
|
|
62
|
+
verbose?: boolean
|
|
63
|
+
): void {
|
|
64
|
+
progressBar.fail(t('command.update.pnpmInstallFailed'))
|
|
65
|
+
|
|
66
|
+
// Show stderr if available and verbose mode enabled or short output
|
|
67
|
+
if (result.stderr) {
|
|
68
|
+
const stderrLines = result.stderr.split('\n').filter((line) => line.trim())
|
|
69
|
+
const displayLines = verbose ? stderrLines : stderrLines.slice(-5)
|
|
70
|
+
if (displayLines.length > 0) {
|
|
71
|
+
cliOutput.error(chalk.gray(`\n${displayLines.join('\n')}`))
|
|
72
|
+
if (!verbose && stderrLines.length > 5) {
|
|
73
|
+
cliOutput.error(
|
|
74
|
+
chalk.gray(
|
|
75
|
+
` ... (${t('command.update.moreLines', { count: stderrLines.length - 5 })})`
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Provide helpful suggestions based on exit code
|
|
83
|
+
this.suggestInstallFix(result.code, pmName)
|
|
84
|
+
|
|
85
|
+
// Log for debugging - don't throw since catalog update succeeded
|
|
86
|
+
logger.warn(`${pmName} install failed`, {
|
|
87
|
+
code: result.code,
|
|
88
|
+
stderr: result.stderr?.slice(0, 500),
|
|
89
|
+
error: result.error?.message,
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Suggest fixes for common install failures
|
|
95
|
+
* Enhanced error handling with actionable suggestions
|
|
96
|
+
*/
|
|
97
|
+
private suggestInstallFix(exitCode: number | null, pmName: string): void {
|
|
98
|
+
cliOutput.print(chalk.yellow(`\nš” ${t('command.update.suggestFix')}`))
|
|
99
|
+
|
|
100
|
+
if (exitCode === 1) {
|
|
101
|
+
// Generic failure - likely dependency conflict
|
|
102
|
+
cliOutput.print(
|
|
103
|
+
chalk.gray(` - ${t('command.update.suggestManualInstall', { pm: pmName })}`)
|
|
104
|
+
)
|
|
105
|
+
cliOutput.print(chalk.gray(` - ${t('command.update.suggestCheckDeps')}`))
|
|
106
|
+
} else if (exitCode === 127) {
|
|
107
|
+
// Command not found
|
|
108
|
+
cliOutput.print(chalk.gray(` - ${t('command.update.suggestInstallPm', { pm: pmName })}`))
|
|
109
|
+
} else if (exitCode === null) {
|
|
110
|
+
// Timeout or signal
|
|
111
|
+
cliOutput.print(chalk.gray(` - ${t('command.update.suggestRetry')}`))
|
|
112
|
+
cliOutput.print(chalk.gray(` - ${t('command.update.suggestCheckNetwork')}`))
|
|
113
|
+
} else {
|
|
114
|
+
// Other exit codes
|
|
115
|
+
cliOutput.print(
|
|
116
|
+
chalk.gray(` - ${t('command.update.suggestManualInstall', { pm: pmName })}`)
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Log unexpected install errors
|
|
123
|
+
*/
|
|
124
|
+
private logInstallError(error: unknown, pmName: string): void {
|
|
125
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
126
|
+
cliOutput.error(chalk.red(`\n${t('command.update.installError')}: ${errorMessage}`))
|
|
127
|
+
|
|
128
|
+
logger.error(`Unexpected ${pmName} install error`, error instanceof Error ? error : undefined)
|
|
129
|
+
}
|
|
130
|
+
}
|