diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 957175a..c958a0c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,13 +18,13 @@ jobs: - run: dart pub get - run: dart format --output none --set-exit-if-changed . - run: dart analyze - - run: dart run tool/coverage.dart + - run: ./chore coverage - name: Upload coverage uses: coverallsapp/github-action@v2.2.3 with: github-token: ${{ secrets.GITHUB_TOKEN }} path-to-lcov: coverage/lcov.info - - run: dart run tool/dartdoc.dart + - run: ./chore dartdoc - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index d2bf3d8..336de9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## Unreleased + +**Misc**: + +- Bumped Dart SDK to `^3.5.0` . + ## 0.1.0 🎉 Initial release 🎉 diff --git a/chore b/chore new file mode 100755 index 0000000..5d374a6 --- /dev/null +++ b/chore @@ -0,0 +1,15 @@ +#!/usr/bin/env sh + +# Chore is a tiny task runner with some pre-defined commands. + +set -e + +GIT_URL="https://github.com/matanlurey/chore.dart.git" +GIT_REF="8b252e7" + +# Silently activate the pinned version of `chore.dart` from GitHub. +# Only print if there is an error. +dart pub global activate -sgit $GIT_URL --git-ref=$GIT_REF 2>&1 > /dev/null + +# Now run and forward arguments and the output. +dart pub global run chore "$@" diff --git a/lib/src/extensions.dart b/lib/src/extensions.dart index 8114579..564e4b3 100644 --- a/lib/src/extensions.dart +++ b/lib/src/extensions.dart @@ -78,12 +78,9 @@ extension AnsiStringSink on W { T syncAnsiUpdate(T Function(W) update) { writeAnsi(SynchronousUpdates.start); try { - final result = update(this); + return update(this); + } finally { writeAnsi(SynchronousUpdates.end); - return result; - } on Object catch (_) { - writeAnsi(SynchronousUpdates.end); - rethrow; } } } diff --git a/pubspec.yaml b/pubspec.yaml index a3add02..c18166b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: A stately library for crafting and deciphering ANSI escape codes. version: 0.1.0 environment: - sdk: ^3.4.0 + sdk: ^3.5.0 repository: https://github.com/matanlurey/mansion @@ -13,12 +13,8 @@ dependencies: meta: ^1.15.0 dev_dependencies: - args: ^2.5.0 benchmark_harness: ^2.2.2 checks: ^0.3.0 coverage: ^1.8.0 - oath: ^0.2.0 - path: ^1.9.0 - shelf: ^1.4.2 - shelf_static: ^1.1.2 + oath: ^0.2.1 test: ^1.25.7 diff --git a/test/codec_test.dart b/test/codec_test.dart index fb6e4ef..5d4b48e 100644 --- a/test/codec_test.dart +++ b/test/codec_test.dart @@ -31,6 +31,7 @@ void main() { }); group('$AnsiDecoder(allowInvalid: false)', () { + // Make this explicit for tests. // ignore: avoid_redundant_argument_values const decoder = AnsiDecoder(allowInvalid: false); @@ -50,6 +51,7 @@ void main() { }); group('$AnsiDecoder.startChunkedConversion', () { + // Make this explicit for tests. // ignore: avoid_redundant_argument_values const decoder = AnsiDecoder(allowInvalid: false); diff --git a/tool/coverage.dart b/tool/coverage.dart deleted file mode 100755 index 47efcbc..0000000 --- a/tool/coverage.dart +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env dart - -import 'dart:io' as io; - -import 'package:args/args.dart'; - -/// Generates a coverage report for the project. -void main(List args) async { - final isCI = io.Platform.environment['CI'] == 'true'; - final parser = ArgParser() - ..addFlag( - 'help', - abbr: 'h', - help: 'Prints this help message.', - negatable: false, - ) - ..addOption( - 'report', - abbr: 'r', - help: 'What kind of report to generate.', - allowed: ['lcov-only', 'html', 'html-open-browser'], - defaultsTo: isCI ? 'lcov-only' : 'html-open-browser', - ); - final results = parser.parse(args); - - if (results['help'] as bool) { - io.stderr.writeln(parser.usage); - return; - } - - await _testWithCoverage(); - - // If we're reporting html or html-open-browser, generate the HTML report. - if (results['report'] != 'lcov-only') { - await _generateHtmlReport(); - - // Open the browser if requested. - if (results['report'] == 'html-open-browser') { - final process = await io.Process.start( - 'open', - ['coverage/html/index.html'], - ); - - process.stdout.listen(io.stdout.add); - process.stderr.listen(io.stderr.add); - - final exitCode = await process.exitCode; - if (exitCode != 0) { - throw Exception('Failed to open browser: $exitCode'); - } - } - } -} - -/// Runs `dart run coverage:test_with_coverage -- -P coverage`. -Future _testWithCoverage() async { - final process = await io.Process.start( - 'dart', - [ - 'run', - 'coverage:test_with_coverage', - '--', - '-P', - 'coverage', - ], - ); - - process.stdout.listen(io.stdout.add); - process.stderr.listen(io.stderr.add); - - final exitCode = await process.exitCode; - if (exitCode != 0) { - throw Exception('Failed to run test_with_coverage: $exitCode'); - } -} - -/// Runs `genhtml coverage/lcov.info -o coverage/html`. -Future _generateHtmlReport() async { - final process = await io.Process.start( - 'genhtml', - [ - 'coverage/lcov.info', - '-o', - 'coverage/html', - ], - ); - - process.stdout.listen(io.stdout.add); - process.stderr.listen(io.stderr.add); - - final exitCode = await process.exitCode; - if (exitCode != 0) { - throw Exception('Failed to generate HTML report: $exitCode'); - } -} diff --git a/tool/dartdoc.dart b/tool/dartdoc.dart deleted file mode 100755 index 62476f1..0000000 --- a/tool/dartdoc.dart +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env dart - -import 'dart:io' as io; - -import 'package:args/args.dart'; -import 'package:shelf/shelf_io.dart' as shelf_io; -import 'package:shelf_static/shelf_static.dart'; - -/// Generates dartdoc for the project. -void main(List args) async { - final isCI = io.Platform.environment['CI'] == 'true'; - final parser = ArgParser() - ..addFlag( - 'help', - abbr: 'h', - help: 'Prints this help message.', - negatable: false, - ) - ..addFlag( - 'generate', - help: 'Generates the documentation.', - defaultsTo: true, - ) - ..addOption( - 'preview', - abbr: 'p', - help: 'Opens the generated documentation in a browser.', - allowed: ['none', 'listen', 'listen-open-browser'], - defaultsTo: isCI ? 'none' : 'listen-open-browser', - ); - final results = parser.parse(args); - - if (results['help'] as bool) { - io.stderr.writeln(parser.usage); - return; - } - - final preview = results['preview'] as String; - final generate = results['generate'] as bool; - - if (generate) { - final dartdoc = await io.Process.start('dart', ['doc']); - - dartdoc.stdout.listen(io.stdout.add); - dartdoc.stderr.listen(io.stderr.add); - - final exitCode = await dartdoc.exitCode; - if (exitCode != 0) { - throw Exception('Failed to generate documentation: $exitCode'); - } - } - - if (preview != 'none') { - final handler = createStaticHandler('doc/api'); - final server = await shelf_io.serve(handler, 'localhost', 8080); - - io.stdout.writeln( - 'Serving documentation on http://localhost:8080/index.html', - ); - io.stdout.writeln('Press Ctrl+C to exit.'); - - if (preview == 'listen-open-browser') { - final process = await io.Process.start( - 'open', - ['http://localhost:8080/index.html'], - ); - - process.stdout.listen(io.stdout.add); - process.stderr.listen(io.stderr.add); - - final exitCode = await process.exitCode; - if (exitCode != 0) { - throw Exception('Failed to open browser: $exitCode'); - } - } - - await io.ProcessSignal.sigint.watch().first; - await server.close(force: true); - } -}