Files
logsdu/Makefile

103 lines
4.6 KiB
Makefile
Raw Permalink Normal View History

# **************************************************************************
# * (C)opyright 2026 by Ruben Carlo Benante *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU General Public License as published by *
# * the Free Software Foundation, either version 3 of the License, or *
# * (at your option) any later version. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU General Public License for more details. *
# * *
# * You should have received a copy of the GNU General Public License *
# * along with this program. If not, see http://www.gnu.org/licenses/. *
# * *
# * Contact author at: *
# * Ruben Carlo Benante *
# * rcb@beco.cc *
# **************************************************************************
# Makefile for logsdu - build the unpacked extension into build/.
#
# Usage:
# make # typecheck and bundle into build/
2026-08-10 14:32:58 -03:00
# make test # run the unit tests
# make xpi # build, then package build/ as logsdu-<version>.xpi
# make clean # remove build/ and the package
#
# Dependencies are installed with pnpm, never npm:
# corepack pnpm install
#
# Permanent install (Firefox ESR, Developer Edition or Nightly):
# set xpinstall.signatures.required=false in about:config, then
# about:addons -> gear -> Install Add-on From File -> pick the .xpi
#
# Release Firefox refuses unsigned add-ons whatever that pref says. There the
# same .xpi has to go through addons.mozilla.org as an unlisted add-on first,
# which signs it automatically without publishing or reviewing it.
#
# Throwaway install for development: about:debugging -> This Firefox ->
# Load Temporary Add-on -> pick build/manifest.json (dropped on restart).
EXT_ID := logsdu
VERSION := $(shell node -p "require('./package.json').version")
XPI := $(EXT_ID)-$(VERSION).xpi
2026-08-10 15:23:17 -03:00
.PHONY: all build chrome test xpi clean check-deps
all: build
2026-08-10 14:32:58 -03:00
# Unit tests for the pure logic: the input formatters and the decision that
# says whether a page load may press "Entrar". Run straight through Node's
# built-in runner and type stripping, so there is no test framework to install.
test:
node --test "src/**/*.test.ts"
# Call the local toolchain directly, so this works regardless of how pnpm is
# provided (corepack vs standalone). Run "corepack pnpm install" first.
build: check-deps
node_modules/.bin/tsc -noEmit -skipLibCheck
node esbuild.config.mjs production
2026-08-10 15:23:17 -03:00
# The same sources with Chrome's background key. Untested against Chrome; it
# exists so the port is a build flag rather than a fork.
chrome: check-deps
node_modules/.bin/tsc -noEmit -skipLibCheck
TARGET=chrome node esbuild.config.mjs production
@echo "Chrome build in build/ -- load it via chrome://extensions (Developer mode)."
# An .xpi is just a zip of the extension directory, with the manifest at the
# top level rather than inside a wrapper folder. The same file installs
# directly on ESR and uploads to AMO for signing.
xpi: build
rm -f $(XPI)
cd build && zip -qr ../$(XPI) .
2026-08-10 14:58:43 -03:00
@echo
@echo "Built: $(CURDIR)/$(XPI)"
@echo
2026-08-10 15:23:17 -03:00
@echo "This file is UNSIGNED. Two ways to use it:"
@echo
@echo " Publish -- upload it at addons.mozilla.org/developers/addon/submit/"
@echo " Mozilla signs it; the signed file installs on any Firefox."
2026-08-10 14:58:43 -03:00
@echo
2026-08-10 15:23:17 -03:00
@echo " Install locally -- only on ESR, Developer Edition or Nightly:"
@echo " 1. about:config -> xpinstall.signatures.required = false"
@echo " 2. about:addons -> gear icon -> Install Add-on From File"
@echo " 3. paste this path into the file picker:"
@echo " $(CURDIR)/$(XPI)"
2026-08-10 14:58:43 -03:00
@echo
clean:
rm -rf build
rm -f $(EXT_ID)-*.xpi $(EXT_ID)-*.zip
# Fail with a useful message rather than a confusing "tsc: not found".
check-deps:
@test -x node_modules/.bin/tsc || { \
echo "ERROR: dependencies are not installed."; \
echo "Run: corepack pnpm install (do NOT use npm install in this tree)"; \
exit 1; \
}