-
Notifications
You must be signed in to change notification settings - Fork 866
Add JavaScript publish methods, AddNextJsApp, and switch to YARP #15736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b661852
Add JavaScript publish methods, AddNextJsApp, and switch to YARP
davidfowl 953c5d3
Add full E2E service verification with checked-in verify.sh
davidfowl 403f142
Fix CopyFixtures to include root-level files like verify.sh
davidfowl 811273f
Address review feedback: lockfile-aware prod install, source-share YA…
davidfowl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
669 changes: 657 additions & 12 deletions
669
src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Aspire.Hosting.JavaScript/JavaScriptPublishModeAnnotation.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // 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.JavaScript; | ||
|
|
||
| internal enum JavaScriptPublishMode | ||
| { | ||
| StaticWebsite, | ||
| NodeServer, | ||
| NpmScript, | ||
| NextStandalone | ||
| } | ||
|
|
||
| internal sealed class JavaScriptPublishModeAnnotation(JavaScriptPublishMode mode) : IResourceAnnotation | ||
| { | ||
| public JavaScriptPublishMode Mode { get; } = mode; | ||
|
|
||
| public string OutputPath { get; init; } = "dist"; | ||
|
|
||
| // NodeServer properties | ||
| public string? EntryPoint { get; init; } | ||
|
|
||
| // NpmScript properties | ||
| public string? StartScriptName { get; init; } | ||
| public string? RunScriptArguments { get; init; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.JavaScript; | ||
|
|
||
| /// <summary> | ||
| /// Represents a Next.js application resource. | ||
| /// </summary> | ||
| /// <param name="name">The unique name used to identify the Next.js application resource.</param> | ||
| /// <param name="command">The command to execute the application.</param> | ||
| /// <param name="workingDirectory">The working directory from which the application command is executed.</param> | ||
| [AspireExport(ExposeProperties = true)] | ||
| public class NextJsAppResource(string name, string command, string workingDirectory) | ||
| : JavaScriptAppResource(name, command, workingDirectory); |
32 changes: 32 additions & 0 deletions
32
src/Aspire.Hosting.JavaScript/PublishAsStaticWebsiteOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.JavaScript; | ||
|
|
||
| /// <summary> | ||
| /// Options for configuring the static website publish mode. | ||
| /// </summary> | ||
| public class PublishAsStaticWebsiteOptions | ||
| { | ||
| /// <summary> | ||
| /// Gets or sets the relative path to the directory containing the built static files. | ||
| /// Defaults to <c>dist</c>. Some frameworks use a different output directory, | ||
| /// for example Angular uses <c>dist/browser</c>. | ||
| /// </summary> | ||
| public string OutputPath { get; set; } = "dist"; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets whether to remove the API path prefix before forwarding to the backend. | ||
| /// For example, with <c>apiPath="/api"</c> and <c>StripPrefix=true</c>, a request to | ||
| /// <c>/api/weatherforecast</c> is forwarded as <c>/weatherforecast</c>. | ||
| /// Defaults to <see langword="true"/>. | ||
| /// </summary> | ||
| public bool StripPrefix { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the name of a specific endpoint on the API target resource to proxy to. | ||
| /// When <see langword="null"/>, YARP uses service discovery to resolve the appropriate endpoint, | ||
| /// preferring HTTPS when available. | ||
| /// </summary> | ||
| public string? TargetEndpointName { get; set; } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/Aspire.Hosting.JavaScript/SuppressStandaloneValidationAnnotation.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // 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.JavaScript; | ||
|
|
||
| internal sealed class SuppressPublishValidationAnnotation : IResourceAnnotation; |
9 changes: 9 additions & 0 deletions
9
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/api/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "name": "api", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "node server.js", | ||
| "build": "echo 'no build needed'", | ||
| "start": "node server.js" | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/api/server.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const http = require('http'); | ||
| const port = process.env.PORT || 3001; | ||
| http.createServer((req, res) => { | ||
| res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
| res.end(JSON.stringify([ | ||
| { date: '2026-04-01', temperatureC: 22, summary: 'Warm' }, | ||
| { date: '2026-04-02', temperatureC: 18, summary: 'Cool' }, | ||
| { date: '2026-04-03', temperatureC: 30, summary: 'Hot' } | ||
| ])); | ||
| }).listen(port, '0.0.0.0', () => console.log(`API on port ${port}`)); |
3 changes: 3 additions & 0 deletions
3
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/nextjs/app/layout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function RootLayout({ children }: { children: React.ReactNode }) { | ||
| return <html><body>{children}</body></html>; | ||
| } |
3 changes: 3 additions & 0 deletions
3
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/nextjs/app/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export default function Home() { | ||
| return <h1>Hello from Next.js</h1>; | ||
| } |
5 changes: 5 additions & 0 deletions
5
tests/Aspire.Cli.EndToEnd.Tests/Fixtures/JsPublish/nextjs/next.config.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type { NextConfig } from 'next'; | ||
| const nextConfig: NextConfig = { | ||
| output: 'standalone', | ||
| }; | ||
| export default nextConfig; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this scenario. Why doesn't this use AddNodeApp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dev time uses the vite dev server, publish time uses a node based server.