Skip to content

Commit e82eb9b

Browse files
authored
Merge pull request #366 from dokar3/dokar/bun
Migrate from Node and Yarn to Bun
2 parents bf8ff52 + d09007c commit e82eb9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+136
-332
lines changed

.github/workflows/build.yaml

+6-28
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,13 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v4
3939

40-
- name: Set up node.js
41-
uses: actions/setup-node@v4
40+
- name: Setup Bun
41+
uses: oven-sh/setup-bun@v1
4242
with:
43-
node-version: 18
43+
bun-version: latest
4444

45-
- name: Upgrade yarn
46-
run: |
47-
corepack enable
48-
corepack prepare yarn@stable --activate
49-
echo "yarn version: $(yarn -v)"
50-
51-
- name: Get yarn cache directory path
52-
id: yarn-cache-dir-path
53-
run: echo "dir=$(yarn config get globalFolder)/cache" >> $GITHUB_OUTPUT
54-
shell: bash
55-
56-
- name: Restore yarn cache
57-
uses: actions/cache@v4
58-
with:
59-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
60-
key: yarn-cache-folder-${{ hashFiles('js/**/yarn.lock', 'js/**/.yarnrc.yml') }}
61-
restore-keys: |
62-
yarn-cache-folder-
63-
64-
- name: Setup yarn and js projects
65-
run: |
66-
node ./scripts/service/setup.js
67-
echo "yarn version: $(yarn -v)"
68-
shell: bash
45+
- name: Setup js projects
46+
run: bun ./scripts/service/setup.js
6947

7048
- name: Set up JDK 17
7149
uses: actions/setup-java@v4
@@ -90,7 +68,7 @@ jobs:
9068
echo "secret 'keystore_base64' is not set"
9169
exit 1
9270
fi
93-
node ./scripts/fileBase64Converter.js str2f $ENCODED_KEYSTORE $KEYSTORE_PATH
71+
bun ./scripts/fileBase64Converter.js str2f $ENCODED_KEYSTORE $KEYSTORE_PATH
9472
9573
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
9674
- name: Enable KVM group perms

android/app/build_services.gradle

+8-19
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@ def cmd(File dir, String command) {
4949
)
5050
}
5151

52-
def checkNodeJs() {
53-
def check = "node -v"
54-
def out = cmd(builtinServicesDir(), check).stdout
55-
return Pattern.compile("v\\d+\\.\\d+\\.\\d+").matcher(out).matches()
56-
}
57-
58-
def checkYarn() {
59-
def check = "yarn -v"
52+
def checkBun() {
53+
def check = "bun -v"
6054
def out = cmd(builtinServicesDir(), check).stdout
6155
return Pattern.compile("\\d+\\.\\d+\\.\\d+").matcher(out).matches()
6256
}
@@ -69,22 +63,17 @@ task compileBuiltinJsServices() {
6963
inputs.files(inputFiles)
7064
outputs.dir(compiledJsDir())
7165
doLast {
72-
// Check nodejs
73-
println("Checking node.js")
74-
if (!checkNodeJs()) {
75-
throw new GradleException("Node.js is not installed, please install it " +
76-
"manually: https://nodejs.org")
77-
}
78-
79-
if (!checkYarn()) {
80-
throw new GradleException("Yarn is not installed, please install it " +
81-
"manually: https://yarnpkg.com/getting-started/install")
66+
// Check Bun
67+
println("Checking Bun...")
68+
if (!checkBun()) {
69+
throw new GradleException("Bun is not installed, please install it " +
70+
"manually: https://bun.sh")
8271
}
8372

8473
println("Compiling builtin js services...")
8574
// Compile js files
8675
def outputDir = compiledJsDir().absolutePath
87-
def buildCmd = "node scripts/service/buildAll.js " +
76+
def buildCmd = "bun scripts/service/buildAll.js " +
8877
"--platform=android " +
8978
"--output=${outputDir} " +
9079
"--file-prefix=file:///android_asset/js/"

js/README.md

+14-16
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ Built-in services.
3838

3939
**Requirements:**
4040

41-
- [Node.js](https://nodejs.org/) The JavaScript runtime for compiling and packing.
42-
- [yarn](https://yarnpkg.com/) The dependency management.
41+
- [Bun](https://bun.sh/) The JavaScript runtime and package manager.
4342

4443
**Setup:**
4544

@@ -51,41 +50,40 @@ node ./scripts/service/setup.js
5150

5251
The `setup.js` script will do:
5352

54-
1. Check and install `yarn` (if not)
55-
2. Install dependencies for projects in the `js/any-***` and `js/services/` folder
56-
3. Build local dependencies, e.g. `js/any-service-api`, `js/any-service-test`
57-
4. Link `js/any-service-cli` so you can use the `any-service-cli` command to create a new project
53+
1. Install dependencies for projects in the `js/any-***` and `js/services/` folder
54+
2. Build local dependencies, e.g. `js/any-service-api`, `js/any-service-test`
55+
3. Link `js/any-service-cli` so you can use the `any-service-cli` command to create a new project
5856

5957
**Create and run a new service:**
6058

6159

62-
3. Run `any-service-cli` command to create new project:
60+
1. Run `any-service-cli` command to create new project:
6361

6462
```shell
6563
cd js/services/
6664

6765
any-service-cli
6866
```
6967

70-
4. Install dependencies:
68+
2. Install dependencies:
7169

7270
```shell
7371
cd NewProject
7472
75-
yarn
73+
bun install
7674
```
7775

78-
5. Test, run and build:
76+
3. Test, run and build:
7977

8078
```shell
8179
# Test with jest framework
82-
yarn test
80+
bun test
8381
8482
# (WIP) Start runner servers to debug service in a browser
85-
yarn runner
83+
bun runner
8684
8785
# Build
88-
yarn build-android
86+
bun build-android
8987
```
9088

9189
### Other commands and scripts
@@ -94,14 +92,14 @@ The `setup.js` script will do:
9492

9593
```shell
9694
# Install dependencies for all projects
97-
node ./scripts/service/runInEachProject.js yarn
95+
bun ./scripts/service/runInEachProject.js bun install
9896
9997
# Upgrade 'typescript' for all projects
100-
node ./scripts/service/runInEachProject.js yarn up typescript
98+
bun ./scripts/service/runInEachProject.js bun update typescript
10199
```
102100

103101
**Build all built-in services:**
104102

105103
```shell
106-
node ./scripts/service/buildAll.js --platform=android --output=/path/to/output_dir
104+
bun ./scripts/service/buildAll.js --platform=android --output=/path/to/output_dir
107105
```

js/any-service-api/bun.lockb

7.38 KB
Binary file not shown.

js/any-service-api/jest.config.js

-10
This file was deleted.

js/any-service-api/package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
"main": "dist/index.js",
88
"types": "dist/index.d.ts",
99
"scripts": {
10-
"test": "jest ./test",
10+
"test": "bun test",
1111
"build": "tsc",
12-
"gen-doc": "yarn typedoc --entryPoints src/index.ts --disableSources --includeVersion"
12+
"gen-doc": "typedoc --entryPoints src/index.ts --disableSources --includeVersion"
1313
},
1414
"devDependencies": {
15-
"@types/jest": "^29.0.0",
16-
"jest": "^29.0.0",
17-
"ts-jest": "^29.0.0",
15+
"@types/bun": "^1.1.3",
1816
"tsc": "^2.0.4",
1917
"typedoc": "^0.25.0",
2018
"typescript": "^5.0.0"

js/any-service-api/test/Features.test.ts

-46
This file was deleted.

js/any-service-api/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"declaration": true,
88
"emitDeclarationOnly": false,
99
"allowJs": true,
10-
"outDir": "dist"
10+
"outDir": "dist",
11+
"skipLibCheck": true
1112
},
1213
"include": [
1314
"src/**/*"

js/any-service-cli/bun.lockb

25.9 KB
Binary file not shown.

js/any-service-compile/bun.lockb

154 KB
Binary file not shown.

js/any-service-runner/bun.lockb

216 KB
Binary file not shown.

js/any-service-runner/package.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"name": "any-service-runner",
33
"version": "1.0.0",
4-
"description": "Any service runner for browsers.",
5-
"type": "module",
64
"author": "Any",
7-
"license": "Apache-2.0",
85
"dependencies": {
96
"@babel/core": "^7.20.5",
107
"@babel/preset-env": "^7.16.11",
@@ -21,9 +18,9 @@
2118
"webpack": "^5.75.0",
2219
"webpack-dev-server": "^5.0.0"
2320
},
24-
"devDependencies": {
25-
"any-service-compile": "portal:../any-service-compile"
26-
},
2721
"bin": "./src/main.js",
28-
"packageManager": "[email protected]"
22+
"description": "Any service runner for browsers.",
23+
"license": "Apache-2.0",
24+
"packageManager": "[email protected]",
25+
"type": "module"
2926
}

js/any-service-template/jest.config.js

-11
This file was deleted.

js/any-service-template/package.json

+7-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "{{license}}",
77
"type": "module",
88
"scripts": {
9-
"test": "jest ./test",
9+
"test": "bun test",
1010
"build-android": "any-service-build --platform=android --output=./dist/",
1111
"build-desktop": "any-service-build --platform=desktop --output=./dist/",
1212
"build-browser": "any-service-build --platform=browser --output=./dist/",
@@ -15,15 +15,13 @@
1515
"runner": "concurrently --kill-others -n \"Backend \",\"Frontend\" \"npm run any-service-runner-backend\" \"npm run any-service-runner-frontend\""
1616
},
1717
"dependencies": {
18-
"any-service-api": "portal:{{anyApiPath}}"
18+
"any-service-api": "link:any-service-api"
1919
},
2020
"devDependencies": {
21-
"@types/jest": "^29.0.0",
22-
"any-service-compile": "portal:{{anyCompilePath}}",
23-
"any-service-runner": "portal:{{anyRunnerPath}}",
24-
"any-service-testing": "portal:{{anyTestingPath}}",
25-
"concurrently": "^8.0.0",
26-
"jest": "^29.0.0",
27-
"ts-jest": "^29.0.0"
21+
"@types/bun": "^1.1.3",
22+
"any-service-compile": "link:any-service-compile",
23+
"any-service-runner": "link:any-service-runner",
24+
"any-service-testing": "link:any-service-testing",
25+
"concurrently": "^8.0.0"
2826
}
2927
}

js/any-service-template/test/Service.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, expect, test } from "@jest/globals";
21
import { createTestService } from "any-service-testing";
32
import { features } from "../src/main";
43

js/any-service-testing/bun.lockb

34.7 KB
Binary file not shown.

js/any-service-testing/jest.config.js

-7
This file was deleted.

js/any-service-testing/package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
{
2-
"name": "any-testing",
2+
"name": "any-service-testing",
33
"version": "1.0.0",
44
"author": "Any",
55
"description": "Create and test services on the node.js environment",
66
"main": "dist/index.js",
77
"types": "dist/index.d.ts",
88
"scripts": {
9-
"test": "jest ./test",
9+
"test": "bun test",
1010
"build": "tsc"
1111
},
1212
"license": "Apache-2.0",
13+
"dependencies": {
14+
"any-service-api": "link:any-service-api"
15+
},
1316
"devDependencies": {
14-
"@types/jest": "^29.2.2",
15-
"any-service-api": "portal:../any-service-api",
16-
"jest": "^29.3.1",
17+
"@types/bun": "^1.1.3",
1718
"jsdom": "^24.0.0",
1819
"os-locale": "^6.0.2",
1920
"sync-request": "^6.1.0",
20-
"ts-jest": "^29.0.3",
2121
"typescript": "^5.0.0"
22-
},
23-
"packageManager": "[email protected]"
22+
}
2423
}

js/any-service-testing/test/createTestService.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { describe, expect, test } from "@jest/globals";
21
import {
32
NotImplementedError,
43
ServiceFeatures,

js/any-service-testing/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"allowJs": true,
77
"declaration": true,
88
"emitDeclarationOnly": false,
9-
"outDir": "dist"
9+
"outDir": "dist",
10+
"skipLibCheck": true
1011
},
1112
"include": [
1213
"src/**/*"

js/services/9GAG/bun.lockb

14.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)