# Maintainer: Alynx Zhou pkgname=hikarujs pkgver=1.13.3 pkgrel=1 pkgdesc='A static site generator that generates routes based on directories naturally.' arch=('any') url='https://hikaru.alynx.one/' license=('Apache') depends=('nodejs>=10.13.0') makedepends=('npm' 'jq') source=("https://registry.npmjs.org/${pkgname}/-/${pkgname}-${pkgver}.tgz") noextract=("${pkgname}-${pkgver}.tgz") sha512sums=('1b21aa1be491c987eb80ea4a5dcddb7102abbe7775ee4c21d315745edb2fe4c04b3ef81829a9a94894862b38418cd97edf574c76d70add16f87fa7a248afe94d') package() { # Use `--cache="${srcdir}/.npm"` to prevent npm from generating cache in home. # Use `--loglevel=error` to remove fsevents warning. npm install \ --global \ --user=root \ --loglevel=error \ --prefix="${pkgdir}/usr" \ --cache="${srcdir}/.npm" \ "${srcdir}/${pkgname}-${pkgver}.tgz" # Remove all src dir reference in dependencies' package.json with sed. find "${pkgdir}" -name package.json -print0 | xargs -r -0 sed -i '/_where/d' # Remove src dir reference in package.json with jq. local tmpjson="$(mktemp)" local pkgjson="${pkgdir}/usr/lib/node_modules/${pkgname}/package.json" jq '.|=with_entries(select(.key|test("_.+")|not))' "${pkgjson}" > "${tmpjson}" mv "${tmpjson}" "${pkgjson}" chmod 0644 "${pkgjson}" # npm sometimes gives dirs 777, fix it. find "${pkgdir}" -type d -exec chmod 0755 {} + # npm sets all owner to build user, which results in a lot of error which package checking. chown -R root:root "${pkgdir}" # Install LICENSE. install -Dm0644 \ "${pkgdir}/usr/lib/node_modules/${pkgname}/LICENSE" \ "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" }