diff --git a/README.md b/README.md index ce0170510..c5f35f90d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ This repository contains the source code for the Aspire Community Toolkit, a col | - **Learn More**: [`Hosting.Deno`][deno-integration-docs]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.Deno][deno-shields]][deno-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects][sql-database-projects-shields]][sql-database-projects-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.Rust][rust-shields]][rust-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.Bun][bun-shields]][bun-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.Bun][bun-shields]][bun-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.Perl][perl-shields]][perl-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Python.Extensions][python-ext-shields]][python-ext-nuget]
- 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]
- Stable 📦: [![CommunityToolkit.Aspire.Hosting.KurrentDB][kurrentdb-shields]][kurrentdb-nuget]
- Preview 📦: [![CommunityToolkit.Aspire.Hosting.KurrentDB][kurrentdb-shields-preview]][kurrentdb-nuget-preview] | An Aspire hosting integration leveraging the [KurrentDB](https://www.kurrent.io) container. | diff --git a/examples/bun/CommunityToolkit.Aspire.Hosting.Bun.AppHost/Program.cs b/examples/bun/CommunityToolkit.Aspire.Hosting.Bun.AppHost/Program.cs index 4003493f6..d8590ee2c 100644 --- a/examples/bun/CommunityToolkit.Aspire.Hosting.Bun.AppHost/Program.cs +++ b/examples/bun/CommunityToolkit.Aspire.Hosting.Bun.AppHost/Program.cs @@ -1,3 +1,5 @@ +#pragma warning disable CS0618 + var builder = DistributedApplication.CreateBuilder(args); var api = builder.AddBunApp("api") @@ -6,3 +8,5 @@ .WithHttpHealthCheck("/"); builder.Build().Run(); + +#pragma warning restore CS0618 diff --git a/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs b/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs index e87b4c5c4..43d994dee 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs +++ b/src/CommunityToolkit.Aspire.Hosting.Bun/BunAppExtensions.cs @@ -11,6 +11,8 @@ namespace Aspire.Hosting; /// 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."; + /// /// Adds a Bun app to the builder. /// @@ -21,6 +23,7 @@ public static class BunAppExtensions /// Whether to watch for changes. /// A reference to the . [AspireExport] + [Obsolete(BunDeprecationMessage)] public static IResourceBuilder AddBunApp( this IDistributedApplicationBuilder builder, [ResourceName] string name, @@ -51,6 +54,7 @@ public static IResourceBuilder AddBunApp( /// A reference to the . /// This overload is not available in polyglot app hosts. Use instead. [AspireExportIgnore(Reason = "Action> is not ATS-compatible. Use the overload without configureInstaller instead.")] + [Obsolete(BunDeprecationMessage)] public static IResourceBuilder WithBunPackageInstallation(this IResourceBuilder resource, Action>? configureInstaller = null) => WithBunPackageInstallationCore(resource, configureInstaller); diff --git a/src/CommunityToolkit.Aspire.Hosting.Bun/CommunityToolkit.Aspire.Hosting.Bun.csproj b/src/CommunityToolkit.Aspire.Hosting.Bun/CommunityToolkit.Aspire.Hosting.Bun.csproj index 771dbd5b9..c2899924f 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Bun/CommunityToolkit.Aspire.Hosting.Bun.csproj +++ b/src/CommunityToolkit.Aspire.Hosting.Bun/CommunityToolkit.Aspire.Hosting.Bun.csproj @@ -1,8 +1,8 @@  - hosting bun javascript - An Aspire integration for hosting Bun apps. + hosting bun javascript deprecated + 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. diff --git a/src/CommunityToolkit.Aspire.Hosting.Bun/README.md b/src/CommunityToolkit.Aspire.Hosting.Bun/README.md index 951b227a2..d4bb13a9d 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Bun/README.md +++ b/src/CommunityToolkit.Aspire.Hosting.Bun/README.md @@ -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 @@ -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 diff --git a/src/CommunityToolkit.Aspire.Hosting.Bun/api/CommunityToolkit.Aspire.Hosting.Bun.cs b/src/CommunityToolkit.Aspire.Hosting.Bun/api/CommunityToolkit.Aspire.Hosting.Bun.cs index fb909edd5..a82273f2e 100644 --- a/src/CommunityToolkit.Aspire.Hosting.Bun/api/CommunityToolkit.Aspire.Hosting.Bun.cs +++ b/src/CommunityToolkit.Aspire.Hosting.Bun/api/CommunityToolkit.Aspire.Hosting.Bun.cs @@ -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 AddBunApp(this IDistributedApplicationBuilder builder, string name, string? workingDirectory = null, string entryPoint = "index.ts", bool watch = false) { throw null; } [AspireExportIgnore(Reason = "Action> 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 WithBunPackageInstallation(this ApplicationModel.IResourceBuilder resource, System.Action>? configureInstaller = null) { throw null; } } } diff --git a/tests/CommunityToolkit.Aspire.Hosting.Bun.Tests/AddBunAppTests.cs b/tests/CommunityToolkit.Aspire.Hosting.Bun.Tests/AddBunAppTests.cs index b05a8aa52..ce952143e 100644 --- a/tests/CommunityToolkit.Aspire.Hosting.Bun.Tests/AddBunAppTests.cs +++ b/tests/CommunityToolkit.Aspire.Hosting.Bun.Tests/AddBunAppTests.cs @@ -3,6 +3,8 @@ namespace CommunityToolkit.Aspire.Hosting.Bun.Tests; +#pragma warning disable CS0618 + public class AddBunAppTests { [Fact] @@ -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), typeof(Action>)]); + + 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