# Template file for 'yaml-language-server'
pkgname=yaml-language-server
version=1.21.0
revision=1
hostmakedepends="nodejs"
depends="nodejs"
short_desc="Language server for YAML files"
maintainer="Alex March <alex@hosaka.cc>"
license="MIT"
homepage="https://github.com/redhat-developer/yaml-language-server"
changelog="https://raw.githubusercontent.com/redhat-developer/yaml-language-server/refs/heads/main/CHANGELOG.md"
distfiles="https://github.com/redhat-developer/yaml-language-server/archive/refs/tags/${version}.tar.gz"
checksum=9a1e16e508d29ab74113b34fa8957b61de81d79ec6c1b7be943c1749e1ac5038

do_configure() {
	npm ci
}

do_build() {
	# UMD (Universal Module Definition) modules and ES Modules (ESM) are not
	# necessary, compiling to CommonJS is enough to have a working server
	npm run compile
}

do_check() {
	npm test
}

do_install() {
	TARGET_PATH="usr/lib/${pkgname}"

	rm -r node_modules
	npm install --omit=dev --ignore-scripts

	vmkdir ${TARGET_PATH}
	vcopy bin ${TARGET_PATH}
	vcopy l10n ${TARGET_PATH}
	vcopy node_modules ${TARGET_PATH}
	vcopy out ${TARGET_PATH}
	vcopy package.json ${TARGET_PATH}

	vmkdir usr/bin
	ln -sf /${TARGET_PATH}/bin/${pkgname} ${DESTDIR}/usr/bin/${pkgname}

	vlicense LICENSE
}
