-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·68 lines (62 loc) · 1.86 KB
/
run.sh
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
#!/bin/bash
# run.sh - Simple script to set up and run the project
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check for required tools
if ! command_exists npm; then
echo -e "${RED}Error: npm is not installed${NC}"
exit 1
fi
# Check for package.json
if [ ! -f "package.json" ]; then
echo -e "${RED}Error: package.json not found${NC}"
echo "Are you in the project root directory?"
exit 1
fi
# Install dependencies if node_modules doesn't exist
if [ ! -d "node_modules" ]; then
echo -e "${BLUE}Installing dependencies...${NC}"
npm install
else
echo -e "${GREEN}Dependencies already installed${NC}"
fi
# Parse command line arguments
if [ "$1" == "analyze" ]; then
shift
echo -e "${BLUE}Running analyzer...${NC}"
node src/analyze.js "$@"
elif [ "$1" == "serve" ]; then
shift
echo -e "${BLUE}Starting development server...${NC}"
node src/index.js "$@"
elif [ "$1" == "help" ] || [ "$1" == "" ]; then
echo -e "${BLUE}ReactStream CLI${NC}"
echo ""
echo "Usage:"
echo " ./run.sh analyze <component.js> [options]"
echo " ./run.sh serve <component.js> [options]"
echo ""
echo "Options for analyze:"
echo " --fix Attempt to automatically fix issues"
echo " --debug Show debug information"
echo " --verbose Show more detailed output"
echo ""
echo "Options for serve:"
echo " --port=<port> Specify the port to run the server on (default: 3000)"
echo ""
echo "Examples:"
echo " ./run.sh analyze MyComponent.js --debug"
echo " ./run.sh serve MyComponent.js --port=8080"
else
echo -e "${RED}Unknown command: $1${NC}"
echo "Use './run.sh help' for usage information"
exit 1
fi