# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        yarnpkg yarn 1.22.22 v
revision            0
checksums           rmd160  b52cd4abfcd1e438c7439e35847a836b3306b02f \
                    sha256  88268464199d1611fcf73ce9c0a6c4d44c7d5363682720d8506f6508addf36a0 \
                    size    1247457

categories          devel

platforms           any
supported_archs     noarch

license             BSD

maintainers         {andrewsforge.com:code @jambonrose} \
                    {gmail.com:isomarcte @isomarcte} \
                    openmaintainer

description         JavaScript dependency manager
long_description    Created by Facebook to replace NPM, yarn boasts about its \
                    speed, security, and reliability. Most notably, yarn \
                    dependencies are installed deterministically, whereas \
                    NPM's dependencies are not.

homepage            https://yarnpkg.com/
github.tarball_from releases
distname            ${name}-${git.branch}

depends_run         path:bin/node:nodejs22

platform darwin {
    if {${os.major} < 13} {
        depends_run-replace path:bin/node:nodejs22 path:bin/node:nodejs14
    }
}

use_configure       no
build {
    reinplace "s|Darwin|# Darwin|g" ${worksrcpath}/bin/yarn
}

destroot {
  copy ${worksrcpath} ${destroot}${prefix}/libexec/yarn
  ln -s ${prefix}/libexec/yarn/bin/yarn ${destroot}${prefix}/bin/yarn
  ln -s ${prefix}/libexec/yarn/bin/yarnpkg ${destroot}${prefix}/bin/yarnpkg
}

notes "
${name} stores data in:

    ~/.yarn
    ~/.yarnrc
    ~/.cache/yarn
    ~/.config/yarn

Should you choose to install packages globally with ${name} (yarn global\
add), these files will not be removed if you deactivate or uninstall ${name}.\
By default, these packages will be installed in ~/.config/yarn/global, and\
soft-linked to ${prefix}/bin. To uninstall them all:

$ ls -1 \$HOME/.config/yarn/global/node_modules/ \
| xargs sudo yarn global remove

You may then remove the directories listed above and uninstall ${name}.

${name} is meant to replace NPM, and may cause conflicts if you use both.

You may override the default global installation directory by setting the\
PREFIX environment variable, e.g.

mkdir -p \$HOME/.config/yarn/bin # Or wherever you want
export PREFIX=\$HOME/.config/yarn/bin
export PATH=\$PREFIX:\$PATH
"

livecheck.url       ${github.homepage}/releases/latest
