Skip to content

Commit

Permalink
feat: add Firefox support with web-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Nov 16, 2023
1 parent 32e4165 commit 9df526d
Show file tree
Hide file tree
Showing 8 changed files with 2,027 additions and 35 deletions.
32 changes: 24 additions & 8 deletions .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,50 @@ pnpm install
> This repository includes a list of suggested VS Code extensions.
> It's a good idea to use [VS Code](https://code.visualstudio.com) and accept its suggestion to install them, as they'll help with development.
## Building
## Building for Development

Run [ESBuild](https://esbuild.github.io) locally to build source files:

```shell
pnpm build
pnpm dev
```

Add `--watch` to run the builder in a watch mode that continuously re-builds as you save files:

```shell
pnpm build --watch
pnpm dev --watch
```

### Using Local Builds
### Local Development with Chrome

Follow Google Chrome's _[Load an unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/#unpacked)_ guide to load this repository's directory as an extension locally.

> ♻️ Remember to reload the extension in `chrome://extensions` whenever you make changes locally!
## Publishing
### Local Development with Firefox

Follow Firefox's _[Temporary installation in Firefox](https://extensionworkshop.com/documentation/develop/temporary-installation-in-firefox/)_ guide to load this repository's directory as an extension locally.

You'll then need to authorize the extension to run on <https://github.com>:

1. Find and select the _Extensions_ icon in the top right of Firefox
2. Select the _"Manage Extension"_ gear icon next to _Refined Saved Replies_
3. Select the _"Always Allow on github.com"_ option

The `zip` command will create a `./refined-saved-replies.zip` file containing relevant `manifest.json`, `assets/`, and `lib/` contents.
> ♻️ Remember to reload the extension in `about:debugging#/runtime/this-firefox` whenever you make changes locally!
## Building for Production

Run [`web-ext`](https://extensionworkshop.com) to build a production-ready `.zip` under `./web-ext-artifacts/`:

```shell
pnpm zip
pnpm build
```

Upload that file to the [Chrome Web Store Developer Dashboard](https://chrome.google.com/webstore/devconsole).
Then upload that `./web-ext-artifacts/refined_saved_replies-*.zip` file to:

- [Chrome Web Store Developer Dashboard](https://chrome.google.com/webstore/devconsole)
- [Firefox Add-ons Developer Hub](https://addons.mozilla.org/en-US/developers/addon/submit/distribution)

## Formatting

Expand All @@ -63,6 +78,7 @@ Each should be shown in VS Code, and can be run manually on the command-line:
- `pnpm lint:package-json` ([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the `package.json` file
- `pnpm lint:packages` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the `pnpm-lock.yml` file
- `pnpm lint:spelling` ([cspell](https://cspell.org)): Spell checks across all source files
- `pnpm lint:web-ext` ([web-ext](https://extensionworkshop.com)): Lints browser extension metadata

Read the individual documentation for each linter to understand how it can be configured and used best.

Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/lint-web-ext.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
jobs:
lint_web_ext:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm lint:web-ext

name: Lint Web Ext

on:
pull_request: ~
push:
branches:
- main
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
coverage/
lib/
node_modules/
web-ext-artifacts
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ This extension modifies the Saved Replies for issues or pull requests on any rep

[![Available in the Chrome Web Store](assets/chrome.png)](https://chrome.google.com/webstore/detail/refined-saved-replies/ngcinicnlicdndmpcfjjifononfcceih/)

> Coming soon: Firefox! 🔥🦊
## Development

See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
Expand Down
5 changes: 5 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"browser_specific_settings": {
"gecko": {
"id": "refined-saved-replies@joshuakgoldberg.com"
}
},
"content_scripts": [
{
"js": ["lib/content-script.js"],
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "refined-saved-replies",
"version": "0.5.0",
"description": "Chrome extension for GitHub's Saved Replies that adds replies from a repository's .github/replies.yml. 📨",
"description": "Browser extension for GitHub's Saved Replies that adds replies from a repository's .github/replies.yml. 📨",
"homepage": "https://github.com/JoshuaKGoldberg/refined-saved-replies#readme",
"bugs": {
"url": "https://github.com/JoshuaKGoldberg/refined-saved-replies/issues"
Expand All @@ -24,19 +24,20 @@
"README.md"
],
"scripts": {
"build": "esbuild src/content-script.ts --bundle --minify --outfile=lib/content-script.js --sourcemap",
"build": "web-ext build --overwrite-dest",
"dev": "esbuild src/content-script.ts --bundle --minify --outfile=lib/content-script.js --sourcemap",
"format": "prettier \"**/*\" --ignore-unknown",
"lint": "eslint . .*js --max-warnings 0 --report-unused-disable-directives",
"lint:knip": "knip",
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
"lint:package-json": "npmPkgJsonLint .",
"lint:packages": "pnpm dedupe --check",
"lint:spelling": "cspell \"**\" \".github/**/*\"",
"lint:web-ext": "web-ext lint",
"prepare": "husky install",
"should-semantic-release": "should-semantic-release --verbose",
"test": "vitest",
"tsc": "tsc",
"zip": "node script/zip.js"
"tsc": "tsc"
},
"lint-staged": {
"*": "prettier --ignore-unknown --write"
Expand Down Expand Up @@ -83,6 +84,7 @@
"should-semantic-release": "^0.2.1",
"typescript": "^5.2.2",
"vitest": "^0.34.6",
"web-ext": "^7.8.0",
"yaml-eslint-parser": "^1.2.2",
"zip-lib": "^0.7.3"
},
Expand Down
Loading

0 comments on commit 9df526d

Please sign in to comment.