-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into saihaj/graph-cli-header
- Loading branch information
Showing
37 changed files
with
569 additions
and
535 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,103 @@ | ||
#!/bin/bash | ||
{ | ||
set -e | ||
SUDO='' | ||
if [ "$(id -u)" != "0" ]; then | ||
SUDO='sudo' | ||
echo "This script requires superuser access." | ||
echo "You will be prompted for your password by sudo." | ||
# clear any previous sudo permission | ||
sudo -k | ||
fi | ||
|
||
# run inside sudo | ||
$SUDO bash << SCRIPT | ||
set -e | ||
OS="" | ||
ARCH="" | ||
OS_ARCH="" | ||
echoerr() { echo "\$@" 1>&2; } | ||
unsupported_arch() { | ||
local os=$1 | ||
local arch=$2 | ||
echoerr "The Graph CLI does not support $os / $arch at this time." | ||
exit 1 | ||
} | ||
|
||
set_os_arch() { | ||
if [ "\$(uname)" == "Darwin" ]; then | ||
OS=darwin | ||
elif [ "\$(expr substr \$(uname -s) 1 5)" == "Linux" ]; then | ||
OS=linux | ||
else | ||
OS=win32 | ||
fi | ||
if [ -n "$1" ] | ||
then | ||
INSTALL_DIR=${1%%/} | ||
BIN_DIR= | ||
else | ||
INSTALL_DIR=/usr/local/lib | ||
BIN_DIR=/usr/local/bin | ||
fi | ||
|
||
if [ ! -w "$INSTALL_DIR" ] | ||
then | ||
cat <<EOF | ||
usage: install.sh [DIR] | ||
Install graph-cli to DIR. DIR defaults to /usr/local/lib. | ||
The directory $INSTALL_DIR is not writable by the current user. | ||
Try running this script as root for a system-wide install which will also | ||
put 'graph' into /usr/local/bin or pass an installation directory that is | ||
writable by the current user as DIR | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
|
||
OS="" | ||
ARCH="" | ||
|
||
echoerr() { echo "$@" 1>&2; } | ||
|
||
ARCH="\$(uname -m)" | ||
if [ "\$ARCH" == "x86_64" ]; then | ||
ARCH=x64 | ||
elif [ "\$ARCH" == "amd64" ]; then | ||
ARCH=x64 | ||
elif [ "\$ARCH" == "arm64" ]; then | ||
if [ "\$OS" == "darwin" ]; then | ||
unsupported_arch() { | ||
local os=$1 | ||
local arch=$2 | ||
echoerr "The Graph CLI does not support $os / $arch at this time." | ||
exit 1 | ||
} | ||
|
||
set_os_arch() { | ||
if [ "$(uname)" == "Darwin" ]; then | ||
OS=darwin | ||
elif [ "$(uname -s)" == "Linux" ]; then | ||
OS=linux | ||
else | ||
OS=win32 | ||
fi | ||
|
||
ARCH="$(uname -m)" | ||
if [ "$ARCH" == "x86_64" ]; then | ||
ARCH=x64 | ||
elif [ "$ARCH" == "amd64" ]; then | ||
ARCH=x64 | ||
elif [ "$ARCH" == "arm64" ]; then | ||
if [ "$OS" == "darwin" ]; then | ||
ARCH=arm64 | ||
else | ||
ARCH=arm | ||
fi | ||
elif [[ "\$ARCH" == aarch* ]]; then | ||
ARCH=arm | ||
else | ||
unsupported_arch $OS $ARCH | ||
ARCH=arm | ||
fi | ||
} | ||
elif [[ "$ARCH" == aarch* ]]; then | ||
ARCH=arm | ||
else | ||
unsupported_arch $OS $ARCH | ||
fi | ||
} | ||
|
||
download() { | ||
DOWNLOAD_DIR=$(mktemp -d) | ||
download() { | ||
DOWNLOAD_DIR=$(mktemp -d) | ||
|
||
TARGET="\$OS-\$ARCH" | ||
URL="https://github.com/graphprotocol/graph-tooling/releases/latest/download/graph-\$TARGET.tar.gz" | ||
echo "Downloading \$URL" | ||
TARGET="$OS-$ARCH" | ||
URL="https://github.com/graphprotocol/graph-tooling/releases/latest/download/graph-$TARGET.tar.gz" | ||
echo "Downloading $URL" | ||
|
||
if ! curl --progress-bar --fail -L "\$URL" -o "\$DOWNLOAD_DIR/graph.tar.gz"; then | ||
echo "Download failed." | ||
exit 1 | ||
fi | ||
if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/graph.tar.gz"; then | ||
echo "Download failed." | ||
exit 1 | ||
fi | ||
|
||
echo "Downloaded to \$DOWNLOAD_DIR" | ||
echo "Downloaded to $DOWNLOAD_DIR" | ||
|
||
rm -rf "/usr/local/lib/graph" | ||
tar xzf "\$DOWNLOAD_DIR/graph.tar.gz" -C /usr/local/lib | ||
rm -rf "\$DOWNLOAD_DIR" | ||
echo "Unpacked to /usr/local/lib/graph" | ||
rm -rf "${INSTALL_DIR}/graph" | ||
tar xzf "$DOWNLOAD_DIR/graph.tar.gz" -C "$INSTALL_DIR" | ||
rm -rf "$DOWNLOAD_DIR" | ||
echo "Unpacked to $INSTALL_DIR" | ||
|
||
echo "Installing to /usr/local/bin/graph" | ||
rm -f /usr/local/bin/graph | ||
ln -s /usr/local/lib/graph/bin/graph /usr/local/bin/graph | ||
} | ||
if [ -n "$BIN_DIR" ] | ||
then | ||
echo "Installing to ${BIN_DIR}/graph" | ||
rm -f "$BIN_DIR/graph" | ||
ln -s "$INSTALL_DIR/graph/bin/graph" "$BIN_DIR/graph" | ||
LOCATION="$BIN_DIR/graph" | ||
else | ||
LOCATION="$INSTALL_DIR/graph/bin/graph" | ||
fi | ||
} | ||
|
||
set_os_arch | ||
download | ||
set_os_arch | ||
download | ||
|
||
SCRIPT | ||
LOCATION=$(command -v graph) | ||
echo "The Graph CLI installed to $LOCATION" | ||
graph --version | ||
} | ||
echo "The Graph CLI installed to $LOCATION" | ||
$LOCATION --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,5 @@ | |
}, | ||
"devDependencies": { | ||
"@graphprotocol/graph-ts": "0.31.0" | ||
}, | ||
"resolutions": { | ||
"assemblyscript": "0.19.10" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.