Skip to content

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

danmoseley
Copy link
Member

Description

Vibe coded :)

Fixes #9290
Fixes #9327

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

@Copilot Copilot AI review requested due to automatic review settings May 16, 2025 19:37
@github-actions github-actions bot added the area-integrations Issues pertaining to Aspire Integrations packages label May 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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.

@danmoseley danmoseley requested a review from mitchdenny May 16, 2025 21:33
@@ -641,6 +641,58 @@ public async Task NewCommand_WhenCertificateServiceThrows_ReturnsNonZeroExitCode
Assert.Equal(ExitCodeConstants.FailedToTrustCertificates, exitCode);
}

[Fact]
public async Task NewCommand_SanitizesInvalidProjectName_WhenProvidedOnCommandLine()
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-integrations Issues pertaining to Aspire Integrations packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aspire new doesn't explain invalid project name aspire new project should replace invalid characters with _
1 participant