-
Notifications
You must be signed in to change notification settings - Fork 619
Fix CLI to cleanup invalid project names #9366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the CLI’s handling of invalid project names by sanitizing them automatically and notifying the user with warnings. Key changes include the addition of new tests, the introduction of a DisplayWarning message in the interaction layer, and modifications to both the project name retrieval and validation logic in NewCommand.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/Aspire.Cli.Tests/Utils/ProjectNameValidatorTests.cs | Added unit tests to verify project name validation and sanitization behavior. |
tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs | Added end-to-end tests to ensure invalid project names are correctly sanitized on the command line. |
src/Aspire.Cli/Interaction/InteractionService.cs | Introduced DisplayWarning functionality to present user-friendly warnings. |
src/Aspire.Cli/Interaction/IInteractionService.cs | Updated interface to include a DisplayWarning method. |
src/Aspire.Cli/Commands/NewCommand.cs | Refactored project name handling to sanitize invalid names and display warnings; updated ProjectNameValidator regex and sanitization logic. |
@@ -641,6 +641,58 @@ public async Task NewCommand_WhenCertificateServiceThrows_ReturnsNonZeroExitCode | |||
Assert.Equal(ExitCodeConstants.FailedToTrustCertificates, exitCode); | |||
} | |||
|
|||
[Fact] | |||
public async Task NewCommand_SanitizesInvalidProjectName_WhenProvidedOnCommandLine() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really don't know if there is a better way to write this. copilot did it
Description
Vibe coded :)
Fixes #9290
Fixes #9327
Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template