Skip to content

Conversation

@eerhardt
Copy link
Member

@eerhardt eerhardt commented Oct 22, 2025

Description

Remove the dependency on Community Toolkit in the py template.

Move AddViteApp and WithNpmPackageManager implementation from https://github.com/CommunityToolkit/Aspire/tree/main/src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions to this repo.

  • Add support for a JavaScriptPackageManagerAnnotation which drives the different Command names, and command line args for install, run, and build.
  • Implement a default dockerfile for a Vite app which produces a docker image with the built app in it. This can be consumed by changes in Add support for docker static files #12265

Contributes to #12199

Checklist

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

Remove the dependency on Community Toolkit in the py template.

Contributes to dotnet#12199
@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 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 -- 12283

Or

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

@eerhardt
Copy link
Member Author

cc @aaronpowell - I plan on moving the Npm installation and ViteApp from CommunityToolkit into dotnet/aspire so our template can use them without depending on an external package.

@eerhardt eerhardt marked this pull request as ready for review October 23, 2025 00:39
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 moves the AddViteApp and WithNpmPackageManager functionality from the CommunityToolkit to the core Aspire repository, removing the dependency on the Community Toolkit in the Python starter template. The implementation introduces a resource-based architecture for package installation using npm, with support for configurable package managers through annotations.

Key Changes:

  • Added ViteAppResource and NpmInstallerResource types to represent Vite applications and npm package installers as first-class resources
  • Implemented JavaScriptPackageManagerAnnotation to configure package manager commands (install, run, build)
  • Added WithNpmPackageManager extension method that creates installer resources and establishes parent-child relationships with wait dependencies
  • Updated the Python starter template to use the new built-in methods instead of Community Toolkit packages

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Aspire.Hosting.NodeJs/ViteAppResource.cs Defines the ViteAppResource class for Vite applications
src/Aspire.Hosting.NodeJs/NpmInstallerResource.cs Defines the NpmInstallerResource for npm package installation
src/Aspire.Hosting.NodeJs/NodeExtensions.cs Adds AddViteApp and WithNpmPackageManager extension methods with Dockerfile generation support
src/Aspire.Hosting.NodeJs/JavaScriptPackageManagerAnnotation.cs Defines annotation for configuring package manager commands
src/Aspire.Hosting.NodeJs/JavaScriptPackageInstallerAnnotation.cs Defines annotation to track installer resources
tests/Aspire.Hosting.NodeJs.Tests/*.cs Comprehensive test coverage for resource creation, package installation, and integration scenarios
src/Aspire.ProjectTemplates/templates/aspire-py-starter/13.0/apphost.cs Updates template to use WithNpmPackageManager instead of Community Toolkit
playground/AspireWithJavaScript/* Updates playground to demonstrate the new Vite app functionality
Aspire.slnx Reorganizes playground folder structure in solution

eerhardt and others added 3 commits October 22, 2025 19:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@eerhardt eerhardt changed the title Add ViteApp and NpmInstallation Add ViteApp and Npm Package Manager Oct 23, 2025
Copy link
Contributor

@aaronpowell aaronpowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is merged, can you send a PR to deprecate the implementation in the Community Toolkit and target our aspire-13 branch

/// <param name="useCI">When true, use <code>npm ci</code>, otherwise use <code>npm install</code> when installing packages.</param>
/// <param name="configureInstaller">Configure the npm installer resource.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
public static IResourceBuilder<TResource> WithNpmPackageManager<TResource>(this IResourceBuilder<TResource> resource, bool useCI = false, Action<IResourceBuilder<NpmInstallerResource>>? configureInstaller = null) where TResource : NodeAppResource
Copy link
Member

@davidfowl davidfowl Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should delete this bool and make it part of the NpmInstallerResource and a callback

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useCI bool? The reason I left it in is so we could use the same thing in the docker build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can leave it for now. Imagined this as a method on the callback rather than this.

@azure-pipelines
Copy link

There was an error handling pipeline event 59a60cbb-2988-4846-83a6-ebadedb8652b.

}
}
},
"reactvite": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vhvb1989 this is what wil break azd, we're not deploying this resource but need to build it.

@davidfowl
Copy link
Member

I'm pretty happy where this is, but if we merge it, it will break publishing the template until we have the other changes right? I'd love to get this in though...

@eerhardt
Copy link
Member Author

but if we merge it, it will break publishing the template until we have the other changes right?

I can deploy the template app in this change to ACA by itself, and it works. It's just that you get an "empty" frontend docker container deployed as well until more changes from #12265 land.

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well!

@davidfowl davidfowl merged commit a0eb933 into dotnet:main Oct 23, 2025
302 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 13.0 milestone Oct 23, 2025
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