-
Couldn't load subscription status.
- Fork 712
Add ViteApp and Npm Package Manager #12283
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
11 commits
Select commit
Hold shift + click to select a range
fb48603
Add ViteApp and NpmInstallation
eerhardt 7fe9800
Create a ViteAppResource class
eerhardt 167c5bf
Port unit tests from CommunityToolkit.
eerhardt 87288a4
Add dockerfile test.
eerhardt 5cdddfd
Apply suggestion from @Copilot
eerhardt 083ef66
Apply suggestion from @Copilot
eerhardt 95e9dc2
Apply suggestion from @Copilot
eerhardt f4528a6
Rename NpmInstallerResource to NodeInstallerResource.
eerhardt 6517db1
Remove npm install from csproj and use NpmPackageManager in the playg…
eerhardt dcf6b33
Check for an existing dockerfile.
eerhardt 7965516
Default to npm in ViteApp.
eerhardt 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,12 +27,16 @@ | |
| } | ||
| }, | ||
| "angular": { | ||
| "type": "dockerfile.v0", | ||
| "path": "../AspireJavaScript.Angular/Dockerfile", | ||
| "context": "../AspireJavaScript.Angular", | ||
| "type": "container.v1", | ||
| "build": { | ||
| "context": "../AspireJavaScript.Angular", | ||
| "dockerfile": "../AspireJavaScript.Angular/Dockerfile" | ||
| }, | ||
| "env": { | ||
| "NODE_ENV": "development", | ||
| "WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}", | ||
| "services__weatherapi__http__0": "{weatherapi.bindings.http.url}", | ||
| "WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}", | ||
| "services__weatherapi__https__0": "{weatherapi.bindings.https.url}", | ||
| "PORT": "{angular.bindings.http.targetPort}" | ||
| }, | ||
|
|
@@ -47,12 +51,16 @@ | |
| } | ||
| }, | ||
| "react": { | ||
| "type": "dockerfile.v0", | ||
| "path": "../AspireJavaScript.React/Dockerfile", | ||
| "context": "../AspireJavaScript.React", | ||
| "type": "container.v1", | ||
| "build": { | ||
| "context": "../AspireJavaScript.React", | ||
| "dockerfile": "../AspireJavaScript.React/Dockerfile" | ||
| }, | ||
| "env": { | ||
| "NODE_ENV": "development", | ||
| "WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}", | ||
| "services__weatherapi__http__0": "{weatherapi.bindings.http.url}", | ||
| "WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}", | ||
| "services__weatherapi__https__0": "{weatherapi.bindings.https.url}", | ||
| "BROWSER": "none", | ||
| "PORT": "{react.bindings.http.targetPort}" | ||
|
|
@@ -68,12 +76,16 @@ | |
| } | ||
| }, | ||
| "vue": { | ||
| "type": "dockerfile.v0", | ||
| "path": "../AspireJavaScript.Vue/Dockerfile", | ||
| "context": "../AspireJavaScript.Vue", | ||
| "type": "container.v1", | ||
| "build": { | ||
| "context": "../AspireJavaScript.Vue", | ||
| "dockerfile": "../AspireJavaScript.Vue/Dockerfile" | ||
| }, | ||
| "env": { | ||
| "NODE_ENV": "development", | ||
| "WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}", | ||
| "services__weatherapi__http__0": "{weatherapi.bindings.http.url}", | ||
| "WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}", | ||
| "services__weatherapi__https__0": "{weatherapi.bindings.https.url}", | ||
| "PORT": "{vue.bindings.http.targetPort}" | ||
| }, | ||
|
|
@@ -86,6 +98,31 @@ | |
| "external": true | ||
| } | ||
| } | ||
| }, | ||
| "reactvite": { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| "type": "container.v1", | ||
| "build": { | ||
| "context": "../AspireJavaScript.Vite", | ||
| "dockerfile": "reactvite.Dockerfile" | ||
| }, | ||
| "env": { | ||
| "NODE_ENV": "development", | ||
| "PORT": "{reactvite.bindings.http.targetPort}", | ||
| "WEATHERAPI_HTTP": "{weatherapi.bindings.http.url}", | ||
| "services__weatherapi__http__0": "{weatherapi.bindings.http.url}", | ||
| "WEATHERAPI_HTTPS": "{weatherapi.bindings.https.url}", | ||
| "services__weatherapi__https__0": "{weatherapi.bindings.https.url}", | ||
| "BROWSER": "none" | ||
| }, | ||
| "bindings": { | ||
| "http": { | ||
| "scheme": "http", | ||
| "protocol": "tcp", | ||
| "transport": "http", | ||
| "targetPort": 8003, | ||
| "external": true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
5 changes: 5 additions & 0 deletions
5
playground/AspireWithJavaScript/AspireJavaScript.AppHost/reactvite.Dockerfile
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 @@ | ||
| FROM node:22-slim | ||
| WORKDIR /app | ||
| COPY . . | ||
| RUN npm install | ||
| RUN npm run build |
23 changes: 0 additions & 23 deletions
23
playground/AspireWithJavaScript/AspireJavaScript.Vite/Dockerfile
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/Aspire.Hosting.NodeJs/JavaScriptPackageInstallerAnnotation.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,17 @@ | ||
| // 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 an annotation for a JavaScript installer resource. | ||
| /// </summary> | ||
| public sealed class JavaScriptPackageInstallerAnnotation(ExecutableResource installerResource) : IResourceAnnotation | ||
| { | ||
| /// <summary> | ||
| /// The instance of the Installer resource used. | ||
| /// </summary> | ||
| public ExecutableResource Resource { get; } = installerResource; | ||
| } |
39 changes: 39 additions & 0 deletions
39
src/Aspire.Hosting.NodeJs/JavaScriptPackageManagerAnnotation.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,39 @@ | ||
| // 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="packageManager">The name of the JavaScript package manager.</param> | ||
| public sealed class JavaScriptPackageManagerAnnotation(string packageManager) : IResourceAnnotation | ||
| { | ||
| /// <summary> | ||
| /// Gets the name of the JavaScript package manager. | ||
| /// </summary> | ||
| public string PackageManager { get; } = packageManager; | ||
|
|
||
| /// <summary> | ||
| /// Gets the command line arguments for the JavaScript package manager's install command. | ||
| /// </summary> | ||
| public string[] InstallCommandLineArgs { get; init; } = []; | ||
|
|
||
| /// <summary> | ||
| /// Gets the command line arguments for the JavaScript package manager's run command. | ||
| /// </summary> | ||
| public string[] RunCommandLineArgs { get; init; } = []; | ||
|
|
||
| /// <summary> | ||
| /// Gets a string value that separates the package manager command line args from the tool's command line args. | ||
| /// By default, this is "--". | ||
| /// </summary> | ||
| public string? CommandSeparator { get; init; } = "--"; | ||
|
|
||
| /// <summary> | ||
| /// Gets the command line arguments for the JavaScript package manager's command that produces assets for distribution. | ||
| /// </summary> | ||
| public string[] BuildCommandLineArgs { get; init; } = []; | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.