-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphx
More file actions
executable file
·107 lines (88 loc) · 2.34 KB
/
Copy pathphx
File metadata and controls
executable file
·107 lines (88 loc) · 2.34 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env bash
# HyperScript CLI
# Main executable for building and managing HyperScript projects
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Show help
show_help() {
cat << HELP
HyperScript CLI - PHP to WebAssembly Framework
Usage:
phx <command> [options]
Commands:
build Build the current project
serve [port] Build and serve the project (default port: 8080)
new <name> Create a new HyperScript project (coming soon)
help Show this help message
version Show version information
Examples:
phx build # Build the project
phx serve # Build and serve on port 8080
phx serve 3000 # Build and serve on port 3000
phx help # Show this help
For more information, visit: https://github.com/lucasacoutinho/HypeScript
HELP
}
# Show version
show_version() {
echo "HyperScript v0.1.0"
echo "PHP to WebAssembly Framework"
}
# Build project
build_project() {
echo -e "${BLUE}Building HyperScript project...${NC}"
if [ ! -f "$SCRIPT_DIR/.phx/build.sh" ]; then
echo -e "${RED}Error: Not a HyperScript project (no .phx/build.sh found)${NC}"
exit 1
fi
export PATH="$HOME/.dotnet:$PATH"
bash "$SCRIPT_DIR/.phx/build.sh"
}
# Serve project
serve_project() {
local port=${1:-8080}
# Build first
build_project
if [ ! -d "$SCRIPT_DIR/dist" ]; then
echo -e "${RED}Error: Build output not found${NC}"
exit 1
fi
echo ""
echo -e "${GREEN}Starting development server...${NC}"
echo -e "${BLUE}URL: ${NC}http://localhost:$port"
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
echo ""
cd "$SCRIPT_DIR/dist"
python3 -m http.server "$port"
}
# Main command handler
case "${1:-}" in
build)
build_project
;;
serve)
serve_project "${2:-8080}"
;;
new)
echo -e "${YELLOW}The 'new' command is coming soon!${NC}"
exit 1
;;
version|--version|-v)
show_version
;;
help|--help|-h|"")
show_help
;;
*)
echo -e "${RED}Error: Unknown command '${1}'${NC}"
echo ""
show_help
exit 1
;;
esac