Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shorebird_cli): improve shorebird apps list display #202

Merged
merged 3 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
feat(shorebird_cli): improve shorebird apps list display
  • Loading branch information
felangel committed Mar 29, 2023
commit 184f75102f7df092c15c4485cb7d1250247cb357
9 changes: 7 additions & 2 deletions packages/shorebird_cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ shorebird apps list

```
shorebird apps list
my_counter: v1.0.0 (patch #1)
my_example: v2.1.0 (patch #2)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ID β”‚ Name β”‚ Release β”‚ Patch β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 30370f27-dbf1-4673-8b20-fb096e38dffa β”‚ Shorebird Counter β”‚ 1.0.0 β”‚ 1 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 05b45471-a5f3-48cd-b26a-da29d95914a7 β”‚ Shorebird Clock β”‚ -- β”‚ -- β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜
```

### Run
Expand Down
52 changes: 42 additions & 10 deletions packages/shorebird_cli/lib/src/commands/apps/list_apps_command.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

import 'package:barbecue/barbecue.dart';
import 'package:mason_logger/mason_logger.dart';
import 'package:shorebird_cli/src/command.dart';
import 'package:shorebird_cli/src/shorebird_config_mixin.dart';
Expand Down Expand Up @@ -40,33 +41,64 @@ class ListAppsCommand extends ShorebirdCommand with ShorebirdConfigMixin {
hostedUri: hostedUri,
);

late final List<AppMetadata> apps;
final List<AppMetadata> apps;
try {
apps = await client.getApps();
} catch (error) {
logger.err('$error');
return ExitCode.software.code;
}

logger.info('πŸ“± Apps');

if (apps.isEmpty) {
logger.info('(empty)');
return ExitCode.success.code;
}

for (final app in apps) {
logger.info(app.prettyPrint());
}
logger.info(apps.prettyPrint());

return ExitCode.success.code;
}
}

extension on AppMetadata {
extension on List<AppMetadata> {
String prettyPrint() {
final latestReleasePart =
latestReleaseVersion != null ? 'v$latestReleaseVersion' : '(empty)';
final latestPatchPart =
latestPatchNumber != null ? ' (patch #$latestPatchNumber)' : '';
return '$displayName: $latestReleasePart$latestPatchPart ($appId)';
const cellStyle = CellStyle(
paddingLeft: 1,
paddingRight: 1,
borderBottom: true,
borderTop: true,
borderLeft: true,
borderRight: true,
);
return Table(
cellStyle: cellStyle,
header: const TableSection(
rows: [
Row(
cells: [
Cell('ID'),
Cell('Name'),
Cell('Release'),
Cell('Patch'),
],
)
],
),
body: TableSection(
rows: [
for (final app in this)
Row(
cells: [
Cell(app.appId),
Cell(app.displayName),
Cell(app.latestReleaseVersion ?? '--'),
Cell(app.latestPatchNumber?.toString() ?? '--'),
],
),
],
),
).render();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,23 @@ void main() {
latestReleaseVersion: '1.0.0',
latestPatchNumber: 1,
),
const AppMetadata(
appId: '05b45471-a5f3-48cd-b26a-da29d95914a7',
displayName: 'Shorebird Clock',
),
];
when(() => codePushClient.getApps()).thenAnswer((_) async => apps);
expect(await command.run(), ExitCode.success.code);
verify(
() => logger.info(
'''Shorebird Counter: v1.0.0 (patch #1) (30370f27-dbf1-4673-8b20-fb096e38dffa)''',
'''
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ID β”‚ Name β”‚ Release β”‚ Patch β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 30370f27-dbf1-4673-8b20-fb096e38dffa β”‚ Shorebird Counter β”‚ 1.0.0 β”‚ 1 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 05b45471-a5f3-48cd-b26a-da29d95914a7 β”‚ Shorebird Clock β”‚ -- β”‚ -- β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜''',
),
).called(1);
});
Expand Down