# -*- 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           npm 1.0

name                gemini-cli
version             0.29.7
revision            0

categories          llm
platforms           darwin
maintainers         {breun @breun} openmaintainer
license             Apache-2
supported_archs     x86_64 arm64

description         Use Google Gemini from your terminal
long_description    Gemini CLI is an open-source AI agent that brings the power of Google Gemini directly into your terminal.

homepage            https://geminicli.com

npm.rootname        @google/${name}
distname            ${name}-${version}

checksums           rmd160  1b91377755a47dea2fc973a6b2b37abb768cea2d \
                    sha256  8cadaf20c72deaa5d16d540cc187fac4c32741e129986626984335a5b71ca228 \
                    size    4223135

post-destroot {
    set node_modules_dir ${destroot}${prefix}/lib/node_modules/${npm.rootname}/node_modules

    # Remove binaries for other operating systems
    if {${os.platform} ne "darwin"} {
        delete {*}[glob ${node_modules_dir}/@lydell/node-pty-darwin*]
        delete {*}[glob ${node_modules_dir}/node-pty/prebuilds/darwin*]
    }
    if {${os.platform} ne "linux"} {
        delete ${node_modules_dir}/clipboardy/fallbacks/linux
        delete {*}[glob ${node_modules_dir}/tree-sitter-bash/prebuilds/linux*]
    }
    if {${os.platform} ne "windows"} {
        delete {*}[glob ${node_modules_dir}/node-pty/prebuilds/win*]
        delete {*}[glob ${node_modules_dir}/node-pty/third_party/conpty/*/win*]
        delete {*}[glob ${node_modules_dir}/tree-sitter-bash/prebuilds/win*]
    }

    # Remove binaries for other CPU architectures
    if {${configure.build_arch} ne "x86_64"} {
        delete ${node_modules_dir}/node-pty/prebuilds/darwin-x64
        delete ${node_modules_dir}/tree-sitter-bash/prebuilds/darwin-x64
    }
    if {${configure.build_arch} ne "arm64"} {
        delete ${node_modules_dir}/@lydell/node-pty-darwin-arm64
        delete ${node_modules_dir}/node-pty/prebuilds/darwin-arm64
        delete ${node_modules_dir}/tree-sitter-bash/prebuilds/darwin-arm64
    }
}
