gallery / setup-template-repos.sh
Hanzo Dev
Add git submodule architecture for templates with Hugging Face integration
366fe97
#!/bin/bash
# Setup Template Repositories as Git Submodules
# This allows each template to be managed independently while being included in the gallery
echo "πŸ“¦ Setting up template repositories..."
# Array of template names and their source directories
declare -A templates=(
["devforge"]="../devtool"
["mobilefirst"]="../mobile"
["saasify"]="../saas"
["startupkit"]="../startup"
["analyticsdash"]="../analytics"
["blog"]="../blog"
["changelog"]="../changelog"
["portfolio"]="../portfolio"
)
# Create templates-repos directory if it doesn't exist
mkdir -p templates-repos
# Copy existing templates to repos directory for now (until proper GitHub repos are created)
for template in "${!templates[@]}"; do
src="${templates[$template]}"
dest="templates-repos/$template"
echo "πŸ“‹ Setting up $template..."
if [ -d "$src" ]; then
# Copy template if source exists
if [ ! -d "$dest" ]; then
echo " Copying from $src to $dest..."
cp -r "$src" "$dest"
# Initialize as git repo
cd "$dest"
git init
echo "# $template Template" > README.md
echo "" >> README.md
echo "A Hanzo template for building modern applications." >> README.md
echo "" >> README.md
echo "## Installation" >> README.md
echo '```bash' >> README.md
echo "npx create-hanzo-app --template $template" >> README.md
echo '```' >> README.md
# Add gitignore
cat > .gitignore << EOF
node_modules
.next
.env.local
.DS_Store
*.log
dist
build
EOF
git add .
git commit -m "Initial commit for $template template"
cd ../..
else
echo " βœ“ $template already exists"
fi
else
echo " ⚠️ Source $src not found, creating placeholder..."
mkdir -p "$dest"
cd "$dest"
# Create a minimal package.json
cat > package.json << EOF
{
"name": "@hanzo/template-$template",
"version": "1.0.0",
"description": "Hanzo $template template",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^15.3.5",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"@hanzo/ui": "latest"
}
}
EOF
# Create basic structure
mkdir -p app
cat > app/page.tsx << EOF
export default function HomePage() {
return (
<div className="min-h-screen flex items-center justify-center">
<h1 className="text-4xl font-bold">$template Template</h1>
</div>
)
}
EOF
git init
git add .
git commit -m "Initial placeholder for $template template"
cd ../..
fi
done
# Add new AI templates
echo "πŸ“‹ Setting up new AI templates..."
# Create AI chat template
if [ ! -d "templates-repos/ai-chat" ]; then
echo " Creating AI Chat template..."
cp -r "../ai-chat-interface" "templates-repos/ai-chat" 2>/dev/null || mkdir -p "templates-repos/ai-chat"
fi
# Create search template
if [ ! -d "templates-repos/search" ]; then
echo " Creating Search template..."
mkdir -p "templates-repos/search"
fi
# Create e-commerce template
if [ ! -d "templates-repos/ecommerce" ]; then
echo " Creating E-commerce template..."
cp -r "../ecommerce-storefront" "templates-repos/ecommerce" 2>/dev/null || mkdir -p "templates-repos/ecommerce"
fi
# Create API docs template
if [ ! -d "templates-repos/api-docs" ]; then
echo " Creating API Docs template..."
mkdir -p "templates-repos/api-docs"
fi
echo ""
echo "βœ… Template repositories setup complete!"
echo ""
echo "πŸ“ Next steps:"
echo "1. Push each template to Hugging Face Spaces:"
echo " ./push-to-huggingface.sh"
echo ""
echo "2. Or manually push individual templates:"
echo " cd templates-repos/[template-name]"
echo " git remote add hf https://huggingface.co/spaces/hanzo-community/template-[name]"
echo " git push hf main"
echo ""
echo "3. Add as submodules to gallery:"
echo " git submodule add https://huggingface.co/spaces/hanzo-community/template-[name] templates-repos/[name]"
echo ""
echo "4. Gallery will automatically load from templates-repos/"