Skip to content

Instantly share code, notes, and snippets.

@mrverdant13
Created August 15, 2021 02:50
Show Gist options
  • Save mrverdant13/e7c9a7b3ee2d0ea5518ed55da9de7d3e to your computer and use it in GitHub Desktop.
Save mrverdant13/e7c9a7b3ee2d0ea5518ed55da9de7d3e to your computer and use it in GitHub Desktop.
Melos config for Flutter
name: bloc_samples
packages:
- "*"
- analysis_options/*
- features/**
scripts:
gen:single:
run: melos exec -c 1 --fail-fast -- flutter pub run build_runner build --delete-conflicting-outputs
description: Generate files with `build_runner` for a selected package.
select-package:
depends-on: build_runner
gen:all:
run: melos run gen:single --no-select
description: Generate files with `build_runner` for all packages.
select-package:
depends-on: build_runner
test:
run: melos exec --dir-exists="test" --fail-fast -- flutter test --no-pub --test-randomize-ordering-seed random
description: Run all tests.
cov:gen:
run: melos exec --dir-exists="test" --fail-fast -- flutter test --no-pub --coverage --test-randomize-ordering-seed random
description: Run all test and generate coverage data per package
cov:merge:l:
run: rm -dfr coverage/lcov.info && melos exec -- sh MELOS_ROOT_PATH/merge-coverage.sh
description: Merge all coverage data (Linux)
cov:merge:m:
run: rm -dfr coverage/lcov.info && melos exec -- sh MELOS_ROOT_PATH/merge-coverage.sh
description: Merge all coverage data (macOS)
cov:merge:w:
run: if exist Coverage\lcov.info ( del /f /q coverage\lcov.info ) && melos exec -- MELOS_ROOT_PATH\merge-coverage.bat
description: Merge all coverage data (Windows)
cov:wipe:
# To use this script, you need to:
# 1. Install the remove_from_coverage package (https://pub.dev/packages/remove_from_coverage).
run: remove_from_coverage -f coverage/lcov.info -r "\.freezed\.dart$","\.g\.dart$","\.gr\.dart$"
description: Remove coverage data about generated Dart files
cov:rep:l:
run: genhtml coverage/lcov.info -o coverage/html/ && xdg-open coverage/html/index.html
description: Generate and preview the global coverage report (Linux)
cov:rep:m:
run: genhtml coverage/lcov.info -o coverage/html/ && open coverage/html/index.html
description: Generate and preview the global coverage report (macOS)
cov:rep:w:
# To use this script, you need to:
# 1. Install `lcov` utils with Chocolatey.
# 2. Set the `LCOV_TOOLS_PATH` env variable to the `lcov\tools\bin` folder absolute path (Often `C:\ProgramData\chocolatey\lib\lcov\tools\bin`).
run: perl %LCOV_TOOLS_PATH%\genhtml -o coverage\html coverage\lcov.info && start coverage\html\index.html
description: Generate and preview the global coverage report (Windows)
wf:l:
run: melos run cov:gen && melos run cov:merge:l && melos run cov:wipe && melos run cov:rep:l
description: Run full workflow (Linux)
wf:m:
run: melos run cov:gen && melos run cov:merge:m && melos run cov:wipe && melos run cov:rep:m
description: Run full workflow (macOS)
wf:w:
run: melos run cov:gen && melos run cov:merge:w && melos run cov:wipe && melos run cov:rep:w
description: Run full workflow (Windows)
@echo off
setLocal EnableDelayedExpansion
set relPath=!cd:%MELOS_ROOT_PATH%\=!
if exist pubspec.yaml (
if exist coverage\ (
if not exist %MELOS_ROOT_PATH%\coverage\ (
mkdir %MELOS_ROOT_PATH%\coverage
)
for /f "delims=" %%a in (coverage\lcov.info) do (
SET s=%%a
SET s=!s:SF:lib\=SF:%relPath%\lib\!
echo !s!>>%MELOS_ROOT_PATH%\coverage\lcov.info
)
)
)
endLocal
#!/usr/bin/env bash
relPath="$(echo `pwd` | sed "s|$MELOS_ROOT_PATH/||g" | sed 's|/|\\/|g')"
if [ -f "pubspec.yaml" ]; then
if [ -d "coverage" ]; then
if [ ! -d "$MELOS_ROOT_PATH/coverage" ]; then
mkdir "$MELOS_ROOT_PATH/coverage"
fi
sed "s/^SF:lib/SF:$relPath\/lib/g" coverage/lcov.info >> "$MELOS_ROOT_PATH/coverage/lcov.info"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment