Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixing how the monorepo tests work to ensure they run nx/turbo properly
  • Loading branch information
aaronpowell committed Nov 12, 2025
commit e36c0a3974062d323c2e9bbb7737deb1ca5d83cf
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
var builder = DistributedApplication.CreateBuilder(args);

var nx = builder.AddNxApp("nx-demo")
.WithNpm(install: true);
.WithNpm(install: true)
.WithPackageManagerLaunch();

nx.AddApp("blog-monorepo")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
.WithHttpHealthCheck();

var turbo = builder.AddTurborepoApp("turborepo-demo")
.WithNpm(install: true);
.WithNpm(install: true)
.WithPackageManagerLaunch();

turbo.AddApp("turbo-web", filter: "web")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
.WithHttpHealthCheck();

turbo.AddApp("turbo-docs", filter: "docs")
.WithHttpEndpoint(env: "PORT")
.WithMappedEndpointPort()
Expand Down
27 changes: 27 additions & 0 deletions examples/javascript-ext/nx-demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions examples/javascript-ext/turborepo-demo/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static IResourceBuilder<TurborepoAppResource> AddApp(this IResourceBuilde
/// <param name="packageManager">The package manager to use. If none is provided it will attempt to use the installer annotation's resource command.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
/// <exception cref="InvalidOperationException">Thrown if the Nx workspace is already configured to use a different package manager.</exception>
public static IResourceBuilder<NxResource> RunWithPackageManager(this IResourceBuilder<NxResource> builder, string? packageManager = null)
public static IResourceBuilder<NxResource> WithPackageManagerLaunch(this IResourceBuilder<NxResource> builder, string? packageManager = null)
{
ArgumentNullException.ThrowIfNull(builder);

Expand Down Expand Up @@ -176,7 +176,7 @@ public static IResourceBuilder<NxResource> RunWithPackageManager(this IResourceB
/// <param name="packageManager">The package manager to use. If none is provided it will attempt to use the installer annotation's resource command.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
/// <exception cref="InvalidOperationException">Thrown if the Turborepo workspace is already configured to use a different package manager.</exception>
public static IResourceBuilder<TurborepoResource> RunWithPackageManager(this IResourceBuilder<TurborepoResource> builder, string? packageManager = null)
public static IResourceBuilder<TurborepoResource> WithPackageManagerLaunch(this IResourceBuilder<TurborepoResource> builder, string? packageManager = null)
{
ArgumentNullException.ThrowIfNull(builder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,29 @@ Both Nx and Turborepo support yarn and pnpm package managers:

### Configuring Package Manager for App Execution

Use `RunWithPackageManager()` to configure which package manager command is used when running individual apps:
Use `WithPackageManagerLaunch()` to configure which package manager command is used when running individual apps:

```csharp
// Auto-infer from package installer annotation
var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")
.WithYarnPackageInstaller()
.RunWithPackageManager(); // Will use 'yarn' command
.WithPackageManagerLaunch(); // Will use 'yarn' command

// Explicitly specify package manager (independent of installer)
var turbo = builder.AddTurborepoApp("turbo", workingDirectory: "../frontend")
.WithPnpmPackageInstaller()
.RunWithPackageManager("yarn"); // Uses 'yarn' despite pnpm installer
.WithPackageManagerLaunch("yarn"); // Uses 'yarn' despite pnpm installer

// Without RunWithPackageManager - uses default commands
// Without WithPackageManagerLaunch - uses default commands
var nxDefault = builder.AddNxApp("nx-default", workingDirectory: "../frontend");
nxDefault.AddApp("app1"); // Runs: nx serve app1 (no package manager prefix)
```

**Command Generation Examples:**

- `RunWithPackageManager("yarn")` → `yarn nx serve app1` or `yarn turbo run dev --filter app1`
- `RunWithPackageManager("pnpm")` → `pnpm nx serve app1` or `pnpm turbo run dev --filter app1`
- No `RunWithPackageManager()` → `nx serve app1` or `turbo run dev --filter app1`
- `WithPackageManagerLaunch("yarn")` → `yarn nx serve app1` or `yarn turbo run dev --filter app1`
- `WithPackageManagerLaunch("pnpm")` → `pnpm nx serve app1` or `pnpm turbo run dev --filter app1`
- No `WithPackageManagerLaunch()` → `nx serve app1` or `turbo run dev --filter app1`

## How It Works

Expand Down Expand Up @@ -119,7 +119,7 @@ You can migrate to:
// New monorepo approach
var nx = builder.AddNxApp("nx", workingDirectory: "./Frontend")
.WithYarnPackageInstaller()
.RunWithPackageManager(); // Configure package manager for app execution
.WithPackageManagerLaunch(); // Configure package manager for app execution

var app1 = nx.AddApp("app-1", appName: "app1");
var app2 = nx.AddApp("app-2", appName: "app2");
Expand All @@ -135,12 +135,13 @@ This provides cleaner syntax and automatic dependency management.
It's important to understand the difference between package installation and app execution:

- **Package Installer** (`.WithYarnPackageInstaller()`, `.WithPnpmPackageInstaller()`) - Controls how packages are installed in the workspace
- **Package Manager for Apps** (`.RunWithPackageManager()`) - Controls which command is used to run individual apps
- **Package Manager for Apps** (`.WithPackageManagerLaunch()`) - Controls which command is used to run individual apps

```csharp
var nx = builder.AddNxApp("nx", workingDirectory: "../frontend")
.WithPnpmPackageInstaller() // Install packages with: pnpm install
.RunWithPackageManager("yarn"); // Run apps with: yarn nx serve app1
.WithPackageManagerLaunch("yarn"); // Run apps with: yarn nx serve app1

// This is valid - you can install with pnpm but run apps with yarn
```

Loading
Loading