1 #!/usr/bin/env nix-shell
2 #!nix-shell -i bash -p curl nix-update prefetch-npm-deps nodejs jq gnused ruby bundix
6 # Make a temporary directory and make sure it's removed when the script exits
8 trap "rm -rf $tmp" EXIT
10 package_dir
="$(dirname "${BASH_SOURCE[0]}")"
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!"
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
32 nix-update shopify-cli
--version $version