|
- @echo off
- rem Runs a code generator inside the running "axonasp" container with the AxonASP CLI.
- rem
- rem scripts\gen.cmd migration <migration_name>
- rem scripts\gen.cmd controller <Name> Index "Show(id)" NewForm Create "Edit(id)" "Update(id)" "Delete(id)"
- rem scripts\gen.cmd repo /table:<Table> /pk:<PrimaryKey>
- rem scripts\gen.cmd api /table:<Table> /pk:<PrimaryKey> (repo + JSON API controller, routes, OpenAPI spec)
- rem
- rem Controller actions are separate arguments (quote the ones with parentheses).
- setlocal
- set "GEN=%~1"
- set "SCRIPT="
- if "%GEN%"=="migration" set "SCRIPT=generateMigration.vbs"
- if "%GEN%"=="controller" set "SCRIPT=generateController.vbs"
- if "%GEN%"=="repo" set "SCRIPT=GenerateRepo.vbs"
- if "%GEN%"=="api" set "SCRIPT=GenerateRepo.vbs"
- if not defined SCRIPT goto usage
- set "A1=%~2"
- set "A2=%~3"
- if not "%GEN%"=="controller" goto run
- set "A2="
- shift
- shift
- :collect
- set "CUR=%~1"
- if not defined CUR goto run
- if defined A2 goto join
- set "A2=%CUR%"
- goto next
- :join
- set "A2=%A2%;%CUR%"
- :next
- shift
- goto collect
- :run
- docker exec -u axonasp -e SERVER_WEB_ROOT=/opt/axonasp/site -e "ARG1=%A1%" -e "ARG2=%A2%" axonasp ./axonasp-cli -m vbscript -r /opt/axonasp/site/scripts/%SCRIPT%
- if not "%GEN%"=="api" exit /b %errorlevel%
- rem api: the repo/POBO were generated above, now the controller, routes and spec
- docker exec -u axonasp -e SERVER_WEB_ROOT=/opt/axonasp/site -e "ARG1=%A1%" -e "ARG2=%A2%" axonasp ./axonasp-cli -m vbscript -r /opt/axonasp/site/scripts/GenerateApi.vbs
- exit /b %errorlevel%
- :usage
- echo Usage: scripts\gen.cmd (migration^|controller^|repo^|api) args...
- exit /b 1
|