forgegit 1.4.0 → 1.5.0

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.
Files changed (30) hide show
  1. package/.forge/commands/.gitkeep +0 -0
  2. package/.forge/commands/abrir.cmd +51 -0
  3. package/.forge/commands/auditar.cmd +340 -0
  4. package/.forge/commands/historial.cmd +85 -0
  5. package/.forge/commands/push.cmd +97 -0
  6. package/.forge/commands/save.cmd +73 -0
  7. package/{config.cmd → .forge/config.cmd} +1 -1
  8. package/.forge/init.cmd +173 -0
  9. package/.forge/lib/.gitkeep +0 -0
  10. package/.forge/templates/.gitkeep +0 -0
  11. package/.forge/templates/serve-static.js +86 -0
  12. package/.forge/templates/serve.cmd.tpl +209 -0
  13. package/.forge/templates/snapshots.cmd.tpl +329 -0
  14. package/forge.cmd +120 -0
  15. package/package.json +29 -36
  16. package/init.cmd +0 -200
  17. /package/{templates/serve.cmd.tpl → .forge/commands/serve.cmd} +0 -0
  18. /package/{templates/snapshots.cmd.tpl → .forge/commands/snapshots.cmd} +0 -0
  19. /package/{lib → .forge/lib}/git-ops.cmd +0 -0
  20. /package/{lib → .forge/lib}/templates.cmd +0 -0
  21. /package/{lib → .forge/lib}/ui.cmd +0 -0
  22. /package/{templates → .forge}/serve-static.js +0 -0
  23. /package/{templates → .forge/templates}/abrir.cmd.tpl +0 -0
  24. /package/{templates → .forge/templates}/auditar.cmd.tpl +0 -0
  25. /package/{templates → .forge/templates}/forge.cmd.tpl +0 -0
  26. /package/{templates → .forge/templates}/gitignore.tpl +0 -0
  27. /package/{templates → .forge/templates}/historial.cmd.tpl +0 -0
  28. /package/{templates → .forge/templates}/push.cmd.tpl +0 -0
  29. /package/{templates → .forge/templates}/readme.md.tpl +0 -0
  30. /package/{templates → .forge/templates}/save.cmd.tpl +0 -0
@@ -0,0 +1,173 @@
1
+ @echo off
2
+ setlocal EnableDelayedExpansion
3
+ chcp 65001 >nul 2>nul
4
+
5
+ REM ============================================================
6
+ REM forge-git / .forge/init.cmd
7
+ REM init.cmd SIEMPRE vive en .forge/
8
+ REM PROJECT_ROOT es el padre (../)
9
+ REM ============================================================
10
+
11
+ pushd "%~dp0.."
12
+ set "PROJECT_ROOT=%CD%"
13
+ popd
14
+
15
+ set "FORGE_DIR=%~dp0"
16
+ set "LIB=%FORGE_DIR%lib"
17
+ set "TPL=%FORGE_DIR%templates"
18
+ set "CMDS=%FORGE_DIR%commands"
19
+
20
+ set "FORCE=0"
21
+ if /i "%~1"=="--force" set "FORCE=1"
22
+ if /i "%~1"=="force" set "FORCE=1"
23
+ if /i "%~1"=="-f" set "FORCE=1"
24
+
25
+ call "%FORGE_DIR%config.cmd"
26
+
27
+ pushd "%PROJECT_ROOT%"
28
+ for %%a in ("%CD%") do set "PROJECT_NAME=%%~nxa"
29
+ popd
30
+
31
+ call "%LIB%\ui.cmd" banner
32
+
33
+ cd /d "%PROJECT_ROOT%"
34
+
35
+ where node >nul 2>nul
36
+ if errorlevel 1 (
37
+ echo [1/17] Node.js MISSING
38
+ echo Descargalo desde: https://nodejs.org/
39
+ goto :abort
40
+ )
41
+ for /f "tokens=*" %%v in ('node --version 2^>nul') do set "NODE_VER=%%v"
42
+ call "%LIB%\ui.cmd" step 1/17 "Node.js !NODE_VER!" "OK"
43
+
44
+ where git >nul 2>nul
45
+ if errorlevel 1 (
46
+ echo [2/17] Git MISSING
47
+ echo Descargalo desde: https://git-scm.com/download/win
48
+ goto :abort
49
+ )
50
+ for /f "tokens=*" %%v in ('git --version 2^>nul') do set "GIT_VER=%%v"
51
+ call "%LIB%\ui.cmd" step 2/17 "!GIT_VER!" "OK"
52
+
53
+ call "%LIB%\git-ops.cmd" init
54
+ call "%LIB%\git-ops.cmd" branch_main
55
+
56
+ if exist ".forge\commands" (
57
+ call "%LIB%\ui.cmd" step 5/17 "Estructura .forge/" "YA EXISTE"
58
+ ) else (
59
+ mkdir ".forge" 2>nul
60
+ mkdir ".forge\commands" 2>nul
61
+ mkdir ".forge\lib" 2>nul
62
+ mkdir ".forge\templates" 2>nul
63
+ call "%LIB%\ui.cmd" step 5/17 "Estructura .forge/" "CREADO"
64
+ )
65
+
66
+ if exist ".gitignore" (
67
+ call "%LIB%\ui.cmd" step 6/17 ".gitignore" "YA EXISTE"
68
+ ) else (
69
+ call "%LIB%\templates.cmd" write_gitignore
70
+ call "%LIB%\ui.cmd" step 6/17 ".gitignore universal" "CREADO"
71
+ )
72
+
73
+ if exist "README.md" (
74
+ call "%LIB%\ui.cmd" step 7/17 "README.md" "YA EXISTE"
75
+ ) else (
76
+ call "%LIB%\templates.cmd" write_readme
77
+ call "%LIB%\ui.cmd" step 7/17 "README.md adaptativo" "CREADO"
78
+ )
79
+
80
+ if exist "forge.cmd" (
81
+ call "%LIB%\ui.cmd" step 8/17 "forge.cmd" "YA EXISTE"
82
+ ) else (
83
+ call "%LIB%\templates.cmd" write_forge
84
+ call "%LIB%\ui.cmd" step 8/17 "forge.cmd menu" "CREADO"
85
+ )
86
+
87
+ if exist ".forge\commands\save.cmd" (
88
+ call "%LIB%\ui.cmd" step 9/17 "save.cmd" "YA EXISTE"
89
+ ) else (
90
+ call "%LIB%\templates.cmd" write_save
91
+ call "%LIB%\ui.cmd" step 9/17 "save.cmd" "CREADO"
92
+ )
93
+
94
+ if exist ".forge\commands\push.cmd" (
95
+ call "%LIB%\ui.cmd" step 10/17 "push.cmd" "YA EXISTE"
96
+ ) else (
97
+ call "%LIB%\templates.cmd" write_push
98
+ call "%LIB%\ui.cmd" step 10/17 "push.cmd" "CREADO"
99
+ )
100
+
101
+ if exist ".forge\commands\snapshots.cmd" (
102
+ call "%LIB%\ui.cmd" step 11/17 "snapshots.cmd" "YA EXISTE"
103
+ ) else (
104
+ call "%LIB%\templates.cmd" write_snapshots
105
+ call "%LIB%\ui.cmd" step 11/17 "snapshots.cmd" "CREADO"
106
+ )
107
+
108
+ if exist ".forge\commands\historial.cmd" (
109
+ call "%LIB%\ui.cmd" step 12/17 "historial.cmd" "YA EXISTE"
110
+ ) else (
111
+ call "%LIB%\templates.cmd" write_historial
112
+ call "%LIB%\ui.cmd" step 12/17 "historial.cmd" "CREADO"
113
+ )
114
+
115
+ if exist ".forge\commands\abrir.cmd" (
116
+ call "%LIB%\ui.cmd" step 13/17 "abrir.cmd" "YA EXISTE"
117
+ ) else (
118
+ call "%LIB%\templates.cmd" write_abrir
119
+ call "%LIB%\ui.cmd" step 13/17 "abrir.cmd" "CREADO"
120
+ )
121
+
122
+ if exist ".forge\commands\auditar.cmd" (
123
+ call "%LIB%\ui.cmd" step 14/17 "auditar.cmd" "YA EXISTE"
124
+ ) else (
125
+ call "%LIB%\templates.cmd" write_auditar
126
+ call "%LIB%\ui.cmd" step 14/17 "auditar.cmd" "CREADO"
127
+ )
128
+
129
+ if exist ".forge\commands\serve.cmd" (
130
+ call "%LIB%\ui.cmd" step 15/17 "serve.cmd" "YA EXISTE"
131
+ ) else (
132
+ call "%LIB%\templates.cmd" write_serve
133
+ call "%LIB%\ui.cmd" step 15/17 "serve.cmd" "CREADO"
134
+ )
135
+
136
+ call "%LIB%\git-ops.cmd" has_changes
137
+ if errorlevel 1 (
138
+ set "USER_MSG="
139
+ set /p "USER_MSG= Mensaje del commit [Enter = default]: "
140
+ if "!USER_MSG!"=="" set "USER_MSG=%COMMIT_MESSAGE%"
141
+ call "%LIB%\git-ops.cmd" commit "!USER_MSG!"
142
+ call "%LIB%\ui.cmd" step 16/17 "Commit: !USER_MSG!" "CREADO"
143
+ ) else (
144
+ call "%LIB%\ui.cmd" step 16/17 "Sin cambios para commit" "SKIP"
145
+ )
146
+
147
+ call "%LIB%\git-ops.cmd" tag
148
+ if errorlevel 1 (
149
+ call "%LIB%\ui.cmd" step 17/17 "Tag %TAG_INITIAL%" "CREADO"
150
+ ) else (
151
+ call "%LIB%\ui.cmd" step 17/17 "Tag %TAG_INITIAL%" "YA EXISTE"
152
+ )
153
+
154
+ call "%LIB%\ui.cmd" done
155
+ call :shell_if_double_click
156
+ endlocal
157
+ exit /b 0
158
+
159
+ :abort
160
+ call "%LIB%\ui.cmd" abort
161
+ call :shell_if_double_click
162
+ endlocal
163
+ exit /b 1
164
+
165
+ :shell_if_double_click
166
+ if "%NO_PAUSE%"=="1" goto :eof
167
+ echo %cmdcmdline% | find /i "%~nx0" >nul
168
+ if errorlevel 1 goto :eof
169
+ echo.
170
+ echo Sesion interactiva abierta. Escribe 'exit' para cerrar.
171
+ echo.
172
+ cmd /k
173
+ goto :eof
File without changes
File without changes
@@ -0,0 +1,86 @@
1
+ // serve-static.js - Minimal static file server (no dependencies)
2
+ // Usage: node serve-static.js [port] [root]
3
+
4
+ const http = require('http');
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ const PORT = parseInt(process.argv[2] || '8080', 10);
9
+ const ROOT = path.resolve(process.argv[3] || process.cwd());
10
+
11
+ const MIME = {
12
+ '.html': 'text/html; charset=utf-8',
13
+ '.htm': 'text/html; charset=utf-8',
14
+ '.js': 'application/javascript; charset=utf-8',
15
+ '.mjs': 'application/javascript; charset=utf-8',
16
+ '.css': 'text/css; charset=utf-8',
17
+ '.json': 'application/json; charset=utf-8',
18
+ '.xml': 'application/xml; charset=utf-8',
19
+ '.txt': 'text/plain; charset=utf-8',
20
+ '.md': 'text/markdown; charset=utf-8',
21
+ '.png': 'image/png',
22
+ '.jpg': 'image/jpeg',
23
+ '.jpeg': 'image/jpeg',
24
+ '.gif': 'image/gif',
25
+ '.svg': 'image/svg+xml',
26
+ '.webp': 'image/webp',
27
+ '.ico': 'image/x-icon',
28
+ '.wasm': 'application/wasm',
29
+ '.woff': 'font/woff',
30
+ '.woff2': 'font/woff2',
31
+ '.ttf': 'font/ttf',
32
+ '.mp4': 'video/mp4',
33
+ '.webm': 'video/webm',
34
+ '.mp3': 'audio/mpeg',
35
+ '.wav': 'audio/wav'
36
+ };
37
+
38
+ const server = http.createServer((req, res) => {
39
+ let urlPath;
40
+ try {
41
+ urlPath = decodeURIComponent(req.url.split('?')[0]);
42
+ } catch (e) {
43
+ res.writeHead(400); res.end('400 Bad Request'); return;
44
+ }
45
+
46
+ if (urlPath === '/') urlPath = '/index.html';
47
+
48
+ const filePath = path.resolve(path.join(ROOT, urlPath));
49
+
50
+ // Bloqueo de path traversal
51
+ if (!filePath.startsWith(ROOT)) {
52
+ res.writeHead(403); res.end('403 Forbidden'); return;
53
+ }
54
+
55
+ fs.readFile(filePath, (err, data) => {
56
+ if (err) {
57
+ res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
58
+ res.end('404 Not Found: ' + urlPath);
59
+ return;
60
+ }
61
+ const ext = path.extname(filePath).toLowerCase();
62
+ res.writeHead(200, {
63
+ 'Content-Type': MIME[ext] || 'application/octet-stream',
64
+ 'Cache-Control': 'no-cache'
65
+ });
66
+ res.end(data);
67
+ });
68
+ });
69
+
70
+ server.on('error', (err) => {
71
+ if (err.code === 'EADDRINUSE') {
72
+ console.error('[ERROR] Port ' + PORT + ' is already in use.');
73
+ process.exit(1);
74
+ }
75
+ console.error('[ERROR] ' + err.message);
76
+ process.exit(1);
77
+ });
78
+
79
+ server.listen(PORT, '127.0.0.1', () => {
80
+ console.log('');
81
+ console.log(' Serving ' + ROOT);
82
+ console.log(' -> http://localhost:' + PORT + '/');
83
+ console.log('');
84
+ console.log(' Press Ctrl+C to stop');
85
+ console.log('');
86
+ });
@@ -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