refactor: replace project debug command with doctor command#859
refactor: replace project debug command with doctor command#859Soner (shyim) merged 1 commit intomainfrom
Conversation
Replaces the debug command with an improved doctor command that provides better project health checks and displays extensions/bundles in a table format.
There was a problem hiding this comment.
Pull request overview
This pull request replaces the project debug command with an improved project doctor command that provides better project health checks with visual indicators and formatted output.
Changes:
- Replaced
project debugcommand withproject doctorcommand - Added visual indicators (✓ and ⚠) for different status types using the lipgloss library
- Changed from internal/table to lipgloss/table for improved table formatting
- Made the project directory argument optional (defaults to current working directory)
- Displays relative paths for extensions/bundles instead of absolute paths
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| cmd/project/project_doctor.go | New command implementation with improved UX, visual indicators, and optional project directory argument |
| cmd/project/project_debug.go | Removed old debug command that required explicit project directory argument |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fmt.Println(doctorSectionStyle.Render("Project")) | ||
| fmt.Println() | ||
|
|
||
| shopCfg, err := shop.ReadConfig(cmd.Context(), projectConfigPath, true) |
There was a problem hiding this comment.
The config file is being read from the current working directory instead of from the projectDir specified in the arguments. When a user runs shopware-cli project doctor /path/to/project, the command should read the config from /path/to/project/.shopware-project.yml, but currently it reads from the current working directory. To fix this, the config path should be constructed based on projectDir when projectConfigPath is a relative path. Consider using filepath.Join(projectDir, filepath.Base(projectConfigPath)) if projectConfigPath is not an absolute path, or change to the projectDir before reading the config.
| shopCfg, err := shop.ReadConfig(cmd.Context(), projectConfigPath, true) | |
| configPath := projectConfigPath | |
| if !filepath.IsAbs(configPath) { | |
| configPath = filepath.Join(projectDir, filepath.Base(configPath)) | |
| } | |
| shopCfg, err := shop.ReadConfig(cmd.Context(), configPath, true) |
| if shopCfg.IsFallback() { | ||
| fmt.Printf("%s Project config: %s\n", doctorCheckWarn, color.SecondaryText.Render("not found, using fallback")) | ||
| } else { | ||
| fmt.Printf("%s Project config: %s\n", doctorCheckOK, color.GreenText.Render(shop.DefaultConfigFileName())) |
There was a problem hiding this comment.
When displaying the project config filename, the code uses shop.DefaultConfigFileName() which returns the default filename in the current working directory. This may not reflect the actual config file that was read, especially if the user specified a custom path via the --project-config flag. Consider using projectConfigPath instead, or better yet, displaying the actual file path that was read to avoid confusion.
| fmt.Printf("%s Project config: %s\n", doctorCheckOK, color.GreenText.Render(shop.DefaultConfigFileName())) | |
| configDisplayName := projectConfigPath | |
| if configDisplayName == "" { | |
| configDisplayName = shop.DefaultConfigFileName() | |
| } | |
| fmt.Printf("%s Project config: %s\n", doctorCheckOK, color.GreenText.Render(configDisplayName)) |
| ) | ||
|
|
||
| var projectDoctor = &cobra.Command{ | ||
| Use: "doctor", |
There was a problem hiding this comment.
The Use field should document the optional project directory argument. Following the pattern used in other commands like admin-build, it should be "doctor [project-dir]" instead of just "doctor" to make it clear that a project directory can be optionally specified.
| Use: "doctor", | |
| Use: "doctor [project-dir]", |
|
|
||
| var projectDoctor = &cobra.Command{ | ||
| Use: "doctor", | ||
| Short: "Check your Shopware project for potential problems", |
There was a problem hiding this comment.
The command should explicitly validate the number of arguments using Args field. Since the command accepts an optional project directory (0 or 1 arguments), add Args: cobra.MaximumNArgs(1) to the command definition. This will provide a clear error message if users accidentally provide too many arguments, rather than silently ignoring them.
| Short: "Check your Shopware project for potential problems", | |
| Short: "Check your Shopware project for potential problems", | |
| Args: cobra.MaximumNArgs(1), |
Summary
project debugcommand with an improvedproject doctorcommandTest plan
shopware-cli project doctorin a Shopware projectshopware-cli project doctor /path/to/projectwith explicit path