From 29be73df8c2eb1cd5608f9cecb1b864bea109242 Mon Sep 17 00:00:00 2001 From: Oli Date: Sat, 10 Feb 2024 17:10:06 +0100 Subject: [PATCH] Update CONTRIBUTING.md --- CONTRIBUTING.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56cd741..9bff606 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,12 +4,15 @@ - commit any feature containing pull requests against the develop-branch - commit any hot-fixes against main-branch +## Getting started with browser extensions + +If you never worked with browser extensions before, you should read this very [nice tutorial](https://developer.chrome.com/docs/extensions/mv2/getstarted/). We are working with manifest v3 already. Alternatively you can use the instructions from [mozilla](https://developer.mozilla.org/de/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension). Make sure you understand the difference between content- and background-scripts, their scopes and how they can exchange information with messaging. ## Working with this repo -Everything related to the browser extension can be found in `/src`: `manifest.json`, background-script (`background.js`) and so on. Content scripts are in `/src/contentScripts`. In `/src/freshContent` you can find newly created content that is used in TUfast, e.g. the popup or settings-page. +Everything related to the browser extension can be found in `/src`: `manifest.json`, background-script (`background.js`) and so on. Content scripts are in `/src/contentScripts`. In `/src/freshContent` you can find newly created content that is used in TUfast, e.g. the popup or settings-page. `/docs` does _not_ contain documentation for the code, but further instructions for users of TUfast. -Steps to contribute: +Steps to contribute (that's standard [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)): 1. Create a local clone of this repo `git clone ` 2. Checkout develop branch `git checkout develop` @@ -19,7 +22,7 @@ Steps to contribute: 6. Run `npm run dev` while developing. This is will compile sass and ts files and watch for changes in your working tree. 7. Load the ./build directory as an unpacked extension in your browser 8. Run tests locally before committing code `npm run test` -9. Create a pull request +9. Create a pull request against `develop` 10. Await our review **Note:** as a member of TUfast you can work in this repo directly, e.g. you can create branches and push to them, making the contribution process easier. @@ -29,10 +32,6 @@ Steps to contribute: - CSS-Preprocessor: We are using [SASS](https://sass-lang.com/). - ESlint: We are following standard styling with minor additions. Run `npm run lint` or `npm run test` to check your code style before committing code. -## Getting started with browser extensions - -If you never worked with browser extensions before, you should read this very [nice tutorial](https://developer.chrome.com/docs/extensions/mv2/getstarted/). Currently we are still using manifest v2, but we plan to switch to v3 in proximate future. Alternatively you can use the instructions from [mozilla](https://developer.mozilla.org/de/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension). Make sure you understand the difference between content- and background-scripts, their scopes and how they can exchange information with messaging. - ### Known peculiarities with browser extensions **Error:** `Unchecked runtime.lastError: The message port closed before a response was received.` Promisifying chrome.runtime.sendMessage({...}) doesnt work, because when you define a callback (Promise.resolve) sendMessage will wait until sendResponse is called in the message handler. It just stalls execution and then dies if it's never called. **Solutions:** 1) Unpromisify sendMessage. 2) Always return a value (return true is fine).