From 9164cd979fcc6bd6ff318cee58c0bcc471c62bc8 Mon Sep 17 00:00:00 2001 From: frank-aleo Date: Fri, 29 Sep 2023 11:37:58 -0700 Subject: [PATCH] add leo installation to create aleo app --- create-aleo-app/template-react-leo/install.sh | 30 +++++++++++++++++++ .../template-react-leo/package.json | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100755 create-aleo-app/template-react-leo/install.sh diff --git a/create-aleo-app/template-react-leo/install.sh b/create-aleo-app/template-react-leo/install.sh new file mode 100755 index 000000000..add482688 --- /dev/null +++ b/create-aleo-app/template-react-leo/install.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# script exists immediately if command fails +set -e + +# check for dependencies +command -v git >/dev/null 2>&1 || { echo >&2 "git is required but it's not installed. Aborting."; exit 1; } +command -v cargo >/dev/null 2>&1 || { echo >&2 "cargo is required but it's not installed. Aborting."; exit 1; } + +INSTALL_DIR="${INSTALL_DIR:-$HOME/.leo}" + +# ask for confirmation +read -p "This script will install Leo into $INSTALL_DIR. Do you want to continue? (y/N) " choice +case "$choice" in + y|Y ) echo "Continuing installation...";; + * ) echo "Aborting."; exit;; +esac + +# clone or update the repo +if [ -d "$INSTALL_DIR" ]; then + echo "Directory $INSTALL_DIR exists. Updating repository..." + git -C "$INSTALL_DIR" pull +else + echo "Cloning repository into $INSTALL_DIR..." + git clone https://github.com/AleoHQ/leo "$INSTALL_DIR" +fi + +# build and install +echo "Building and installing from source..." +cargo install --path "$INSTALL_DIR" diff --git a/create-aleo-app/template-react-leo/package.json b/create-aleo-app/template-react-leo/package.json index 8f2cb6dae..562e94354 100644 --- a/create-aleo-app/template-react-leo/package.json +++ b/create-aleo-app/template-react-leo/package.json @@ -8,7 +8,8 @@ "build": "webpack --config webpack.config.js", "build:vite": "vite build", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "install-leo": "./install.sh" }, "dependencies": { "@aleohq/sdk": "^0.5.10",