# yaml-language-server: $schema=https://taskfile.dev/schema.json

version: "3"

vars:
  DEFAULT_PORT: 8080

tasks:
  serve:
    desc: Run web-server
    cmd: flutter run -d web-server --web-port 8080
    silent: true

  get-proto-from-branch:
    desc: Get the latest version of generated protobuf code from the branch
    silent: true
    vars:
      WORKDIR:
        sh: mktemp -d
    cmds:
      - git clone git@gitea.badhouseplants.net:softplayer/softplayer-dart-proto.git '{{ .WORKDIR }}'
      - git -C '{{ .WORKDIR }}' checkout '{{ .CLI_ARGS }}'
      - yq -i ".dependencies.softplayer_dart_proto.git.ref = \"$(git -C '{{ .WORKDIR }}' rev-parse HEAD)\"" pubspec.yaml
      - rm -rf '{{ .WORKDIR }}'
      - flutter pub get
