Skip to content

Commit 91be38f

Browse files
committed
Rename Aspire.Hosting.NodeJs to Aspire.Hosting.JavaScript (dotnet#12681)
* Rename Aspire.Hosting.NodeJs to Aspire.Hosting.JavaScript This makes the library consistent to use language naming, and not a single technology. It allows for more JS features in the future that aren't tied to Node.js. Since the library is being renamed, I also removed the Obsolete APIs since there is no reason to ship them in the new library. Contributes to dotnet#12058 * Fix build * Fix Helix tests
1 parent 6878394 commit 91be38f

35 files changed

+64
-153
lines changed

Aspire.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<Project Path="src/Aspire.Hosting.MongoDB/Aspire.Hosting.MongoDB.csproj" />
6161
<Project Path="src/Aspire.Hosting.MySql/Aspire.Hosting.MySql.csproj" />
6262
<Project Path="src/Aspire.Hosting.Nats/Aspire.Hosting.Nats.csproj" />
63-
<Project Path="src/Aspire.Hosting.NodeJs/Aspire.Hosting.NodeJs.csproj" />
63+
<Project Path="src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj" />
6464
<Project Path="src/Aspire.Hosting.OpenAI/Aspire.Hosting.OpenAI.csproj" />
6565
<Project Path="src/Aspire.Hosting.Oracle/Aspire.Hosting.Oracle.csproj" />
6666
<Project Path="src/Aspire.Hosting.Orleans/Aspire.Hosting.Orleans.csproj" />
@@ -425,7 +425,7 @@
425425
<Project Path="tests/Aspire.Hosting.MongoDB.Tests/Aspire.Hosting.MongoDB.Tests.csproj" />
426426
<Project Path="tests/Aspire.Hosting.MySql.Tests/Aspire.Hosting.MySql.Tests.csproj" />
427427
<Project Path="tests/Aspire.Hosting.Nats.Tests/Aspire.Hosting.Nats.Tests.csproj" />
428-
<Project Path="tests/Aspire.Hosting.NodeJs.Tests/Aspire.Hosting.NodeJs.Tests.csproj" />
428+
<Project Path="tests/Aspire.Hosting.JavaScript.Tests/Aspire.Hosting.JavaScript.Tests.csproj" />
429429
<Project Path="tests/Aspire.Hosting.OpenAI.Tests/Aspire.Hosting.OpenAI.Tests.csproj" />
430430
<Project Path="tests/Aspire.Hosting.Oracle.Tests/Aspire.Hosting.Oracle.Tests.csproj" />
431431
<Project Path="tests/Aspire.Hosting.PostgreSQL.Tests/Aspire.Hosting.PostgreSQL.Tests.csproj" />

AspireWithMaui.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<Project Path="src/Aspire.Hosting.MongoDB/Aspire.Hosting.MongoDB.csproj" />
6161
<Project Path="src/Aspire.Hosting.MySql/Aspire.Hosting.MySql.csproj" />
6262
<Project Path="src/Aspire.Hosting.Nats/Aspire.Hosting.Nats.csproj" />
63-
<Project Path="src/Aspire.Hosting.NodeJs/Aspire.Hosting.NodeJs.csproj" />
63+
<Project Path="src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj" />
6464
<Project Path="src/Aspire.Hosting.OpenAI/Aspire.Hosting.OpenAI.csproj" />
6565
<Project Path="src/Aspire.Hosting.Oracle/Aspire.Hosting.Oracle.csproj" />
6666
<Project Path="src/Aspire.Hosting.Orleans/Aspire.Hosting.Orleans.csproj" />
@@ -432,7 +432,7 @@
432432
<Project Path="tests/Aspire.Hosting.MongoDB.Tests/Aspire.Hosting.MongoDB.Tests.csproj" />
433433
<Project Path="tests/Aspire.Hosting.MySql.Tests/Aspire.Hosting.MySql.Tests.csproj" />
434434
<Project Path="tests/Aspire.Hosting.Nats.Tests/Aspire.Hosting.Nats.Tests.csproj" />
435-
<Project Path="tests/Aspire.Hosting.NodeJs.Tests/Aspire.Hosting.NodeJs.Tests.csproj" />
435+
<Project Path="tests/Aspire.Hosting.JavaScript.Tests/Aspire.Hosting.JavaScript.Tests.csproj" />
436436
<Project Path="tests/Aspire.Hosting.OpenAI.Tests/Aspire.Hosting.OpenAI.Tests.csproj" />
437437
<Project Path="tests/Aspire.Hosting.Oracle.Tests/Aspire.Hosting.Oracle.Tests.csproj" />
438438
<Project Path="tests/Aspire.Hosting.PostgreSQL.Tests/Aspire.Hosting.PostgreSQL.Tests.csproj" />

playground/AspireWithJavaScript/AspireJavaScript.AppHost/AspireJavaScript.AppHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
14-
<AspireProjectOrPackageReference Include="Aspire.Hosting.NodeJs" />
14+
<AspireProjectOrPackageReference Include="Aspire.Hosting.JavaScript" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

playground/AspireWithNode/AspireWithNode.AppHost/AspireWithNode.AppHost.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" />
14-
<AspireProjectOrPackageReference Include="Aspire.Hosting.NodeJs" />
14+
<AspireProjectOrPackageReference Include="Aspire.Hosting.JavaScript" />
1515
<AspireProjectOrPackageReference Include="Aspire.Hosting.Redis" />
1616
</ItemGroup>
1717

playground/AspireWithNode/AspireWithNode.AppHost/NodeHostingExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.Extensions.Hosting;
1+
using Aspire.Hosting.JavaScript;
2+
using Microsoft.Extensions.Hosting;
23

34
namespace Aspire.Hosting;
45

@@ -8,7 +9,7 @@ internal static class NodeHostingExtensions
89
/// Injects the ASP.NET Core HTTPS developer certificate into the resource via the specified environment variables when
910
/// <paramref name="builder"/>.<see cref="IResourceBuilder{T}.ApplicationBuilder">ApplicationBuilder</see>.<see cref="IDistributedApplicationBuilder.ExecutionContext">ExecutionContext</see>.<see cref="DistributedApplicationExecutionContext.IsRunMode">IsRunMode</see><c> == true</c>.<br/>
1011
/// </summary>
11-
public static IResourceBuilder<NodeAppResource> RunWithHttpsDevCertificate(this IResourceBuilder<NodeAppResource> builder, string certFileEnv, string certKeyFileEnv)
12+
public static IResourceBuilder<JavaScriptAppResource> RunWithHttpsDevCertificate(this IResourceBuilder<JavaScriptAppResource> builder, string certFileEnv, string certKeyFileEnv)
1213
{
1314
if (builder.ApplicationBuilder.ExecutionContext.IsRunMode && builder.ApplicationBuilder.Environment.IsDevelopment())
1415
{

src/Aspire.Hosting.NodeJs/Aspire.Hosting.NodeJs.csproj renamed to src/Aspire.Hosting.JavaScript/Aspire.Hosting.JavaScript.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
<TargetFramework>$(DefaultTargetFramework)</TargetFramework>
55
<IsPackable>true</IsPackable>
66
<PackageTags>aspire integration hosting Node Nodejs javascript framework runtime</PackageTags>
7-
<Description>Node.js support for Aspire.</Description>
7+
<Description>JavaScript support for Aspire.</Description>
8+
<!-- Disable package validation as this package hasn't shipped stable yet. -->
9+
<EnablePackageValidation>false</EnablePackageValidation>
810
</PropertyGroup>
911

1012
<ItemGroup>
1113
<Compile Include="$(SharedDir)PathNormalizer.cs" Link="Utils\PathNormalizer.cs" />
12-
<Compile Include="$(SharedDir)OverloadResolutionPriorityAttribute.cs" Link="Utils\OverloadResolutionPriorityAttribute.cs" />
1314
</ItemGroup>
1415

1516
<ItemGroup>

src/Aspire.Hosting.NodeJs/JavaScriptAppResource.cs renamed to src/Aspire.Hosting.JavaScript/JavaScriptAppResource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Aspire.Hosting.ApplicationModel;
55

6-
namespace Aspire.Hosting;
6+
namespace Aspire.Hosting.JavaScript;
77

88
/// <summary>
99
/// A resource that represents a JavaScript application.

src/Aspire.Hosting.NodeJs/JavaScriptBuildScriptAnnotation.cs renamed to src/Aspire.Hosting.JavaScript/JavaScriptBuildScriptAnnotation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Aspire.Hosting.ApplicationModel;
55

6-
namespace Aspire.Hosting.NodeJs;
6+
namespace Aspire.Hosting.JavaScript;
77

88
/// <summary>
99
/// Represents the annotation for the JavaScript package manager's build script.

src/Aspire.Hosting.NodeJs/NodeExtensions.cs renamed to src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs

Lines changed: 3 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
#pragma warning disable ASPIREDOCKERFILEBUILDER001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
55

6-
using System.ComponentModel;
76
using System.Globalization;
8-
using System.Runtime.CompilerServices;
97
using System.Text.Json;
108
using Aspire.Hosting.ApplicationModel;
11-
using Aspire.Hosting.NodeJs;
9+
using Aspire.Hosting.JavaScript;
1210
using Aspire.Hosting.Utils;
1311
using Microsoft.Extensions.DependencyInjection;
1412
using Microsoft.Extensions.Hosting;
@@ -18,42 +16,12 @@
1816
namespace Aspire.Hosting;
1917

2018
/// <summary>
21-
/// Provides extension methods for adding Node applications to an <see cref="IDistributedApplicationBuilder"/>.
19+
/// Provides extension methods for adding JavaScript applications to an <see cref="IDistributedApplicationBuilder"/>.
2220
/// </summary>
23-
public static class NodeAppHostingExtension
21+
public static class JavaScriptHostingExtensions
2422
{
2523
private const string DefaultNodeVersion = "22";
2624

27-
/// <summary>
28-
/// Adds a node application to the application model. Node should be available on the PATH.
29-
/// </summary>
30-
/// <param name="builder">The <see cref="IDistributedApplicationBuilder"/> to add the resource to.</param>
31-
/// <param name="name">The name of the resource.</param>
32-
/// <param name="scriptPath">The path to the script that Node will execute.</param>
33-
/// <param name="workingDirectory">The working directory to use for the command. If null, the directory of the <paramref name="scriptPath"/> is used.</param>
34-
/// <param name="args">The arguments to pass to the command.</param>
35-
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
36-
[Obsolete("Use AddNodeApp that takes an appDirectory and relative scriptPath instead.")]
37-
[EditorBrowsable(EditorBrowsableState.Never)]
38-
public static IResourceBuilder<NodeAppResource> AddNodeApp(this IDistributedApplicationBuilder builder, [ResourceName] string name, string scriptPath, string? workingDirectory = null, string[]? args = null)
39-
{
40-
ArgumentNullException.ThrowIfNull(builder);
41-
ArgumentException.ThrowIfNullOrEmpty(name);
42-
ArgumentException.ThrowIfNullOrEmpty(scriptPath);
43-
44-
args ??= [];
45-
string[] effectiveArgs = [scriptPath, .. args];
46-
workingDirectory ??= Path.GetDirectoryName(scriptPath)!;
47-
workingDirectory = PathNormalizer.NormalizePathForCurrentPlatform(Path.Combine(builder.AppHostDirectory, workingDirectory));
48-
49-
var resource = new NodeAppResource(name, "node", workingDirectory);
50-
51-
return builder.AddResource(resource)
52-
.WithNodeDefaults()
53-
.WithArgs(effectiveArgs)
54-
.WithIconName("CodeJsRectangle");
55-
}
56-
5725
/// <summary>
5826
/// Adds a node application to the application model. Node should be available on the PATH.
5927
/// </summary>
@@ -80,7 +48,6 @@ public static IResourceBuilder<NodeAppResource> AddNodeApp(this IDistributedAppl
8048
/// builder.Build().Run();
8149
/// </code>
8250
/// </example>
83-
[OverloadResolutionPriority(1)]
8451
public static IResourceBuilder<NodeAppResource> AddNodeApp(this IDistributedApplicationBuilder builder, [ResourceName] string name, string appDirectory, string scriptPath)
8552
{
8653
ArgumentNullException.ThrowIfNull(builder);
@@ -200,36 +167,6 @@ public static IResourceBuilder<NodeAppResource> AddNodeApp(this IDistributedAppl
200167
return resourceBuilder;
201168
}
202169

203-
/// <summary>
204-
/// Adds a node application to the application model. Executes the npm command with the specified script name.
205-
/// </summary>
206-
/// <param name="builder">The <see cref="IDistributedApplicationBuilder"/> to add the resource to.</param>
207-
/// <param name="name">The name of the resource.</param>
208-
/// <param name="workingDirectory">The working directory to use for the command.</param>
209-
/// <param name="scriptName">The npm script to execute. Defaults to "start".</param>
210-
/// <param name="args">The arguments to pass to the command.</param>
211-
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
212-
[Obsolete("Use AddJavaScriptApp instead.")]
213-
public static IResourceBuilder<NodeAppResource> AddNpmApp(this IDistributedApplicationBuilder builder, [ResourceName] string name, string workingDirectory, string scriptName = "start", string[]? args = null)
214-
{
215-
ArgumentNullException.ThrowIfNull(builder);
216-
ArgumentException.ThrowIfNullOrEmpty(name);
217-
ArgumentException.ThrowIfNullOrEmpty(workingDirectory);
218-
ArgumentException.ThrowIfNullOrEmpty(scriptName);
219-
220-
string[] allArgs = args is { Length: > 0 }
221-
? ["run", scriptName, "--", .. args]
222-
: ["run", scriptName];
223-
224-
workingDirectory = PathNormalizer.NormalizePathForCurrentPlatform(Path.Combine(builder.AppHostDirectory, workingDirectory));
225-
var resource = new NodeAppResource(name, "npm", workingDirectory);
226-
227-
return builder.AddResource(resource)
228-
.WithNodeDefaults()
229-
.WithArgs(allArgs)
230-
.WithIconName("CodeJsRectangle");
231-
}
232-
233170
private static IResourceBuilder<TResource> WithNodeDefaults<TResource>(this IResourceBuilder<TResource> builder) where TResource : JavaScriptAppResource =>
234171
builder.WithOtlpExporter()
235172
.WithEnvironment("NODE_ENV", builder.ApplicationBuilder.Environment.IsDevelopment() ? "development" : "production")

src/Aspire.Hosting.NodeJs/JavaScriptInstallCommandAnnotation.cs renamed to src/Aspire.Hosting.JavaScript/JavaScriptInstallCommandAnnotation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using Aspire.Hosting.ApplicationModel;
55

6-
namespace Aspire.Hosting.NodeJs;
6+
namespace Aspire.Hosting.JavaScript;
77

88
/// <summary>
99
/// Represents the annotation for the JavaScript package manager's install command.

0 commit comments

Comments
 (0)