forked from simongonzalezdc/EvoLab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch-game.applescript
More file actions
105 lines (91 loc) · 4.48 KB
/
Copy pathlaunch-game.applescript
File metadata and controls
105 lines (91 loc) · 4.48 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
-- EvoLab Game Launcher (AppleScript)
-- This creates a double-clickable application to launch EvoLab
on run
set projectPath to "/Volumes/External Drive/02_DEVELOPMENT/Active Projects/Vibecoding/EvoLab"
-- Setup PATH and check for Node.js in common locations
set nodePath to ""
set commonPaths to {"/opt/homebrew/bin/node", "/usr/local/bin/node", "/usr/bin/node"}
-- Check common installation paths
repeat with testPath in commonPaths
try
do shell script "test -x " & quoted form of testPath
set nodePath to testPath
exit repeat
end try
end repeat
-- If not found in common paths, try which with proper PATH
if nodePath is "" then
try
set nodePath to do shell script "export PATH=\"/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:$PATH\" && which node"
on error
display dialog "Node.js is not installed. Please install Node.js 18+ from https://nodejs.org/" buttons {"OK"} default button "OK" with icon stop
return
end try
end if
-- Check if npm is available (usually in same directory as node)
set npmPath to ""
try
set npmDir to do shell script "dirname " & quoted form of nodePath
set npmPath to npmDir & "/npm"
do shell script "test -x " & quoted form of npmPath
on error
-- Try to find npm in PATH
try
set npmPath to do shell script "export PATH=\"/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:$PATH\" && which npm"
on error
display dialog "npm is not installed. Please install Node.js which includes npm." buttons {"OK"} default button "OK" with icon stop
return
end try
end if
-- Check if dependencies need to be installed or updated
set needInstall to false
set installMessage to ""
-- Check if node_modules doesn't exist
try
do shell script "test -d " & quoted form of (projectPath & "/node_modules")
on error
set needInstall to true
set installMessage to "Installing dependencies for the first time. This may take a few minutes..."
end try
-- Check if package.json is newer than node_modules (dependencies may have changed)
if not needInstall then
try
do shell script "test " & quoted form of (projectPath & "/package.json") & " -nt " & quoted form of (projectPath & "/node_modules") & " && exit 0 || exit 1"
set needInstall to true
set installMessage to "Dependencies need to be updated. Installing..."
end try
end if
-- Check if package-lock.json is newer than node_modules
if not needInstall then
try
do shell script "test -f " & quoted form of (projectPath & "/package-lock.json") & " && test " & quoted form of (projectPath & "/package-lock.json") & " -nt " & quoted form of (projectPath & "/node_modules") & " && exit 0 || exit 1"
set needInstall to true
set installMessage to "Dependencies need to be updated. Installing..."
end try
end if
-- Check if node_modules is incomplete (missing key files)
if not needInstall then
try
do shell script "test ! -f " & quoted form of (projectPath & "/node_modules/.bin/vite") & " && exit 0 || exit 1"
set needInstall to true
set installMessage to "Dependencies appear to be incomplete. Reinstalling..."
end try
end if
-- Install dependencies if needed
if needInstall then
display dialog installMessage buttons {"OK"} default button "OK" with icon note
try
do shell script "export PATH=\"/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:$PATH\" && cd " & quoted form of projectPath & " && npm install"
on error
display dialog "Failed to install dependencies. Please check your internet connection and try again." buttons {"OK"} default button "OK" with icon stop
return
end try
end if
-- Open browser after delay
do shell script "sleep 3 && open http://localhost:5173" without altering line endings
-- Start the development server in a new Terminal window with proper PATH
tell application "Terminal"
activate
do script "export PATH=\"/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/local/sbin:$PATH\" && cd " & quoted form of projectPath & " && npm run dev"
end tell
end run