68 lines
1.9 KiB
Bash
68 lines
1.9 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -e
|
||
|
|
||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
cd "${script_dir}"
|
||
|
|
||
|
echo "Docs directory: $script_dir"
|
||
|
|
||
|
# Function to check if a command exists
|
||
|
command_exists() {
|
||
|
command -v "$1" >/dev/null 2>&1
|
||
|
}
|
||
|
|
||
|
# Check operating system
|
||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||
|
echo "Detected macOS system"
|
||
|
|
||
|
# Check if Homebrew is installed
|
||
|
if ! command_exists brew; then
|
||
|
echo "Homebrew is not installed. Installing..."
|
||
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||
|
fi
|
||
|
|
||
|
# Install Node.js if not present
|
||
|
if ! command_exists node; then
|
||
|
echo "Node.js is not installed. Installing with Homebrew..."
|
||
|
brew install node
|
||
|
fi
|
||
|
|
||
|
# Install pnpm if not present
|
||
|
if ! command_exists pnpm; then
|
||
|
echo "pnpm is not installed. Installing with npm..."
|
||
|
npm install -g pnpm
|
||
|
fi
|
||
|
|
||
|
elif [[ "$OSTYPE" == "linux-gnu"* ]] && command_exists apt-get; then
|
||
|
echo "Detected Ubuntu system"
|
||
|
|
||
|
# Update package list
|
||
|
sudo apt-get update
|
||
|
|
||
|
# Install Node.js if not present
|
||
|
if ! command_exists node; then
|
||
|
echo "Node.js is not installed. Installing with apt..."
|
||
|
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
||
|
sudo apt-get install -y nodejs
|
||
|
fi
|
||
|
|
||
|
# Install pnpm if not present
|
||
|
if ! command_exists pnpm; then
|
||
|
echo "pnpm is not installed. Installing with npm..."
|
||
|
sudo npm install -g pnpm
|
||
|
fi
|
||
|
|
||
|
else
|
||
|
echo "Error: This script only supports macOS or Ubuntu systems"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "Installing dependencies..."
|
||
|
export PATH=${BASE}/node_modules/.bin:$PATH
|
||
|
|
||
|
pnpm install @docusaurus/core @docusaurus/preset-classic @docusaurus/theme-mermaid
|
||
|
pnpm install react-player
|
||
|
pnpm install --save-dev @types/node @docusaurus/types @docusaurus/preset-classic prism-react-renderer redocusaurus
|
||
|
pnpm install
|