Skip to content

Commit

Permalink
feat: reformat, makefile, precommit hook, misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Mar 14, 2024
1 parent b6ddbeb commit 13369d4
Show file tree
Hide file tree
Showing 25 changed files with 14,846 additions and 13,541 deletions.
11 changes: 10 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# Unix-style newlines with a newline ending every file
[*]
indent_style = space
indent_size = 2
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
charset = utf-8

# 2 spaces for JS, HTML and CSS/SASS
[*.{ts,js,html,css,scss,sass,less}]
indent_size = 2

# 4 spaces for markdown
[*.md]
indent_size = 4
trim_trailing_whitespace = false

# Hard TAB for Makefile
[Makefile]
indent_style = tab
56 changes: 28 additions & 28 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
name: Build

on:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'

- run: npm ci
- run: npm ci

- name: Build Firefox
run: npm run build:firefox
- name: Upload artifact
uses: actions/upload-artifact@v2-preview
with:
name: firefox
path: dist.zip
- name: Build Firefox
run: npm run build:firefox
- name: Upload artifact
uses: actions/upload-artifact@v2-preview
with:
name: firefox
path: dist.zip

- name: Build Chrome
run: npm run build:chrome
- name: Upload artifact
uses: actions/upload-artifact@v2-preview
with:
name: chrome
path: dist.zip
- name: Build Chrome
run: npm run build:chrome
- name: Upload artifact
uses: actions/upload-artifact@v2-preview
with:
name: chrome
path: dist.zip
62 changes: 31 additions & 31 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
schedule:
- cron: "25 4 * * 3"
push:
branches: ['master']
pull_request:
branches: ['master']
schedule:
- cron: '25 4 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout
uses: actions/checkout@v3
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript, typescript
queries: +security-and-quality
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript, typescript
queries: +security-and-quality

- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "npm"
- run: npm ci
- run: npm run build:chrome
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- run: npm ci
- run: npm run build:chrome

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
node_modules
dist
build

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx prettier --write .
5 changes: 2 additions & 3 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"semi": false,
"printWidth": 110,
"singleQuote": true
"singleQuote": true,
"semi": false
}
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.PHONY: build install clean

install:
npm ci

compile:
npx tsc --noEmit

clean:
rm -rf node_modules build

#---------
## Building

dev:
NODE_ENV=development npx vite build --mode development --watch

# This is what Google wants us to upload when we release a new version to the Addon "store"
build-chrome: install
make update-chrome
make zip-build

update-chrome:
VITE_TARGET_BROWSER=chrome npx vite build

# This is what Mozilla wants us to upload when we release a new version to the Addon "store"
build-firefox: install
make update-firefox
make zip-build

update-firefox:
VITE_TARGET_BROWSER=firefox npx vite build

#---------
## Zipping

# To build a zip archive for uploading to the Chrome Web Store or Mozilla Addons
zip-build:
cd build && zip ../build.zip -r *

# To build a source archive, wanted by Mozilla reviewers. Include media subdir.
zip-src:
rm -rfv build
mkdir -p build
# archive the main repo
git archive --prefix=aw-watcher-web/ -o build/aw-watcher-web.zip HEAD
# archive the media subrepo
(cd media/ && git archive --prefix=aw-watcher-web/media/ -o ../build/media.zip HEAD)
# extract the archives into a single directory
(cd build && unzip -q aw-watcher-web.zip)
(cd build && unzip -q media.zip)
# zip the whole thing
(cd build && zip -r aw-watcher-web.zip aw-watcher-web)
# clean up
(cd build && rm -r media.zip aw-watcher-web)
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@

A cross-browser WebExtension that serves as a web browser watcher for [ActivityWatch][activitywatch].


## Usage

Install for your browser:

- [Chrome][chrome]
- ~~Firefox~~
- Due to Mozilla incompetency, the addon is no longer listed in the Mozilla Addons store (see [discussion #818][818]).
- ~~You can install the latest Mozilla-signed version [here][last-xpi].~~ (we are apparently not allowed to self-distribute this, see discussion linked above)
- You can also build from source, see [this comment][build-source-cmt] and instructions below.
- [Chrome][chrome]
- [Firefox][firefox]

[activitywatch]: https://github.com/ActivityWatch/activitywatch
[firefox]: https://addons.mozilla.org/en-US/firefox/addon/aw-watcher-web/
Expand All @@ -26,17 +22,18 @@ Install for your browser:
### Firefox Enterprise Policy

Due to the issue mentioned above, a privacy notice has to be displayed to follow the Mozilla add-on policy. This can be pre-accepted by setting the following Firefox Enterprise Policy:

```json
{
"policies": {
"3rdparty": {
"Extensions": {
"{ef87d84c-2127-493f-b952-5b4e744245bc}": {
"consentOfflineDataCollection": true
"policies": {
"3rdparty": {
"Extensions": {
"{ef87d84c-2127-493f-b952-5b4e744245bc}": {
"consentOfflineDataCollection": true
}
}
}
}
}
}
}
```

Expand Down
Binary file added dist/aw-watcher-web.zip
Binary file not shown.
Loading

0 comments on commit 13369d4

Please sign in to comment.