toxic: 0.15.1 -> 0.16.0
[NixPkgs.git] / pkgs / by-name / sh / shopify-cli / update.sh
blob6421f59a3a17f9c50c0697637734f3ca94c7592c
1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl nix-update prefetch-npm-deps nodejs jq gnused ruby bundix
4 set -eu -o pipefail
6 # Make a temporary directory and make sure it's removed when the script exits
7 tmp=$(mktemp -d)
8 trap "rm -rf $tmp" EXIT
10 package_dir="$(dirname "${BASH_SOURCE[0]}")"
11 pushd "$package_dir"
13 curl -sfL ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/Shopify/cli/releases/latest > $tmp/latest.json
14 version=$(cat $tmp/latest.json | jq -r '.tag_name')
16 if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
17 echo "Already up to date!"
18 exit 0
21 # Update the package.json
22 sed -i "s|$UPDATE_NIX_OLD_VERSION|$version|g" package.json
24 # Update the package-lock.json
25 rm -f package-lock.json
26 npm i --package-lock-only
27 npm_hash=$(prefetch-npm-deps package-lock.json)
28 sed -i "s|npmDepsHash = \".*\";|npmDepsHash = \"$npm_hash\";|" package.nix
30 popd
32 nix-update shopify-cli --version $version