tasks:
  - name: Setup Spin environment and Composer dependencies
    # Fix because of https://github.com/gitpod-io/gitpod/issues/16614
    before: sudo curl -o /usr/local/bin/docker-compose -fsSL https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-$(uname -m)
    init: |
      cp .env.example .env &&
      sed -i "s#APP_URL=http://localhost#APP_URL=$(gp url 8000)#g" .env
      sed -i "s#USERID=#USERID=33333#g" .env
      sed -i "s#GROUPID=#GROUPID=33333#g" .env
      composer install --ignore-platform-reqs
      ./vendor/bin/spin up -d
      ./vendor/bin/spin exec -u webuser coolify php artisan key:generate
      ./vendor/bin/spin exec -u webuser coolify php artisan storage:link
      ./vendor/bin/spin exec -u webuser coolify php artisan migrate:fresh --seed
      cat .jesus-is-king
      gp sync-done spin-is-ready

  - name: Install Node dependencies and run Vite
    command: |
      echo "Waiting for Sail environment to boot up."
      gp sync-await spin-is-ready
      ./vendor/bin/spin exec vite npm install
      ./vendor/bin/spin exec vite npm run dev

  - name: Laravel Queue Worker, listening to code changes
    command: |
      echo "Waiting for Sail environment to boot up."
      gp sync-await spin-is-ready
      ./vendor/bin/spin exec -u webuser coolify php artisan queue:listen

ports:
  - port: 5432
    onOpen: ignore
    name: PostgreSQL
    visibility: public
  - port: 5173
    onOpen: ignore
    visibility: public
    name: Node Server for Vite
  - port: 8000
    onOpen: ignore
    visibility: public
    name: Coolify

# Configure vscode
vscode:
  extensions:
    - bmewburn.vscode-intelephense-client
    - ikappas.composer
    - ms-azuretools.vscode-docker
    - ecmel.vscode-html-css
    - MehediDracula.php-namespace-resolver
    - wmaurer.change-case
    - Equinusocio.vsc-community-material-theme
    - EditorConfig.EditorConfig
    - streetsidesoftware.code-spell-checker
    - rangav.vscode-thunder-client
    - PKief.material-icon-theme
    - cierra.livewire-vscode
    - lennardv.livewire-goto-updated
    - bradlc.vscode-tailwindcss
    - heybourn.headwind
    - adrianwilczynski.alpine-js-intellisense
    - amiralizadeh9480.laravel-extra-intellisense
    - shufo.vscode-blade-formatter
