Rules-based browser launcher for TUI + GNOME. switchyard.aly.codes
tui gnome bowser go
0

Configure Feed

Select the types of activity you want to include in your feed.

switchyard / justfile
6.9 kB 186 lines
1PREFIX := env_var_or_default('PREFIX', '/usr/local') 2DESTDIR := env_var_or_default('DESTDIR', '') 3BINDIR := PREFIX / 'bin' 4DATADIR := PREFIX / 'share' 5APPID := 'io.github.alyraffauf.Switchyard' 6 7# Show available recipes 8default: 9 @just --list 10 11# Install development dependencies 12install-deps: 13 sudo dnf install golang gtk4-devel glib2-devel gobject-introspection-devel libadwaita-devel just 14 15# Install Flatpak dependencies 16install-flatpak-deps: 17 flatpak install flathub org.gnome.Platform//50 org.gnome.Sdk//50 org.freedesktop.Sdk.Extension.golang//25.08 18 19# Build the application 20build: 21 go build -mod=mod -trimpath -ldflags="-s -w" -o switchyard ./cmd/switchyard 22 23# Install to system 24install: build 25 install -Dm755 switchyard {{DESTDIR}}{{BINDIR}}/switchyard 26 install -Dm644 data/{{APPID}}.desktop {{DESTDIR}}{{DATADIR}}/applications/{{APPID}}.desktop 27 install -Dm644 data/{{APPID}}.metainfo.xml {{DESTDIR}}{{DATADIR}}/metainfo/{{APPID}}.metainfo.xml 28 install -Dm644 data/icons/hicolor/scalable/apps/{{APPID}}.svg {{DESTDIR}}{{DATADIR}}/icons/hicolor/scalable/apps/{{APPID}}.svg 29 30# Uninstall from system 31uninstall: 32 rm -f {{DESTDIR}}{{BINDIR}}/switchyard 33 rm -f {{DESTDIR}}{{DATADIR}}/applications/{{APPID}}.desktop 34 rm -f {{DESTDIR}}{{DATADIR}}/metainfo/{{APPID}}.metainfo.xml 35 rm -f {{DESTDIR}}{{DATADIR}}/icons/hicolor/scalable/apps/{{APPID}}.svg 36 37# Clean build artifacts 38clean: 39 rm -f switchyard 40 41# Update the bundled AdGuard tracking-parameter filter list 42update-adguard: 43 curl -fsSL https://raw.githubusercontent.com/AdguardTeam/AdGuardFilters/master/TrackParamFilter/sections/general_url.txt -o internal/routing/embedded/adguard_filter.txt 44 @echo "Updated internal/routing/embedded/adguard_filter.txt" 45 46# Set as default browser 47set-default: 48 xdg-mime default {{APPID}}.desktop x-scheme-handler/http 49 xdg-mime default {{APPID}}.desktop x-scheme-handler/https 50 @echo "Switchyard is now your default browser" 51 52# Update Go dependencies 53update-go-deps: 54 go mod tidy 55 scripts/generate-flatpak-go-modules.py 56 57# Run unit tests 58test: 59 go test ./internal/... 60 61# Run tests with coverage report 62test-coverage: 63 @echo "Running tests with coverage..." 64 go test -coverprofile=coverage.out ./internal/... 65 go tool cover -func=coverage.out 66 @echo "" 67 @echo "To view HTML coverage report, run: go tool cover -html=coverage.out" 68 69# Build and install Flatpak (development version) 70flatpak: 71 [ -f build-repo/config ] || rm -rf build-repo 72 flatpak run org.flatpak.Builder --user --install --force-clean --repo=build-repo build-dir flatpak/{{APPID}}.Devel.yml 73 74# Build Flatpak and export a .flatpak bundle for distribution 75flatpak-bundle: flatpak 76 flatpak build-bundle build-repo switchyard.flatpak {{APPID}}.Devel 77 78# Build the browser extension (TypeScript + React) 79build-extension: 80 cd webextension && npm ci && npm run build 81 82# Package the already-built extension as a Firefox-targeted directory 83package-extension-firefox: 84 #!/usr/bin/env bash 85 set -euo pipefail 86 root="{{justfile_directory()}}" 87 extdir="${root}/webextension" 88 outdir="${root}/firefox-extension" 89 90 rm -rf "${outdir}" 91 mkdir -p "${outdir}" 92 cp -R "${extdir}/build" "${extdir}/icons" "${extdir}/popup.html" "${outdir}/" 93 rm -f "${outdir}/build/manifest.firefox.json" 94 cp "${extdir}/manifest.firefox.json" "${outdir}/manifest.json" 95 echo "Extension packaged: firefox-extension/" 96 97# Package the already-built extension as a Chrome-targeted zip archive 98package-extension-chrome: 99 #!/usr/bin/env bash 100 set -euo pipefail 101 root="{{justfile_directory()}}" 102 extdir="${root}/webextension" 103 outfile="${root}/switchyard-webextension-chrome.zip" 104 staging="$(mktemp -d)" 105 trap 'rm -rf "${staging}"' EXIT 106 107 rm -f "${outfile}" 108 cp -R "${extdir}/build" "${extdir}/icons" "${extdir}/popup.html" "${staging}/" 109 jq 'del(.key)' "${extdir}/manifest.json" > "${staging}/manifest.json" 110 cd "${staging}" && zip -r "${outfile}" . 111 echo "Extension bundled: switchyard-webextension-chrome.zip" 112 113# Build the extension once and package it for both Firefox and Chrome 114bundle-extension: build-extension package-extension-firefox package-extension-chrome 115 116# Cut a new release: bump version, commit, tag, and push master + tag 117release version: 118 #!/usr/bin/env bash 119 set -euo pipefail 120 version="{{version}}" 121 tag="v${version}" 122 metainfo="data/{{APPID}}.metainfo.xml" 123 manifest="webextension/manifest.json" 124 firefox_manifest="webextension/manifest.firefox.json" 125 pkgjson="webextension/package.json" 126 127 if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then 128 echo "error: '$version' is not valid semver (expected X.Y.Z)" >&2 129 exit 1 130 fi 131 132 branch="$(git symbolic-ref --short HEAD)" 133 if [ "$branch" != "master" ]; then 134 echo "error: must be on master (currently on $branch)" >&2 135 exit 1 136 fi 137 138 dirty="$(git status --porcelain -- ':!gtk/app.go' ":!${metainfo}" ":!${manifest}" ":!${firefox_manifest}" ":!${pkgjson}")" 139 if [ -n "$dirty" ]; then 140 echo "error: working tree has changes outside gtk/app.go, ${metainfo}, ${manifest}, ${firefox_manifest}, ${pkgjson}:" >&2 141 echo "$dirty" >&2 142 exit 1 143 fi 144 145 if git rev-parse --verify --quiet "refs/tags/${tag}" >/dev/null; then 146 echo "error: tag ${tag} already exists" >&2 147 exit 1 148 fi 149 150 if ! grep -q "<release version=\"${version}\"" "${metainfo}"; then 151 echo "error: ${metainfo} has no <release version=\"${version}\"> entry" >&2 152 echo " add a release entry with notes before running 'just release'" >&2 153 exit 1 154 fi 155 156 just test 157 158 sed -i -E "s/^(\s*Version\s*=\s*)\"[^\"]+\"/\1\"${version}\"/" gtk/app.go 159 if ! grep -qE "Version\s*=\s*\"${version}\"" gtk/app.go; then 160 echo "error: failed to update Version in gtk/app.go" >&2 161 exit 1 162 fi 163 164 sed -i -E 's/^(\s*"version"\s*:\s*)"[^"]+"/\1"'"${version}"'"/' "${manifest}" 165 if ! grep -qE '"version"\s*:\s*"'"${version}"'"' "${manifest}"; then 166 echo "error: failed to update version in ${manifest}" >&2 167 exit 1 168 fi 169 170 sed -i -E 's/^(\s*"version"\s*:\s*)"[^"]+"/\1"'"${version}"'"/' "${firefox_manifest}" 171 if ! grep -qE '"version"\s*:\s*"'"${version}"'"' "${firefox_manifest}"; then 172 echo "error: failed to update version in ${firefox_manifest}" >&2 173 exit 1 174 fi 175 176 sed -i -E 's/^(\s*"version"\s*:\s*)"[^"]+"/\1"'"${version}"'"/' "${pkgjson}" 177 if ! grep -qE '"version"\s*:\s*"'"${version}"'"' "${pkgjson}"; then 178 echo "error: failed to update version in ${pkgjson}" >&2 179 exit 1 180 fi 181 182 git add gtk/app.go "${metainfo}" "${manifest}" "${firefox_manifest}" "${pkgjson}" 183 git commit -m "update for ${tag}" 184 git tag -a "${tag}" -m "${tag}" 185 git push origin master 186 git push origin "${tag}"