You've already forked hotpocket
BTHLABS-52: Firefox Desktop Extension
This commit is contained in:
1
services/extension/.gitignore
vendored
1
services/extension/.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
node_modules/
|
||||
dist/
|
||||
secrets/*.json
|
||||
secrets/*.pem
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
"watch:safari": "HOTPOCKET_EXTENSION_TARGET=safari npx rollup -c rollup.config.js -w",
|
||||
"build:chrome": "NODE_ENV=production HOTPOCKET_EXTENSION_TARGET=chrome npx rollup -c rollup.config.js",
|
||||
"dev:chrome": "HOTPOCKET_EXTENSION_TARGET=chrome npx rollup -c rollup.config.js",
|
||||
"watch:chrome": "HOTPOCKET_EXTENSION_TARGET=chrome npx rollup -c rollup.config.js -w"
|
||||
"watch:chrome": "HOTPOCKET_EXTENSION_TARGET=chrome npx rollup -c rollup.config.js -w",
|
||||
"build:firefox": "NODE_ENV=production HOTPOCKET_EXTENSION_TARGET=firefox npx rollup -c rollup.config.js",
|
||||
"dev:firefox": "HOTPOCKET_EXTENSION_TARGET=firefox npx rollup -c rollup.config.js",
|
||||
"watch:firefox": "HOTPOCKET_EXTENSION_TARGET=firefox npx rollup -c rollup.config.js -w"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "9.33.0",
|
||||
|
||||
@@ -5,6 +5,7 @@ import {string} from 'rollup-plugin-string';
|
||||
import packageJSON from './package.json' with {type: 'json'};
|
||||
import manifestChrome from './src/manifest/chrome.json' with {type: 'json'};
|
||||
import manifestCommon from './src/manifest/common.json' with {type: 'json'};
|
||||
import manifestFirefox from './src/manifest/firefox.json' with {type: 'json'};
|
||||
import manifestSafari from './src/manifest/safari.json' with {type: 'json'};
|
||||
|
||||
const BANNER = `/*!
|
||||
@@ -68,6 +69,11 @@ const manifestJsonOutputPlugin = () => {
|
||||
...result,
|
||||
...manifestChrome,
|
||||
};
|
||||
} else if (TARGET == 'firefox') {
|
||||
result = {
|
||||
...result,
|
||||
...manifestFirefox,
|
||||
};
|
||||
}
|
||||
|
||||
result.version = packageJSON.version;
|
||||
|
||||
6
services/extension/src/background/firefox.js
Normal file
6
services/extension/src/background/firefox.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import main from './main';
|
||||
|
||||
main({
|
||||
platform: 'Firefox',
|
||||
api: browser,
|
||||
});
|
||||
6
services/extension/src/content/firefox.js
Normal file
6
services/extension/src/content/firefox.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import main from './main';
|
||||
|
||||
main({
|
||||
platform: 'Firefox',
|
||||
api: browser,
|
||||
});
|
||||
27
services/extension/src/manifest/firefox.json
Normal file
27
services/extension/src/manifest/firefox.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"action": {
|
||||
"default_title": "__MSG_extension_name__",
|
||||
"default_icon": {
|
||||
"16": "images/toolbar-icon-16.png",
|
||||
"32": "images/toolbar-icon-32.png"
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
"scripts": [
|
||||
"background-bundle.js"
|
||||
],
|
||||
"type": "module"
|
||||
},
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "@Extension.HotPocket.BTHLabs",
|
||||
"strict_min_version": "142.0",
|
||||
"data_collection_permissions": {
|
||||
"required": [
|
||||
"websiteActivity",
|
||||
"technicalAndInteraction"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from invoke import task
|
||||
import json
|
||||
|
||||
from invoke import Context, task
|
||||
from invoke.exceptions import UnexpectedExit
|
||||
|
||||
from hotpocket_workspace_tools import get_workspace_mode
|
||||
@@ -12,18 +14,18 @@ WORKSPACE_MODE = get_workspace_mode()
|
||||
|
||||
|
||||
@task
|
||||
def clean(ctx):
|
||||
def clean(ctx: Context):
|
||||
ctx.run('rm -rf dist/')
|
||||
|
||||
|
||||
@task
|
||||
def test(ctx):
|
||||
def test(ctx: Context):
|
||||
# ctx.run('pytest -v --disable-warnings')
|
||||
print('NOOP')
|
||||
|
||||
|
||||
@task
|
||||
def flake8(ctx):
|
||||
def flake8(ctx: Context):
|
||||
ctx.run('flake8')
|
||||
|
||||
|
||||
@@ -45,12 +47,12 @@ def isort(ctx, check=False, diff=False):
|
||||
|
||||
|
||||
@task
|
||||
def eslint(ctx):
|
||||
def eslint(ctx: Context):
|
||||
ctx.run('yarn run eslint')
|
||||
|
||||
|
||||
@task
|
||||
def lint(ctx):
|
||||
def lint(ctx: Context):
|
||||
ihazsuccess = True
|
||||
|
||||
try:
|
||||
@@ -73,17 +75,17 @@ def lint(ctx):
|
||||
|
||||
|
||||
@task
|
||||
def typecheck(ctx):
|
||||
def typecheck(ctx: Context):
|
||||
ctx.run('mypy .')
|
||||
|
||||
|
||||
@task
|
||||
def django_shell(ctx):
|
||||
def django_shell(ctx: Context):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@task
|
||||
def ci(ctx):
|
||||
def ci(ctx: Context):
|
||||
ihazsuccess = True
|
||||
|
||||
ci_tasks = [test, lint, typecheck]
|
||||
@@ -98,35 +100,58 @@ def ci(ctx):
|
||||
|
||||
|
||||
@task
|
||||
def setup(ctx):
|
||||
def setup(ctx: Context):
|
||||
print('NOOP')
|
||||
|
||||
|
||||
@task
|
||||
def start_web(ctx):
|
||||
def start_web(ctx: Context):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@task
|
||||
def start_safari(ctx):
|
||||
def start_safari(ctx: Context):
|
||||
ctx.run('yarn watch:safari')
|
||||
|
||||
|
||||
@task(pre=[clean])
|
||||
def start_chrome(ctx):
|
||||
def start_chrome(ctx: Context):
|
||||
ctx.run('yarn watch:chrome')
|
||||
|
||||
|
||||
@task(pre=[clean])
|
||||
def start_firefox(ctx: Context):
|
||||
ctx.run('yarn watch:firefox')
|
||||
|
||||
|
||||
@task
|
||||
def build_safari(ctx):
|
||||
def build_safari(ctx: Context):
|
||||
ctx.run('yarn build:safari')
|
||||
|
||||
|
||||
@task(pre=[clean])
|
||||
def build_chrome(ctx):
|
||||
def build_chrome(ctx: Context):
|
||||
ctx.run('yarn build:chrome')
|
||||
ctx.run(' '.join([
|
||||
r'/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome',
|
||||
'--pack-extension=dist/chrome-production/',
|
||||
'--pack-extension-key=secrets/chrome.pem',
|
||||
]))
|
||||
|
||||
|
||||
@task(pre=[clean])
|
||||
def build_firefox(ctx: Context):
|
||||
ctx.run('yarn build:firefox')
|
||||
|
||||
firefox_secrets = None
|
||||
with open('secrets/firefox.json', 'r', encoding='utf-8') as firefox_secrets_f:
|
||||
firefox_secrets = json.load(firefox_secrets_f)
|
||||
|
||||
with ctx.cd('dist/firefox-production'):
|
||||
ctx.run(' '.join([
|
||||
'web-ext',
|
||||
'sign',
|
||||
'--channel=unlisted',
|
||||
f'--api-key={firefox_secrets["api_key"]}',
|
||||
f'--api-secret={firefox_secrets["api_secret"]}',
|
||||
]))
|
||||
|
||||
Reference in New Issue
Block a user