scripts:
  _: &coverage_scripts
    coverage:
      run: >
        melos exec -c 1 --fail-fast -- "dart pub add --dev coverage && dart test --coverage=coverage && dart pub global activate coverage && dart pub global run coverage:format_coverage -l --packages=.dart_tool/package_config.json --report-on=lib/ -i coverage -o coverage/lcov.info && dart pub remove coverage"
      description: Run tests with coverage and generate LCOV report for each package
    coverage_report:
      run: >
        melos exec -c 1 --fail-fast -- "
        if [ -s coverage/lcov.info ]; then
          genhtml -o coverage_report coverage/lcov.info;
          echo 'Coverage report generated successfully.';
        else
          echo 'No valid coverage data found. Skipping report generation.';
        fi
        "
      description: Generate HTML coverage report from LCOV data for each package, if valid data exists
