-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(setup): Add setup scripts for easier installation
- Manual Installation section updated to include step-by-step instructions - Add setup script "setup_sc.sh" for automated setup process - Add one-liner setup script "setup_quick_wget.sh" for swift setup - Updated README.md to include instructions on using setup scripts - Minor chores
- Loading branch information
Showing
3 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Variables | ||
REPO_URL="https://github.com/5n00py/SmartCommit.git" | ||
INSTALL_DIR="$HOME/.local/share/SmartCommit" | ||
|
||
# Create the installation directory if it doesn't exist | ||
mkdir -p "$INSTALL_DIR" | ||
|
||
# Clone the repository | ||
echo "Cloning SmartCommit repository into $INSTALL_DIR" | ||
git clone "$REPO_URL" "$INSTALL_DIR" | ||
|
||
# Navigate to the SmartCommit setup directory | ||
cd "$INSTALL_DIR/setup" || exit | ||
|
||
# Make the setup script executable | ||
chmod +x setup_sc.sh | ||
|
||
# Run the setup script | ||
echo "Running setup script..." | ||
./setup_sc.sh | ||
|
||
# End of script | ||
echo "Quick setup of SmartCommit is complete." |
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
# Navigate to the script's directory | ||
cd "$(dirname "$0")" || exit | ||
# Set GCS_ROOT to the parent of the current directory (SmartCommit root) | ||
GCS_ROOT=$(cd .. && pwd) | ||
echo "Setting GCS_ROOT to $GCS_ROOT" | ||
|
||
# Set up Python environment | ||
echo "Setting up the Python environment..." | ||
python3 -m venv "$GCS_ROOT/python/venv" | ||
# shellcheck disable=SC1091 | ||
source "$GCS_ROOT/python/venv/bin/activate" | ||
|
||
# Check Python version | ||
python_version=$(python3 --version | cut -d ' ' -f 2) | ||
minimum_version="3.7" | ||
|
||
if printf '%s\n' "$python_version" "$minimum_version" | sort -V | head -n 1 | grep -q "$minimum_version"; then | ||
echo "Python version is $python_version, which is acceptable." | ||
else | ||
echo "Python 3.7 or higher is required. Please upgrade your Python." | ||
exit 1 | ||
fi | ||
|
||
# Install required libraries | ||
echo "Installing required Python libraries..." | ||
pip install -r "$GCS_ROOT/python/requirements.txt" | ||
|
||
# Deactivate the virtual environment | ||
deactivate | ||
|
||
# Make scripts executable | ||
chmod +x "$GCS_ROOT/gc-smart" | ||
chmod +x "$GCS_ROOT/python/gpt-commit-prompter" | ||
|
||
# Check for OpenAI API key | ||
if [ -z "$OPENAI_API_KEY" ]; then | ||
echo "Settin up the OpenAI API Key:" | ||
echo "See also: https://help.openai.com/en/articles/4936850-where-do-i-find-my-api-key" | ||
echo "Please enter your OpenAI API key:" | ||
read -r OPENAI_API_KEY | ||
|
||
# Check if .bashrc exists and write the key export | ||
if [ -f "$HOME/.bashrc" ]; then | ||
echo "export OPENAI_API_KEY='$OPENAI_API_KEY'" >> "$HOME/.bashrc" | ||
echo "Your OpenAI API key has been added to your .bashrc file." | ||
fi | ||
|
||
# Check if .zshrc exists and write the key export | ||
if [ -f "$HOME/.zshrc" ]; then | ||
echo "export OPENAI_API_KEY='$OPENAI_API_KEY'" >> "$HOME/.zshrc" | ||
echo "Your OpenAI API key has been added to your .zshrc file." | ||
fi | ||
|
||
# If neither file exists, return an error | ||
if [ ! -f "$HOME/.bashrc" ] && [ ! -f "$HOME/.zshrc" ]; then | ||
echo "ERROR: Neither .bashrc nor .zshrc was found." | ||
echo "Please manually add the OPENAI_API_KEY to your shell's configuration." | ||
exit 1 | ||
fi | ||
|
||
echo "WARNING: Keep your API key secure and do not share it." | ||
fi | ||
|
||
# Add script to PATH | ||
echo "Adding gc-smart script to PATH..." | ||
script_path="$GCS_ROOT/gc-smart" | ||
if [ -f "$HOME/.bashrc" ]; then | ||
echo "export PATH=\"\$PATH:$script_path\"" >> "$HOME/.bashrc" | ||
fi | ||
if [ -f "$HOME/.zshrc" ]; then | ||
echo "export PATH=\"\$PATH:$script_path\"" >> "$HOME/.zshrc" | ||
fi | ||
|
||
|
||
echo "Setup complete. Please restart your terminal or source your .bashrc/.zshrc file." |