From 5a27bbcca148a8c6cfa783a7bbacfdc25740374a Mon Sep 17 00:00:00 2001 From: f3ath Date: Sun, 9 Jun 2024 20:12:31 -0700 Subject: [PATCH] 0.2.8 --- CHANGELOG.md | 5 +++++ lib/src/cli/cider_cli.dart | 20 +++++++++++--------- lib/src/cli/command/cider_command.dart | 2 +- lib/src/cli/command/describe_command.dart | 2 +- lib/src/cli/command/list_command.dart | 11 ++++++----- lib/src/cli/command/log_sub_command.dart | 1 - lib/src/cli/find_project_root.dart | 12 ++++++------ pubspec.yaml | 8 ++++---- test/find_project_root_test.dart | 8 ++++---- test/functional_test.dart | 11 +++++++++-- test/subcommands_usage.expect.dart | 10 ---------- 11 files changed, 47 insertions(+), 43 deletions(-) delete mode 100644 test/subcommands_usage.expect.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c532f..dd95c7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.8] - 2024-06-09 +### Changed +- Deps version bump and a minor refactor + ## [0.2.7] - 2024-03-01 ### Fixed - The log command used to accept any prefix as an alias, this was broken in 0.2.6 @@ -120,6 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial version +[0.2.8]: https://github.com/f3ath/cider/compare/0.2.7...0.2.8 [0.2.7]: https://github.com/f3ath/cider/compare/0.2.6...0.2.7 [0.2.6]: https://github.com/f3ath/cider/compare/0.2.5...0.2.6 [0.2.5]: https://github.com/f3ath/cider/compare/0.2.4...0.2.5 diff --git a/lib/src/cli/cider_cli.dart b/lib/src/cli/cider_cli.dart index 6dd81e7..4b798a1 100644 --- a/lib/src/cli/cider_cli.dart +++ b/lib/src/cli/cider_cli.dart @@ -17,15 +17,17 @@ class CiderCli extends CommandRunner { CiderCli({this.console = const Console()}) : super('cider', 'Dart package maintenance tools') { argParser.addOption('project-root'); - addCommand(BumpCommand(console)); - addCommand(DescribeCommand(console)); - addCommand(ListCommand(console)); - addCommand(LogCommand(console)); - addCommand(PreambleCommand(console)); - addCommand(ReleaseCommand(console)); - addCommand(UnyankCommand(console)); - addCommand(VersionCommand(console)); - addCommand(YankCommand(console)); + [ + BumpCommand(console), + DescribeCommand(console), + ListCommand(console), + LogCommand(console), + PreambleCommand(console), + ReleaseCommand(console), + UnyankCommand(console), + VersionCommand(console), + YankCommand(console), + ].forEach(addCommand); } final Console console; diff --git a/lib/src/cli/command/cider_command.dart b/lib/src/cli/command/cider_command.dart index bcee012..9a8fcee 100644 --- a/lib/src/cli/command/cider_command.dart +++ b/lib/src/cli/command/cider_command.dart @@ -19,7 +19,7 @@ abstract class CiderCommand extends Command { @override Future run() async { final projectRoot = globalResults!['project-root'] ?? - findProjectRoot(Directory.current).absolute.path; + (await findProjectRoot(Directory.current)).absolute.path; final config = await _readConfigFromPubspec(projectRoot); return await exec(Project(projectRoot, config)); } diff --git a/lib/src/cli/command/describe_command.dart b/lib/src/cli/command/describe_command.dart index 829bf84..8aad64b 100644 --- a/lib/src/cli/command/describe_command.dart +++ b/lib/src/cli/command/describe_command.dart @@ -1,5 +1,5 @@ -import 'package:cider/src/project.dart'; import 'package:cider/src/cli/command/cider_command.dart'; +import 'package:cider/src/project.dart'; class DescribeCommand extends CiderCommand { DescribeCommand(super.console) { diff --git a/lib/src/cli/command/list_command.dart b/lib/src/cli/command/list_command.dart index 0f6c963..3d73481 100644 --- a/lib/src/cli/command/list_command.dart +++ b/lib/src/cli/command/list_command.dart @@ -1,5 +1,5 @@ -import 'package:cider/src/project.dart'; import 'package:cider/src/cli/command/cider_command.dart'; +import 'package:cider/src/project.dart'; class ListCommand extends CiderCommand { ListCommand(super.console) { @@ -26,10 +26,11 @@ class ListCommand extends CiderCommand { @override Future exec(Project project) async { - (await project.getAllVersions( - includeYanked: argResults![includeYanked], - includeUnreleased: argResults![includeUnreleased])) - .forEach(console.out.writeln); + final versions = await project.getAllVersions( + includeYanked: argResults![includeYanked], + includeUnreleased: argResults![includeUnreleased], + ); + versions.forEach(console.out.writeln); return 0; } } diff --git a/lib/src/cli/command/log_sub_command.dart b/lib/src/cli/command/log_sub_command.dart index 6763ed7..a4879c1 100644 --- a/lib/src/cli/command/log_sub_command.dart +++ b/lib/src/cli/command/log_sub_command.dart @@ -29,7 +29,6 @@ class LogSubCommand extends CiderCommand { @override Future exec(Project project) async { await project.addUnreleased(type.name, argResults!.rest.first); - return 0; } } diff --git a/lib/src/cli/find_project_root.dart b/lib/src/cli/find_project_root.dart index 36d3969..ef67bf7 100644 --- a/lib/src/cli/find_project_root.dart +++ b/lib/src/cli/find_project_root.dart @@ -5,13 +5,13 @@ import 'package:path/path.dart'; /// Finds the project root by locating 'pubspec.yaml'. /// Starts from [dir] and makes its way up to the system root folder. /// Throws a [StateError] if 'pubspec.yaml' can not be located. -Directory findProjectRoot(Directory dir) { - if (File(join(dir.path, 'pubspec.yaml')).existsSync()) return dir; - if (dir.isRoot) throw StateError('Can not find project root'); - return findProjectRoot(dir.parent); +Future findProjectRoot(Directory dir) async { + if (await File(join(dir.path, 'pubspec.yaml')).exists()) return dir; + if (await dir.isRoot()) throw StateError('Can not find project root'); + return await findProjectRoot(dir.parent); } extension _DirectoryExt on Directory { - bool get isRoot => - FileSystemEntity.identicalSync(this.absolute.path, parent.absolute.path); + Future isRoot() => + FileSystemEntity.identical(this.absolute.path, parent.absolute.path); } diff --git a/pubspec.yaml b/pubspec.yaml index e9c80ca..473c202 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: cider -version: 0.2.7 -description: Tools for Dart package maintainers. Automates changelog and pubspec updates. +version: 0.2.8 +description: Automatically increments, sets, prints the package version in pubspec.yaml. Adds, lists, prints entries in the changelog. Creates diff links in the changelog. homepage: https://github.com/f3ath/cider repository: https://github.com/f3ath/cider issue_tracker: https://github.com/f3ath/cider/issues environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.4.0 <4.0.0" dependencies: args: ^2.0.0 change: ^0.7.1 @@ -18,7 +18,7 @@ dependencies: pubspec_parse: ^1.0.0 dev_dependencies: - lints: ">=2.0.1 <5.0.0" + lints: ^4.0.0 test: ^1.15.3 coverage: ^1.0.2 check_coverage: ^0.0.2 diff --git a/test/find_project_root_test.dart b/test/find_project_root_test.dart index e9b4716..d570aeb 100644 --- a/test/find_project_root_test.dart +++ b/test/find_project_root_test.dart @@ -7,11 +7,11 @@ void main() { group('find_project_root', () { bool expectCurrent(Directory dir) => FileSystemEntity.identicalSync( dir.absolute.path, Directory.current.path); - test('from the project root', () { - expectCurrent(findProjectRoot(Directory.current)); + test('from the project root', () async { + expectCurrent(await findProjectRoot(Directory.current)); }); - test('from the test directory', () { - expectCurrent(findProjectRoot(Directory('test'))); + test('from the test directory', () async { + expectCurrent(await findProjectRoot(Directory('test'))); }); }); } diff --git a/test/functional_test.dart b/test/functional_test.dart index 8001b94..da5b405 100644 --- a/test/functional_test.dart +++ b/test/functional_test.dart @@ -7,8 +7,6 @@ import 'package:path/path.dart' as path; import 'package:pubspec_parse/pubspec_parse.dart'; import 'package:test/test.dart'; -import 'subcommands_usage.expect.dart'; - void main() { late Directory temp; final out = BufferChannel(); @@ -293,3 +291,12 @@ Future runIn(Directory dir, Future Function() f) async { Directory.current = current; } } + +void expectSubcommandsUsage(String output, {String? command}) { + if (command != null) { + expect(output, contains('Usage: cider $command [arguments]')); + } + expect(output, contains('-h, --help Print this usage information.')); + expect(output, contains('Available subcommands:')); + expect(output, contains('Run "cider help" to see global options.')); +} diff --git a/test/subcommands_usage.expect.dart b/test/subcommands_usage.expect.dart deleted file mode 100644 index 3e0cdd1..0000000 --- a/test/subcommands_usage.expect.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:test/test.dart'; - -void expectSubcommandsUsage(String output, {String? command}) { - if (command != null) { - expect(output, contains('Usage: cider $command [arguments]')); - } - expect(output, contains('-h, --help Print this usage information.')); - expect(output, contains('Available subcommands:')); - expect(output, contains('Run "cider help" to see global options.')); -}