forgegit 1.3.0 → 1.4.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.
- package/MANUAL.md +61 -68
- package/config.cmd +14 -14
- package/init.cmd +199 -190
- package/lib/git-ops.cmd +91 -91
- package/lib/templates.cmd +98 -97
- package/lib/ui.cmd +58 -57
- package/package.json +1 -1
- package/templates/forge.cmd.tpl +6 -2
- package/templates/serve-static.js +86 -0
- package/templates/serve.cmd.tpl +209 -0
package/lib/git-ops.cmd
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM ============================================================
|
|
3
|
-
REM forge-git / lib/git-ops.cmd
|
|
4
|
-
REM Git operations
|
|
5
|
-
REM
|
|
6
|
-
REM Usage:
|
|
7
|
-
REM call "git-ops.cmd" init - init repo
|
|
8
|
-
REM call "git-ops.cmd" branch_main - rename branch to main
|
|
9
|
-
REM call "git-ops.cmd" has_changes - check for pending changes
|
|
10
|
-
REM call "git-ops.cmd" commit "msg" - commit with message
|
|
11
|
-
REM call "git-ops.cmd" tag - create tag
|
|
12
|
-
REM
|
|
13
|
-
REM Return codes:
|
|
14
|
-
REM 0 = nothing to do (already exists / no changes)
|
|
15
|
-
REM 1 = action performed
|
|
16
|
-
REM ============================================================
|
|
17
|
-
|
|
18
|
-
REM --- Detectar PROJECT_ROOT ---
|
|
19
|
-
REM Si git-ops.cmd esta en .forge/lib/ -> PROJECT_ROOT = ..\..
|
|
20
|
-
REM Si git-ops.cmd esta en lib/ -> PROJECT_ROOT = ..
|
|
21
|
-
set "ROOT=%~dp0"
|
|
22
|
-
REM Detectar si estamos dentro de .forge
|
|
23
|
-
echo "%ROOT%" | find /i ".forge" >nul
|
|
24
|
-
if not errorlevel 1 (
|
|
25
|
-
set "PROJECT_ROOT=%ROOT%..\.."
|
|
26
|
-
) else (
|
|
27
|
-
set "PROJECT_ROOT=%ROOT%.."
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
if "%~1"=="init" goto :init
|
|
31
|
-
if "%~1"=="branch_main" goto :branch_main
|
|
32
|
-
if "%~1"=="has_changes" goto :has_changes
|
|
33
|
-
if "%~1"=="commit" goto :commit
|
|
34
|
-
if "%~1"=="tag" goto :tag
|
|
35
|
-
goto :eof
|
|
36
|
-
|
|
37
|
-
:init
|
|
38
|
-
pushd "%PROJECT_ROOT%"
|
|
39
|
-
if exist ".git" (
|
|
40
|
-
popd
|
|
41
|
-
call "%~dp0ui.cmd" step 3/
|
|
42
|
-
exit /b 0
|
|
43
|
-
)
|
|
44
|
-
git init -q
|
|
45
|
-
if errorlevel 1 (
|
|
46
|
-
popd
|
|
47
|
-
call "%~dp0ui.cmd" step 3/
|
|
48
|
-
exit /b 1
|
|
49
|
-
)
|
|
50
|
-
popd
|
|
51
|
-
call "%~dp0ui.cmd" step 3/
|
|
52
|
-
exit /b 1
|
|
53
|
-
|
|
54
|
-
:branch_main
|
|
55
|
-
pushd "%PROJECT_ROOT%"
|
|
56
|
-
git branch -M %BRANCH_MAIN% >nul 2>nul
|
|
57
|
-
popd
|
|
58
|
-
call "%~dp0ui.cmd" step 4/
|
|
59
|
-
exit /b 0
|
|
60
|
-
|
|
61
|
-
:has_changes
|
|
62
|
-
pushd "%PROJECT_ROOT%"
|
|
63
|
-
git add -A >nul 2>nul
|
|
64
|
-
git diff --cached --quiet
|
|
65
|
-
set "RC=%ERRORLEVEL%"
|
|
66
|
-
popd
|
|
67
|
-
if %RC% NEQ 0 ( exit /b 1 ) else ( exit /b 0 )
|
|
68
|
-
|
|
69
|
-
:commit
|
|
70
|
-
set "MSG=%~2"
|
|
71
|
-
if "!MSG!"=="" set "MSG=%COMMIT_MESSAGE%"
|
|
72
|
-
pushd "%PROJECT_ROOT%"
|
|
73
|
-
git commit -q -m "!MSG!"
|
|
74
|
-
set "RC=%ERRORLEVEL%"
|
|
75
|
-
popd
|
|
76
|
-
if %RC% NEQ 0 ( exit /b 0 ) else ( exit /b 1 )
|
|
77
|
-
|
|
78
|
-
:tag
|
|
79
|
-
pushd "%PROJECT_ROOT%"
|
|
80
|
-
git rev-parse %TAG_INITIAL% >nul 2>nul
|
|
81
|
-
if not errorlevel 1 (
|
|
82
|
-
popd
|
|
83
|
-
exit /b 0
|
|
84
|
-
)
|
|
85
|
-
git rev-parse HEAD >nul 2>nul
|
|
86
|
-
if errorlevel 1 (
|
|
87
|
-
popd
|
|
88
|
-
exit /b 0
|
|
89
|
-
)
|
|
90
|
-
git tag -a %TAG_INITIAL% -m "%TAG_MESSAGE%" 2>nul
|
|
91
|
-
popd
|
|
1
|
+
@echo off
|
|
2
|
+
REM ============================================================
|
|
3
|
+
REM forge-git / lib/git-ops.cmd
|
|
4
|
+
REM Git operations
|
|
5
|
+
REM
|
|
6
|
+
REM Usage:
|
|
7
|
+
REM call "git-ops.cmd" init - init repo
|
|
8
|
+
REM call "git-ops.cmd" branch_main - rename branch to main
|
|
9
|
+
REM call "git-ops.cmd" has_changes - check for pending changes
|
|
10
|
+
REM call "git-ops.cmd" commit "msg" - commit with message
|
|
11
|
+
REM call "git-ops.cmd" tag - create tag
|
|
12
|
+
REM
|
|
13
|
+
REM Return codes:
|
|
14
|
+
REM 0 = nothing to do (already exists / no changes)
|
|
15
|
+
REM 1 = action performed
|
|
16
|
+
REM ============================================================
|
|
17
|
+
|
|
18
|
+
REM --- Detectar PROJECT_ROOT ---
|
|
19
|
+
REM Si git-ops.cmd esta en .forge/lib/ -> PROJECT_ROOT = ..\..
|
|
20
|
+
REM Si git-ops.cmd esta en lib/ -> PROJECT_ROOT = ..
|
|
21
|
+
set "ROOT=%~dp0"
|
|
22
|
+
REM Detectar si estamos dentro de .forge
|
|
23
|
+
echo "%ROOT%" | find /i ".forge" >nul
|
|
24
|
+
if not errorlevel 1 (
|
|
25
|
+
set "PROJECT_ROOT=%ROOT%..\.."
|
|
26
|
+
) else (
|
|
27
|
+
set "PROJECT_ROOT=%ROOT%.."
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
if "%~1"=="init" goto :init
|
|
31
|
+
if "%~1"=="branch_main" goto :branch_main
|
|
32
|
+
if "%~1"=="has_changes" goto :has_changes
|
|
33
|
+
if "%~1"=="commit" goto :commit
|
|
34
|
+
if "%~1"=="tag" goto :tag
|
|
35
|
+
goto :eof
|
|
36
|
+
|
|
37
|
+
:init
|
|
38
|
+
pushd "%PROJECT_ROOT%"
|
|
39
|
+
if exist ".git" (
|
|
40
|
+
popd
|
|
41
|
+
call "%~dp0ui.cmd" step 3/17 "Repositorio Git" "YA EXISTE"
|
|
42
|
+
exit /b 0
|
|
43
|
+
)
|
|
44
|
+
git init -q
|
|
45
|
+
if errorlevel 1 (
|
|
46
|
+
popd
|
|
47
|
+
call "%~dp0ui.cmd" step 3/17 "Repositorio Git" "ERROR"
|
|
48
|
+
exit /b 1
|
|
49
|
+
)
|
|
50
|
+
popd
|
|
51
|
+
call "%~dp0ui.cmd" step 3/17 "Repositorio Git" "CREADO"
|
|
52
|
+
exit /b 1
|
|
53
|
+
|
|
54
|
+
:branch_main
|
|
55
|
+
pushd "%PROJECT_ROOT%"
|
|
56
|
+
git branch -M %BRANCH_MAIN% >nul 2>nul
|
|
57
|
+
popd
|
|
58
|
+
call "%~dp0ui.cmd" step 4/17 "Rama principal: %BRANCH_MAIN%" "OK"
|
|
59
|
+
exit /b 0
|
|
60
|
+
|
|
61
|
+
:has_changes
|
|
62
|
+
pushd "%PROJECT_ROOT%"
|
|
63
|
+
git add -A >nul 2>nul
|
|
64
|
+
git diff --cached --quiet
|
|
65
|
+
set "RC=%ERRORLEVEL%"
|
|
66
|
+
popd
|
|
67
|
+
if %RC% NEQ 0 ( exit /b 1 ) else ( exit /b 0 )
|
|
68
|
+
|
|
69
|
+
:commit
|
|
70
|
+
set "MSG=%~2"
|
|
71
|
+
if "!MSG!"=="" set "MSG=%COMMIT_MESSAGE%"
|
|
72
|
+
pushd "%PROJECT_ROOT%"
|
|
73
|
+
git commit -q -m "!MSG!"
|
|
74
|
+
set "RC=%ERRORLEVEL%"
|
|
75
|
+
popd
|
|
76
|
+
if %RC% NEQ 0 ( exit /b 0 ) else ( exit /b 1 )
|
|
77
|
+
|
|
78
|
+
:tag
|
|
79
|
+
pushd "%PROJECT_ROOT%"
|
|
80
|
+
git rev-parse %TAG_INITIAL% >nul 2>nul
|
|
81
|
+
if not errorlevel 1 (
|
|
82
|
+
popd
|
|
83
|
+
exit /b 0
|
|
84
|
+
)
|
|
85
|
+
git rev-parse HEAD >nul 2>nul
|
|
86
|
+
if errorlevel 1 (
|
|
87
|
+
popd
|
|
88
|
+
exit /b 0
|
|
89
|
+
)
|
|
90
|
+
git tag -a %TAG_INITIAL% -m "%TAG_MESSAGE%" 2>nul
|
|
91
|
+
popd
|
|
92
92
|
exit /b 1
|
package/lib/templates.cmd
CHANGED
|
@@ -1,97 +1,98 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM ============================================================
|
|
3
|
-
REM forge-git / lib/templates.cmd
|
|
4
|
-
REM Copies templates from templates/ to destinations
|
|
5
|
-
REM ============================================================
|
|
6
|
-
|
|
7
|
-
if "%~1"=="write_gitignore" goto :write_gitignore
|
|
8
|
-
if "%~1"=="write_readme" goto :write_readme
|
|
9
|
-
if "%~1"=="write_forge" goto :write_forge
|
|
10
|
-
if "%~1"=="write_save" goto :write_save
|
|
11
|
-
if "%~1"=="write_push" goto :write_push
|
|
12
|
-
if "%~1"=="write_snapshots" goto :write_snapshots
|
|
13
|
-
if "%~1"=="write_historial" goto :write_historial
|
|
14
|
-
if "%~1"=="write_abrir" goto :write_abrir
|
|
15
|
-
if "%~1"=="write_auditar" goto :write_auditar
|
|
16
|
-
goto :
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
:write_gitignore
|
|
20
|
-
call :copy_root "gitignore.tpl" ".gitignore"
|
|
21
|
-
goto :eof
|
|
22
|
-
|
|
23
|
-
:write_readme
|
|
24
|
-
call :apply_root "readme.md.tpl" "README.md"
|
|
25
|
-
goto :eof
|
|
26
|
-
|
|
27
|
-
:write_forge
|
|
28
|
-
call :copy_root "forge.cmd.tpl" "forge.cmd"
|
|
29
|
-
goto :eof
|
|
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
|
-
set "
|
|
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
|
-
|
|
1
|
+
@echo off
|
|
2
|
+
REM ============================================================
|
|
3
|
+
REM forge-git / lib/templates.cmd
|
|
4
|
+
REM Copies templates from templates/ to destinations
|
|
5
|
+
REM ============================================================
|
|
6
|
+
|
|
7
|
+
if "%~1"=="write_gitignore" goto :write_gitignore
|
|
8
|
+
if "%~1"=="write_readme" goto :write_readme
|
|
9
|
+
if "%~1"=="write_forge" goto :write_forge
|
|
10
|
+
if "%~1"=="write_save" goto :write_save
|
|
11
|
+
if "%~1"=="write_push" goto :write_push
|
|
12
|
+
if "%~1"=="write_snapshots" goto :write_snapshots
|
|
13
|
+
if "%~1"=="write_historial" goto :write_historial
|
|
14
|
+
if "%~1"=="write_abrir" goto :write_abrir
|
|
15
|
+
if "%~1"=="write_auditar" goto :write_auditar
|
|
16
|
+
if "%~1"=="write_serve" goto :write_serve
|
|
17
|
+
goto :eof
|
|
18
|
+
|
|
19
|
+
:write_gitignore
|
|
20
|
+
call :copy_root "gitignore.tpl" ".gitignore"
|
|
21
|
+
goto :eof
|
|
22
|
+
|
|
23
|
+
:write_readme
|
|
24
|
+
call :apply_root "readme.md.tpl" "README.md"
|
|
25
|
+
goto :eof
|
|
26
|
+
|
|
27
|
+
:write_forge
|
|
28
|
+
call :copy_root "forge.cmd.tpl" "forge.cmd"
|
|
29
|
+
goto :eof
|
|
30
|
+
|
|
31
|
+
:write_save
|
|
32
|
+
call :copy_cmd "save.cmd.tpl" "save.cmd"
|
|
33
|
+
goto :eof
|
|
34
|
+
|
|
35
|
+
:write_push
|
|
36
|
+
call :copy_cmd "push.cmd.tpl" "push.cmd"
|
|
37
|
+
goto :eof
|
|
38
|
+
|
|
39
|
+
:write_snapshots
|
|
40
|
+
call :copy_cmd "snapshots.cmd.tpl" "snapshots.cmd"
|
|
41
|
+
goto :eof
|
|
42
|
+
|
|
43
|
+
:write_historial
|
|
44
|
+
call :copy_cmd "historial.cmd.tpl" "historial.cmd"
|
|
45
|
+
goto :eof
|
|
46
|
+
|
|
47
|
+
:write_abrir
|
|
48
|
+
call :copy_cmd "abrir.cmd.tpl" "abrir.cmd"
|
|
49
|
+
goto :eof
|
|
50
|
+
|
|
51
|
+
:write_auditar
|
|
52
|
+
call :copy_cmd "auditar.cmd.tpl" "auditar.cmd"
|
|
53
|
+
goto :eof
|
|
54
|
+
|
|
55
|
+
:write_serve
|
|
56
|
+
call :copy_cmd "serve.cmd.tpl" "serve.cmd"
|
|
57
|
+
call :copy_forge_root "serve-static.js" "serve-static.js"
|
|
58
|
+
goto :eof
|
|
59
|
+
|
|
60
|
+
:copy_root
|
|
61
|
+
set "SRC=%~dp0..\templates\%~1"
|
|
62
|
+
set "DST=%~dp0..\..\%~2"
|
|
63
|
+
if not exist "%SRC%" (
|
|
64
|
+
echo [X] Template no encontrado: %SRC%
|
|
65
|
+
exit /b 1
|
|
66
|
+
)
|
|
67
|
+
copy /Y "%SRC%" "%DST%" >nul
|
|
68
|
+
exit /b 0
|
|
69
|
+
|
|
70
|
+
:copy_cmd
|
|
71
|
+
set "SRC=%~dp0..\templates\%~1"
|
|
72
|
+
set "DST=%~dp0..\commands\%~2"
|
|
73
|
+
if not exist "%SRC%" (
|
|
74
|
+
echo [X] Template no encontrado: %SRC%
|
|
75
|
+
exit /b 1
|
|
76
|
+
)
|
|
77
|
+
copy /Y "%SRC%" "%DST%" >nul
|
|
78
|
+
exit /b 0
|
|
79
|
+
|
|
80
|
+
:copy_forge_root
|
|
81
|
+
set "SRC=%~dp0..\templates\%~1"
|
|
82
|
+
set "DST=%~dp0..\%~2"
|
|
83
|
+
if not exist "%SRC%" (
|
|
84
|
+
echo [X] Template no encontrado: %SRC%
|
|
85
|
+
exit /b 1
|
|
86
|
+
)
|
|
87
|
+
copy /Y "%SRC%" "%DST%" >nul
|
|
88
|
+
exit /b 0
|
|
89
|
+
|
|
90
|
+
:apply_root
|
|
91
|
+
set "SRC=%~dp0..\templates\%~1"
|
|
92
|
+
set "DST=%~dp0..\..\%~2"
|
|
93
|
+
if not exist "%SRC%" (
|
|
94
|
+
echo [X] Template no encontrado: %SRC%
|
|
95
|
+
exit /b 1
|
|
96
|
+
)
|
|
97
|
+
powershell -NoProfile -ExecutionPolicy Bypass -Command "$c = Get-Content -Raw -LiteralPath '%SRC%'; $c = $c.Replace('{{PROJECT_NAME}}', '%PROJECT_NAME%'); $c = $c.Replace('{{FG_VERSION}}', '%FG_VERSION%'); [System.IO.File]::WriteAllText('%DST%', $c, [System.Text.UTF8Encoding]::new($false))"
|
|
98
|
+
exit /b 0
|
package/lib/ui.cmd
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
@echo off
|
|
2
|
-
REM ============================================================
|
|
3
|
-
REM forge-git / lib/ui.cmd
|
|
4
|
-
REM UI helpers
|
|
5
|
-
REM ============================================================
|
|
6
|
-
|
|
7
|
-
if "%~1"=="banner" goto :banner
|
|
8
|
-
if "%~1"=="step" goto :step
|
|
9
|
-
if "%~1"=="done" goto :done
|
|
10
|
-
if "%~1"=="abort" goto :abort
|
|
11
|
-
goto :eof
|
|
12
|
-
|
|
13
|
-
:banner
|
|
14
|
-
echo.
|
|
15
|
-
echo ############################################
|
|
16
|
-
echo # forge-git v%FG_VERSION% #
|
|
17
|
-
echo # Bootstrap universal de proyecto #
|
|
18
|
-
echo ############################################
|
|
19
|
-
echo.
|
|
20
|
-
echo Proyecto: %PROJECT_NAME%
|
|
21
|
-
echo Ruta: %CD%
|
|
22
|
-
echo.
|
|
23
|
-
goto :eof
|
|
24
|
-
|
|
25
|
-
:step
|
|
26
|
-
echo [%~2] %~3 %~4
|
|
27
|
-
goto :eof
|
|
28
|
-
|
|
29
|
-
:done
|
|
30
|
-
echo.
|
|
31
|
-
echo ############################################
|
|
32
|
-
echo # Bootstrap completado #
|
|
33
|
-
echo ############################################
|
|
34
|
-
echo.
|
|
35
|
-
echo Comandos disponibles:
|
|
36
|
-
echo.
|
|
37
|
-
echo Esenciales:
|
|
38
|
-
echo init.cmd Bootstrap
|
|
39
|
-
echo forge.cmd Menu interactivo
|
|
40
|
-
echo.
|
|
41
|
-
echo Uso CLI directo:
|
|
42
|
-
echo forge save Commit de cambios
|
|
43
|
-
echo forge push Push a GitHub
|
|
44
|
-
echo forge log Ver commits
|
|
45
|
-
echo.
|
|
46
|
-
echo Otros:
|
|
47
|
-
echo forge snap Snapshots
|
|
48
|
-
echo forge audit Reporte diff
|
|
49
|
-
echo forge open Abrir en VS Code
|
|
50
|
-
echo forge
|
|
51
|
-
echo
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
echo
|
|
57
|
-
|
|
1
|
+
@echo off
|
|
2
|
+
REM ============================================================
|
|
3
|
+
REM forge-git / lib/ui.cmd
|
|
4
|
+
REM UI helpers
|
|
5
|
+
REM ============================================================
|
|
6
|
+
|
|
7
|
+
if "%~1"=="banner" goto :banner
|
|
8
|
+
if "%~1"=="step" goto :step
|
|
9
|
+
if "%~1"=="done" goto :done
|
|
10
|
+
if "%~1"=="abort" goto :abort
|
|
11
|
+
goto :eof
|
|
12
|
+
|
|
13
|
+
:banner
|
|
14
|
+
echo.
|
|
15
|
+
echo ############################################
|
|
16
|
+
echo # forge-git v%FG_VERSION% #
|
|
17
|
+
echo # Bootstrap universal de proyecto #
|
|
18
|
+
echo ############################################
|
|
19
|
+
echo.
|
|
20
|
+
echo Proyecto: %PROJECT_NAME%
|
|
21
|
+
echo Ruta: %CD%
|
|
22
|
+
echo.
|
|
23
|
+
goto :eof
|
|
24
|
+
|
|
25
|
+
:step
|
|
26
|
+
echo [%~2] %~3 %~4
|
|
27
|
+
goto :eof
|
|
28
|
+
|
|
29
|
+
:done
|
|
30
|
+
echo.
|
|
31
|
+
echo ############################################
|
|
32
|
+
echo # Bootstrap completado #
|
|
33
|
+
echo ############################################
|
|
34
|
+
echo.
|
|
35
|
+
echo Comandos disponibles:
|
|
36
|
+
echo.
|
|
37
|
+
echo Esenciales:
|
|
38
|
+
echo init.cmd Bootstrap
|
|
39
|
+
echo forge.cmd Menu interactivo
|
|
40
|
+
echo.
|
|
41
|
+
echo Uso CLI directo:
|
|
42
|
+
echo forge save Commit de cambios
|
|
43
|
+
echo forge push Push a GitHub
|
|
44
|
+
echo forge log Ver commits
|
|
45
|
+
echo.
|
|
46
|
+
echo Otros:
|
|
47
|
+
echo forge snap Snapshots
|
|
48
|
+
echo forge audit Reporte diff
|
|
49
|
+
echo forge open Abrir en VS Code
|
|
50
|
+
echo forge serve Servidor de desarrollo
|
|
51
|
+
echo forge help Ayuda completa
|
|
52
|
+
echo.
|
|
53
|
+
goto :eof
|
|
54
|
+
|
|
55
|
+
:abort
|
|
56
|
+
echo.
|
|
57
|
+
echo Bootstrap abortado. Instala los requisitos y vuelve a intentar.
|
|
58
|
+
pause
|
|
58
59
|
goto :eof
|
package/package.json
CHANGED
package/templates/forge.cmd.tpl
CHANGED
|
@@ -28,7 +28,7 @@ if not exist "%CMD_DIR%\save.cmd" (
|
|
|
28
28
|
exit /b 1
|
|
29
29
|
)
|
|
30
30
|
|
|
31
|
-
REM --- Modo CLI directo
|
|
31
|
+
REM --- Modo CLI directo ---
|
|
32
32
|
if not "%~1"=="" (
|
|
33
33
|
if /i "%~1"=="save" ( call "%CMD_DIR%\save.cmd" & exit /b 0 )
|
|
34
34
|
if /i "%~1"=="push" ( call "%CMD_DIR%\push.cmd" & exit /b 0 )
|
|
@@ -36,6 +36,7 @@ if not "%~1"=="" (
|
|
|
36
36
|
if /i "%~1"=="log" ( call "%CMD_DIR%\historial.cmd" & exit /b 0 )
|
|
37
37
|
if /i "%~1"=="audit" ( call "%CMD_DIR%\auditar.cmd" & exit /b 0 )
|
|
38
38
|
if /i "%~1"=="open" ( call "%CMD_DIR%\abrir.cmd" & exit /b 0 )
|
|
39
|
+
if /i "%~1"=="serve" ( call "%CMD_DIR%\serve.cmd" & exit /b 0 )
|
|
39
40
|
if /i "%~1"=="help" goto :help
|
|
40
41
|
if /i "%~1"=="-h" goto :help
|
|
41
42
|
if /i "%~1"=="--help" goto :help
|
|
@@ -45,7 +46,7 @@ if not "%~1"=="" (
|
|
|
45
46
|
)
|
|
46
47
|
|
|
47
48
|
REM ============================================================
|
|
48
|
-
REM MENU PRINCIPAL
|
|
49
|
+
REM MENU PRINCIPAL
|
|
49
50
|
REM ============================================================
|
|
50
51
|
:menu
|
|
51
52
|
cls
|
|
@@ -63,6 +64,7 @@ echo !C_BC!Herramientas:!C_RS!
|
|
|
63
64
|
echo !C_YE![4]!C_RS! Snapshots !C_GY!(backup/restore)!C_RS!
|
|
64
65
|
echo !C_YE![5]!C_RS! Auditar cambios !C_GY!(diff report)!C_RS!
|
|
65
66
|
echo !C_YE![6]!C_RS! Abrir en VS Code
|
|
67
|
+
echo !C_YE![7]!C_RS! Servidor dev !C_GY!(auto-detect)!C_RS!
|
|
66
68
|
echo.
|
|
67
69
|
echo !C_BC!Sistema:!C_RS!
|
|
68
70
|
echo !C_YE![0]!C_RS! Salir
|
|
@@ -79,6 +81,7 @@ if "!OPT!"=="3" ( call "%CMD_DIR%\historial.cmd" & echo. & pause & goto :menu )
|
|
|
79
81
|
if "!OPT!"=="4" ( call "%CMD_DIR%\snapshots.cmd" & echo. & pause & goto :menu )
|
|
80
82
|
if "!OPT!"=="5" ( call "%CMD_DIR%\auditar.cmd" & echo. & pause & goto :menu )
|
|
81
83
|
if "!OPT!"=="6" ( call "%CMD_DIR%\abrir.cmd" & echo. & pause & goto :menu )
|
|
84
|
+
if "!OPT!"=="7" ( call "%CMD_DIR%\serve.cmd" & echo. & pause & goto :menu )
|
|
82
85
|
if "!OPT!"=="0" goto :end
|
|
83
86
|
if /i "!OPT!"=="q" goto :end
|
|
84
87
|
|
|
@@ -101,6 +104,7 @@ echo !C_WH!forge snap!C_RS! Snapshots
|
|
|
101
104
|
echo !C_WH!forge log!C_RS! Historial
|
|
102
105
|
echo !C_WH!forge audit!C_RS! Auditar cambios
|
|
103
106
|
echo !C_WH!forge open!C_RS! Abrir en VS Code
|
|
107
|
+
echo !C_WH!forge serve!C_RS! Servidor de desarrollo
|
|
104
108
|
echo !C_WH!forge help!C_RS! Esta ayuda
|
|
105
109
|
echo.
|
|
106
110
|
goto :end
|
|
@@ -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
|
+
});
|