about summary refs log tree commit diff
path: root/pkgs/applications/networking/instant-messengers/element/keytar/update.sh
blob: 9b8d014f03c96274e0763afd3b42e0c9a16e7027 (plain) (blame)
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
#!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../../../../ -i bash -p wget prefetch-npm-deps nix-prefetch-github

if [ "$#" -gt 1 ] || [[ "$1" == -* ]]; then
  echo "Regenerates packaging data for the keytar package."
  echo "Usage: $0 [git release tag]"
  exit 1
fi

version="$1"

set -euo pipefail

if [ -z "$version" ]; then
  version="$(wget -O- "https://api.github.com/repos/atom/node-keytar/releases?per_page=1" | jq -r '.[0].tag_name')"
fi

# strip leading "v"
version="${version#v}"

SRC="https://raw.githubusercontent.com/atom/node-keytar/v$version"

wget "$SRC/package-lock.json"
wget "$SRC/package.json"
npm_hash=$(prefetch-npm-deps package-lock.json)
rm -rf node_modules package.json package-lock.json

src_hash=$(nix-prefetch-github atom node-keytar --rev v${version} | jq -r .hash)

cat > pin.json << EOF
{
  "version": "$version",
  "srcHash": "$src_hash",
  "npmHash": "$npm_hash"
}
EOF