|
4 | 4 |
|
5 | 5 | To handle the difference in scope injection we expose multiple utilities which behave differently per browser in `src/utils.js` and `ContentFeature` base class. For Firefox the code exposed handles [xrays correctly](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts) without needing the features to be authored differently.
|
6 | 6 |
|
| 7 | +## Development Setup |
| 8 | + |
| 9 | +### Repository Access |
| 10 | + |
| 11 | +1. **Clone the repository**: `https://github.com/duckduckgo/content-scope-scripts` |
| 12 | +2. **Request write-access** (for contributors): Submit a request via [Internal Support README](https://app.asana.com/1/137249556945/project/908478224964033/task/1209367367171662?focus=true) asking for `https://github.com/orgs/duckduckgo/teams/core` group access |
| 13 | + |
| 14 | +### Local Development Setup |
| 15 | + |
| 16 | +**Important**: Before cloning the repo on Windows, to avoid major headaches, make sure you clone it with unix-style line endings: |
| 17 | + |
| 18 | +```shell |
| 19 | +git clone --config core.autocrlf=false https://github.com/duckduckgo/content-scope-scripts |
| 20 | +``` |
| 21 | + |
| 22 | +The Content Scope Scripts repo includes the build artifacts, which need to be generated as part of your commit. |
| 23 | + |
| 24 | +### Initial Setup |
| 25 | + |
| 26 | +Inside the repo, run: |
| 27 | + |
| 28 | +```shell |
| 29 | +npm ci # Preferred over 'npm install' for accurate lockfile updates |
| 30 | +``` |
| 31 | + |
| 32 | +Ensure you have a version of node that matches what's in the `.nvmrc` file. |
| 33 | + |
| 34 | +Now, to ensure everything's setup, try a full build: |
| 35 | + |
| 36 | +```shell |
| 37 | +npm run build |
| 38 | +``` |
| 39 | + |
| 40 | +This will place built files into the top-level `build` folder. If this command ran successfully, you can continue with development. |
| 41 | + |
| 42 | +### Windows Development |
| 43 | + |
| 44 | +The tools should work on Windows, but if you have problems you _may_ wish to try using WSL. |
| 45 | + |
| 46 | +**Optional:**: Use Windows Subsystem for Linux - [WSL Installation Guide](https://learn.microsoft.com/en-us/windows/wsl/install) |
| 47 | + |
| 48 | +Once you have WSL running, make sure you have node and make installed: |
| 49 | + |
| 50 | +```shell |
| 51 | +sudo apt update |
| 52 | +sudo apt install make |
| 53 | +``` |
| 54 | + |
| 55 | +For Node.js installation: [How to Install Node.js on Ubuntu/Debian](https://computingforgeeks.com/how-to-install-node-js-on-ubuntu-debian/) |
| 56 | + |
| 57 | +Once node is installed, navigate to the repo path (e.g., `/mnt/c/dev/git/content-scope-scripts`) and: |
| 58 | + |
| 59 | +```shell |
| 60 | +npm install # Install packages |
| 61 | +npm run build # Build JS artifacts |
| 62 | +``` |
| 63 | + |
| 64 | +After this, you can commit the generated files from your Windows environment through the usual git tools. |
| 65 | + |
| 66 | +### Docker Alternative |
| 67 | + |
| 68 | +If you don't want to install npm on your machine, you can use Docker instead: |
| 69 | + |
| 70 | +```shell |
| 71 | +docker run -it --rm -v "<repo root>/submodules/content-scope-scripts:/content-scope-scripts" node:latest /bin/bash |
| 72 | + |
| 73 | +root@<id>:/# cd /content-scope-scripts |
| 74 | +root@<id>:/content-scope-scripts# npm install |
| 75 | +root@<id>:/content-scope-scripts# npm run build |
| 76 | +``` |
| 77 | + |
7 | 78 | ## ContentFeature Utilities
|
8 | 79 |
|
9 | 80 | ### `ContentFeature.defineProperty(object, propertyName, descriptor)`
|
|
0 commit comments