|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
set -e |
|
|
|
|
|
RED='\033[0;31m' |
|
GREEN='\033[0;32m' |
|
YELLOW='\033[1;33m' |
|
NC='\033[0m' |
|
|
|
echo -e "${GREEN}π€ Reachy Mini App Setup Script${NC}" |
|
echo "==================================" |
|
|
|
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then |
|
echo -e "${RED}Error: Not in a git repository${NC}" |
|
exit 1 |
|
fi |
|
|
|
|
|
REPO_NAME=$(basename -s .git $(git config --get remote.origin.url) 2>/dev/null || basename "$(pwd)") |
|
|
|
if [ -z "$REPO_NAME" ]; then |
|
echo -e "${RED}Error: Could not determine repository name${NC}" |
|
exit 1 |
|
fi |
|
|
|
echo -e "${YELLOW}Repository name: $REPO_NAME${NC}" |
|
|
|
|
|
|
|
PACKAGE_NAME=$(echo "$REPO_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/-/_/g') |
|
|
|
|
|
CLASS_NAME=$(echo "$REPO_NAME" | sed 's/[-_]/ /g' | sed 's/\b\(.\)/\U\1/g' | sed 's/ //g') |
|
|
|
|
|
ENTRY_POINT_NAME="$REPO_NAME" |
|
|
|
echo -e "${YELLOW}Package name: $PACKAGE_NAME${NC}" |
|
echo -e "${YELLOW}Class name: ${CLASS_NAME}App${NC}" |
|
echo -e "${YELLOW}Entry point: $ENTRY_POINT_NAME${NC}" |
|
|
|
echo -e "${YELLOW}Setting up app from repo: $REPO_NAME${NC}" |
|
|
|
|
|
echo "π Updating pyproject.toml..." |
|
if [ -f "pyproject.toml" ]; then |
|
|
|
sed -i.bak "s/name = \"reachy_mini_app_example\"/name = \"$PACKAGE_NAME\"/" pyproject.toml |
|
|
|
|
|
sed -i.bak "s/reachy_mini_app_example = \"reachy_mini_app_example.main:ExampleApp\"/$ENTRY_POINT_NAME = \"$PACKAGE_NAME.main:${CLASS_NAME}App\"/" pyproject.toml |
|
|
|
echo -e "${GREEN}β pyproject.toml updated${NC}" |
|
else |
|
echo -e "${RED}Error: pyproject.toml not found${NC}" |
|
exit 1 |
|
fi |
|
|
|
|
|
echo "π Updating README.md..." |
|
if [ -f "README.md" ]; then |
|
|
|
sed -i.bak "s/Reachy Mini App Example/${REPO_NAME^} App/g" README.md |
|
sed -i.bak "s/reachy_mini_app_example/$PACKAGE_NAME/g" README.md |
|
|
|
echo -e "${GREEN}β README.md updated${NC}" |
|
else |
|
echo -e "${YELLOW}Warning: README.md not found, skipping...${NC}" |
|
fi |
|
|
|
|
|
echo "π Updating index.html..." |
|
if [ -f "index.html" ]; then |
|
|
|
sed -i.bak "s/Reachy Mini New App Tutorial/${REPO_NAME^} App/g" index.html |
|
sed -i.bak "s/reachy_mini_new_app_tuto/$PACKAGE_NAME/g" index.html |
|
|
|
echo -e "${GREEN}β index.html updated${NC}" |
|
else |
|
echo -e "${YELLOW}Warning: index.html not found, skipping...${NC}" |
|
fi |
|
|
|
|
|
echo "π Renaming package directory..." |
|
if [ -d "reachy_mini_app_example" ]; then |
|
mv "reachy_mini_app_example" "$PACKAGE_NAME" |
|
echo -e "${GREEN}β Package directory renamed to $PACKAGE_NAME${NC}" |
|
elif [ -d "reachy_mini_new_app_tuto" ]; then |
|
mv "reachy_mini_new_app_tuto" "$PACKAGE_NAME" |
|
echo -e "${GREEN}β Package directory renamed to $PACKAGE_NAME${NC}" |
|
else |
|
echo -e "${YELLOW}Warning: No package directory found to rename${NC}" |
|
fi |
|
|
|
|
|
echo "π Updating main.py class name..." |
|
if [ -f "$PACKAGE_NAME/main.py" ]; then |
|
|
|
sed -i.bak "s/class ExampleApp/class ${CLASS_NAME}App/g" "$PACKAGE_NAME/main.py" |
|
sed -i.bak "s/class ReachyMiniNewAppTuto/class ${CLASS_NAME}App/g" "$PACKAGE_NAME/main.py" |
|
|
|
echo -e "${GREEN}β main.py class name updated to ${CLASS_NAME}App${NC}" |
|
else |
|
echo -e "${YELLOW}Warning: main.py not found in $PACKAGE_NAME directory${NC}" |
|
fi |
|
|
|
|
|
echo "π§Ή Cleaning up backup files..." |
|
find . -name "*.bak" -delete |
|
echo -e "${GREEN}β Backup files cleaned up${NC}" |
|
|
|
|
|
echo "" |
|
echo -e "${GREEN}π Setup complete!${NC}" |
|
echo "==================================" |
|
echo "Your new Reachy Mini app '$REPO_NAME' is ready!" |
|
echo "" |
|
echo "Generated names:" |
|
echo " π¦ Package: $PACKAGE_NAME" |
|
echo " π·οΈ Class: ${CLASS_NAME}App" |
|
echo " π§ Entry point: $ENTRY_POINT_NAME" |
|
echo "" |
|
echo "Next steps:" |
|
echo "1. Review the updated files" |
|
echo "2. Install dependencies: pip install -e ." |
|
echo "3. Test your app: $ENTRY_POINT_NAME" |
|
echo "4. Commit and push to your repository" |
|
echo "" |
|
echo -e "${YELLOW}Happy coding with Reachy Mini! π€${NC}" |