Something went wrong. Try again.
Rules-based browser launcher for TUI + GNOME. switchyard.aly.codes
tui gnome bowser go
Something went wrong. Try again.
switchyard justfile
6.9 kB · 186 lines
Just
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187PREFIX := env_var_or_default('PREFIX', '/usr/local')DESTDIR := env_var_or_default('DESTDIR', '')BINDIR := PREFIX / 'bin'DATADIR := PREFIX / 'share'APPID := 'io.github.alyraffauf.Switchyard'# Show available recipesdefault: @just --list# Install development dependenciesinstall-deps: sudo dnf install golang gtk4-devel glib2-devel gobject-introspection-devel libadwaita-devel just# Install Flatpak dependenciesinstall-flatpak-deps: flatpak install flathub org.gnome.Platform//50 org.gnome.Sdk//50 org.freedesktop.Sdk.Extension.golang//25.08# Build the applicationbuild: go build -mod=mod -trimpath -ldflags="-s -w" -o switchyard ./cmd/switchyard# Install to systeminstall: build install -Dm755 switchyard {{DESTDIR}}{{BINDIR}}/switchyard install -Dm644 data/{{APPID}}.desktop {{DESTDIR}}{{DATADIR}}/applications/{{APPID}}.desktop install -Dm644 data/{{APPID}}.metainfo.xml {{DESTDIR}}{{DATADIR}}/metainfo/{{APPID}}.metainfo.xml install -Dm644 data/icons/hicolor/scalable/apps/{{APPID}}.svg {{DESTDIR}}{{DATADIR}}/icons/hicolor/scalable/apps/{{APPID}}.svg# Uninstall from systemuninstall: rm -f {{DESTDIR}}{{BINDIR}}/switchyard rm -f {{DESTDIR}}{{DATADIR}}/applications/{{APPID}}.desktop rm -f {{DESTDIR}}{{DATADIR}}/metainfo/{{APPID}}.metainfo.xml rm -f {{DESTDIR}}{{DATADIR}}/icons/hicolor/scalable/apps/{{APPID}}.svg# Clean build artifactsclean: rm -f switchyard# Update the bundled AdGuard tracking-parameter filter listupdate-adguard: curl -fsSL https://raw.githubusercontent.com/AdguardTeam/AdGuardFilters/master/TrackParamFilter/sections/general_url.txt -o internal/routing/embedded/adguard_filter.txt @echo "Updated internal/routing/embedded/adguard_filter.txt"# Set as default browserset-default: xdg-mime default {{APPID}}.desktop x-scheme-handler/http xdg-mime default {{APPID}}.desktop x-scheme-handler/https @echo "Switchyard is now your default browser"# Update Go dependenciesupdate-go-deps: go mod tidy scripts/generate-flatpak-go-modules.py# Run unit teststest: go test ./internal/...# Run tests with coverage reporttest-coverage: @echo "Running tests with coverage..." go test -coverprofile=coverage.out ./internal/... go tool cover -func=coverage.out @echo "" @echo "To view HTML coverage report, run: go tool cover -html=coverage.out"# Build and install Flatpak (development version)flatpak: [ -f build-repo/config ] || rm -rf build-repo flatpak run org.flatpak.Builder --user --install --force-clean --repo=build-repo build-dir flatpak/{{APPID}}.Devel.yml# Build Flatpak and export a .flatpak bundle for distributionflatpak-bundle: flatpak flatpak build-bundle build-repo switchyard.flatpak {{APPID}}.Devel# Build the browser extension (TypeScript + React)build-extension: cd webextension && npm ci && npm run build# Package the already-built extension as a Firefox-targeted directorypackage-extension-firefox: #!/usr/bin/env bash set -euo pipefail root="{{justfile_directory()}}" extdir="${root}/webextension" outdir="${root}/firefox-extension" rm -rf "${outdir}" mkdir -p "${outdir}" cp -R "${extdir}/build" "${extdir}/icons" "${extdir}/popup.html" "${outdir}/" rm -f "${outdir}/build/manifest.firefox.json" cp "${extdir}/manifest.firefox.json" "${outdir}/manifest.json" echo "Extension packaged: firefox-extension/"# Package the already-built extension as a Chrome-targeted zip archivepackage-extension-chrome: #!/usr/bin/env bash set -euo pipefail root="{{justfile_directory()}}" extdir="${root}/webextension" outfile="${root}/switchyard-webextension-chrome.zip" staging="$(mktemp -d)" trap 'rm -rf "${staging}"' EXIT rm -f "${outfile}" cp -R "${extdir}/build" "${extdir}/icons" "${extdir}/popup.html" "${staging}/" jq 'del(.key)' "${extdir}/manifest.json" > "${staging}/manifest.json" cd "${staging}" && zip -r "${outfile}" . echo "Extension bundled: switchyard-webextension-chrome.zip"# Build the extension once and package it for both Firefox and Chromebundle-extension: build-extension package-extension-firefox package-extension-chrome# Cut a new release: bump version, commit, tag, and push master + tagrelease version: #!/usr/bin/env bash set -euo pipefail version="{{version}}" tag="v${version}" metainfo="data/{{APPID}}.metainfo.xml" manifest="webextension/manifest.json" firefox_manifest="webextension/manifest.firefox.json" pkgjson="webextension/package.json" if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then echo "error: '$version' is not valid semver (expected X.Y.Z)" >&2 exit 1 fi branch="$(git symbolic-ref --short HEAD)" if [ "$branch" != "master" ]; then echo "error: must be on master (currently on $branch)" >&2 exit 1 fi dirty="$(git status --porcelain -- ':!gtk/app.go' ":!${metainfo}" ":!${manifest}" ":!${firefox_manifest}" ":!${pkgjson}")" if [ -n "$dirty" ]; then echo "error: working tree has changes outside gtk/app.go, ${metainfo}, ${manifest}, ${firefox_manifest}, ${pkgjson}:" >&2 echo "$dirty" >&2 exit 1 fi if git rev-parse --verify --quiet "refs/tags/${tag}" >/dev/null; then echo "error: tag ${tag} already exists" >&2 exit 1 fi if ! grep -q "<release version=\"${version}\"" "${metainfo}"; then echo "error: ${metainfo} has no <release version=\"${version}\"> entry" >&2 echo " add a release entry with notes before running 'just release'" >&2 exit 1 fi just test sed -i -E "s/^(\s*Version\s*=\s*)\"[^\"]+\"/\1\"${version}\"/" gtk/app.go if ! grep -qE "Version\s*=\s*\"${version}\"" gtk/app.go; then echo "error: failed to update Version in gtk/app.go" >&2 exit 1 fi sed -i -E 's/^(\s*"version"\s*:\s*)"[^"]+"/\1"'"${version}"'"/' "${manifest}" if ! grep -qE '"version"\s*:\s*"'"${version}"'"' "${manifest}"; then echo "error: failed to update version in ${manifest}" >&2 exit 1 fi sed -i -E 's/^(\s*"version"\s*:\s*)"[^"]+"/\1"'"${version}"'"/' "${firefox_manifest}" if ! grep -qE '"version"\s*:\s*"'"${version}"'"' "${firefox_manifest}"; then echo "error: failed to update version in ${firefox_manifest}" >&2 exit 1 fi sed -i -E 's/^(\s*"version"\s*:\s*)"[^"]+"/\1"'"${version}"'"/' "${pkgjson}" if ! grep -qE '"version"\s*:\s*"'"${version}"'"' "${pkgjson}"; then echo "error: failed to update version in ${pkgjson}" >&2 exit 1 fi git add gtk/app.go "${metainfo}" "${manifest}" "${firefox_manifest}" "${pkgjson}" git commit -m "update for ${tag}" git tag -a "${tag}" -m "${tag}" git push origin master git push origin "${tag}"