added an helper for repo duplication
Browse files- update_app_name.sh +134 -0
update_app_name.sh
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Reachy Mini App Setup Script
|
| 4 |
+
# This script sets up a new Reachy Mini app based on the example template
|
| 5 |
+
|
| 6 |
+
set -e # Exit on any error
|
| 7 |
+
|
| 8 |
+
# Colors for output
|
| 9 |
+
RED='\033[0;31m'
|
| 10 |
+
GREEN='\033[0;32m'
|
| 11 |
+
YELLOW='\033[1;33m'
|
| 12 |
+
NC='\033[0m' # No Color
|
| 13 |
+
|
| 14 |
+
echo -e "${GREEN}π€ Reachy Mini App Setup Script${NC}"
|
| 15 |
+
echo "=================================="
|
| 16 |
+
|
| 17 |
+
# Get repository name from git
|
| 18 |
+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
| 19 |
+
echo -e "${RED}Error: Not in a git repository${NC}"
|
| 20 |
+
exit 1
|
| 21 |
+
fi
|
| 22 |
+
|
| 23 |
+
# Extract repository name from git remote or directory name
|
| 24 |
+
REPO_NAME=$(basename -s .git $(git config --get remote.origin.url) 2>/dev/null || basename "$(pwd)")
|
| 25 |
+
|
| 26 |
+
if [ -z "$REPO_NAME" ]; then
|
| 27 |
+
echo -e "${RED}Error: Could not determine repository name${NC}"
|
| 28 |
+
exit 1
|
| 29 |
+
fi
|
| 30 |
+
|
| 31 |
+
echo -e "${YELLOW}Repository name: $REPO_NAME${NC}"
|
| 32 |
+
|
| 33 |
+
# Convert repo name to different formats needed
|
| 34 |
+
# Python package name: lowercase, hyphens to underscores (my-app -> my_app)
|
| 35 |
+
PACKAGE_NAME=$(echo "$REPO_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/-/_/g')
|
| 36 |
+
|
| 37 |
+
# Python class name: PascalCase, remove hyphens/underscores (my-app -> MyApp)
|
| 38 |
+
CLASS_NAME=$(echo "$REPO_NAME" | sed 's/[-_]/ /g' | sed 's/\b\(.\)/\U\1/g' | sed 's/ //g')
|
| 39 |
+
|
| 40 |
+
# Entry point name: keep original repo format for CLI commands
|
| 41 |
+
ENTRY_POINT_NAME="$REPO_NAME"
|
| 42 |
+
|
| 43 |
+
echo -e "${YELLOW}Package name: $PACKAGE_NAME${NC}"
|
| 44 |
+
echo -e "${YELLOW}Class name: ${CLASS_NAME}App${NC}"
|
| 45 |
+
echo -e "${YELLOW}Entry point: $ENTRY_POINT_NAME${NC}"
|
| 46 |
+
|
| 47 |
+
echo -e "${YELLOW}Setting up app from repo: $REPO_NAME${NC}"
|
| 48 |
+
|
| 49 |
+
# Step 1: Update pyproject.toml
|
| 50 |
+
echo "π Updating pyproject.toml..."
|
| 51 |
+
if [ -f "pyproject.toml" ]; then
|
| 52 |
+
# Update name (use package name format)
|
| 53 |
+
sed -i.bak "s/name = \"reachy_mini_app_example\"/name = \"$PACKAGE_NAME\"/" pyproject.toml
|
| 54 |
+
|
| 55 |
+
# Update entry point (entry point name can have hyphens, points to package.main:ClassApp)
|
| 56 |
+
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
|
| 57 |
+
|
| 58 |
+
echo -e "${GREEN}β pyproject.toml updated${NC}"
|
| 59 |
+
else
|
| 60 |
+
echo -e "${RED}Error: pyproject.toml not found${NC}"
|
| 61 |
+
exit 1
|
| 62 |
+
fi
|
| 63 |
+
|
| 64 |
+
# Step 2: Update README.md
|
| 65 |
+
echo "π Updating README.md..."
|
| 66 |
+
if [ -f "README.md" ]; then
|
| 67 |
+
# Replace example references with new names (use repo name for display)
|
| 68 |
+
sed -i.bak "s/Reachy Mini App Example/${REPO_NAME^} App/g" README.md
|
| 69 |
+
sed -i.bak "s/reachy_mini_app_example/$PACKAGE_NAME/g" README.md
|
| 70 |
+
|
| 71 |
+
echo -e "${GREEN}β README.md updated${NC}"
|
| 72 |
+
else
|
| 73 |
+
echo -e "${YELLOW}Warning: README.md not found, skipping...${NC}"
|
| 74 |
+
fi
|
| 75 |
+
|
| 76 |
+
# Step 3: Update index.html
|
| 77 |
+
echo "π Updating index.html..."
|
| 78 |
+
if [ -f "index.html" ]; then
|
| 79 |
+
# Update title and content (use repo name for display)
|
| 80 |
+
sed -i.bak "s/Reachy Mini New App Tutorial/${REPO_NAME^} App/g" index.html
|
| 81 |
+
sed -i.bak "s/reachy_mini_new_app_tuto/$PACKAGE_NAME/g" index.html
|
| 82 |
+
|
| 83 |
+
echo -e "${GREEN}β index.html updated${NC}"
|
| 84 |
+
else
|
| 85 |
+
echo -e "${YELLOW}Warning: index.html not found, skipping...${NC}"
|
| 86 |
+
fi
|
| 87 |
+
|
| 88 |
+
# Step 4: Rename package directory
|
| 89 |
+
echo "π Renaming package directory..."
|
| 90 |
+
if [ -d "reachy_mini_app_example" ]; then
|
| 91 |
+
mv "reachy_mini_app_example" "$PACKAGE_NAME"
|
| 92 |
+
echo -e "${GREEN}β Package directory renamed to $PACKAGE_NAME${NC}"
|
| 93 |
+
elif [ -d "reachy_mini_new_app_tuto" ]; then
|
| 94 |
+
mv "reachy_mini_new_app_tuto" "$PACKAGE_NAME"
|
| 95 |
+
echo -e "${GREEN}β Package directory renamed to $PACKAGE_NAME${NC}"
|
| 96 |
+
else
|
| 97 |
+
echo -e "${YELLOW}Warning: No package directory found to rename${NC}"
|
| 98 |
+
fi
|
| 99 |
+
|
| 100 |
+
# Step 5: Update main.py class name
|
| 101 |
+
echo "π Updating main.py class name..."
|
| 102 |
+
if [ -f "$PACKAGE_NAME/main.py" ]; then
|
| 103 |
+
# Update class name (use PascalCase class name)
|
| 104 |
+
sed -i.bak "s/class ExampleApp/class ${CLASS_NAME}App/g" "$PACKAGE_NAME/main.py"
|
| 105 |
+
sed -i.bak "s/class ReachyMiniNewAppTuto/class ${CLASS_NAME}App/g" "$PACKAGE_NAME/main.py"
|
| 106 |
+
|
| 107 |
+
echo -e "${GREEN}β main.py class name updated to ${CLASS_NAME}App${NC}"
|
| 108 |
+
else
|
| 109 |
+
echo -e "${YELLOW}Warning: main.py not found in $PACKAGE_NAME directory${NC}"
|
| 110 |
+
fi
|
| 111 |
+
|
| 112 |
+
# Step 6: Clean up backup files
|
| 113 |
+
echo "π§Ή Cleaning up backup files..."
|
| 114 |
+
find . -name "*.bak" -delete
|
| 115 |
+
echo -e "${GREEN}β Backup files cleaned up${NC}"
|
| 116 |
+
|
| 117 |
+
# Step 7: Final summary
|
| 118 |
+
echo ""
|
| 119 |
+
echo -e "${GREEN}π Setup complete!${NC}"
|
| 120 |
+
echo "=================================="
|
| 121 |
+
echo "Your new Reachy Mini app '$REPO_NAME' is ready!"
|
| 122 |
+
echo ""
|
| 123 |
+
echo "Generated names:"
|
| 124 |
+
echo " π¦ Package: $PACKAGE_NAME"
|
| 125 |
+
echo " π·οΈ Class: ${CLASS_NAME}App"
|
| 126 |
+
echo " π§ Entry point: $ENTRY_POINT_NAME"
|
| 127 |
+
echo ""
|
| 128 |
+
echo "Next steps:"
|
| 129 |
+
echo "1. Review the updated files"
|
| 130 |
+
echo "2. Install dependencies: pip install -e ."
|
| 131 |
+
echo "3. Test your app: $ENTRY_POINT_NAME"
|
| 132 |
+
echo "4. Commit and push to your repository"
|
| 133 |
+
echo ""
|
| 134 |
+
echo -e "${YELLOW}Happy coding with Reachy Mini! π€${NC}"
|