| #!/bin/bash |
|
|
| |
| |
|
|
| |
| RED='\033[0;31m' |
| GREEN='\033[0;32m' |
| YELLOW='\033[1;33m' |
| BLUE='\033[0;34m' |
| CYAN='\033[0;36m' |
| NC='\033[0m' |
|
|
| |
| echo -e "${BLUE}" |
| cat << "EOF" |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| β β |
| β π Smart Academic Report Generator β |
| β Professional PhD-Level Reports Installer β |
| β β |
| ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
| EOF |
| echo -e "${NC}" |
|
|
| |
| if [ -z "$BASH_VERSION" ]; then |
| echo -e "${RED}β This script must be run with bash${NC}" |
| exit 1 |
| fi |
|
|
| echo -e "${CYAN}Starting installation...${NC}\n" |
|
|
| |
| echo -e "${YELLOW}[1/6]${NC} Checking Node.js installation..." |
| if command -v node &> /dev/null; then |
| NODE_VERSION=$(node --version) |
| echo -e "${GREEN}β
Node.js is installed: $NODE_VERSION${NC}" |
| |
| |
| REQUIRED_VERSION="16.0.0" |
| CURRENT_VERSION=$(node --version | cut -d'v' -f2) |
| |
| if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$CURRENT_VERSION" | sort -V | head -n1)" = "$REQUIRED_VERSION" ]; then |
| echo -e "${GREEN} Version is compatible (>= v16.0.0)${NC}" |
| else |
| echo -e "${YELLOW} β οΈ Version might be too old. Recommended: >= v16.0.0${NC}" |
| fi |
| else |
| echo -e "${RED}β Node.js is not installed${NC}" |
| echo -e "${YELLOW} Please install Node.js from: https://nodejs.org/${NC}" |
| exit 1 |
| fi |
|
|
| |
| echo -e "\n${YELLOW}[2/6]${NC} Checking npm installation..." |
| if command -v npm &> /dev/null; then |
| NPM_VERSION=$(npm --version) |
| echo -e "${GREEN}β
npm is installed: v$NPM_VERSION${NC}" |
| else |
| echo -e "${RED}β npm is not installed${NC}" |
| echo -e "${YELLOW} npm should come with Node.js. Please reinstall Node.js${NC}" |
| exit 1 |
| fi |
|
|
| |
| echo -e "\n${YELLOW}[3/6]${NC} Installing docx package..." |
| if npm list -g docx &> /dev/null; then |
| echo -e "${GREEN}β
docx is already installed globally${NC}" |
| else |
| echo -e "${CYAN} Installing docx globally...${NC}" |
| if npm install -g docx; then |
| echo -e "${GREEN}β
docx installed successfully${NC}" |
| else |
| echo -e "${YELLOW} β οΈ Global install failed. Trying local install...${NC}" |
| if npm install docx; then |
| echo -e "${GREEN}β
docx installed locally${NC}" |
| else |
| echo -e "${RED}β Failed to install docx${NC}" |
| exit 1 |
| fi |
| fi |
| fi |
|
|
| |
| echo -e "\n${YELLOW}[4/6]${NC} Verifying required files..." |
| REQUIRED_FILES=( |
| "generate-academic-report.js" |
| "sample-config.json" |
| "package.json" |
| "README.md" |
| "QUICKSTART.md" |
| "index.html" |
| ) |
|
|
| MISSING_FILES=0 |
| for file in "${REQUIRED_FILES[@]}"; do |
| if [ -f "$file" ]; then |
| echo -e "${GREEN} β
$file${NC}" |
| else |
| echo -e "${RED} β Missing: $file${NC}" |
| MISSING_FILES=$((MISSING_FILES + 1)) |
| fi |
| done |
|
|
| if [ $MISSING_FILES -gt 0 ]; then |
| echo -e "${RED}\nβ $MISSING_FILES required file(s) missing${NC}" |
| echo -e "${YELLOW} Please ensure all files are in the current directory${NC}" |
| exit 1 |
| fi |
|
|
| |
| echo -e "\n${YELLOW}[5/6]${NC} Setting up output directory..." |
| OUTPUT_DIR="/mnt/user-data/outputs" |
|
|
| if [ -d "$OUTPUT_DIR" ]; then |
| echo -e "${GREEN}β
Output directory exists: $OUTPUT_DIR${NC}" |
| else |
| echo -e "${CYAN} Creating output directory...${NC}" |
| if mkdir -p "$OUTPUT_DIR" 2>/dev/null; then |
| echo -e "${GREEN}β
Output directory created${NC}" |
| else |
| echo -e "${YELLOW} β οΈ Could not create $OUTPUT_DIR${NC}" |
| echo -e "${YELLOW} Will use current directory instead${NC}" |
| OUTPUT_DIR="./outputs" |
| mkdir -p "$OUTPUT_DIR" |
| fi |
| fi |
|
|
| |
| echo -e "\n${YELLOW}[6/6]${NC} Setting file permissions..." |
| chmod +x generate-academic-report.js 2>/dev/null |
| chmod +x test-suite.js 2>/dev/null |
| echo -e "${GREEN}β
Permissions set${NC}" |
|
|
| |
| echo -e "\n${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}" |
| echo -e "${GREEN}β β${NC}" |
| echo -e "${GREEN}β β
Installation completed successfully! β${NC}" |
| echo -e "${GREEN}β β${NC}" |
| echo -e "${GREEN}ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ${NC}" |
|
|
| |
| echo -e "\n${CYAN}π Next Steps:${NC}\n" |
| echo -e "${YELLOW}1.${NC} Test the installation:" |
| echo -e " ${CYAN}node generate-academic-report.js --config sample-config.json${NC}\n" |
|
|
| echo -e "${YELLOW}2.${NC} Run the test suite:" |
| echo -e " ${CYAN}node test-suite.js${NC}\n" |
|
|
| echo -e "${YELLOW}3.${NC} Create your first report:" |
| echo -e " ${CYAN}cp sample-config.json my-config.json${NC}" |
| echo -e " ${CYAN}# Edit my-config.json with your details${NC}" |
| echo -e " ${CYAN}node generate-academic-report.js --config my-config.json${NC}\n" |
|
|
| echo -e "${YELLOW}4.${NC} Open HTML interface:" |
| echo -e " ${CYAN}Open index.html in your web browser${NC}\n" |
|
|
| echo -e "${CYAN}π Documentation:${NC}" |
| echo -e " β’ README.md - Complete documentation" |
| echo -e " β’ QUICKSTART.md - Quick reference guide" |
| echo -e " β’ EXAMPLES.md - Usage examples & tutorials" |
|
|
| echo -e "\n${CYAN}π Happy Report Writing!${NC}\n" |
|
|
| |
| echo -e "${YELLOW}Would you like to run a test now? (y/n)${NC} " |
| read -r -n 1 response |
| echo |
|
|
| if [[ "$response" =~ ^[Yy]$ ]]; then |
| echo -e "\n${CYAN}Running test...${NC}\n" |
| node test-suite.js |
| |
| if [ $? -eq 0 ]; then |
| echo -e "\n${GREEN}β
Test passed! You're ready to generate reports.${NC}\n" |
| else |
| echo -e "\n${RED}β Test failed. Please check the error messages above.${NC}\n" |
| fi |
| else |
| echo -e "${YELLOW}Skipping test. Run 'node test-suite.js' anytime to verify.${NC}\n" |
| fi |
|
|
| exit 0 |
|
|