Something went wrong. Try again.
Noah's NUR repo
Something went wrong. Try again.
1.7 kB · 67 lines
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#!/usr/bin/env rcflag e +cd `{dirname $0}for(tool in awk jq npm perl seq) { if(! whatis $tool > /dev/null >[2=1]) { echo 'error: required command not found: '$tool >[1=2] exit 127 }}file=default.nixcurrent=`{awk ' $1 == "version" { gsub(/[";]/, "", $3) print $3 exit }' $file}latest=`{npm view '@opencode/cli-darwin-arm64@latest' version --json | jq -r .}if(! ~ $#current 1 || ! ~ $#latest 1 || ~ $latest null '') { echo 'opencode-v2: could not determine the current or latest version' >[1=2] exit 1}if(~ $current $latest) { echo 'opencode-v2: current ('$current')' exit 0}current_hashes=`{awk ' $1 == "hash" { gsub(/[";]/, "", $3) print $3 }' $file}artifacts=(cli-darwin-arm64 cli-darwin-x64-baseline cli-linux-arm64 cli-linux-x64)if(! ~ $#current_hashes $#artifacts) { echo 'opencode-v2: could not determine the current artifact hashes' >[1=2] exit 1}hashes=()for(artifact in $artifacts) { package='@opencode/'^$artifact^'@'^$latest metadata=`{npm view $package version dist.integrity --json} package_version=`{echo $metadata | jq -r .version} hash=`{echo $metadata | jq -r '."dist.integrity"'} if(! ~ $#package_version 1 || ! ~ $package_version $latest || ! ~ $#hash 1 || ~ $hash null '') { echo 'opencode-v2: could not update the hash for '$artifact >[1=2] exit 1 } hashes=($hashes $hash)}echo 'opencode-v2: '$current' -> '$latestperl -0pi -e 'BEGIN { $old = shift; $new = shift } s/\Q$old\E/$new/g' \ $current $latest $filefor(i in `{seq $#artifacts}) { perl -0pi -e 'BEGIN { $old = shift; $new = shift } s/\Q$old\E/$new/g' \ $current_hashes($i) $hashes($i) $file}