Skip to content

Commit

Permalink
Bun hosting integration (#235)
Browse files Browse the repository at this point in the history
* Adding bun to the devcontainer + extension

* Removing old docs task

* Task to generate PublicAPI files

* Initial implementation of the Bun integration

Closes #108

* Adding tests for Bun

* readme for bun

* Adding healthcheck

* Fixing bun tests by properly handling paths

* Implementing a package installer for bun

* Using package installer

* Adding bun to ci

* Extrac args by using ArgumentEvaluator

---------

Co-authored-by: Alireza Baloochi <Dev.AlirezaBaloochi@gmail.com>
  • Loading branch information
aaronpowell and Alirexaa authored Nov 14, 2024
1 parent e482d09 commit 2aaf7d4
Show file tree
Hide file tree
Showing 28 changed files with 767 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"vscjava.vscode-java-pack",
"esbenp.prettier-vscode",
"redhat.vscode-yaml",
"rust-lang.rust-analyzer"
"rust-lang.rust-analyzer",
"oven.bun-vscode"
]
}
},
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ cd ../../../
echo Install Aspire 9 templates
dotnet new install Aspire.ProjectTemplates

echo Installing Bun
curl -fsSL https://bun.sh/install | bash

echo Done!
7 changes: 7 additions & 0 deletions .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ jobs:
run_install: false

- uses: denoland/setup-deno@v2
name: Setup Deno
with:
deno-version: v2.x

- uses: oven-sh/setup-bun@v2
name: Setup Bun
with:
bun-version: latest

- uses: actions/cache@v4
name: Cache NuGet packages
with:
Expand Down Expand Up @@ -175,3 +181,4 @@ jobs:
needs: build
uses: ./.github/workflows/code-coverage.yml
secrets: inherit

7 changes: 7 additions & 0 deletions .github/workflows/dotnet-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ jobs:
run_install: false

- uses: denoland/setup-deno@v2
name: Setup Deno
with:
deno-version: v2.x

- uses: oven-sh/setup-bun@v2
name: Setup Bun
with:
bun-version: latest

- uses: actions/cache@v4
name: Cache NuGet packages
with:
Expand Down Expand Up @@ -271,3 +277,4 @@ jobs:
needs: build
uses: ./.github/workflows/code-coverage.yml
secrets: inherit

6 changes: 6 additions & 0 deletions .github/workflows/dotnet-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ jobs:
run_install: false

- uses: denoland/setup-deno@v2
name: Setup Deno
with:
deno-version: v2.x

- uses: oven-sh/setup-bun@v2
name: Setup Bun
with:
bun-version: latest

- uses: actions/cache@v4
name: Cache NuGet packages
with:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"default": "CommunityToolkit.Aspire.MyIntegration"
}
]
}
}
24 changes: 24 additions & 0 deletions CommunityToolkit.Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hos
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Python.Extensions.Tests", "tests\CommunityToolkit.Aspire.Hosting.Python.Extensions.Tests\CommunityToolkit.Aspire.Hosting.Python.Extensions.Tests.csproj", "{5B825CF9-E8B8-4960-9330-648ED0323FE0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Bun", "src\CommunityToolkit.Aspire.Hosting.Bun\CommunityToolkit.Aspire.Hosting.Bun.csproj", "{6095E8B8-7F99-4A12-B7E2-376F7EDD7435}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bun", "bun", "{A7614F2B-E810-412E-91E7-8B6272DD5DBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Bun.AppHost", "examples\bun\CommunityToolkit.Aspire.Hosting.Bun.AppHost\CommunityToolkit.Aspire.Hosting.Bun.AppHost.csproj", "{36FC2579-582A-4DAF-9B20-AB33331624C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Bun.Tests", "tests\CommunityToolkit.Aspire.Hosting.Bun.Tests\CommunityToolkit.Aspire.Hosting.Bun.Tests.csproj", "{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -351,6 +359,18 @@ Global
{2CC61B84-CF97-4CE7-A08F-2EECF4AEAD92}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CC61B84-CF97-4CE7-A08F-2EECF4AEAD92}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CC61B84-CF97-4CE7-A08F-2EECF4AEAD92}.Release|Any CPU.Build.0 = Release|Any CPU
{6095E8B8-7F99-4A12-B7E2-376F7EDD7435}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6095E8B8-7F99-4A12-B7E2-376F7EDD7435}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6095E8B8-7F99-4A12-B7E2-376F7EDD7435}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6095E8B8-7F99-4A12-B7E2-376F7EDD7435}.Release|Any CPU.Build.0 = Release|Any CPU
{36FC2579-582A-4DAF-9B20-AB33331624C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36FC2579-582A-4DAF-9B20-AB33331624C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36FC2579-582A-4DAF-9B20-AB33331624C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36FC2579-582A-4DAF-9B20-AB33331624C6}.Release|Any CPU.Build.0 = Release|Any CPU
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -420,6 +440,10 @@ Global
{373472DA-BAEB-44B6-915D-1EF3DA845797} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{79CBF217-CED1-4BB2-9A72-37D2429F83B8} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{2CC61B84-CF97-4CE7-A08F-2EECF4AEAD92} = {79CBF217-CED1-4BB2-9A72-37D2429F83B8}
{6095E8B8-7F99-4A12-B7E2-376F7EDD7435} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{A7614F2B-E810-412E-91E7-8B6272DD5DBB} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{36FC2579-582A-4DAF-9B20-AB33331624C6} = {A7614F2B-E810-412E-91E7-8B6272DD5DBB}
{DA5DD2CB-51D9-429F-91F5-BF3D1A13A21A} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08B1D4B8-D2C5-4A64-BB8B-E1A2B29525F0}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="$(AspireAppHostSdkVersion)" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>7e518d7d-87e8-4337-8806-1c99acce5dfb</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../../src/CommunityToolkit.Aspire.Hosting.Bun/CommunityToolkit.Aspire.Hosting.Bun.csproj" IsAspireProjectResource="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var builder = DistributedApplication.CreateBuilder(args);

var api = builder.AddBunApp("api")
.WithBunPackageInstallation()
.WithHttpEndpoint(env: "PORT")
.WithHttpHealthCheck("/");

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17047;http://localhost:15023",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21036",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22247"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15023",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19100",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20022"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
175 changes: 175 additions & 0 deletions examples/bun/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
15 changes: 15 additions & 0 deletions examples/bun/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# bun

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.1.34. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Binary file added examples/bun/api/bun.lockb
Binary file not shown.
Loading

0 comments on commit 2aaf7d4

Please sign in to comment.