Skip to content

Commit cb4f3b5

Browse files
Copilotaaronpowell
andcommitted
Add documentation and example for new args functionality
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
1 parent 263edc3 commit cb4f3b5

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

examples/nodejs-ext/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.AppHost/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@
99
builder.AddViteApp("pnpm-demo", packageManager: "pnpm")
1010
.WithPnpmPackageInstallation();
1111

12+
// Example of using custom args - useful for legacy packages
13+
builder.AddNpmApp("npm-with-flags", "../vite-demo")
14+
.WithNpmPackageInstallation(useCI: false, args: ["--legacy-peer-deps"])
15+
.WithHttpEndpoint(env: "PORT");
16+
1217
builder.Build().Run();

src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ builder.AddPnpmApp("pnpm-demo")
2424
.WithExternalHttpEndpoints();
2525
```
2626

27+
### Package installation with custom flags
28+
29+
You can pass additional flags to package managers during installation:
30+
31+
```csharp
32+
// npm with legacy peer deps support
33+
builder.AddNpmApp("npm-app", "./path/to/app")
34+
.WithNpmPackageInstallation(useCI: false, args: ["--legacy-peer-deps"])
35+
.WithExternalHttpEndpoints();
36+
37+
// yarn with frozen lockfile
38+
builder.AddYarnApp("yarn-app", "./path/to/app")
39+
.WithYarnPackageInstallation(args: ["--frozen-lockfile", "--verbose"])
40+
.WithExternalHttpEndpoints();
41+
42+
// pnpm with frozen lockfile
43+
builder.AddPnpmApp("pnpm-app", "./path/to/app")
44+
.WithPnpmPackageInstallation(args: ["--frozen-lockfile"])
45+
.WithExternalHttpEndpoints();
46+
```
47+
2748
## Additional Information
2849

2950
https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-nodejs-extensions

src/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions/api/CommunityToolkit.Aspire.Hosting.NodeJS.Extensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public static partial class NodeJSHostingExtensions
1616

1717
public static ApplicationModel.IResourceBuilder<NodeAppResource> AddYarnApp(this IDistributedApplicationBuilder builder, string name, string workingDirectory, string scriptName = "start", string[]? args = null) { throw null; }
1818

19-
public static ApplicationModel.IResourceBuilder<NodeAppResource> WithNpmPackageInstallation(this ApplicationModel.IResourceBuilder<NodeAppResource> resource, bool useCI = false) { throw null; }
19+
public static ApplicationModel.IResourceBuilder<NodeAppResource> WithNpmPackageInstallation(this ApplicationModel.IResourceBuilder<NodeAppResource> resource, bool useCI = false, string[]? args = null) { throw null; }
2020

21-
public static ApplicationModel.IResourceBuilder<NodeAppResource> WithPnpmPackageInstallation(this ApplicationModel.IResourceBuilder<NodeAppResource> resource) { throw null; }
21+
public static ApplicationModel.IResourceBuilder<NodeAppResource> WithPnpmPackageInstallation(this ApplicationModel.IResourceBuilder<NodeAppResource> resource, string[]? args = null) { throw null; }
2222

23-
public static ApplicationModel.IResourceBuilder<NodeAppResource> WithYarnPackageInstallation(this ApplicationModel.IResourceBuilder<NodeAppResource> resource) { throw null; }
23+
public static ApplicationModel.IResourceBuilder<NodeAppResource> WithYarnPackageInstallation(this ApplicationModel.IResourceBuilder<NodeAppResource> resource, string[]? args = null) { throw null; }
2424
}
2525
}

0 commit comments

Comments
 (0)