Skip to content

Commit

Permalink
0.2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
f3ath committed Jun 10, 2024
1 parent 9fee3ff commit 5a27bbc
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions lib/src/cli/cider_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ class CiderCli extends CommandRunner<int> {
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;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/command/cider_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class CiderCommand extends Command<int> {
@override
Future<int> 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));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/cli/command/describe_command.dart
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
11 changes: 6 additions & 5 deletions lib/src/cli/command/list_command.dart
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -26,10 +26,11 @@ class ListCommand extends CiderCommand {

@override
Future<int> 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;
}
}
1 change: 0 additions & 1 deletion lib/src/cli/command/log_sub_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class LogSubCommand extends CiderCommand {
@override
Future<int> exec(Project project) async {
await project.addUnreleased(type.name, argResults!.rest.first);

return 0;
}
}
12 changes: 6 additions & 6 deletions lib/src/cli/find_project_root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Directory> 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<bool> isRoot() =>
FileSystemEntity.identical(this.absolute.path, parent.absolute.path);
}
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/find_project_root_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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')));
});
});
}
11 changes: 9 additions & 2 deletions test/functional_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -293,3 +291,12 @@ Future<T> runIn<T>(Directory dir, Future<T> Function() f) async {
Directory.current = current;
}
}

void expectSubcommandsUsage(String output, {String? command}) {
if (command != null) {
expect(output, contains('Usage: cider $command <subcommand> [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.'));
}
10 changes: 0 additions & 10 deletions test/subcommands_usage.expect.dart

This file was deleted.

0 comments on commit 5a27bbc

Please sign in to comment.