Skip to content

Commit 4f19cde

Browse files
refactor: enhance installation process with error handling and warnings - Replace fatal errors with warnings for failed installations of runtimes and tools - Update installation completion message to reflect any failures - Add guideline to remove dead unused code
1 parent 08160cb commit 4f19cde

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

.cursor/rules/cursor.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ alwaysApply: true
99
## Key Rules
1010
- use fulnames like e.g. feature, instaed of feat
1111
- run go build after each code modification to see if app compiles
12+
- remove dead unused code
1213

1314
## Code Style Guidelines
1415
- **Imports**: Standard lib first, external packages second, internal last

cmd/install.go

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ var installCmd = &cobra.Command{
166166
"version": runtime.Version,
167167
"error": err.Error(),
168168
})
169-
log.Fatal(err)
169+
fmt.Printf("\n⚠️ Warning: Failed to install runtime %s v%s: %v\n", name, runtime.Version, err)
170+
// Continue with next runtime instead of fatal
171+
progressBar.Add(1)
172+
continue
170173
}
171174
logger.Info("Successfully installed runtime", logrus.Fields{
172175
"runtime": name,
@@ -191,7 +194,10 @@ var installCmd = &cobra.Command{
191194
"version": tool.Version,
192195
"error": err.Error(),
193196
})
194-
log.Fatal(err)
197+
fmt.Printf("\n⚠️ Warning: Failed to install tool %s v%s: %v\n", name, tool.Version, err)
198+
// Continue with next tool instead of fatal
199+
progressBar.Add(1)
200+
continue
195201
}
196202
logger.Info("Successfully installed tool", logrus.Fields{
197203
"tool": name,
@@ -206,21 +212,39 @@ var installCmd = &cobra.Command{
206212
devNull.Close()
207213
log.SetOutput(os.Stderr)
208214

209-
// Print completion status
215+
// Print completion status with warnings for failed installations
210216
fmt.Println()
217+
var hasFailures bool
211218
for name, runtime := range cfg.Config.Runtimes() {
212219
if !cfg.Config.IsRuntimeInstalled(name, runtime) {
213-
green.Printf(" ✓ Runtime: %s v%s\n", name, runtime.Version)
220+
if cfg.Config.IsRuntimeInstalled(name, runtime) {
221+
green.Printf(" ✓ Runtime: %s v%s\n", name, runtime.Version)
222+
} else {
223+
color.Yellow(" ⚠️ Runtime: %s v%s (installation failed)", name, runtime.Version)
224+
hasFailures = true
225+
}
214226
}
215227
}
216228
for name, tool := range cfg.Config.Tools() {
217229
if !cfg.Config.IsToolInstalled(name, tool) {
218-
green.Printf(" ✓ Tool: %s v%s\n", name, tool.Version)
230+
if cfg.Config.IsToolInstalled(name, tool) {
231+
green.Printf(" ✓ Tool: %s v%s\n", name, tool.Version)
232+
} else {
233+
color.Yellow(" ⚠️ Tool: %s v%s (installation failed)", name, tool.Version)
234+
hasFailures = true
235+
}
219236
}
220237
}
221238
fmt.Println()
222-
logger.Info("Installation completed successfully", nil)
223-
bold.Println("✅ Installation completed successfully!")
239+
if hasFailures {
240+
logger.Warn("Installation completed with some failures", nil)
241+
bold.Println("⚠️ Installation completed with some failures!")
242+
fmt.Println("Some components failed to install. You can try installing them again with:")
243+
fmt.Println(" codacy-cli install")
244+
} else {
245+
logger.Info("Installation completed successfully", nil)
246+
bold.Println("✅ Installation completed successfully!")
247+
}
224248
},
225249
}
226250

0 commit comments

Comments
 (0)