Skip to main content

๐Ÿ“œ Documentation Scripts Guide

Automated setup and management for your documentation website


๐ŸŽฏ Available Scriptsโ€‹

๐Ÿš€ setup-website.sh (Advanced Bash Script)โ€‹

Full-featured script with error checking, colored output, and deployment guidance

./setup-website.sh [command]

Commands:

  • setup - Install dependencies and check prerequisites
  • dev - Start development server with hot reload
  • build - Build static site for production
  • preview - Preview built site locally
  • deploy - Deployment guidance for GitHub Pages
  • clean - Clean build artifacts and cache
  • help - Show detailed help

๐Ÿ“ฆ npm Scripts (Simple & Cross-Platform)โ€‹

Quick npm-based commands for common tasks

npm run [command]

Commands:

  • setup - Quick dependency installation
  • dev - Start development server
  • build - Build for production
  • deploy - Build + deployment info
  • clean - Clean build artifacts

๐Ÿ”„ When to Use Whichโ€‹

Use npm Scripts When:โ€‹

โœ… You want simple, cross-platform commands
โœ… You're familiar with npm workflow
โœ… You don't need detailed progress feedback
โœ… You're on Windows or prefer npm

Use Bash Script When:โ€‹

โœ… You want detailed progress information
โœ… You need comprehensive error checking
โœ… You want deployment guidance
โœ… You prefer rich terminal output
โœ… You're on macOS/Linux


โšก Quick Referenceโ€‹

First Time Setupโ€‹

# Option A: npm (simple)
cd docs
npm run setup

# Option B: script (detailed)
cd docs
./setup-website.sh setup

Developmentโ€‹

# Option A: npm
npm run dev

# Option B: script
./setup-website.sh dev

Production Buildโ€‹

# Option A: npm
npm run build

# Option B: script
./setup-website.sh build

Deploymentโ€‹

# Option A: npm (just builds)
npm run deploy

# Option B: script (guidance + git integration)
./setup-website.sh deploy

๐ŸŽจ Script Featuresโ€‹

setup-website.sh Features:โ€‹

  • ๐ŸŽจ Colored output with emojis for better UX
  • โœ… Prerequisites checking (Node.js version, location)
  • ๐Ÿ“Š Build statistics (file count, size)
  • ๐Ÿš€ Git integration for deployment
  • ๐Ÿงน Interactive cleanup with confirmations
  • โŒ Error handling with helpful messages

npm Scripts Features:โ€‹

  • โšก Fast execution with minimal overhead
  • ๐ŸŒ Cross-platform compatibility
  • ๐Ÿ“ Simple output with status emojis
  • ๐Ÿ”„ Standard npm workflow integration

๐Ÿ› ๏ธ Customizationโ€‹

Adding New Commandsโ€‹

To npm scripts (edit package.json):

"scripts": {
"your-command": "echo '๐ŸŽฏ Your command' && your-actual-command"
}

To bash script (edit setup-website.sh):

# Add to the case statement
"your-command")
your_function
;;

Modifying Existing Commandsโ€‹

  • npm scripts: Edit the scripts section in package.json
  • bash script: Edit the corresponding function in setup-website.sh

๐Ÿ”ง Troubleshooting Scriptsโ€‹

Script Permission Issuesโ€‹

chmod +x setup-website.sh

npm Scripts Not Workingโ€‹

# Verify package.json exists
ls -la package.json

# Reinstall if needed
rm -rf node_modules package-lock.json
npm install

Script Path Issuesโ€‹

# Ensure you're in the docs directory
pwd # Should end with /docs
cd docs # If not

๐Ÿ“Š Performance Comparisonโ€‹

Tasknpm ScriptsBash ScriptWinner
Speedโšก Fast๐ŸŒ Slower (checks)npm
Feedback๐Ÿ“ Basic๐ŸŽจ RichScript
Error HandlingโŒ Basicโœ… ComprehensiveScript
Cross-Platformโœ… Yesโš ๏ธ Unix onlynpm
Deployment Help๐Ÿ“ Basic๐Ÿš€ GuidedScript

For Developers:โ€‹

# Daily development
npm run dev

# Building for production
./setup-website.sh build # Better feedback

# Deploying
./setup-website.sh deploy # Guided process

For CI/CD:โ€‹

# Automated builds (use npm for consistency)
npm run setup
npm run build

For New Contributors:โ€‹

# First time (use script for guidance)
./setup-website.sh setup
./setup-website.sh help


๐ŸŽ‰ Both approaches get you to the same amazing documentation website - choose the one that fits your workflow best!