# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Bruno Galeotti <bgaleotti at gmail dot com>

_name=TypeScript
pkgname=typescript
pkgver=5.2.2
pkgrel=1
pkgdesc='JavaScript with syntax for types'
arch=(any)
url=http://www.typescriptlang.org
license=('Apache')
depends=('nodejs')
makedepends=('npm' 'rsync')
source=("https://github.com/microsoft/$_name/archive/v$pkgver/$pkgname-$pkgver.tar.gz")
b2sums=('3fa418b69c22494df80be0cdcd39ae52e13d35d908f084aec57af52a2d65d4a8081704239dbf47fad177ae3da907dcb384e61a3131f5751cf1f90b13a4bece8a')

prepare() {
  cd $_name-$pkgver
  npm ci
}

build() {
  cd $_name-$pkgver
  npx hereby LKG
}

check() {
  cd $_name-$pkgver
  npm run test
}

package() {
  install -d "$pkgdir"/usr/{bin,lib/node_modules/$pkgname}
  ln -s ../lib/node_modules/$pkgname/bin/{tsc,tsserver} "$pkgdir"/usr/bin

  cd $_name-$pkgver
  rsync -r --exclude .gitattributes README.md SECURITY.md bin lib package.json \
    "$pkgdir"/usr/lib/node_modules/$pkgname
  install -Dt "$pkgdir"/usr/share/licenses/$pkgname ThirdPartyNoticeText.txt
}
