# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Severen Redwood <me@severen.dev>
# Contributor: Tomasz Jakub Rup <tomasz.rup@gmail.com>

pkgname=pnpm
pkgver=10.22.0
pkgrel=1
pkgdesc='Fast, disk space efficient package manager'
arch=(any)
url=https://pnpm.io
license=(MIT)
depends=(node-gyp)
makedepends=(
  git
  pnpm
  python
)
source=("git+https://github.com/$pkgname/$pkgname.git#tag=v$pkgver?signed")
b2sums=('7a13bcbcd8fdc6ca76c82f55b2b9577efec3c19a77326ef1d0c9202ffc7f8b3636bef5934c581c692b1f7b9e9e3ca56a0dc1bd27d0011ab698eeefc33a87f3bc')
validpgpkeys=(7B74D1299568B586BA9962B5649E4D4AF74E7DEC) # Zoltan Kochan <z@kochan.io>

prepare() {
  cd $pkgname/$pkgname
  pnpm install --frozen-lockfile
}

build() {
  cd $pkgname/$pkgname
  pnpm run compile
}

package() {
  local mod_dir=/usr/lib/node_modules/$pkgname

  install -d "$pkgdir"/{usr/bin,$mod_dir/dist}
  ln -s $mod_dir/bin/$pkgname.cjs "$pkgdir"/usr/bin/$pkgname
  ln -s $mod_dir/bin/pnpx.cjs "$pkgdir"/usr/bin/pnpx

  cd $pkgname/$pkgname
  cp -r bin package.json "$pkgdir"/$mod_dir
  install -Dt "$pkgdir"/usr/share/licenses/$pkgname LICENSE
  cd dist
  cp -r $pkgname.cjs pnpmrc templates worker.js "$pkgdir"/$mod_dir/dist
}
