#!/bin/bash # Push templates to Hugging Face Spaces under hanzo-community # Prerequisites: # - Hugging Face CLI installed: pip install huggingface-hub # - Logged in: huggingface-cli login echo "🤗 Pushing templates to Hugging Face Spaces (hanzo-community)..." # Function to create and push a template to Hugging Face push_template() { local name=$1 local dir="templates-repos/$name" echo "📦 Processing $name..." if [ -d "$dir" ]; then cd "$dir" # Add README if it doesn't exist if [ ! -f "README.md" ]; then cat > README.md << EOF --- title: $name Template emoji: 🚀 colorFrom: gray colorTo: gray sdk: docker app_port: 3000 pinned: true --- # $name Template A Hanzo template for building modern applications. ## Features - Built with @hanzo/ui - Fully responsive - TypeScript support - Tailwind CSS styling - shadcn/ui components ## Installation \`\`\`bash npx create-hanzo-app --template $name \`\`\` ## Development \`\`\`bash npm install npm run dev \`\`\` ## Build \`\`\`bash npm run build \`\`\` Check out the [Hanzo Template Gallery](https://huggingface.co/spaces/hanzoai/gallery) for more templates. EOF fi # Add Dockerfile if it doesn't exist if [ ! -f "Dockerfile" ]; then cat > Dockerfile << 'EOF' FROM node:20-slim WORKDIR /app # Copy package files COPY package*.json ./ # Install dependencies RUN npm ci --only=production # Copy application files COPY . . # Build the application RUN npm run build # Expose port EXPOSE 3000 # Start the application CMD ["npm", "start"] EOF fi # Initialize git if not already if [ ! -d ".git" ]; then git init # Add gitignore if missing if [ ! -f ".gitignore" ]; then cat > .gitignore << 'GITEOF' node_modules .next .cache dist build .DS_Store *.log .env.local .env.*.local *.tsbuildinfo GITEOF fi git add . git commit -m "Initial commit for $name template" fi # Add Hugging Face remote git remote remove hf 2>/dev/null git remote add hf https://huggingface.co/spaces/hanzo-community/$name # Push to Hugging Face echo " Pushing to Hugging Face..." git push hf main --force cd ../.. echo " ✅ $name pushed successfully!" else echo " ⚠️ Directory $dir not found" fi } # List of templates templates=( "devforge" "mobilefirst" "saasify" "startupkit" "analyticsdash" "blog" "changelog" "portfolio" "ai-chat" "search" "ecommerce" "api-docs" ) # Check if huggingface-cli is installed if ! command -v huggingface-cli &> /dev/null; then echo "⚠️ huggingface-cli not found. Please install it:" echo " pip install huggingface-hub" echo " huggingface-cli login" exit 1 fi # Push each template for template in "${templates[@]}"; do push_template "$template" done echo "" echo "✅ All templates pushed to Hugging Face Spaces!" echo "" echo "📝 View your templates at:" echo " https://huggingface.co/hanzo-community" echo "" echo "🔗 Each template is available at:" for template in "${templates[@]}"; do echo " https://huggingface.co/spaces/hanzo-community/$template" done