๐ 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 prerequisitesdev
- Start development server with hot reloadbuild
- Build static site for productionpreview
- Preview built site locallydeploy
- Deployment guidance for GitHub Pagesclean
- Clean build artifacts and cachehelp
- Show detailed help
๐ฆ npm Scripts (Simple & Cross-Platform)โ
Quick npm-based commands for common tasks
npm run [command]
Commands:
setup
- Quick dependency installationdev
- Start development serverbuild
- Build for productiondeploy
- Build + deployment infoclean
- 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 inpackage.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โ
Task | npm Scripts | Bash Script | Winner |
---|---|---|---|
Speed | โก Fast | ๐ Slower (checks) | npm |
Feedback | ๐ Basic | ๐จ Rich | Script |
Error Handling | โ Basic | โ Comprehensive | Script |
Cross-Platform | โ Yes | โ ๏ธ Unix only | npm |
Deployment Help | ๐ Basic | ๐ Guided | Script |
๐ฏ Recommended Workflowโ
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
๐ Related Documentationโ
- QUICK_START.md - Fastest way to get started
- WEBSITE_SETUP.md - Complete setup documentation
- package.json - npm scripts configuration
- setup-website.sh - Bash script source code
๐ Both approaches get you to the same amazing documentation website - choose the one that fits your workflow best!