Skip to content

Commit d6ebf0f

Browse files
authored
feat(browser): migrate browser extension to use plasmo (#48)
1 parent f287899 commit d6ebf0f

File tree

17 files changed

+1655
-93
lines changed

17 files changed

+1655
-93
lines changed

.github/workflows/browser.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Submit to Web Store"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "apps/browser/**"
8+
- "packages/server/**"
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
environment: deploy-browser
14+
defaults:
15+
run:
16+
working-directory: ./apps/browser
17+
env:
18+
CRX_PUBLIC_KEY: ${{ secrets.CRX_PUBLIC_KEY }}
19+
CLERK_FRONTEND_API: ${{ secrets.CLERK_FRONTEND_API }}
20+
21+
steps:
22+
- name: 💾 Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: 📦 Setup bun
26+
uses: oven-sh/setup-bun@v2
27+
28+
- name: 📦 Install dependencies
29+
run: bun ci
30+
31+
- name: 🛠️ Build the Chrome Extension
32+
run: bun run build
33+
34+
- name: 🛠️ Package the extension into a zip artifact
35+
run: bun run package
36+
37+
- name: 🚀 Browser Platform Publish
38+
uses: PlasmoHQ/bpp@v3
39+
with:
40+
keys: ${{ secrets.SUBMIT_KEYS }}
41+
artifact: ./apps/browser/build/chrome-mv3-prod.zip

.github/workflows/chrome.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.

apps/browser/.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
3+
4+
# dependencies
5+
/node_modules
6+
/.pnp
7+
.pnp.js
8+
9+
# testing
10+
/coverage
11+
12+
#cache
13+
.turbo
14+
15+
# misc
16+
.DS_Store
17+
*.pem
18+
19+
# debug
20+
npm-debug.log*
21+
yarn-debug.log*
22+
yarn-error.log*
23+
.pnpm-debug.log*
24+
25+
# local env files
26+
.env*
27+
28+
out/
29+
build/
30+
dist/
31+
32+
# plasmo - https://www.plasmo.com
33+
.plasmo
34+
35+
# bpp - http://bpp.browser.market/
36+
keys.json
37+
38+
# typescript
39+
.tsbuildinfo

apps/browser/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
This is a [Plasmo extension](https://docs.plasmo.com/) project bootstrapped with [`plasmo init`](https://www.npmjs.com/package/plasmo).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
pnpm dev
9+
# or
10+
npm run dev
11+
```
12+
13+
Open your browser and load the appropriate development build. For example, if you are developing for the chrome browser, using manifest v3, use: `build/chrome-mv3-dev`.
14+
15+
You can start editing the popup by modifying `popup.tsx`. It should auto-update as you make changes. To add an options page, simply add a `options.tsx` file to the root of the project, with a react component default exported. Likewise to add a content page, add a `content.ts` file to the root of the project, importing some module and do some logic, then reload the extension on your browser.
16+
17+
For further guidance, [visit our Documentation](https://docs.plasmo.com/)
18+
19+
## Making production build
20+
21+
Run the following:
22+
23+
```bash
24+
pnpm build
25+
# or
26+
npm run build
27+
```
28+
29+
This should create a production bundle for your extension, ready to be zipped and published to the stores.
30+
31+
## Submit to the webstores
32+
33+
The easiest way to deploy your Plasmo extension is to use the built-in [bpp](https://bpp.browser.market) GitHub action. Prior to using this action however, make sure to build your extension and upload the first version to the store to establish the basic credentials. Then, simply follow [this setup instruction](https://docs.plasmo.com/framework/workflows/submit) and you should be on your way for automated submission!

apps/browser/assets/icon.png

77.9 KB
Loading

apps/browser/biome.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"root": false,
3+
"$schema": "https://biomejs.dev/schemas/2.2.6/schema.json",
4+
"extends": "//",
5+
"files": {
6+
"includes": ["**", "!build", "!src/components/ui"]
7+
},
8+
"linter": {
9+
"rules": {
10+
"suspicious": {
11+
"noUnknownAtRules": "off"
12+
}
13+
},
14+
"domains": {
15+
"react": "recommended"
16+
}
17+
}
18+
}

apps/browser/package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "browser",
3+
"displayName": "Browser",
4+
"version": "0.0.1",
5+
"description": "A course registration companion for Albert",
6+
"author": "Tech@NYU <[email protected]>",
7+
"scripts": {
8+
"dev": "doppler run -- plasmo dev",
9+
"build": "plasmo build",
10+
"package": "plasmo package",
11+
"check": "biome check",
12+
"check:types": "tsc -noEmit"
13+
},
14+
"dependencies": {
15+
"@clerk/chrome-extension": "^2.7.7",
16+
"convex": "^1.28.0",
17+
"plasmo": "0.90.5",
18+
"react": "19.2.0",
19+
"react-dom": "19.2.0",
20+
"tailwindcss": "4.1.14"
21+
},
22+
"devDependencies": {
23+
"@types/chrome": "0.1.24",
24+
"@types/node": "24.8.1",
25+
"@types/react": "19.2.2",
26+
"@types/react-dom": "19.2.2",
27+
"postcss": "8.5.6",
28+
"typescript": "5.9.3"
29+
},
30+
"manifest": {
31+
"key": "$CRX_PUBLIC_KEY",
32+
"permissions": [
33+
"cookies",
34+
"storage"
35+
],
36+
"host_permissions": [
37+
"$PLASMO_PUBLIC_CLERK_SYNC_HOST/*",
38+
"$CLERK_FRONTEND_API/*"
39+
]
40+
}
41+
}

apps/browser/postcss.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @type {import('postcss').ProcessOptions}
3+
*/
4+
module.exports = {
5+
plugins: {
6+
tailwindcss: {},
7+
},
8+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { ClerkProvider, useAuth } from "@clerk/chrome-extension";
2+
import { ConvexReactClient } from "convex/react";
3+
import { ConvexProviderWithClerk } from "convex/react-clerk";
4+
5+
const PUBLISHABLE_KEY = process.env
6+
.PLASMO_PUBLIC_CLERK_PUBLISHABLE_KEY as string;
7+
const SYNC_HOST = process.env.PLASMO_PUBLIC_CLERK_SYNC_HOST as string;
8+
9+
const convex = new ConvexReactClient(
10+
process.env.PLASMO_PUBLIC_CONVEX_URL as string,
11+
);
12+
13+
const ConvexWithClerkProvider = ({ children }) => {
14+
return (
15+
<ClerkProvider
16+
publishableKey={PUBLISHABLE_KEY}
17+
syncHost={SYNC_HOST}
18+
afterSignOutUrl={chrome.runtime.getURL("popup.html")}
19+
>
20+
<ConvexProviderWithClerk client={convex} useAuth={useAuth}>
21+
{children}
22+
</ConvexProviderWithClerk>
23+
</ClerkProvider>
24+
);
25+
};
26+
27+
export default ConvexWithClerkProvider;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const SignIn = () => {
2+
const handleSignIn = () => {
3+
chrome.tabs.create({
4+
url: `${process.env.PLASMO_PUBLIC_CLERK_SYNC_HOST}/signin`,
5+
});
6+
};
7+
return (
8+
<button type="button" onClick={handleSignIn}>
9+
Sign in
10+
</button>
11+
);
12+
};
13+
14+
export default SignIn;

0 commit comments

Comments
 (0)