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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This repository contains the source code for the Aspire Community Toolkit, a col
| - **Learn More**: [`Hosting.Deno`][deno-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Deno][deno-shields]][deno-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Deno][deno-shields-preview]][deno-nuget-preview] | A hosting integration for the Deno apps. |
| - **Learn More**: [`Hosting.SqlDatabaseProjects`][sql-database-projects-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects][sql-database-projects-shields]][sql-database-projects-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects][sql-database-projects-shields-preview]][sql-database-projects-nuget-preview] | A hosting integration for the SQL Databases Projects. |
| - **Learn More**: [`Hosting.Rust`][rust-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Rust][rust-shields]][rust-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Rust][rust-shields-preview]][rust-nuget-preview] | A hosting integration for the Rust apps. |
| - **Learn More**: [`Hosting.Bun`][bun-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Bun][bun-shields]][bun-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Bun][bun-shields-preview]][bun-nuget-preview] | A hosting integration for the Bun apps. |
| - **Learn More**: [`Hosting.Bun`][bun-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Bun][bun-shields]][bun-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Bun][bun-shields-preview]][bun-nuget-preview] | **Deprecated**: use the core `Aspire.Hosting.JavaScript` `AddBunApp(...)` integration. |
| - **Learn More**: [`Hosting.Perl`][perl-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.Perl][perl-shields]][perl-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Perl][perl-shields-preview]][perl-nuget-preview] | A hosting integration for Perl scripts and APIs. |
| - **Learn More**: [`Hosting.Python.Extensions`][python-ext-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Python.Extensions][python-ext-shields]][python-ext-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.Python.Extensions][python-ext-shields-preview]][python-ext-nuget-preview] | An integration that contains some additional extensions for running python applications |
| - **Learn More**: [`Hosting.KurrentDB`][kurrentdb-integration-docs] <br /> - Stable 📦: [![CommunityToolkit.Aspire.Hosting.KurrentDB][kurrentdb-shields]][kurrentdb-nuget] <br /> - Preview 📦: [![CommunityToolkit.Aspire.Hosting.KurrentDB][kurrentdb-shields-preview]][kurrentdb-nuget-preview] | An Aspire hosting integration leveraging the [KurrentDB](https://www.kurrent.io) container. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma warning disable CS0618

var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddBunApp("api")
Expand All @@ -6,3 +8,5 @@
.WithHttpHealthCheck("/");

builder.Build().Run();

#pragma warning restore CS0618
4 changes: 4 additions & 0 deletions src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace Aspire.Hosting;
/// </summary>
public static class BunAppExtensions
{
private const string BunDeprecationMessage = "CommunityToolkit.Aspire.Hosting.Bun is deprecated. Use Aspire.Hosting.JavaScript and builder.AddBunApp(...) instead. This package will be removed in a future release.";

/// <summary>
/// Adds a Bun app to the builder.
/// </summary>
Expand All @@ -21,6 +23,7 @@ public static class BunAppExtensions
/// <param name="watch">Whether to watch for changes.</param>
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
[AspireExport]
[Obsolete(BunDeprecationMessage)]
public static IResourceBuilder<BunAppResource> AddBunApp(
this IDistributedApplicationBuilder builder,
[ResourceName] string name,
Expand Down Expand Up @@ -51,6 +54,7 @@ public static IResourceBuilder<BunAppResource> AddBunApp(
/// <returns>A reference to the <see cref="IResourceBuilder{T}"/>.</returns>
/// <remarks>This overload is not available in polyglot app hosts. Use <see cref="WithBunPackageInstallation(IResourceBuilder{BunAppResource})"/> instead.</remarks>
[AspireExportIgnore(Reason = "Action<IResourceBuilder<BunInstallerResource>> is not ATS-compatible. Use the overload without configureInstaller instead.")]
[Obsolete(BunDeprecationMessage)]
public static IResourceBuilder<BunAppResource> WithBunPackageInstallation(this IResourceBuilder<BunAppResource> resource, Action<IResourceBuilder<BunInstallerResource>>? configureInstaller = null)
Comment on lines +57 to 58
=> WithBunPackageInstallationCore(resource, configureInstaller);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AdditionalPackageTags>hosting bun javascript</AdditionalPackageTags>
<Description>An Aspire integration for hosting Bun apps.</Description>
<AdditionalPackageTags>hosting bun javascript deprecated</AdditionalPackageTags>
<Description>An Aspire integration for hosting Bun apps. DEPRECATED: Use Aspire.Hosting.JavaScript and builder.AddBunApp(...) instead. This package will be removed in a future release.</Description>
</PropertyGroup>

<ItemGroup>
Expand Down
36 changes: 36 additions & 0 deletions src/CommunityToolkit.Aspire.Hosting.Bun/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# CommunityToolkit.Aspire.Hosting.Bun library

> **⚠️ DEPRECATION NOTICE**
> This package is deprecated. Bun support is now available in the core `Aspire.Hosting.JavaScript` package via `AddBunApp(...)`.
>
> **Migration Guide:**
> - Install `Aspire.Hosting.JavaScript` and remove `CommunityToolkit.Aspire.Hosting.Bun`.
> - Review existing `builder.AddBunApp(...)` calls carefully: if you pass arguments positionally, you may need to reorder them or convert them to named arguments when moving to the core package implementation.
> - If you're using TypeScript AppHost bindings, continue using `builder.addBunApp(...)` from the generated core bindings.
>
> This package will be removed in a future release. Please migrate to `Aspire.Hosting.JavaScript`.

Provides extension methods and resource definitions for an Aspire AppHost to configure a Bun project.

## Getting Started
Expand All @@ -22,6 +32,32 @@ builder.AddBunApp("bun-server", "main.ts")
.WithEndpoint();
```

### Migration from Toolkit Bun to core Bun

Toolkit API:

```csharp
builder.AddBunApp("api", "server.ts")
.WithHttpEndpoint(env: "PORT");
```

Core API (`Aspire.Hosting.JavaScript`):

```csharp
builder.AddBunApp("api", "./api", "server.ts")
.WithHttpEndpoint(env: "PORT")
.WithExternalHttpEndpoints();
```

TypeScript AppHost (core bindings):

```typescript
await builder
.addBunApp("api", "./api", "server.ts")
.withHttpEndpoint({ env: "PORT" })
.withExternalHttpEndpoints();
```

## Additional Information

https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-bun
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ namespace Aspire.Hosting
public static partial class BunAppExtensions
{
[AspireExport("addBunApp", Description = "Adds a Bun app")]
[System.Obsolete("CommunityToolkit.Aspire.Hosting.Bun is deprecated. Use Aspire.Hosting.JavaScript and builder.AddBunApp(...) instead. This package will be removed in a future release.")]
public static ApplicationModel.IResourceBuilder<ApplicationModel.BunAppResource> AddBunApp(this IDistributedApplicationBuilder builder, string name, string? workingDirectory = null, string entryPoint = "index.ts", bool watch = false) { throw null; }

[AspireExportIgnore(Reason = "Action<IResourceBuilder<BunInstallerResource>> is not ATS-compatible. Use the overload without configureInstaller instead.")]
[System.Obsolete("CommunityToolkit.Aspire.Hosting.Bun is deprecated. Use Aspire.Hosting.JavaScript and builder.AddBunApp(...) instead. This package will be removed in a future release.")]
public static ApplicationModel.IResourceBuilder<ApplicationModel.BunAppResource> WithBunPackageInstallation(this ApplicationModel.IResourceBuilder<ApplicationModel.BunAppResource> resource, System.Action<ApplicationModel.IResourceBuilder<ApplicationModel.BunInstallerResource>>? configureInstaller = null) { throw null; }
}
}
Expand Down
16 changes: 16 additions & 0 deletions tests/CommunityToolkit.Aspire.Hosting.Bun.Tests/AddBunAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

namespace CommunityToolkit.Aspire.Hosting.Bun.Tests;

#pragma warning disable CS0618

public class AddBunAppTests
{
[Fact]
Expand Down Expand Up @@ -159,4 +161,18 @@ public void BunAppWithPackageInstallationCreatesInstallerResource()
Assert.Equal("bun-bun-install", installerResource.Name);
Assert.Equal("bun", installerResource.Command);
}

[Fact]
public void BunExtensionsAreDeprecated()
{
var addBunAppMethod = typeof(BunAppExtensions).GetMethod(nameof(BunAppExtensions.AddBunApp), [typeof(IDistributedApplicationBuilder), typeof(string), typeof(string), typeof(string), typeof(bool)]);
var withPackageInstallationMethod = typeof(BunAppExtensions).GetMethod(nameof(BunAppExtensions.WithBunPackageInstallation), [typeof(IResourceBuilder<BunAppResource>), typeof(Action<IResourceBuilder<BunInstallerResource>>)]);

Assert.NotNull(addBunAppMethod);
Assert.NotNull(withPackageInstallationMethod);
Assert.NotNull(addBunAppMethod.GetCustomAttributes(typeof(ObsoleteAttribute), inherit: false).SingleOrDefault());
Assert.NotNull(withPackageInstallationMethod.GetCustomAttributes(typeof(ObsoleteAttribute), inherit: false).SingleOrDefault());
}
}

#pragma warning restore CS0618
Loading