# Maintainer: Alynx Zhou pkgname=hikarujs pkgver=1.13.2 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=('d4852fa903835b490d3dc1a92ffafeac92a15dc861532d93bb26a30c238808fdb77aa8f7a1d203b8c70720ead1e0922fed50295d55935b9ad47ee0c30046799d') 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" }