BTHLABS-66: Prepping for public release: Take two

This commit is contained in:
2025-11-19 20:28:31 +01:00
parent 38785ccf92
commit 22061486a8
6 changed files with 96 additions and 24 deletions

View File

@@ -1,3 +1,36 @@
# HotPocket by BTHLabs
This repository contains the _HotPocket Extension_ project.
## Development environment setup
### Requirements
* macOS (18 or newer) or modern Linux (including WSL2).
* nodejs v22.14 or later.
* yarnpkg v1.22.22 or newer.
### Setup
1. `yarn install`
## Building browser-specific extensions
To build a browser-specific extension, use the following command:
```
$ yarn build:<target>
```
Where `<target>` is the name of the browser. The currently supported targets
are: `safari`, `firefox`, `chrome`. The build result will be placed in
`dist/<target>-production` for Firefox and Chrome extensions. Safari
extension will be built in the `apple` service tree.
## Author
_HotPocket_ is developed by [BTHLabs](https://www.bthlabs.pl/).
## License
_HotPocket_ is licensed under the Apache 2.0 License.

View File

@@ -19,15 +19,22 @@ class Popup {
this.timeout = null;
}
};
replaceInnerHTML = (element, content) => {
for (let child of element.childNodes) {
element.removeChild(child);
}
element.insertAdjacentHTML('beforeend', content);
};
setContent = (content) => {
const shadow = this.container.shadowRoot;
const body = shadow.querySelector('.hotpocket-extension-popup-body');
body.innerHTML = content;
this.replaceInnerHTML(body, content);
const i18nElements = shadow.querySelectorAll('[data-message]');
for (let i18nElement of i18nElements) {
i18nElement.innerHTML = HotPocketExtension.api.i18n.getMessage(
i18nElement.textContent = HotPocketExtension.api.i18n.getMessage(
i18nElement.dataset.message,
);
}
@@ -48,7 +55,7 @@ class Popup {
this.container.hotPocketExtensionPopup = this;
const shadow = this.container.attachShadow({mode: 'open'});
shadow.innerHTML = POPUP;
shadow.setHTMLUnsafe(POPUP);
this.setContent(content);

View File

@@ -14,7 +14,7 @@
},
"browser_specific_settings": {
"gecko": {
"id": "@Extension.HotPocket.BTHLabs",
"id": "@Production.Extension.HotPocket.BTHLabs",
"strict_min_version": "142.0",
"data_collection_permissions": {
"required": [
@@ -24,4 +24,4 @@
}
}
}
}
}

View File

@@ -14,7 +14,7 @@ import werkzeug
import werkzeug.routing
from hotpocket_workspace_tools import get_workspace_mode
from hotpocket_workspace_tools.tasks import * # noqa: F401,F403
from hotpocket_workspace_tools.tasks import bump_version, get_version # noqa: F401
WORKSPACE_MODE = get_workspace_mode()
@@ -198,26 +198,54 @@ def build_safari(ctx: Context):
@task(pre=[clean])
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',
]))
with ctx.cd('dist/chrome-production'):
current_version = get_version(ctx)
ctx.run(' '.join([
'zip',
'-r',
f'../chrome-production-{current_version}.zip',
'.',
]))
@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"]}',
'lint',
]))
current_version = get_version(ctx)
ctx.run(' '.join([
'zip',
'-r',
f'../firefox-production-{current_version}.zip',
'.',
]))
@task
def build_firefox_source(ctx: Context):
# AMO requires source bundle to be uploaded alongside the built version.
ctx.run('rm -rf dist/firefox-source')
ctx.run('mkdir -p dist/firefox-source dist/firefox-source/assets dist/firefox-source/src')
ctx.run('rsync -arv assets/ dist/firefox-source/assets/')
ctx.run('rsync -arv src/ dist/firefox-source/src/')
ctx.run('rsync -arv eslint.config.js package.json README.md rollup.config.js yarn.lock dist/firefox-source/')
with ctx.cd('dist/firefox-source'):
current_version = get_version(ctx)
ctx.run(' '.join([
'zip',
'-r',
f'../firefox-source-{current_version}.zip',
'.',
]))

View File

@@ -1 +1 @@
from .utils import bump_version # noqa: F401
from .utils import bump_version, get_version # noqa: F401

View File

@@ -4,12 +4,16 @@ from __future__ import annotations
from invoke import Context, task
def get_version(ctx: Context) -> str:
result = ctx.run('poetry version -s --no-ansi', hide='out')
assert result is not None, 'Hm?'
return result.stdout.strip()
@task
def bump_version(ctx: Context, next_version: str, build: str | None = None):
current_version_result = ctx.run('poetry version -s --no-ansi', hide='out')
assert current_version_result is not None, 'Hm?'
current_version = current_version_result.stdout.strip()
current_version = get_version(ctx)
print(f'Bumping version: `{current_version}` -> `{next_version}`')