Skip to content

Commit

Permalink
chore(repo): switch from pnpm to bun (#227)
Browse files Browse the repository at this point in the history
* chore(repo): switch from pnpm to bun

* chore(repo): refactor unit tests to bun test

* chore(repo): remove vitest legacy

* chore(repo): set stricter type checking
  • Loading branch information
mrcnk authored Nov 7, 2024
1 parent 2bc5d5c commit a9f95d9
Show file tree
Hide file tree
Showing 106 changed files with 258 additions and 16,636 deletions.
9 changes: 3 additions & 6 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ version = 1
[[analyzers]]
name = "javascript"

[analyzers.meta]
plugins = ["react"]
environment = [
"browser",
"vitest"
]
[analyzers.meta]
plugins = ["react"]
environment = ["browser"]
25 changes: 7 additions & 18 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,14 @@ runs:
with:
repo-token: ${{ inputs.GITHUB_TOKEN }}
server-token: ${{ inputs.TURBO_SERVER_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: oven-sh/setup-bun@v2
name: Install Bun
- uses: actions/cache@v4
name: Setup pnpm cache
name: Setup cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
path: |
~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
- name: Install dependencies
shell: bash
run: pnpm install
run: bun i
6 changes: 3 additions & 3 deletions .github/workflows/apps-extension-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TURBO_SERVER_TOKEN: ${{ secrets.TURBO_SERVER_TOKEN }}
- name: Lint the code
run: pnpm lint
run: bun run lint
- name: Build extension
env:
TURBO_API: "http://127.0.0.1:9080"
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: pallad
run: VITE_APP_DEFAULT_NETWORK_ID=$VITE_APP_DEFAULT_NETWORK_ID pnpm build:extension
run: VITE_APP_DEFAULT_NETWORK_ID=$VITE_APP_DEFAULT_NETWORK_ID bun run build:extension
- name: Run unit tests
run: pnpm test:unit
run: bun run test:unit
- uses: actions/upload-artifact@v4
with:
name: pallad-chromium
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/apps-extension-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
TURBO_API: "http://127.0.0.1:9080"
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: pallad
run: VITE_APP_E2E=$VITE_APP_E2E VITE_APP_DEFAULT_NETWORK_ID=$VITE_APP_DEFAULT_NETWORK_ID pnpm build:extension
run: VITE_APP_E2E=$VITE_APP_E2E VITE_APP_DEFAULT_NETWORK_ID=$VITE_APP_DEFAULT_NETWORK_ID bun run build:extension
- name: Install Chromium for Playwright
working-directory: apps/extension
run: pnpm test:e2e:install
run: bun run test:e2e:install
- name: Run E2E tests
run: pnpm test:e2e:extension
run: bun run test:e2e:extension
- uses: actions/upload-artifact@v4
with:
name: pallad-extension-e2e
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/packages-ui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
TURBO_API: "http://127.0.0.1:9080"
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: pallad
run: pnpm build:features
run: bun run build:features
- name: Build features stories
run: pnpm story:features
run: bun run story:features
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint
bun run lint
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
[![Discord](https://img.shields.io/discord/1127906495409958953?label=Discord)](https://discord.gg/ExzzfTGUnB)
![example workflow](https://github.com/palladians/pallad/actions/workflows/apps-extension-ci.yml/badge.svg)

⚠️ Work in progress ⚠️
🚨 Now in Beta 🚨

</div>

Welcome to Pallad an experimental and progressive Mina Protocol wallet!
Expand All @@ -25,30 +22,24 @@ Pallad is at the frontier, leading the way in innovation and user-centric design

### Prerequisite 📌

- [NVM](https://github.com/nvm-sh/nvm)
- pnpm
- Bun

### Installation 💻

Make sure you're on the right Node.js version, and you got pnpm installed.

```shell
$ nvm use
$ npm i -g pnpm
```
Make sure you're on the latest Bun version.

Install the dependencies:

```shell
$ pnpm i
$ bun i
```

From `apps/extension` copy the `.env.example` as `.env` and adjust the variables there.

Build all the modules in repo:

```shell
$ pnpm build
$ bun run build
```

## Structure 🏗️
Expand All @@ -59,7 +50,7 @@ This is a monorepo for all the Pallad-related code.
- `extension` - Browser extension app.
- `packages`
- `_template` - Template to follow for new packages in this repo.
- `common` - Common configuration for packages (tsup and vitest).
- `common` - Common configuration for packages (tsup).
- `features` - Wallet features, views, and UI components.
- `key-management` - Blockchain agnostic key management.
- `mina-core` - Core Mina Package SDK.
Expand All @@ -74,28 +65,28 @@ This is a monorepo for all the Pallad-related code.
Set up the dev server of extension:

```shell
$ pnpm dev:extension
$ bun run dev:extension
```

## Testing 🧪

Running linter:

```shell
$ pnpm lint
$ bun run lint
```

Running unit tests (Vitest):
Running unit tests (Bun Test):

```shell
$ pnpm test:unit
$ bun run test:unit
```

Running E2E tests for browser extension (Playwright):

```shell
$ npx playwright install chromium # make sure you have Chromium driver
$ pnpm test:e2e:extension
$ bunx playwright install chromium # make sure you have Chromium driver
$ bun run test:e2e:extension
```

## Contributors ✨
Expand Down
11 changes: 4 additions & 7 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"version": "0.6.2",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && pnpm build:rpc && vite build",
"build:rpc": "tsup",
"dev": "bunx --bun vite",
"build": "bunx --bun tsc --noEmit && bun run build:rpc && bunx --bun vite build",
"build:rpc": "bunx --bun tsup",
"build:firefox": "web-ext build --source-dir=dist",
"build:safari": "xcrun safari-web-extension-converter dist --app-name Pallad --bundle-identifier co.pallad.app --swift --no-prompt --force --macos-only --no-open",
"preview": "vite preview",
"preview": "bunx --bun vite preview",
"cleanup": "rimraf node_modules dist .turbo",
"test:e2e": "playwright test",
"test:e2e:install": "npx playwright install --with-deps chromium",
Expand Down Expand Up @@ -40,12 +40,9 @@
"@esbuild-plugins/node-modules-polyfill": "0.2.2",
"@originjs/vite-plugin-commonjs": "1.0.3",
"@playwright/test": "1.45.3",
"@testing-library/react": "16.0.0",
"@total-typescript/ts-reset": "0.5.1",
"@tsconfig/vite-react": "3.0.2",
"@types/chrome": "0.0.269",
"@types/mocha": "10.0.7",
"@types/node": "22.0.0",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@types/webextension-polyfill": "0.10.7",
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default defineConfig({
},
],
webServer: {
command: "pnpm preview",
command: "bun run preview",
url: BASE_URL,
reuseExistingServer: !process.env.CI,
},
Expand Down
Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/adr/002-ways-of-working.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ In Progress can consist of many stages, such as `Development In Progress`, `Read

#### Code Standards

The code we deliver should be as close to 0 weak TypeScript types as possible. The code we deliver should have adequate test automation coverage (unit testing with Vitest and E2E testing with Playwright).
The code we deliver should be as close to 0 weak TypeScript types as possible. The code we deliver should have adequate test automation coverage (unit testing with Bun Test and E2E testing with Playwright).

#### Commits and branches

Expand Down
2 changes: 1 addition & 1 deletion extension.turbowatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default defineConfig({
],
name: "build",
onChange: async ({ spawn }) => {
await spawn`pnpm build:extension`
await spawn`bun run build:extension`
},
},
],
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
"license": "Apache-2.0",
"scripts": {
"build": "turbo run build",
"b": "pnpm build",
"b": "bun run build",
"build:extension": "turbo run build --filter=@palladxyz/extension...",
"build:features": "turbo run build --filter=@palladxyz/features...",
"story:features": "turbo run story:build --filter=@palladxyz/features",
"dev:extension": "turbowatch extension.turbowatch.ts",
"lint": "pnpm biome check .",
"lint:fix": "pnpm lint --write",
"lint": "bunx biome check .",
"lint:fix": "bun run lint --write",
"test:unit": "turbo run test:unit",
"test:e2e:extension": "turbo run test:e2e --filter=@palladxyz/extension",
"format": "pnpm biome check --write .",
"format:unsafe": "pnpm biome check --write --unsafe .",
"f": "pnpm format",
"format": "bunx biome check --write --unsafe .",
"f": "bun run format",
"cleanup": "turbo run cleanup && rimraf node_modules .turbo",
"prepare": "husky install",
"preinstall": "npx only-allow pnpm"
"preinstall": "bunx only-allow bun"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@testing-library/react": "16.0.0",
"@happy-dom/global-registrator": "^15.11.0",
"@mina-js/utils": "https://pkg.pr.new/palladians/mina-js/@mina-js/utils@a51d3b4",
"@testing-library/react": "16.0.1",
"@tsconfig/strictest": "2.0.5",
"@turbo/gen": "2.0.9",
"@vitest/coverage-v8": "2.0.5",
"@mina-js/utils": "https://pkg.pr.new/palladians/mina-js/@mina-js/utils@a51d3b4",
"@types/bun": "^1.1.13",
"autoprefixer": "10.4.19",
"happy-dom": "14.12.3",
"husky": "9.1.4",
Expand All @@ -40,8 +40,8 @@
"tsup": "8.2.3",
"turbo": "2.0.9",
"turbowatch": "2.29.4",
"typescript": "5.5.4",
"vitest": "2.0.4"
"typescript": "5.6.3"
},
"packageManager": "[email protected]"
"workspaces": ["packages/*", "apps/*"],
"packageManager": "[email protected]"
}
6 changes: 0 additions & 6 deletions packages/_template/vitest.config.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
},
"scripts": {
"build": "tsup src/index.ts --dts --format esm --silent",
"cleanup": "rimraf node_modules dist .turbo"
"build": "bunx --bun tsc --noEmit && bunx --bun tsup src/index.ts --dts --format esm --silent",
"cleanup": "bunx --bun rimraf node_modules dist .turbo"
}
}
14 changes: 0 additions & 14 deletions packages/common/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,3 @@ export const baseTsupConfig: Options = {
dts: true,
silent: true,
}

export const baseVitestConfig = {
test: {
environment: "happy-dom",
globals: true,
testTimeout: 100000,
hookTimeout: 100000,
test: {
coverage: {
reporter: ["text", "json", "html"],
},
},
},
}
3 changes: 1 addition & 2 deletions packages/common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"noPropertyAccessFromIndexSignature": false,
"types": ["vitest/globals"]
"noPropertyAccessFromIndexSignature": false
},
"include": ["src", "test"],
"exclude": ["dist", "node_modules", ".turbo"]
Expand Down
15 changes: 6 additions & 9 deletions packages/features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
}
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"build": "bunx --bun tsc --noEmit && bunx --bun tsup",
"dev": "bunx --bun tsup --watch",
"test:unit": "echo 'not yet'",
"story:dev": "VITE_APP_LADLE=true ladle serve",
"story:build": "VITE_APP_LADLE=true ladle build -o ./build",
"story:preview": "VITE_APP_LADLE=true ladle preview",
"cleanup": "rimraf node_modules dist .turbo build"
"story:dev": "VITE_APP_LADLE=true bunx --bun ladle serve",
"story:build": "VITE_APP_LADLE=true bunx --bun ladle build -o ./build",
"story:preview": "VITE_APP_LADLE=true bunx --bun ladle preview",
"cleanup": "bunx --bun rimraf node_modules dist .turbo build"
},
"dependencies": {
"@github/hotkey": "3.1.1",
Expand Down Expand Up @@ -82,13 +82,11 @@
"@ladle/react": "4.1.0",
"@palladxyz/common": "workspace:*",
"@svgr/rollup": "8.1.0",
"@testing-library/react": "16.0.0",
"@trpc/server": "10.45.2",
"@tsconfig/recommended": "1.0.7",
"@tsconfig/vite-react": "3.0.2",
"@types/chrome": "0.0.269",
"@types/js-beautify": "1.14.3",
"@types/mocha": "10.0.7",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@types/webextension-polyfill": "0.10.7",
Expand All @@ -105,7 +103,6 @@
"zod": "3.23.8"
},
"peerDependencies": {
"@types/mocha": "10.0.1",
"react": "18.2.0",
"react-dom": "18.2.0"
}
Expand Down
Loading

0 comments on commit a9f95d9

Please sign in to comment.