forgegit 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,209 @@
1
+ @echo off
2
+ setlocal EnableDelayedExpansion
3
+ chcp 65001 >nul 2>nul
4
+
5
+ cd /d "%~dp0..\.."
6
+
7
+ REM --- Colores ANSI ---
8
+ for /F %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
9
+ if "!ESC!"=="" (
10
+ set "C_CY=" & set "C_BC=" & set "C_GR=" & set "C_YE="
11
+ set "C_RE=" & set "C_GY=" & set "C_WH=" & set "C_RS="
12
+ ) else (
13
+ set "C_CY=!ESC![36m" & set "C_BC=!ESC![96m"
14
+ set "C_GR=!ESC![32m" & set "C_YE=!ESC![33m"
15
+ set "C_RE=!ESC![31m" & set "C_GY=!ESC![90m"
16
+ set "C_WH=!ESC![97m" & set "C_RS=!ESC![0m"
17
+ )
18
+
19
+ echo.
20
+ echo !C_CY!============================================!C_RS!
21
+ echo !C_BC! SERVE!C_RS! !C_GY!- Iniciar servidor de desarrollo!C_RS!
22
+ echo !C_CY!============================================!C_RS!
23
+ echo.
24
+
25
+ REM ============================================================
26
+ REM DETECCION DE STACK
27
+ REM ============================================================
28
+ set "STACK="
29
+ set "CMD="
30
+ set "NEEDS_PYTHON=0"
31
+ set "NEEDS_NODE=0"
32
+ set "PORT="
33
+
34
+ REM --- Node.js: package.json ---
35
+ if exist "package.json" (
36
+ findstr /C:"\"dev\"" package.json >nul 2>nul
37
+ if not errorlevel 1 (
38
+ set "STACK=Node.js (npm run dev)"
39
+ set "CMD=npm run dev"
40
+ set "NEEDS_NODE=1"
41
+ goto :detected
42
+ )
43
+ findstr /C:"\"start\"" package.json >nul 2>nul
44
+ if not errorlevel 1 (
45
+ set "STACK=Node.js (npm start)"
46
+ set "CMD=npm start"
47
+ set "NEEDS_NODE=1"
48
+ goto :detected
49
+ )
50
+ )
51
+
52
+ REM --- Django ---
53
+ if exist "manage.py" (
54
+ set "STACK=Django"
55
+ set "NEEDS_PYTHON=1"
56
+ call :find_free_port 8000
57
+ set "CMD=python manage.py runserver !PORT!"
58
+ goto :detected
59
+ )
60
+
61
+ REM --- Python simple ---
62
+ if exist "app.py" (
63
+ set "STACK=Python (app.py)"
64
+ set "NEEDS_PYTHON=1"
65
+ set "CMD=python app.py"
66
+ goto :detected
67
+ )
68
+ if exist "main.py" (
69
+ set "STACK=Python (main.py)"
70
+ set "NEEDS_PYTHON=1"
71
+ set "CMD=python main.py"
72
+ goto :detected
73
+ )
74
+
75
+ REM --- Node.js simple (server.js) ---
76
+ if exist "server.js" (
77
+ set "STACK=Node.js (server.js)"
78
+ set "NEEDS_NODE=1"
79
+ set "CMD=node server.js"
80
+ goto :detected
81
+ )
82
+
83
+ REM --- Rust ---
84
+ if exist "Cargo.toml" (
85
+ set "STACK=Rust (cargo)"
86
+ set "CMD=cargo run"
87
+ goto :detected
88
+ )
89
+
90
+ REM --- Go ---
91
+ if exist "go.mod" (
92
+ set "STACK=Go"
93
+ set "CMD=go run ."
94
+ goto :detected
95
+ )
96
+
97
+ REM --- Docker Compose ---
98
+ if exist "docker-compose.yml" (
99
+ set "STACK=Docker Compose"
100
+ set "CMD=docker-compose up"
101
+ goto :detected
102
+ )
103
+ if exist "docker-compose.yaml" (
104
+ set "STACK=Docker Compose"
105
+ set "CMD=docker-compose up"
106
+ goto :detected
107
+ )
108
+
109
+ REM --- HTML estatico: NODE primero, PYTHON fallback ---
110
+ if exist "index.html" (
111
+ call :find_free_port 8080
112
+ where node >nul 2>nul
113
+ if not errorlevel 1 (
114
+ set "STACK=HTML estatico (Node.js)"
115
+ set "NEEDS_NODE=1"
116
+ set "CMD=node .forge\serve-static.js !PORT!"
117
+ goto :detected
118
+ )
119
+ where python >nul 2>nul
120
+ if not errorlevel 1 (
121
+ set "STACK=HTML estatico (Python)"
122
+ set "NEEDS_PYTHON=1"
123
+ set "CMD=python -m http.server !PORT!"
124
+ goto :detected
125
+ )
126
+ echo !C_RE![X]!C_RS! No hay Node.js ni Python para servir HTML.
127
+ echo !C_GY!Instala Node.js: https://nodejs.org!C_RS!
128
+ echo !C_GY!O Python: https://python.org!C_RS!
129
+ pause
130
+ goto :end
131
+ )
132
+
133
+ REM --- No detectado ---
134
+ echo !C_YE![!]!C_RS! No se detecto stack automaticamente.
135
+ echo.
136
+ echo !C_GY!Archivos buscados:!C_RS!
137
+ echo - package.json Node.js
138
+ echo - manage.py Django
139
+ echo - app.py / main.py Flask / FastAPI
140
+ echo - server.js Node.js simple
141
+ echo - Cargo.toml Rust
142
+ echo - go.mod Go
143
+ echo - docker-compose.yml Docker
144
+ echo - index.html HTML estatico
145
+ echo.
146
+ pause
147
+ goto :end
148
+
149
+ :detected
150
+ REM --- Verificar dependencias ---
151
+ if "!NEEDS_PYTHON!"=="1" (
152
+ where python >nul 2>nul
153
+ if errorlevel 1 (
154
+ echo !C_RE![X]!C_RS! Python no esta instalado.
155
+ echo !C_GY!Descarga: https://python.org!C_RS!
156
+ pause
157
+ goto :end
158
+ )
159
+ )
160
+ if "!NEEDS_NODE!"=="1" (
161
+ where node >nul 2>nul
162
+ if errorlevel 1 (
163
+ echo !C_RE![X]!C_RS! Node.js no esta instalado.
164
+ echo !C_GY!Descarga: https://nodejs.org!C_RS!
165
+ pause
166
+ goto :end
167
+ )
168
+ )
169
+
170
+ REM --- Mostrar info ---
171
+ echo !C_CY!-!C_RS! !C_GY!Stack:!C_RS! !C_WH!!STACK!!C_RS!
172
+ if not "!PORT!"=="" echo !C_CY!-!C_RS! !C_GY!Puerto:!C_RS! !C_WH!!PORT!!C_RS!
173
+ echo !C_CY!-!C_RS! !C_GY!Comando:!C_RS! !C_WH!!CMD!!C_RS!
174
+ echo.
175
+
176
+ REM --- Confirmar ---
177
+ set "CONFIRM="
178
+ set /p "CONFIRM= !C_BC!Ejecutar servidor?!C_RS! !C_GY![S/n]!C_RS!: "
179
+ if /i "!CONFIRM!"=="n" goto :end
180
+
181
+ echo.
182
+ echo !C_GR!Iniciando servidor...!C_RS!
183
+ echo !C_GY!Ctrl+C para detener!C_RS!
184
+ echo.
185
+
186
+ REM --- Ejecutar ---
187
+ !CMD!
188
+
189
+ goto :end
190
+
191
+ :end
192
+ endlocal
193
+ exit /b 0
194
+
195
+ REM ============================================================
196
+ REM :find_free_port - Encuentra puerto libre desde %1
197
+ REM Prueba %1, %1+1, ... hasta %1+20
198
+ REM ============================================================
199
+ :find_free_port
200
+ set "PORT=%~1"
201
+ set /a "MAX=%~1 + 20"
202
+ :fp_loop
203
+ netstat -an 2>nul | findstr ":!PORT! " >nul 2>nul
204
+ if errorlevel 1 goto :fp_found
205
+ set /a PORT+=1
206
+ if !PORT! LEQ !MAX! goto :fp_loop
207
+ set "PORT=%~1"
208
+ :fp_found
209
+ goto :eof