Skip to content

Commit 47144f2

Browse files
authored
Merge pull request #6 from utopia-php/feat-bun-detector
2 parents 08078af + 039c580 commit 47144f2

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Detector Adapters:
8787
| Python ||
8888
| Ruby ||
8989
| Swift ||
90+
| Bun ||
9091

9192
`✅ - supported, 🛠 - work in progress`
9293

src/Detector/Adapter/Bun.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace Utopia\Detector\Adapter;
4+
5+
use Utopia\Detector\Adapter;
6+
7+
class Bun extends Adapter
8+
{
9+
/**
10+
* @return string[]
11+
*/
12+
public function getLanguages(): array
13+
{
14+
return ['JavaScript', 'TypeScript'];
15+
}
16+
17+
public function getRuntime(): string
18+
{
19+
return 'bun';
20+
}
21+
22+
/**
23+
* @return string[]
24+
*/
25+
public function getFileExtensions(): array
26+
{
27+
return ['ts', 'tsx', 'js', 'jsx'];
28+
}
29+
30+
/**
31+
* @return string[]
32+
*/
33+
public function getFiles(): array
34+
{
35+
return ['bun.lockb'];
36+
}
37+
38+
public function getInstallCommand(): string
39+
{
40+
return 'bun install';
41+
}
42+
43+
public function getBuildCommand(): string
44+
{
45+
return '';
46+
}
47+
48+
public function getEntryPoint(): string
49+
{
50+
return 'main.ts';
51+
}
52+
}

src/Detector/Adapter/JavaScript.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getFileExtensions(): array
3232
*/
3333
public function getFiles(): array
3434
{
35-
return ['package.json', 'package-lock.json', 'yarn.lock', 'tsconfig.json'];
35+
return ['package-lock.json', 'yarn.lock', 'tsconfig.json'];
3636
}
3737

3838
public function getInstallCommand(): string

tests/Detector/DetectorTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Utopia\App;
77
use Utopia\Cache\Adapter\None;
88
use Utopia\Cache\Cache;
9+
use Utopia\Detector\Adapter\Bun;
910
use Utopia\Detector\Adapter\CPP;
1011
use Utopia\Detector\Adapter\Dart;
1112
use Utopia\Detector\Adapter\Deno;
@@ -33,6 +34,7 @@ public function detect($files, $languages): ?string
3334

3435
$detectorFactory
3536
->addDetector(new JavaScript())
37+
->addDetector(new Bun())
3638
->addDetector(new PHP())
3739
->addDetector(new Python())
3840
->addDetector(new Dart())
@@ -70,6 +72,8 @@ public function testLanguageDetection(): void
7072
['Dobiasd', 'FunctionalPlus', 'cpp'],
7173
['anthonychu', 'azure-functions-deno-worker', 'deno'],
7274
['mono', 'mono-basic', 'dotnet'],
75+
['Meldiron', 'bun-function', 'bun'],
76+
['cytoscape', 'cytoscape.js', 'node']
7377
];
7478

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

0 commit comments

Comments
 (0)