forked from Brotherta/wam-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_dev.cmd
More file actions
190 lines (160 loc) · 4.9 KB
/
run_dev.cmd
File metadata and controls
190 lines (160 loc) · 4.9 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
:<<"::CMDLITERAL"
@ECHO OFF
GOTO :WINDOWS
::CMDLITERAL
# -----------------------------------------------------------------------------
# LINUX / MAC / UNIX-LIKE (BASH) IMPLEMENTATION
# -----------------------------------------------------------------------------
cd "$(dirname "$0")" || exit 1
echo "Starting DAWIY Development Environment (Unix-like)..."
check_and_copy_env() {
local DIR=$1
if [ -f "$DIR/.env.example" ] && [ ! -f "$DIR/.env" ]; then
echo "Creating $DIR/.env from .env.example..."
cp "$DIR/.env.example" "$DIR/.env"
fi
}
check_and_install() {
local DIR=$1
local NAME=$2
echo "Checking $NAME dependencies..."
(
cd "$DIR" || { echo "Failed to enter directory $DIR"; exit 1; }
if ! npm ls --parseable --depth=0 >/dev/null 2>&1; then
echo "$NAME dependencies are missing. Installing..."
npm install
else
echo "$NAME dependencies are up to date."
fi
)
}
# ---------------------------------------------------------
# [New] Function: Browser Selection
# ---------------------------------------------------------
select_browser() {
echo "------------------------------------------------"
echo "Select a browser to open the application:"
# Reset options
options=()
# Check common macOS paths
[ -d "/Applications/Google Chrome.app" ] && options+=("Google Chrome")
[ -d "/Applications/Firefox.app" ] && options+=("Firefox")
[ -d "/Applications/Microsoft Edge.app" ] && options+=("Microsoft Edge")
# Default options
options+=("Safari" "System Default")
PS3="Enter number > "
select opt in "${options[@]}"
do
case $opt in
"Google Chrome") export BROWSER="Google Chrome"; break ;;
"Firefox") export BROWSER="firefox"; break ;;
"Microsoft Edge") export BROWSER="Microsoft Edge"; break ;;
"Safari") export BROWSER="Safari"; break ;;
"System Default") unset BROWSER; break ;;
*) echo "Invalid option.";;
esac
done
echo "Target Browser: ${BROWSER:-System Default}"
}
# Execution Flow
check_and_copy_env "public"
check_and_copy_env "bank"
check_and_install "." "Root"
check_and_install "public" "Public"
check_and_install "bank" "Bank"
check_and_install "bank/pedalboard2" "Pedalboard2"
# Call the function
select_browser
npm run dev
exit 0
:WINDOWS
rem -----------------------------------------------------------------------------
rem WINDOWS (BATCH) IMPLEMENTATION
rem -----------------------------------------------------------------------------
setlocal
echo Starting DAWIY Development Environment (Windows)...
call :CheckAndCopyEnv "public"
call :CheckAndCopyEnv "bank"
call :CheckAndInstall "." "Root"
call :CheckAndInstall "public" "Public"
call :CheckAndInstall "bank" "Bank"
call :CheckAndInstall "bank\pedalboard2" "Pedalboard2"
rem Call the browser selection label
call :SelectBrowser
rem Run the integrated dev command
call npm run dev
goto :eof
rem ---------------------------------------------------------
rem [New] Label: Browser Selection
rem ---------------------------------------------------------
:SelectBrowser
echo.
echo ------------------------------------------------
echo Select a browser to open the application:
set "opt_chrome="
set "opt_firefox="
set "opt_edge="
rem Check for browsers in standard Windows paths
if exist "C:\Program Files\Google\Chrome\Application\chrome.exe" (
echo [1] Google Chrome
set "opt_chrome=1"
)
if exist "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" (
echo [1] Google Chrome
set "opt_chrome=1"
)
if exist "C:\Program Files\Mozilla Firefox\firefox.exe" (
echo [2] Firefox
set "opt_firefox=1"
)
if exist "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" (
echo [3] Microsoft Edge
set "opt_edge=1"
)
echo [4] System Default
:AskBrowser
set /p "choice=Enter number > "
if "%choice%"=="1" if defined opt_chrome (
set "BROWSER=chrome"
goto :BrowserSelected
)
if "%choice%"=="2" if defined opt_firefox (
set "BROWSER=firefox"
goto :BrowserSelected
)
if "%choice%"=="3" if defined opt_edge (
set "BROWSER=msedge"
goto :BrowserSelected
)
if "%choice%"=="4" (
set "BROWSER="
goto :BrowserSelected
)
echo Invalid choice or browser not installed.
goto :AskBrowser
:BrowserSelected
echo Target Browser Set.
exit /b 0
:CheckAndCopyEnv
set "DIR=%~1"
if exist "%DIR%\.env.example" (
if not exist "%DIR%\.env" (
echo Creating %DIR%\.env from .env.example...
copy "%DIR%\.env.example" "%DIR%\.env" >nul
)
)
exit /b 0
:CheckAndInstall
set "DIR=%~1"
set "NAME=%~2"
echo Checking %NAME% dependencies...
pushd "%DIR%"
call npm ls --parseable --depth=0 >nul 2>&1
if %errorlevel% neq 0 (
echo %NAME% dependencies are missing or out of sync. Installing...
call npm install
) else (
echo %NAME% dependencies are up to date.
)
popd
exit /b 0