Skip to content

Commit

Permalink
chore: Switch from pnpm to bun (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
aklinker1 authored Oct 19, 2024
1 parent ed5a04d commit d29f157
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 7,085 deletions.
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

20 changes: 7 additions & 13 deletions .github/workflows/submit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,27 @@ jobs:
with:
fetch-depth: 0

- uses: pnpm/action-setup@v2
with:
version: 8

- uses: actions/setup-node@v4
with:
node-version: 18
- uses: oven-sh/setup-bun@v2

- name: Configure Git
run: |
git config user.email "[email protected]"
git config user.name "GitHub Actions"
- name: Install dependencies
run: pnpm install
run: bun install

- name: Bump Version
id: version
run: |
pnpx changelogen@latest --bump
NEW_VERSION=$(node -pe 'require("./package.json").version')
bunx changelogen@latest --bump
NEW_VERSION=$(bun --print 'require("./package.json").version')
echo "newVersion=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Build and Zip
run: |
pnpm zip
pnpm zip:firefox
bun run zip
bun run zip:firefox
- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand All @@ -59,7 +53,7 @@ jobs:

- name: Submit
run: |
pnpm wxt submit \
bun wxt submit \
--chrome-zip .output/*-chrome.zip \
--firefox-zip .output/*-firefox.zip --firefox-sources-zip .output/*-sources.zip
env:
Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
- uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: pnpm install
run: bun install

- name: Run Checks
run: pnpm check
run: bun check

- name: Build
run: pnpm build
run: bun run build

- name: Tests
run: pnpm test:coverage
run: bun run test:coverage
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ dist
dist-*
artifacts
coverage
pnpm-lock.yaml
.wxt
.output
coverage
45 changes: 10 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,60 +27,35 @@ That's it. Very simple, targeted extension for fixing 1 problem with GitHub.

## Development

You must use [PNPM](https://pnpm.io/) with this repo. To install it, run `corepack enable` or `npm i -g pnpm`.
You must use [Bun](https://bun.sh/) with this repo.

Then instal dependencies:
Install dependencies:

```sh
pnpm i
bun i
```

### Scripts

This extension is bundled via [WXT](https://wxt.dev).

- `pnpm dev`: Launchs Chrome with the dev version of the extension installed.
- `pnpm build`: Builds the extension for production. Outputs to the `dist` directory.
- `pnpm zip`: Zips up the `dist` directory into an installable ZIP file.
- `bun dev`: Launches Chrome with the dev version of the extension installed.
- `bun run build`: Builds the extension for production. Outputs to the `dist` directory.
- `bun run zip`: Zips up the `dist` directory into an installable ZIP file.

Add `:firefox` suffix to some commands to target firefox instead of Chrome.

- `pnpm build:firefox`
- `pnpm dev:firefox`
- `bun run build:firefox`
- `bun run dev:firefox`

### Running Tests

Unit tests are written with Vitest.

```ts
pnpm test
bun run test
```

## Release an Update

Eventually, I'll create a GitHub action for this. But for now, you can release an update by:

1. Create a file, `.env.submit`, with the following content:

```sh
# Follow: https://developer.chrome.com/docs/webstore/using_webstore_api/
CHROME_EXTENSION_ID="..."
CHROME_CLIENT_ID="..."
CHROME_CLIENT_SECRET="..."
CHROME_REFRESH_TOKEN="..."

# Follow: https://extensionworkshop.com/documentation/develop/web-ext-command-reference/#web-ext-sign
FIREFOX_EXTENSION_ID="..."
FIREFOX_JWT_ISSUER="..."
FIREFOX_JWT_SECRET="..."

# Follow: https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api#before-you-begin
EDGE_PRODUCT_ID="..."
EDGE_CLIENT_ID="..."
EDGE_CLIENT_SECRET="..."
EDGE_ACCESS_TOKEN_URL="..."
```

2. _Optional_: Run `pnpm submit:dry` to test if your config is correct.

3. Run `pnpm submit` to submit new versions to the stores.
Use the [Submit for Review](https://github.com/aklinker1/github-better-line-counts/actions/workflows/submit.yml) workflow.
Binary file added bun.lockb
Binary file not shown.
33 changes: 12 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Remove generated files from GitHub line counts",
"private": true,
"version": "1.7.0",
"packageManager": "[email protected]",
"packageManager": "[email protected]",
"type": "module",
"scripts": {
"check": "check",
Expand All @@ -16,29 +16,27 @@
"zip": "wxt zip",
"zip:firefox": "wxt zip -b firefox",
"prepare": "simple-git-hooks",
"postinstall": "wxt prepare",
"submit": "env-cmd -f ./.env.submit ./scripts/submit.sh",
"submit:dry": "pnpm -s submit --dry-run"
"postinstall": "wxt prepare"
},
"dependencies": {
"@aklinker1/check": "^1.2.0",
"@tanstack/vue-query": "^5.59.13",
"@vueuse/core": "^9",
"@webext-core/messaging": "^1.4.0",
"@webext-core/proxy-service": "^1.2.0",
"async-mutex": "^0.4.0",
"daisyui": "^3.7.7",
"fast-deep-equal": "^3.1.3",
"minimatch": "^9.0.3",
"ofetch": "^1.3.3",
"vue-query": "^1.26.0"
"ofetch": "^1.3.3"
},
"devDependencies": {
"@aklinker1/generate-changelog": "^1.1.2",
"@iconify/json": "^2.2.119",
"@types/bun": "^1.1.11",
"@types/chrome": "^0.0.269",
"@types/jsdom": "^21.1.3",
"@vitejs/plugin-vue": "^5.0.4",
"@vitest/coverage-v8": "^1.3.1",
"@vitest/coverage-v8": "^2.1.3",
"@wxt-dev/module-vue": "^1.0.0",
"autoprefixer": "^10.4.16",
"env-cmd": "^10.1.0",
Expand All @@ -52,23 +50,16 @@
"simple-git-hooks": "^2.9.0",
"tailwindcss": "^3.3.3",
"tsx": "^3.12.10",
"typescript": "^5.4.2",
"unplugin-icons": "^0.17.0",
"vitest": "^1.3.1",
"typescript": "^5.6.3",
"unplugin-icons": "^0.19.3",
"vitest": "^2.1.3",
"vue": "^3.4.21",
"vue-tsc": "^2.0.6",
"vue-tsc": "^2.1.6",
"webextension-polyfill": "0.12.0",
"wxt": "0.19.1"
},
"pnpm": {
"peerDependencyRules": {
"allowAny": [
"node-fetch"
]
}
"wxt": "^0.19.11"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
"pre-commit": "bun lint-staged"
},
"lint-staged": {
"*": "prettier --write"
Expand Down
Loading

0 comments on commit d29f157

Please sign in to comment.