Skip to content

Commit 399b7a0

Browse files
authored
Merge pull request #18 from CommunityToolkit/node-extensions
Adding a NodeJS extensions pack
2 parents 3d6ee2d + 4f1dace commit 399b7a0

File tree

77 files changed

+15194
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+15194
-6
lines changed

.github/workflows/dotnet-ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030
with:
3131
node-version: "latest"
3232

33+
- uses: pnpm/action-setup@v4
34+
name: Setup pnpm
35+
with:
36+
version: 9
37+
run_install: false
38+
3339
- uses: actions/cache@v4
3440
name: Cache NuGet packages
3541
with:

.github/workflows/dotnet-main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030
with:
3131
node-version: "latest"
3232

33+
- uses: pnpm/action-setup@v4
34+
name: Setup pnpm
35+
with:
36+
version: 9
37+
run_install: false
38+
3339
- uses: actions/cache@v4
3440
name: Cache NuGet packages
3541
with:

.github/workflows/dotnet-release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
with:
3232
node-version: "latest"
3333

34+
- uses: pnpm/action-setup@v4
35+
name: Setup pnpm
36+
with:
37+
version: 9
38+
run_install: false
39+
3440
- uses: actions/cache@v4
3541
name: Cache NuGet packages
3642
with:
@@ -147,3 +153,4 @@ jobs:
147153

148154
- name: Publish to GitHub packages
149155
run: dotnet nuget push ./*.nupkg --source "https://nuget.pkg.github.com/communitytoolkit/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
156+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ appsettings.*.json
88
*.orig
99
test-results
1010
TestResults
11-
nuget
11+
nuget
12+
.pnpm-store

CommunityToolkit.Aspire.sln

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Sta
3737
EndProject
3838
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.StaticWebApps.ServiceDefaults", "examples\swa\CommunityToolkit.Aspire.StaticWebApps.ServiceDefaults\CommunityToolkit.Aspire.StaticWebApps.ServiceDefaults.csproj", "{83FF8083-7EE2-4196-86A8-239F921B443C}"
3939
EndProject
40+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.NodeJS.Extensions", "src\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.csproj", "{1F299343-30DF-4599-A95D-BCFB1754DA48}"
41+
EndProject
42+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nodejs-ext", "nodejs-ext", "{261AC321-8982-4C3A-8DBF-DAFC95F97697}"
43+
EndProject
44+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.AppHost", "examples\nodejs-ext\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.AppHost\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.AppHost.csproj", "{D3F5EF2B-CE37-4339-A8BD-50E6C5B2AFA1}"
45+
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.Tests", "tests\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.Tests\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.Tests.csproj", "{E8F93376-1367-4A7B-A729-116199804356}"
47+
EndProject
4048
Global
4149
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4250
Debug|Any CPU = Debug|Any CPU
@@ -91,6 +99,18 @@ Global
9199
{83FF8083-7EE2-4196-86A8-239F921B443C}.Debug|Any CPU.Build.0 = Debug|Any CPU
92100
{83FF8083-7EE2-4196-86A8-239F921B443C}.Release|Any CPU.ActiveCfg = Release|Any CPU
93101
{83FF8083-7EE2-4196-86A8-239F921B443C}.Release|Any CPU.Build.0 = Release|Any CPU
102+
{1F299343-30DF-4599-A95D-BCFB1754DA48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
103+
{1F299343-30DF-4599-A95D-BCFB1754DA48}.Debug|Any CPU.Build.0 = Debug|Any CPU
104+
{1F299343-30DF-4599-A95D-BCFB1754DA48}.Release|Any CPU.ActiveCfg = Release|Any CPU
105+
{1F299343-30DF-4599-A95D-BCFB1754DA48}.Release|Any CPU.Build.0 = Release|Any CPU
106+
{D3F5EF2B-CE37-4339-A8BD-50E6C5B2AFA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
107+
{D3F5EF2B-CE37-4339-A8BD-50E6C5B2AFA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
108+
{D3F5EF2B-CE37-4339-A8BD-50E6C5B2AFA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
109+
{D3F5EF2B-CE37-4339-A8BD-50E6C5B2AFA1}.Release|Any CPU.Build.0 = Release|Any CPU
110+
{E8F93376-1367-4A7B-A729-116199804356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
111+
{E8F93376-1367-4A7B-A729-116199804356}.Debug|Any CPU.Build.0 = Debug|Any CPU
112+
{E8F93376-1367-4A7B-A729-116199804356}.Release|Any CPU.ActiveCfg = Release|Any CPU
113+
{E8F93376-1367-4A7B-A729-116199804356}.Release|Any CPU.Build.0 = Release|Any CPU
94114
EndGlobalSection
95115
GlobalSection(SolutionProperties) = preSolution
96116
HideSolutionNode = FALSE
@@ -110,6 +130,10 @@ Global
110130
{C083A377-13CA-47C1-8B17-1FE353EA76F0} = {564FA6A0-EC54-41C6-A35F-89890E1D06E3}
111131
{BAEA0F6F-39E9-4893-8787-C4D292D3B169} = {564FA6A0-EC54-41C6-A35F-89890E1D06E3}
112132
{83FF8083-7EE2-4196-86A8-239F921B443C} = {564FA6A0-EC54-41C6-A35F-89890E1D06E3}
133+
{1F299343-30DF-4599-A95D-BCFB1754DA48} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
134+
{261AC321-8982-4C3A-8DBF-DAFC95F97697} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
135+
{D3F5EF2B-CE37-4339-A8BD-50E6C5B2AFA1} = {261AC321-8982-4C3A-8DBF-DAFC95F97697}
136+
{E8F93376-1367-4A7B-A729-116199804356} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
113137
EndGlobalSection
114138
GlobalSection(ExtensibilityGlobals) = postSolution
115139
SolutionGuid = {08B1D4B8-D2C5-4A64-BB8B-E1A2B29525F0}

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ All features are contributed by you, our amazing .NET community, and maintained
1010

1111
This repository contains the source code for the .NET Aspire Community Toolkit, a collection of community created Integrations and extensions for [.NET Aspire](https://aka.ms/dotnet/aspire).
1212

13-
| Package | Latest stable | Latest Preview | Description |
14-
| ----------------------------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
15-
| [`Hosting.Azure.StaticWebApps`][swa-integration-docs] | [![CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps][swa-shields]][swa-nuget] | [![CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps][swa-shields-preview]][swa-nuget-preview] | A hosting component for the [Azure Static Web Apps emulator](https://learn.microsoft.com/azure/static-web-apps/static-web-apps-cli-overview) (Note: this does not support deployment of a project to Azure Static Web Apps). |
16-
| [`Hosting.Java`][java-integration-docs] | [![CommunityToolkit.Aspire.Java][java-shields]][java-nuget] | [![CommunityToolkit.Aspire.Hosting.Java][java-shields-preview]][java-nuget-preview] | A component for running Java code in .NET Aspire either using the local JDK or using a container. |
13+
| Package | Latest stable | Latest Preview | Description |
14+
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
15+
| [`Hosting.Azure.StaticWebApps`][swa-integration-docs] | [![CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps][swa-shields]][swa-nuget] | [![CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps][swa-shields-preview]][swa-nuget-preview] | A hosting integration for the [Azure Static Web Apps emulator](https://learn.microsoft.com/azure/static-web-apps/static-web-apps-cli-overview) (Note: this does not support deployment of a project to Azure Static Web Apps). |
16+
| [`Hosting.Java`][java-integration-docs] | [![CommunityToolkit.Aspire.Java][java-shields]][java-nuget] | [![CommunityToolkit.Aspire.Hosting.Java][java-shields-preview]][java-nuget-preview] | A integration for running Java code in .NET Aspire either using the local JDK or using a container. |
17+
| [`Hosting.NodeJS.Extensions`][nodejs-ext-integration-docs] | [![CommunityToolkit.Aspire.NodeJS.Extensions][nodejs-ext-shields]][nodejs-ext-nuget] | [![CommunityToolkit.Aspire.Hosting.NodeJS.Extensions][nodejs-ext-shields-preview]][nodejs-ext-nuget-preview] | An integration that contains some additional extensions for running Node.js applications |
1718

1819
## 🙌 Getting Started
1920

@@ -45,3 +46,8 @@ Made with [contrib.rocks](https://contrib.rocks).
4546
[java-nuget]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.Java/
4647
[java-shields-preview]: https://img.shields.io/nuget/v/CommunityToolkit.Aspire.Hosting.Java?label=nuget%20(preview)
4748
[java-nuget-preview]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.Java/absoluteLatest
49+
[nodejs-ext-integration-docs]: https://communitytoolkit.github.io/aspire/integrations/hosting-nodejs-extensions
50+
[nodejs-ext-shields]: https://img.shields.io/nuget/v/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions
51+
[nodejs-ext-nuget]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/
52+
[nodejs-ext-shields-preview]: https://img.shields.io/nuget/v/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions?label=nuget%20(preview)
53+
[nodejs-ext-nuget-preview]: https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/absoluteLatest

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Welcome to the .NET Aspire Community Toolkit, a collection of integrations and e
88

99
The Community Toolkit consists of a collection of NuGet packages that can be added to your .NET project, each representing an individual .NET Aspire component. The following packages are available:
1010

11-
- [CommunityToolkit.Aspire.Hosting.Java](integrations/hosting-java.md)
1211
- [CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps](integrations/hosting-azure-static-web-apps.md)
12+
- [CommunityToolkit.Aspire.Hosting.Java](integrations/hosting-java.md)
13+
- [CommunityToolkit.Aspire.Hosting.NodeJS.Extensions](integrations/hosting-nodejs-extensions.md)
1314

1415
## .NET Aspire and the Community Toolkit
1516

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# CommunityToolkit.Aspire.Hosting.NodeJS.Extensions
2+
3+
[![CommunityToolkit.Aspire.Hosting.NodeJS.Extensions](https://img.shields.io/nuget/v/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions)](https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/) | [![CommunityToolkit.Aspire.Hosting.NodeJS.Extensions (latest)](<https://img.shields.io/nuget/vpre/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions?label=nuget%20(preview)>)](https://nuget.org/packages/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/absoluteLatest)
4+
5+
## Overview
6+
7+
This package provides some extensions on the .NET Aspire [NodeJS hosting package](https://nuget.org/packages/Aspire.Hosting.NodeJS) and adds support for:
8+
9+
- Running [Vite](https://vitejs.dev/) applications
10+
- Running Node.js applications using [Yarn](https://yarnpkg.com/) and [pnpm](https://pnpm.io/)
11+
- Ensuring that the packages are installed before running the application (using the specified package manager)
12+
13+
## Usage
14+
15+
```csharp
16+
using CommunityToolkit.Aspire.Hosting.NodeJS.Extensions;
17+
18+
var builder = DistributedApplication.CreateBuilder(args);
19+
20+
builder.AddViteApp("vite-demo")
21+
.WithNpmPackageInstallation();
22+
23+
builder.AddViteApp("yarn-demo", packageManager: "yarn")
24+
.WithYarnPackageInstallation();
25+
26+
builder.AddViteApp("pnpm-demo", packageManager: "pnpm")
27+
.WithPnpmPackageInstallation();
28+
29+
builder.Build().Run();
30+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsAspireHost>true</IsAspireHost>
9+
<UserSecretsId>125d4633-7e41-4639-b0ce-cfc16cd67e39</UserSecretsId>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Aspire.Hosting.AppHost" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions\CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.csproj" IsAspireProjectResource="false" />
18+
</ItemGroup>
19+
20+
<Target Name="CleanNodeModules" AfterTargets="Build">
21+
<Exec WorkingDirectory="../vite-demo" Command="rm -r node_modules" Condition="Exists('../vite-demo/node_modules')" />
22+
<Exec WorkingDirectory="../pnpm-demo" Command="rm -r node_modules" Condition="Exists('../pnpm-demo/node_modules')" />
23+
<Exec WorkingDirectory="../yarn-demo" Command="rm -r node_modules" Condition="Exists('../yarn-demo/node_modules')" />
24+
</Target>
25+
26+
</Project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using CommunityToolkit.Aspire.Hosting.NodeJS.Extensions;
2+
3+
var builder = DistributedApplication.CreateBuilder(args);
4+
5+
builder.AddViteApp("vite-demo")
6+
.WithNpmPackageInstallation();
7+
8+
builder.AddViteApp("yarn-demo", packageManager: "yarn")
9+
.WithYarnPackageInstallation();
10+
11+
builder.AddViteApp("pnpm-demo", packageManager: "pnpm")
12+
.WithPnpmPackageInstallation();
13+
14+
builder.Build().Run();

0 commit comments

Comments
 (0)