Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,30 @@
var weatherApi = builder.AddProject<Projects.AspireJavaScript_MinimalApi>("weatherapi")
.WithExternalHttpEndpoints();

builder.AddNpmApp("angular", "../AspireJavaScript.Angular")
.WithNpm(install: true)
builder.AddJavaScriptApp("angular", "../AspireJavaScript.Angular")
.WithReference(weatherApi)
.WaitFor(weatherApi)
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints()
.PublishAsDockerFile();

builder.AddNpmApp("react", "../AspireJavaScript.React")
.WithNpm(install: true)
builder.AddJavaScriptApp("react", "../AspireJavaScript.React")
.WithReference(weatherApi)
.WaitFor(weatherApi)
.WithEnvironment("BROWSER", "none") // Disable opening browser on npm start
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints()
.PublishAsDockerFile();

builder.AddNpmApp("vue", "../AspireJavaScript.Vue")
.WithInstallCommand("npm", ["ci"]) // Use 'npm ci' for clean install
builder.AddJavaScriptApp("vue", "../AspireJavaScript.Vue")
.WithNpm(installCommand: "ci") // Use 'npm ci' for clean install, requires lock file
.WithReference(weatherApi)
.WaitFor(weatherApi)
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints()
.PublishAsDockerFile();

var reactvite = builder.AddViteApp("reactvite", "../AspireJavaScript.Vite")
.WithNpm(install: true)
.WithReference(weatherApi)
.WithEnvironment("BROWSER", "none")
.WithExternalHttpEndpoints();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

var weatherapi = builder.AddProject<Projects.AspireWithNode_AspNetCoreApi>("weatherapi");

var frontend = builder.AddNpmApp("frontend", "../NodeFrontend", "watch")
var frontend = builder.AddJavaScriptApp("frontend", "../NodeFrontend", "watch")
.WithReference(weatherapi)
.WaitFor(weatherapi)
.WithReference(cache)
Expand Down
15 changes: 15 additions & 0 deletions src/Aspire.Hosting.NodeJs/JavaScriptAppResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting;

/// <summary>
/// A resource that represents a JavaScript application.
/// </summary>
/// <param name="name">The name of the resource.</param>
/// <param name="command">The command to execute.</param>
/// <param name="workingDirectory">The working directory to use for the command.</param>
public class JavaScriptAppResource(string name, string command, string workingDirectory)
: ExecutableResource(name, command, workingDirectory), IResourceWithServiceDiscovery, IResourceWithContainerFiles;
24 changes: 0 additions & 24 deletions src/Aspire.Hosting.NodeJs/JavaScriptBuildCommandAnnotation.cs

This file was deleted.

24 changes: 24 additions & 0 deletions src/Aspire.Hosting.NodeJs/JavaScriptBuildScriptAnnotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.NodeJs;

/// <summary>
/// Represents the annotation for the JavaScript package manager's build script.
/// </summary>
/// <param name="scriptName">The name of the JavaScript package manager's build script.</param>
/// <param name="args">The command line arguments for the JavaScript package manager's build script.</param>
public sealed class JavaScriptBuildScriptAnnotation(string scriptName, string[]? args) : IResourceAnnotation
{
/// <summary>
/// Gets the name of the script used to build.
/// </summary>
public string ScriptName { get; } = scriptName;

/// <summary>
/// Gets the command-line arguments supplied to the build script.
/// </summary>
public string[] Args { get; } = args ?? [];
}
15 changes: 6 additions & 9 deletions src/Aspire.Hosting.NodeJs/JavaScriptInstallCommandAnnotation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ namespace Aspire.Hosting.NodeJs;
/// <summary>
/// Represents the annotation for the JavaScript package manager's install command.
/// </summary>
/// <param name="command">The executable command name</param>
/// <param name="args">The command line arguments for the JavaScript package manager's install command.</param>
public sealed class JavaScriptInstallCommandAnnotation(string command, string[] args) : IResourceAnnotation
/// <param name="args">
/// The command line arguments for the JavaScript package manager's install command.
/// This includes the command itself (i.e. "install").
/// </param>
public sealed class JavaScriptInstallCommandAnnotation(string[] args) : IResourceAnnotation
{
/// <summary>
/// Gets the executable command name.
/// </summary>
public string Command { get; } = command;

/// <summary>
/// Gets the command-line arguments supplied to the application.
/// Gets the command-line arguments supplied to the JavaScript package manager.
/// </summary>
public string[] Args { get; } = args;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
namespace Aspire.Hosting.NodeJs;

/// <summary>
/// A resource that represents a package installer for a node app.
/// A resource that represents a package installer for a JavaScript app.
/// </summary>
/// <param name="name">The name of the resource.</param>
/// <param name="workingDirectory">The working directory to use for the command.</param>
public class NodeInstallerResource(string name, string workingDirectory)
public class JavaScriptInstallerResource(string name, string workingDirectory)
: ExecutableResource(name, "node", workingDirectory);
24 changes: 24 additions & 0 deletions src/Aspire.Hosting.NodeJs/JavaScriptPackageManagerAnnotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.NodeJs;

/// <summary>
/// Represents the annotation for the JavaScript package manager used in a resource.
/// </summary>
/// <param name="executableName">The name of the executable used to run the package manager.</param>
/// <param name="runScriptCommand">The command used to run a script with the JavaScript package manager.</param>
public sealed class JavaScriptPackageManagerAnnotation(string executableName, string? runScriptCommand) : IResourceAnnotation
{
/// <summary>
/// Gets the executable used to run the JavaScript package manager.
/// </summary>
public string ExecutableName { get; } = executableName;

/// <summary>
/// Gets the command used to run a script with the JavaScript package manager.
/// </summary>
public string? ScriptCommand { get; } = runScriptCommand;
}
21 changes: 0 additions & 21 deletions src/Aspire.Hosting.NodeJs/JavaScriptRunCommandAnnotation.cs

This file was deleted.

24 changes: 24 additions & 0 deletions src/Aspire.Hosting.NodeJs/JavaScriptRunScriptAnnotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting.NodeJs;

/// <summary>
/// Represents the annotation for the script used during run mode in a JavaScript resource.
/// </summary>
/// <param name="scriptName">The name of the JavaScript package manager's run script.</param>
/// <param name="args">The command line arguments for the JavaScript package manager's run script.</param>
public sealed class JavaScriptRunScriptAnnotation(string scriptName, string[]? args) : IResourceAnnotation
{
/// <summary>
/// Gets the name of the script to run.
/// </summary>
public string ScriptName { get; } = scriptName;

/// <summary>
/// Gets the command-line arguments for the script.
/// </summary>
public string[] Args { get; } = args ?? [];
}
6 changes: 2 additions & 4 deletions src/Aspire.Hosting.NodeJs/NodeAppResource.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.ApplicationModel;

namespace Aspire.Hosting;

/// <summary>
/// A resource that represents a node application.
/// </summary>
/// <param name="name">The name of the resource.</param>
/// <param name="command">The command to execute.</param>
/// <param name="workingDirectory">The working directory to use for the command. If null, the working directory of the current process is used.</param>
/// <param name="workingDirectory">The working directory to use for the command.</param>
public class NodeAppResource(string name, string command, string workingDirectory)
: ExecutableResource(name, command, workingDirectory), IResourceWithServiceDiscovery;
: JavaScriptAppResource(name, command, workingDirectory), IResourceWithServiceDiscovery;
Loading