summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: db732d914b826554e0d4de90d8df2a74b008b2ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Maintainer: Lukas Westholt <support(at)lukaswestholt(dot)de>

pkgname=dcli-git
pkgver=6.2544.2.r3.8d37e32
pkgrel=1
pkgdesc="Dashlane CLI - Access your secrets in your terminal, servers and CI/CD"
url="https://github.com/Dashlane/dashlane-cli"
arch=("x86_64")
license=('Apache-2.0')
depends=('glibc' 'gcc-libs')
makedepends=('nvm' 'yarn' 'git')
checkdepends=()
optdepends=()
provides=("${pkgname%-*}=$pkgver")
conflicts=("${pkgname%-*}")
conflicts=()
replaces=()
backup=()
options=('!strip')
install=
changelog=
source=("${pkgname%-*}::git+${url}.git")
noextract=()
sha256sums=('SKIP')

# See https://wiki.archlinux.org/title/Node.js_package_guidelines#Using_nvm
_ensure_local_nvm() {
    # Let's be sure we are starting clean
    which nvm >/dev/null 2>&1 && nvm deactivate && nvm unload
    export NVM_DIR="${srcdir}/.nvm"

    # The init script returns 3 if version specified
    # in ./.nvmrc is not (yet) installed in $NVM_DIR
    # but nvm itself still gets loaded ok
    source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
}

pkgver() {
	cd "${srcdir}/${pkgname%-*}"
	printf "%s" "$(git describe --tags --long | sed 's/^v//;s/\([^-]*-\)g/r\1/;s/-/./g')"
}

prepare() {
    cd "${srcdir}/${pkgname%-*}"

    # contain global packages somewhere else
    yarn config set globalFolder "${srcdir}/.yarn"
}

build() {
    # We don't want to depend on nodejs-lts-jod on runtime
    # So we build the dcli as a self-contained binary
    # See: https://github.com/Dashlane/dashlane-cli/issues/52#issuecomment-1447918815

    cd "${srcdir}/${pkgname%-*}"

    # Ensure correct NodeJS version for building
    _ensure_local_nvm
    nvm install 22

    # See https://github.com/Dashlane/dashlane-cli/blob/8d37e32ebba9e95404f25236b659db692d1bdb4d/.github/workflows/release.yml
    export CI=true
    yarn install 
    YARN_ENABLE_INLINE_BUILDS=1 yarn run build
    yarn workspaces focus --all --production
    yarn dlx @yao-pkg/pkg@6.1.1 ./dist -t node22-linux-x64 -o bundle/dcli-linux-x64 -C Brotli "--public" "--public-packages" "tslib,thirty-two,node-hkdf-sync,vows" "--no-bytecode"
}

check() {
    cd "$srcdir/${pkgname%-*}"
    chmod +x bundle/dcli-linux-x64

    # Basic smoke test
    bundle/dcli-linux-x64 --help >/dev/null
}


package() {
    cd "${srcdir}/${pkgname%-*}"
    install -Dm755 bundle/dcli-linux-x64 "${pkgdir}/usr/bin/${pkgname%-*}"
}