Skip to content

Commit

Permalink
Add Bun detector
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron committed Sep 13, 2023
1 parent 08078af commit 0afcd1f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Detector Adapters:
| Python ||
| Ruby ||
| Swift ||
| Bun ||

`✅ - supported, 🛠 - work in progress`

Expand Down
52 changes: 52 additions & 0 deletions src/Detector/Adapter/Bun.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Utopia\Detector\Adapter;

use Utopia\Detector\Adapter;

class Bun extends Adapter
{
/**
* @return string[]
*/
public function getLanguages(): array
{
return ['JavaScript', 'TypeScript'];
}

public function getRuntime(): string
{
return 'bun';
}

/**
* @return string[]
*/
public function getFileExtensions(): array
{
return ['ts', 'tsx', 'js', 'jsx'];
}

/**
* @return string[]
*/
public function getFiles(): array
{
return ['bun.lockb'];
}

public function getInstallCommand(): string
{
return 'bun install';
}

public function getBuildCommand(): string
{
return '';
}

public function getEntryPoint(): string
{
return 'main.ts';
}
}
3 changes: 3 additions & 0 deletions tests/Detector/DetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Utopia\App;
use Utopia\Cache\Adapter\None;
use Utopia\Cache\Cache;
use Utopia\Detector\Adapter\Bun;
use Utopia\Detector\Adapter\CPP;
use Utopia\Detector\Adapter\Dart;
use Utopia\Detector\Adapter\Deno;
Expand Down Expand Up @@ -40,6 +41,7 @@ public function detect($files, $languages): ?string
->addDetector(new Ruby())
->addDetector(new Java())
->addDetector(new CPP())
->addDetector(new Bun())
->addDetector(new Deno())
->addDetector(new Dotnet());

Expand Down Expand Up @@ -70,6 +72,7 @@ public function testLanguageDetection(): void
['Dobiasd', 'FunctionalPlus', 'cpp'],
['anthonychu', 'azure-functions-deno-worker', 'deno'],
['mono', 'mono-basic', 'dotnet'],
['X', 'X', 'bun'],
];

foreach ($languageMap as [$owner, $repositoryName, $expectedRuntime]) {
Expand Down

0 comments on commit 0afcd1f

Please sign in to comment.