Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 23, 2025

Refactor WithNpmPackageManager to WithNpm with install parameter

Changes completed:

  • Update NodeExtensions.cs to rename WithNpmPackageManager to WithNpm
  • Change parameter name from autoInstall to install with default value false
  • Update XML documentation to reflect the new parameter name and default
  • Update example in XML documentation to use .WithNpm(install: true)
  • Update all test usages to explicitly use install: true when installer should be created
  • Update test for install: false behavior (renamed test)
  • Update playground examples to use .WithNpm(install: true)
  • Update template file in aspire-py-starter to use .WithNpm(install: true)
  • 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
  • Fix existing tests to match new installer naming convention ({name}-installer instead of {name}-npm-install)
  • 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)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@eerhardt
Copy link
Member

cc @maddymontaquila

Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor WithNpmPackageManager to WithNpm with updated signature Refactor WithNpmPackageManager to WithNpm with autoInstall parameter Oct 23, 2025
Copilot AI requested a review from eerhardt October 23, 2025 19:51
Copilot finished work on behalf of eerhardt October 23, 2025 19:51
Copy link
Member

@eerhardt eerhardt left a 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>
Copilot AI changed the title Refactor WithNpmPackageManager to WithNpm with autoInstall parameter Refactor WithNpmPackageManager to WithNpm with install parameter Oct 23, 2025
Copilot AI requested a review from eerhardt October 23, 2025 22:21
Copilot finished work on behalf of eerhardt October 23, 2025 22:21
@davidfowl
Copy link
Member

I think Action<IResourceBuilder<NodeInstallerResource>>? configureInstaller = null should be on another overload.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12325

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12325"

@eerhardt eerhardt marked this pull request as ready for review October 24, 2025 16:58
Copilot AI review requested due to automatic review settings October 24, 2025 16:58
Copy link
Contributor

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 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 WithNpmPackageManager to WithNpm with new install parameter (defaults to false)
  • Split monolithic JavaScriptPackageManagerAnnotation into three focused annotations: JavaScriptInstallCommandAnnotation, JavaScriptRunCommandAnnotation, and JavaScriptBuildCommandAnnotation
  • Removed useCI parameter as the installer now always uses npm 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)

… WithInstallCommand, WithBuildCommand)

Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
Copilot finished work on behalf of eerhardt October 24, 2025 19:54
Copilot AI requested a review from eerhardt October 24, 2025 19:54
@eerhardt eerhardt merged commit 089b7ff into main Oct 27, 2025
305 checks passed
@eerhardt eerhardt deleted the copilot/refactor-with-npm-package-manager branch October 27, 2025 17:47
@dotnet-policy-service dotnet-policy-service bot added this to the 13.0 milestone Oct 27, 2025
radical pushed a commit that referenced this pull request Oct 29, 2025
)

## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants