-
Notifications
You must be signed in to change notification settings - Fork 720
Refactor WithNpmPackageManager to WithNpm with install parameter #12325
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
Conversation
Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
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.
@copilot - apply the feedback
Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
|
I think |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12325Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12325" |
…th-npm-package-manager
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 refactors the npm package manager integration by renaming WithNpmPackageManager to WithNpm and introducing an install parameter that provides more granular control over package installation. The default behavior changes from automatically installing packages to requiring explicit opt-in via install: true.
Key Changes:
- Renamed extension method from
WithNpmPackageManagertoWithNpmwith newinstallparameter (defaults tofalse) - Split monolithic
JavaScriptPackageManagerAnnotationinto three focused annotations:JavaScriptInstallCommandAnnotation,JavaScriptRunCommandAnnotation, andJavaScriptBuildCommandAnnotation - Removed
useCIparameter as the installer now always usesnpm install
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting.NodeJs/NodeExtensions.cs | Renamed method, implemented conditional installer creation, refactored to use new annotation types |
| src/Aspire.Hosting.NodeJs/JavaScriptPackageManagerAnnotation.cs | Split single annotation into three specialized annotation classes |
| tests/Aspire.Hosting.NodeJs.Tests/ResourceCreationTests.cs | Updated test names and calls, removed duplicate tests, added new test for install: false behavior |
| tests/Aspire.Hosting.NodeJs.Tests/PackageInstallationTests.cs | Updated tests to use new API, removed CI-specific test scenarios |
| tests/Aspire.Hosting.NodeJs.Tests/IntegrationTests.cs | Updated to use WithNpm(install: true) |
| tests/Aspire.Hosting.NodeJs.Tests/AddViteAppTests.cs | Updated to use WithNpm(install: true) |
| playground/AspireWithJavaScript/AspireJavaScript.AppHost/AppHost.cs | Updated all playground examples to use WithNpm(install: true) |
| src/Aspire.ProjectTemplates/templates/aspire-py-starter/13.0/apphost.cs | Updated template to use WithNpm(install: true) |
src/Aspire.Hosting.NodeJs/JavaScriptPackageManagerAnnotation.cs
Outdated
Show resolved
Hide resolved
…th-npm-package-manager
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… WithInstallCommand, WithBuildCommand) Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
) ## Refactor WithNpmPackageManager to WithNpm with install parameter ### Changes completed: - [x] Update NodeExtensions.cs to rename `WithNpmPackageManager` to `WithNpm` - [x] Change parameter name from `autoInstall` to `install` with default value `false` - [x] Update XML documentation to reflect the new parameter name and default - [x] Update example in XML documentation to use `.WithNpm(install: true)` - [x] Update all test usages to explicitly use `install: true` when installer should be created - [x] Update test for `install: false` behavior (renamed test) - [x] Update playground examples to use `.WithNpm(install: true)` - [x] Update template file in aspire-py-starter to use `.WithNpm(install: true)` - [x] Add comprehensive unit tests for new public APIs: - `WithYarn` - tests for both install=true and install=false - `WithPnpm` - tests for both install=true and install=false - `WithInstallCommand` - tests custom install command with custom args - `WithBuildCommand` - tests custom build command - Override scenarios for both install and build commands - [x] Fix existing tests to match new installer naming convention (`{name}-installer` instead of `{name}-npm-install`) - [x] Run tests to verify all changes work correctly (47 tests passed) ### Summary: Successfully added comprehensive unit tests for all new public APIs introduced in the refactoring. The tests verify: - Package manager annotations are correctly set for each package manager (npm, yarn, pnpm) - Installer resources are created/not created based on the `install` parameter - Custom install and build commands can be set using `WithInstallCommand` and `WithBuildCommand` - Existing commands can be overridden - All tests pass (47/47) * Refactor WithNpmPackageManager to WithNpm with autoInstall parameter Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> * Apply feedback: Rename autoInstall to install with default false Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> * WIP - refactor JS * First round of refactoring * Refactor and add yarn, pnmp, and WithInstall/BuildCommand APIs * Fix build * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add comprehensive unit tests for new public APIs (WithYarn, WithPnpm, WithInstallCommand, WithBuildCommand) Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> * Update AspireWithJavaScript playground app * Add more tests * Update comments. * Apply suggestion from @eerhardt * Respond to PR feedback --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com> Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Refactor WithNpmPackageManager to WithNpm with install parameter
Changes completed:
WithNpmPackageManagertoWithNpmautoInstalltoinstallwith default valuefalse.WithNpm(install: true)install: truewhen installer should be createdinstall: falsebehavior (renamed test).WithNpm(install: true).WithNpm(install: true)WithYarn- tests for both install=true and install=falseWithPnpm- tests for both install=true and install=falseWithInstallCommand- tests custom install command with custom argsWithBuildCommand- tests custom build command{name}-installerinstead of{name}-npm-install)Summary:
Successfully added comprehensive unit tests for all new public APIs introduced in the refactoring. The tests verify:
installparameterWithInstallCommandandWithBuildCommand✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.