# Maintainer: ericek111

pkgname=rotrouter-git
_pkgname=RotRouter
pkgver=r0
pkgrel=1
pkgdesc='Routes N1MM Logger+ antenna rotator commands to the right rotator controller by band'
arch=('any')
url='https://git.lixko.eu/ericek111/RotRouter'
license=('ISC')
depends=('nodejs')
makedepends=('git' 'npm')
provides=('rotrouter')
conflicts=('rotrouter')
backup=('etc/rotrouter/config.json')
source=("$_pkgname::git+ssh://git@git.lixko.eu/ericek111/RotRouter.git")
sha256sums=('SKIP')

pkgver() {
	cd "$_pkgname"
	printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
	cd "$_pkgname"
	npm ci --cache "$srcdir/npm-cache" --no-audit --no-fund
}

build() {
	cd "$_pkgname"
	npm run build
}

check() {
	cd "$_pkgname"
	npm run typecheck
}

package() {
	cd "$_pkgname"
	install -Dm644 dist/rotrouter.cjs "$pkgdir/usr/lib/rotrouter/rotrouter.cjs"
	install -Dm644 public/index.html "$pkgdir/usr/share/rotrouter/public/index.html"
	install -Dm644 config.json "$pkgdir/etc/rotrouter/config.json"
	install -Dm644 packaging/arch/rotrouter.service "$pkgdir/usr/lib/systemd/system/rotrouter.service"
}
