diff --git a/app/Console/Commands/Dev.php b/app/Console/Commands/Dev.php index 80059bf00..964b8e46e 100644 --- a/app/Console/Commands/Dev.php +++ b/app/Console/Commands/Dev.php @@ -9,13 +9,41 @@ class Dev extends Command { - protected $signature = 'dev:init'; + protected $signature = 'dev {--init} {--generate-openapi}'; - protected $description = 'Init the app in dev mode'; + protected $description = 'Helper commands for development.'; public function handle() + { + if ($this->option('init')) { + $this->init(); + + return; + } + if ($this->option('generate-openapi')) { + $this->generateOpenApi(); + + return; + } + + } + + public function generateOpenApi() + { + // Generate OpenAPI documentation + echo "Generating OpenAPI documentation.\n"; + $process = Process::run(['/var/www/html/vendor/bin/openapi', 'app', '-o', 'openapi.yaml']); + $error = $process->errorOutput(); + $error = preg_replace('/^.*an object literal,.*$/m', '', $error); + $error = preg_replace('/^\h*\v+/m', '', $error); + echo $error; + echo $process->output(); + } + + public function init() { // Generate APP_KEY if not exists + if (empty(env('APP_KEY'))) { echo "Generating APP_KEY.\n"; Artisan::call('key:generate'); diff --git a/docker/dev/etc/s6-overlay/s6-rc.d/init-setup/up b/docker/dev/etc/s6-overlay/s6-rc.d/init-setup/up index e974e54cc..e02307e49 100644 --- a/docker/dev/etc/s6-overlay/s6-rc.d/init-setup/up +++ b/docker/dev/etc/s6-overlay/s6-rc.d/init-setup/up @@ -1,5 +1,5 @@ #!/command/execlineb -P foreground { composer -d /var/www/html/ install } foreground { php /var/www/html/artisan migrate --step } -foreground { php /var/www/html/artisan dev:init } +foreground { php /var/www/html/artisan dev --init } diff --git a/scripts/run b/scripts/run index dfb011c39..a8b5af968 100755 --- a/scripts/run +++ b/scripts/run @@ -20,12 +20,6 @@ function help { compgen -A function | cat -n } -# function dev:init { -# docker exec coolify bash -c "php artisan migrate --seed" -# echo "Need to update privileges on a few files. I need your password for that." -# sudo chmod -R o+rwx . -# } - # function sync:v3 { # if [ -z "$1" ]; then # echo -e "Please provide a version.\n\nExample: run sync:v3 3.12.32" @@ -53,7 +47,6 @@ function sync:bunny { # bash spin exec -u webuser coolify php artisan schedule:run # } - # function db { # bash spin exec -u webuser coolify php artisan db # } @@ -85,7 +78,7 @@ function coolify:root { bash spin exec coolify bash } function coolify:proxy { - docker exec -ti coolify-proxy sh + docker exec -ti coolify-proxy sh } function redis { @@ -100,7 +93,6 @@ function tinker { bash spin exec -u webuser coolify php artisan tinker } - # function build:helper { # act -W .github/workflows/coolify-helper.yml --secret-file .env.secrets # }