Skip to content

Commit

Permalink
Merge pull request #6 from utopia-php/feat-bun-detector
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron authored Sep 13, 2023
2 parents 08078af + 039c580 commit 47144f2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
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

0 comments on commit 47144f2

Please sign in to comment.