-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·78 lines (65 loc) · 2.6 KB
/
setup.sh
File metadata and controls
executable file
·78 lines (65 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# SPPU Study Material Generator - Automated Setup Script
# Author: Parth Sali
# Description: Automates the setup and generation process using config.js
set -e
# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${BLUE}"
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ SPPU Study Material Generator - Automated Run ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo -e "${NC}"
# 1. Check if config.js exists
if [ ! -f config.js ]; then
echo -e "${RED}❌ config.js not found!${NC}"
echo "Please copy the template and configure it:"
echo " cp config.example.js config.js"
exit 1
fi
echo -e "${BLUE}ℹ️ Reading configuration from config.js...${NC}"
# 2. Validate config values
# We use node to require the config and check if variables are set
CONFIG_CHECK=$(node -e "
try {
const config = require('./config.js');
if (!config.BRANCH_CODE) throw new Error('BRANCH_CODE missing');
if (!config.TELEGRAM_GROUP) throw new Error('TELEGRAM_GROUP missing');
console.log(config.BRANCH_CODE);
} catch (e) {
console.error(e.message);
process.exit(1);
}
")
if [ $? -ne 0 ]; then
echo -e "${RED}❌ Invalid config.js configuration:${NC}"
echo "$CONFIG_CHECK"
exit 1
fi
echo -e "${GREEN}✅ Configuration valid. Target Branch: $CONFIG_CHECK${NC}\n"
# 3. Check if pnpm is installed
if ! command -v pnpm &> /dev/null; then
echo -e "${RED}❌ pnpm is not installed.${NC}"
echo "Please install it globally: npm install -g pnpm"
exit 1
fi
# 4. Install dependencies
echo -e "${BLUE}📦 Installing dependencies in setup/...${NC}"
cd setup
pnpm install --silent
cd ..
echo -e "${GREEN}✅ Dependencies installed${NC}\n"
# 5. Generate documentation
echo -e "${BLUE}🚀 Generating documentation...${NC}"
cd setup
pnpm generate
cd ..
echo -e "\n${GREEN}"
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ Generation Complete! 🎉 ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo -e "${NC}"
echo -e "${BLUE}📂 Check README.md and years/ folder for output.${NC}\n"