Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Bun detector #6

Merged
merged 4 commits into from
Sep 13, 2023
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
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';
}
}
2 changes: 1 addition & 1 deletion src/Detector/Adapter/JavaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getFileExtensions(): array
*/
public function getFiles(): array
{
return ['package.json', 'package-lock.json', 'yarn.lock', 'tsconfig.json'];
return ['package-lock.json', 'yarn.lock', 'tsconfig.json'];
}

public function getInstallCommand(): string
Expand Down
4 changes: 4 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 @@ -33,6 +34,7 @@ public function detect($files, $languages): ?string

$detectorFactory
->addDetector(new JavaScript())
->addDetector(new Bun())
->addDetector(new PHP())
->addDetector(new Python())
->addDetector(new Dart())
Expand Down Expand Up @@ -70,6 +72,8 @@ public function testLanguageDetection(): void
['Dobiasd', 'FunctionalPlus', 'cpp'],
['anthonychu', 'azure-functions-deno-worker', 'deno'],
['mono', 'mono-basic', 'dotnet'],
['Meldiron', 'bun-function', 'bun'],
['cytoscape', 'cytoscape.js', 'node']
];

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