version: 3

vars:
  RED: '\033[0;31m'
  GREEN: '\033[0;32m'
  COLOROFF: '\033[0m'
  PREFIX: "⏳"

includes:
  gen: ./automation/generator.yml
  pub: ./automation/pub.yml
  run: ./automation/run.yml
  build: ./automation/build.yml

silent: true

tasks:
  help:
    desc: Help dialog.
    aliases: [h, default]
    cmds:
      - task --summary --list-all

  clean:
    desc: Cleans the environment.
    aliases: [cl]
    cmds:
      - echo -e "{{.GREEN}}{{.PREFIX}} Cleaning the project...{{.COLOROFF}}"
      - flutter clean

  format:
    desc: Formats the code.
    aliases: [fmt]
    cmds:
      - echo -e "{{.GREEN}}{{.PREFIX}} Formatting the code...{{.COLOROFF}}"
      - flutter format --fix
      - dart fix --apply

  lint:
    desc: Lints the code.
    aliases: [l]
    cmds:
      - echo -e "{{.GREEN}}{{.PREFIX}} Verifying code...{{.COLOROFF}}"
      - dart analyze . || (echo "Error in project"; exit 1)

  start-emulators:
    desc: Start needed emulators.
    aliases: [emu]
    cmds:
      - echo -e "{{.GREEN}}{{.PREFIX}} Start Firebase emulators...{{.COLOROFF}}"
      - firebase emulators:start --only auth,functions,firestore,storage --import=./functions/saved-data --export-on-exit=./functions/saved-data
