simplified the install script add help instruction

This commit is contained in:
SwiftyOS
2023-09-17 18:41:06 +02:00
parent b181733d59
commit 3ea9d6a70f
2 changed files with 33 additions and 8 deletions

28
cli.py
View File

@@ -45,15 +45,23 @@ d88P 888 "Y88888 "Y888 "Y88P" "Y8888P88 888 888
script_dir = os.path.dirname(os.path.realpath(__file__)) script_dir = os.path.dirname(os.path.realpath(__file__))
setup_script = os.path.join(script_dir, "setup.sh") setup_script = os.path.join(script_dir, "setup.sh")
install_error = False
if os.path.exists(setup_script): if os.path.exists(setup_script):
click.echo(click.style("🚀 Setup initiated...\n", fg="green")) click.echo(click.style("🚀 Setup initiated...\n", fg="green"))
subprocess.Popen([setup_script], cwd=script_dir) try:
subprocess.check_call([setup_script], cwd=script_dir)
except subprocess.CalledProcessError:
click.echo(
click.style("❌ There was an issue with the installation.", fg="red")
)
install_error = True
else: else:
click.echo( click.echo(
click.style( click.style(
"❌ Error: setup.sh does not exist in the current directory.", fg="red" "❌ Error: setup.sh does not exist in the current directory.", fg="red"
) )
) )
install_error = True
try: try:
# Check if GitHub user name is configured # Check if GitHub user name is configured
@@ -99,7 +107,8 @@ d88P 888 "Y88888 "Y888 "Y88P" "Y8888P88 888 888
' git config --global user.email "Your GitHub Email"', fg="red" ' git config --global user.email "Your GitHub Email"', fg="red"
) )
) )
install_error = True
print_access_token_instructions = False
# Check for the existence of the .github_access_token file # Check for the existence of the .github_access_token file
if os.path.exists(".github_access_token"): if os.path.exists(".github_access_token"):
with open(".github_access_token", "r") as file: with open(".github_access_token", "r") as file:
@@ -125,6 +134,7 @@ d88P 888 "Y88888 "Y888 "Y88P" "Y8888P88 888 888
) )
) )
else: else:
install_error = True
click.echo( click.echo(
click.style( click.style(
"❌ GitHub access token does not have the required permissions. Please ensure it has 'public_repo' or 'repo' scope.", "❌ GitHub access token does not have the required permissions. Please ensure it has 'public_repo' or 'repo' scope.",
@@ -132,6 +142,7 @@ d88P 888 "Y88888 "Y888 "Y88P" "Y8888P88 888 888
) )
) )
else: else:
install_error = True
click.echo( click.echo(
click.style( click.style(
"❌ Failed to validate GitHub access token. Please ensure it is correct.", "❌ Failed to validate GitHub access token. Please ensure it is correct.",
@@ -139,17 +150,22 @@ d88P 888 "Y88888 "Y888 "Y88P" "Y8888P88 888 888
) )
) )
else: else:
install_error = True
click.echo( click.echo(
click.style( click.style(
"❌ GitHub access token file is empty. Please follow the instructions below to set up your GitHub access token.", "❌ GitHub access token file is empty. Please follow the instructions below to set up your GitHub access token.",
fg="red", fg="red",
) )
) )
print_access_token_instructions = True
else: else:
# Create the .github_access_token file if it doesn't exist # Create the .github_access_token file if it doesn't exist
with open(".github_access_token", "w") as file: with open(".github_access_token", "w") as file:
file.write("") file.write("")
install_error = True
print_access_token_instructions = True
if print_access_token_instructions:
# Instructions to set up GitHub access token # Instructions to set up GitHub access token
click.echo( click.echo(
click.style( click.style(
@@ -178,6 +194,14 @@ d88P 888 "Y88888 "Y888 "Y88P" "Y8888P88 888 888
click.echo( click.echo(
click.style("\t9. Save the file and run the setup command again.", fg="red") click.style("\t9. Save the file and run the setup command again.", fg="red")
) )
if install_error:
click.echo(
click.style(
"\n\n🔴 If you need help, please raise a ticket on GitHub at https://github.com/Significant-Gravitas/Auto-GPT/issues\n\n",
fg="magenta",
bold=True,
)
)
@cli.group() @cli.group()

View File

@@ -24,30 +24,31 @@ fi
if ! command -v flutter &> /dev/null if ! command -v flutter &> /dev/null
then then
echo "flutter could not be found" echo "flutter could not be found"
echo "Installing flutter..." echo "Please install flutter following the instrutions found at https://docs.flutter.dev/get-started/install"
git clone https://github.com/flutter/flutter.git exit 1
export PATH="$PATH:`pwd`/flutter/bin"
fi fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if ! command -v google-chrome-stable &> /dev/null if ! command -v google-chrome-stable &> /dev/null
then then
echo "Google Chrome could not be found" echo "Google Chrome could not be found"
echo "Installing Google Chrome..." echo "Please install Google Chrome manually from https://www.google.com/chrome/"
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb exit 1
sudo dpkg -i google-chrome-stable_current_amd64.deb
fi fi
elif [[ "$OSTYPE" == "darwin"* ]]; then elif [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome &> /dev/null if ! command -v /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome &> /dev/null
then then
echo "Google Chrome could not be found" echo "Google Chrome could not be found"
echo "Please install Google Chrome manually from https://www.google.com/chrome/" echo "Please install Google Chrome manually from https://www.google.com/chrome/"
exit 1
fi fi
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
if ! command -v /c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe &> /dev/null if ! command -v /c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe &> /dev/null
then then
echo "Google Chrome could not be found" echo "Google Chrome could not be found"
echo "Please install Google Chrome manually from https://www.google.com/chrome/" echo "Please install Google Chrome manually from https://www.google.com/chrome/"
exit 1
fi fi
else else
echo "Unsupported OS. Please install Google Chrome manually from https://www.google.com/chrome/" echo "Unsupported OS. Please install Google Chrome manually from https://www.google.com/chrome/"
exit 1
fi fi