Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,5 @@ app.*.symbols
!test/*.mocks.dart
!test/**/*.mocks.dart
screenshots/
!mise-tasks/screenshots/
test/failures/
7 changes: 5 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,11 @@ MISE_ENV=dev ./bin/mise run build:web
`test` and `analyze` automatically save output to a temp file, print the path before the run starts, and print a ready-to-use grep command at the end. Run once, grep the file as many times as needed — do not re-run to grep different things.

```bash
# Run a specific test file
./bin/mise exec flutter -- flutter test test/my_test.dart
# Run a specific test file or directory
./bin/mise run test test/widgets/drink_card_test.dart

# Run a specific analysis path
./bin/mise run analyze lib/screens/
```

> `TEST_LOG` and `ANALYZE_LOG` env vars let you override the temp file path if you need a stable location across multiple runs.
Expand Down
14 changes: 14 additions & 0 deletions mise-tasks/analyze.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#MISE description="Run after Dart changes — pass a path to limit scope; grep output with the path printed at start"
#MISE depends=["generate"]

set -uo pipefail
ANALYZE_LOG="${ANALYZE_LOG:-$(mktemp /tmp/analyze-XXXXXX.log)}"
echo "ANALYZE_LOG=$ANALYZE_LOG"
flutter analyze --no-fatal-infos "$@" 2>&1 \
| grep -v -E "Woah! You appear|superuser privileges" \
| tee "$ANALYZE_LOG"
EXIT_CODE=${PIPESTATUS[0]}
echo "---"
echo "Grep with: grep -n 'error\|warning' $ANALYZE_LOG"
exit "$EXIT_CODE"
11 changes: 11 additions & 0 deletions mise-tasks/build/web.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
#MISE description="Build Flutter web app in release mode (for local testing/e2e)"

set -euo pipefail
echo "Building Flutter web app in release mode..."
flutter build web --release --base-href "/"
echo ""
echo "Build complete! Output at: build/web/"
echo ""
echo "To serve locally for testing:"
echo " npx http-server build/web -p 8080"
16 changes: 8 additions & 8 deletions mise-tasks/build/web/prod → mise-tasks/build/web/prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ echo "Building Flutter web app for production..."

# Get version information
if [ -x "scripts/get_version_info.sh" ]; then
echo "Gathering version information..."
eval "$(scripts/get_version_info.sh export)"
echo "Gathering version information..."
eval "$(scripts/get_version_info.sh export)"
else
echo "Warning: scripts/get_version_info.sh not found, building without version info"
echo "Warning: scripts/get_version_info.sh not found, building without version info"
fi

# Build with version information
flutter build web --release --base-href "/" \
${GIT_TAG:+--dart-define=GIT_TAG=$GIT_TAG} \
${GIT_COMMIT:+--dart-define=GIT_COMMIT=$GIT_COMMIT} \
${GIT_BRANCH:+--dart-define=GIT_BRANCH=$GIT_BRANCH} \
${BUILD_VERSION:+--dart-define=BUILD_VERSION=$BUILD_VERSION} \
${BUILD_TIME:+--dart-define=BUILD_TIME=$BUILD_TIME}
${GIT_TAG:+--dart-define=GIT_TAG=$GIT_TAG} \
${GIT_COMMIT:+--dart-define=GIT_COMMIT=$GIT_COMMIT} \
${GIT_BRANCH:+--dart-define=GIT_BRANCH=$GIT_BRANCH} \
${BUILD_VERSION:+--dart-define=BUILD_VERSION=$BUILD_VERSION} \
${BUILD_TIME:+--dart-define=BUILD_TIME=$BUILD_TIME}

echo ""
echo "✅ Production build complete! Output at: build/web/"
Expand Down
10 changes: 10 additions & 0 deletions mise-tasks/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
#MISE description="Run tests with coverage reporting (output: coverage/lcov.info)"
#MISE depends=["generate"]

set -uo pipefail
flutter test --coverage 2>&1 | grep -v -E "Woah! You appear|superuser privileges"
EXIT_CODE=${PIPESTATUS[0]}
echo "Coverage report generated at coverage/lcov.info"
echo "To view HTML report, install lcov and run: genhtml coverage/lcov.info -o coverage/html"
exit "$EXIT_CODE"
6 changes: 6 additions & 0 deletions mise-tasks/dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
#MISE description="Start Flutter dev server on localhost:8080"

set -euo pipefail
echo "Starting Flutter dev server on http://localhost:8080"
flutter run -d web-server --web-port 8080 --pid-file flutter-dev.pid
8 changes: 4 additions & 4 deletions mise-tasks/dev/tunnel → mise-tasks/dev/tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ echo ""

# Cleanup function
cleanup() {
echo ""
echo "Stopping tunnel..."
kill $TUNNEL_PID 2>/dev/null
exit
echo ""
echo "Stopping tunnel..."
kill $TUNNEL_PID 2>/dev/null
exit
}

# Set up cleanup on exit
Expand Down
13 changes: 13 additions & 0 deletions mise-tasks/screenshots/batch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
#MISE description="Capture screenshots of multiple pages from config file"
#USAGE arg "[config]" help="Config file path" default="screenshots.config.json"
#USAGE arg "[output]" help="Output directory" default="screenshots"

set -euo pipefail
CONFIG="${usage_config:-screenshots.config.json}"
OUTPUT="${usage_output:-screenshots}"

echo "Running batch screenshot capture..."
echo "Config: $CONFIG"
echo "Output: $OUTPUT"
node scripts/screenshot-batch.mjs -c "$CONFIG" -o "$OUTPUT"
14 changes: 14 additions & 0 deletions mise-tasks/serve/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#MISE description="Serve release build with http-server (SPA mode for deep linking)"

set -euo pipefail
if [ ! -d "build/web" ]; then
echo "Error: build/web directory not found"
echo "Run: MISE_ENV=dev ./bin/mise run build:web first"
exit 1
fi

echo "Starting http-server with SPA routing..."
echo "Available at: http://localhost:8080"
echo "Press Ctrl+C to stop"
npx http-server build/web -p 8080 --proxy http://localhost:8080?
14 changes: 7 additions & 7 deletions mise-tasks/setup/playwright → mise-tasks/setup/playwright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ echo ""

# Install npm dependencies if needed
if [ ! -d node_modules ]; then
echo "Step 1: Installing npm dependencies..."
npm install
echo "Step 1: Installing npm dependencies..."
npm install
else
echo "✓ npm dependencies already installed"
echo "✓ npm dependencies already installed"
fi

# Check if Playwright browsers are installed
if [ ! -d ~/.cache/ms-playwright ] || [ -z "$(ls -A ~/.cache/ms-playwright 2>/dev/null)" ]; then
echo ""
echo "Step 2: Installing Playwright browsers..."
npx playwright install chromium
echo ""
echo "Step 2: Installing Playwright browsers..."
npx playwright install chromium
else
echo "✓ Playwright browsers already installed"
echo "✓ Playwright browsers already installed"
fi

# Install system dependencies (requires sudo)
Expand Down
14 changes: 7 additions & 7 deletions mise-tasks/setup/tunnel → mise-tasks/setup/tunnel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ echo ""

# Check if already logged in
if [ ! -f ~/.cloudflared/cert.pem ]; then
echo "Step 1: Login to Cloudflare (browser will open)..."
cloudflared tunnel login
echo "Step 1: Login to Cloudflare (browser will open)..."
cloudflared tunnel login
else
echo "✓ Already logged in to Cloudflare"
echo "✓ Already logged in to Cloudflare"
fi

# Check if tunnel already exists
if cloudflared tunnel list 2>/dev/null | grep -q "cbf-dev-tunnel"; then
echo "✓ Tunnel 'cbf-dev-tunnel' already exists"
echo "✓ Tunnel 'cbf-dev-tunnel' already exists"
else
echo ""
echo "Step 2: Creating tunnel 'cbf-dev-tunnel'..."
cloudflared tunnel create cbf-dev-tunnel
echo ""
echo "Step 2: Creating tunnel 'cbf-dev-tunnel'..."
cloudflared tunnel create cbf-dev-tunnel
fi

# Route DNS
Expand Down
15 changes: 15 additions & 0 deletions mise-tasks/shell/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
#MISE description="Run after editing any .sh or mise-tasks/ file"

set -euo pipefail

mapfile -t ALL_FILES < <(find . -name "*.sh" -not -path "./.git/*" -not -path "./.mise/*" -not -path "*/node_modules/*" | sort)

if [ "${#ALL_FILES[@]}" -eq 0 ]; then
echo "No shell scripts found"
exit 0
fi

echo "Running shellcheck on ${#ALL_FILES[@]} files..."
shellcheck "${ALL_FILES[@]}"
echo "shellcheck passed"
15 changes: 15 additions & 0 deletions mise-tasks/shell/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
#MISE description="Run after editing any .sh or mise-tasks/ file"

set -euo pipefail

mapfile -t ALL_FILES < <(find . -name "*.sh" -not -path "./.git/*" -not -path "./.mise/*" -not -path "*/node_modules/*" | sort)

if [ "${#ALL_FILES[@]}" -eq 0 ]; then
echo "No shell scripts found"
exit 0
fi

echo "Formatting ${#ALL_FILES[@]} files with shfmt..."
shfmt -w -i 0 -ci "${ALL_FILES[@]}"
echo "shfmt complete"
14 changes: 14 additions & 0 deletions mise-tasks/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
#MISE description="Run before committing — pass a file arg to run a subset; grep output with the path printed at start"
#MISE depends=["generate"]

set -uo pipefail
TEST_LOG="${TEST_LOG:-$(mktemp /tmp/test-XXXXXX.log)}"
echo "TEST_LOG=$TEST_LOG"
flutter test "$@" 2>&1 \
| grep -v -E "Woah! You appear|superuser privileges" \
| tee "$TEST_LOG"
EXIT_CODE=${PIPESTATUS[0]}
echo "---"
echo "Grep with: grep -n 'FAILED\|ERROR' $TEST_LOG"
exit "$EXIT_CODE"
12 changes: 12 additions & 0 deletions mise-tasks/test/check-page.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
#MISE description="Check page for console errors and take screenshot"
#USAGE arg "[url]" help="URL to check" default="http://localhost:8080"
#USAGE arg "[screenshot]" help="Screenshot output path" default="screenshot.png"

set -euo pipefail
URL="${usage_url:-http://localhost:8080}"
SCREENSHOT="${usage_screenshot:-screenshot.png}"

echo "Checking page: $URL"
echo "Screenshot will be saved to: $SCREENSHOT"
node scripts/check-page.mjs -u "$URL" -s "$SCREENSHOT"
6 changes: 6 additions & 0 deletions mise-tasks/test/e2e.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
#MISE description="Run e2e tests with Playwright (headless mode)"

set -euo pipefail
echo "Running e2e tests with Playwright..."
npm run test:e2e
6 changes: 6 additions & 0 deletions mise-tasks/test/e2e/headed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
#MISE description="Run e2e tests in headed mode (visible browser)"

set -euo pipefail
echo "Running e2e tests in headed mode..."
npm run test:e2e:headed
6 changes: 6 additions & 0 deletions mise-tasks/test/e2e/ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
#MISE description="Run e2e tests in Playwright UI mode (interactive)"

set -euo pipefail
echo "Running e2e tests in UI mode..."
npm run test:e2e:ui
104 changes: 13 additions & 91 deletions mise.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,94 +14,16 @@
# Docs: https://mise.jdx.dev/tasks/task-arguments.html
# https://mise.jdx.dev/tasks/file-tasks.html

[tasks.dev]
description = "Start Flutter dev server on localhost:8080"
run = '''
echo "Starting Flutter dev server on http://localhost:8080"
flutter run -d web-server --web-port 8080 --pid-file flutter-dev.pid
'''

# Complex tasks moved to mise-tasks/ for better maintainability:
# - setup:tunnel -> mise-tasks/setup/tunnel
# - setup:playwright -> mise-tasks/setup/playwright
# - dev:tunnel -> mise-tasks/dev/tunnel
# - build:web:prod -> mise-tasks/build/web/prod

[tasks."test:e2e"]
description = "Run e2e tests with Playwright (headless mode)"
run = '''
echo "Running e2e tests with Playwright..."
npm run test:e2e
'''

[tasks."test:e2e:ui"]
description = "Run e2e tests in Playwright UI mode (interactive)"
run = '''
echo "Running e2e tests in UI mode..."
npm run test:e2e:ui
'''

[tasks."test:e2e:headed"]
description = "Run e2e tests in headed mode (visible browser)"
run = '''
echo "Running e2e tests in headed mode..."
npm run test:e2e:headed
'''

[tasks."build:web"]
description = "Build Flutter web app in release mode (for local testing/e2e)"
run = '''
echo "Building Flutter web app in release mode..."
flutter build web --release --base-href "/"
echo ""
echo "✅ Build complete! Output at: build/web/"
echo ""
echo "To serve locally for testing:"
echo " npx http-server build/web -p 8080"
'''

[tasks."serve:release"]
description = "Serve release build with http-server (SPA mode for deep linking)"
run = '''
if [ ! -d "build/web" ]; then
echo "Error: build/web directory not found"
echo "Run: mise run build:web first"
exit 1
fi

echo "Starting http-server with SPA routing..."
echo "Available at: http://localhost:8080"
echo "Press Ctrl+C to stop"
npx http-server build/web -p 8080 --proxy http://localhost:8080?
'''

[tasks."test:check-page"]
description = "Check page for console errors and take screenshot"
usage = '''
arg "[url]" help="URL to check" default="http://localhost:8080"
arg "[screenshot]" help="Screenshot output path" default="screenshot.png"
'''
run = '''
URL="${usage_url:-http://localhost:8080}"
SCREENSHOT="${usage_screenshot:-screenshot.png}"

echo "Checking page: $URL"
echo "Screenshot will be saved to: $SCREENSHOT"
node scripts/check-page.mjs -u "$URL" -s "$SCREENSHOT"
'''

[tasks."screenshots:batch"]
description = "Capture screenshots of multiple pages from config file"
usage = '''
arg "[config]" help="Config file path" default="screenshots.config.json"
arg "[output]" help="Output directory" default="screenshots"
'''
run = '''
CONFIG="${usage_config:-screenshots.config.json}"
OUTPUT="${usage_output:-screenshots}"

echo "Running batch screenshot capture..."
echo "Config: $CONFIG"
echo "Output: $OUTPUT"
node scripts/screenshot-batch.mjs -c "$CONFIG" -o "$OUTPUT"
'''
# All tasks moved to mise-tasks/ for better maintainability and shellcheck/shfmt support:
# - dev -> mise-tasks/dev.sh
# - test:e2e -> mise-tasks/test/e2e.sh
# - test:e2e:ui -> mise-tasks/test/e2e/ui.sh
# - test:e2e:headed -> mise-tasks/test/e2e/headed.sh
# - build:web -> mise-tasks/build/web.sh
# - serve:release -> mise-tasks/serve/release.sh
# - test:check-page -> mise-tasks/test/check-page.sh
# - screenshots:batch -> mise-tasks/screenshots/batch.sh
# - setup:tunnel -> mise-tasks/setup/tunnel.sh
# - setup:playwright -> mise-tasks/setup/playwright.sh
# - dev:tunnel -> mise-tasks/dev/tunnel.sh
# - build:web:prod -> mise-tasks/build/web/prod.sh
Loading
Loading