version: "3"

env:
  PATH: "{{.PWD}}/node_modules/bin:{{.PATH}}"

includes:
  test: ./scripts/Taskfile.test.yml
  ci: ./scripts/Taskfile.ci.yml
  lint: ./scripts/Taskfile.lint.yml
  fmt: ./scripts/Taskfile.fmt.yml
  clean: ./scripts/Taskfile.clean.yml
  ide: ./scripts/Taskfile.ide.yml

tasks:
  cfg:scripts:
    desc: Make scripts executable
    cmds:
      - chmod -R +x ./scripts

  setup:
    desc: install node modules
    cmds:
      - pre-commit install -c ./config/.pre-commit-config.yaml --install-hooks
      - pre-commit install -c ./config/.pre-commit-config.yaml -t commit-msg
      - pnpm install

  isolate:
    desc: Isolate the code in an emulated ubuntu 20.04 environment (within docker)
    cmds:
      - ./scripts/isolate.sh {{.CLI_ARGS}}

  try:docs:build:
    desc: Try documentation building feature. Runs <cli> docs build -k -t ./tmp sample_docs target
    cmds:
      - node ./dist/semantic-generator docs build -k -t ./tmp sample_docs target

  try:docs:host:
    desc: Try hosting the documentation site
    cmds:
      - pnpx -y http-server -p 9090 ./target

  build:
    deps:
      - clean:build
    desc: Builds the project
    cmds:
      - tsc
      - sd var___INJECT_VERSION___ $(cat package.json | jq .version | sd \" '') dist/semantic-generator.js
  dev:
    desc: Watches for changes and constantly rebuild the dist folder
    cmds:
      - tsc --watch

  test:
    desc: Runs unit tests
    cmds:
      - task: test:default

  cover:
    desc: Get tests coverage
    cmds:
      - task: test:cover

  run:
    desc: Runs the CLI
    cmds:
      - node ./dist/semantic-generator {{.CLI_ARGS}}

  lint:
    - task: lint:default

  clean:
    - task: clean:default

  fmt:
    - task: fmt:default
