From d6acced192282830daea12acee497a0e769ff042 Mon Sep 17 00:00:00 2001 From: Jared Dantis Date: Fri, 21 Apr 2023 18:02:41 +0800 Subject: [PATCH 1/4] .github: Run on Node 16 --- .github/workflows/build-extension.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-extension.yml b/.github/workflows/build-extension.yml index daed2a9..df38de2 100644 --- a/.github/workflows/build-extension.yml +++ b/.github/workflows/build-extension.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Install dependencies run: npm ci - name: Build extension (Manifest V2) From 3ef21602c4f67a3209f99b1816cf4f3810d9331a Mon Sep 17 00:00:00 2001 From: Jared Dantis Date: Fri, 21 Apr 2023 18:08:59 +0800 Subject: [PATCH 2/4] Define API URL in env files --- .env.development | 1 + .env.production | 1 + background/background.js | 15 +++------------ public/manifest.json | 3 +-- public/manifest.v3.json | 3 +-- 5 files changed, 7 insertions(+), 16 deletions(-) create mode 100644 .env.development create mode 100644 .env.production diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..8ed0e6b --- /dev/null +++ b/.env.development @@ -0,0 +1 @@ +VITE_API_URL=http://localhost:5000 diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..cf2d573 --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +VITE_API_URL=https://ariadne.dantis.me diff --git a/background/background.js b/background/background.js index 2b2dd4d..9ef75b2 100644 --- a/background/background.js +++ b/background/background.js @@ -4,24 +4,15 @@ class AriadneBackground { constructor() { this._tabStates = []; this._reportStats = {}; - this._API_URL = 'https://ariadne.dantis.me/api/v1'; - - // Determine if running in unpacked mode - const that = this; - browser.management.get(browser.runtime.id) - .then((extensionInfo) => { - if (extensionInfo.installType === 'development') { - console.log('[bg] Running in development mode'); - that._API_URL = 'http://localhost:5000/api/v1'; - } - that.addListeners(); - }); + this._API_URL = import.meta.env.VITE_API_URL + '/api/v1'; // Alias if browser.action is defined, i.e. in Manifest V3 this.BrowserAction = browser.browserAction; if (browser.action !== undefined) { this.BrowserAction = browser.action; } + + this.addListeners(); } addListeners() { diff --git a/public/manifest.json b/public/manifest.json index ea9c7cf..2a4a322 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -7,8 +7,7 @@ "manifest_version": 2, "default_locale": "en", "permissions": [ - "tabs", - "management" + "tabs" ], "optional_permissions": [ "" diff --git a/public/manifest.v3.json b/public/manifest.v3.json index 356a412..dd8cc4f 100644 --- a/public/manifest.v3.json +++ b/public/manifest.v3.json @@ -9,8 +9,7 @@ "default_locale": "en", "minimum_chrome_version": "88", "permissions": [ - "tabs", - "management" + "tabs" ], "icons": { "128": "assets/img/Button@8x.png" From 7bb7423f21e95921641d627b133c99218f8e3658 Mon Sep 17 00:00:00 2001 From: Jared Dantis Date: Fri, 21 Apr 2023 18:14:04 +0800 Subject: [PATCH 3/4] package.json: Add dev build targets --- package.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index c6efc53..373a480 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,17 @@ "url": "https://github.com/wsg-ariadne/ariadne" }, "scripts": { - "dev": "vite", + "dev:bg": "vite build -m development --config vite.bg.config.js", + "dev:content": "vite build -m development --config vite.content.config.js", + "dev:main": "vite build -m development", + "dev": "for TARGET in main bg content; do npm run dev:$TARGET; done", + "dev:v3": "npm run dev && mv dist/manifest.v3.json dist/manifest.json", "build:bg": "vite build --config vite.bg.config.js", "build:content": "vite build --config vite.content.config.js", "build:main": "vite build", "build": "for TARGET in main bg content; do NODE_ENV=production npm run build:$TARGET; done", - "build:v3": "npm run build && mv dist/manifest.v3.json dist/manifest.json", - "package": "npm run build && web-ext build --overwrite-dest --source-dir dist --ignore-files \"**/manifest.v3.json\"", - "package:v3": "npm run build:v3 && web-ext build --overwrite-dest --source-dir dist" + "package": "npm run build && mv dist/manifest.v3.json dist/manifest.json && web-ext build --overwrite-dest --source-dir dist --ignore-files \"**/manifest.v3.json\"", + "package:v3": "npm run build && web-ext build --overwrite-dest --source-dir dist" }, "dependencies": { "@heroicons/vue": "^2.0.16", From a8cedab6fe053ae618152aa863f11a395534a8ed Mon Sep 17 00:00:00 2001 From: Jared Dantis Date: Fri, 21 Apr 2023 18:19:10 +0800 Subject: [PATCH 4/4] .github: Upload artifacts even without tags --- .github/workflows/build-extension.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-extension.yml b/.github/workflows/build-extension.yml index df38de2..c5d2650 100644 --- a/.github/workflows/build-extension.yml +++ b/.github/workflows/build-extension.yml @@ -29,5 +29,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: file: "web-ext-artifacts/*.zip" - tags: true if: github.event_name != 'pull_request'