feat(shorebird_cli): improve shorebird apps list display (#202)
This commit is contained in:
@@ -131,8 +131,14 @@ shorebird apps list
|
|||||||
|
|
||||||
```
|
```
|
||||||
shorebird apps list
|
shorebird apps list
|
||||||
my_counter: v1.0.0 (patch #1)
|
📱 Apps
|
||||||
my_example: v2.1.0 (patch #2)
|
┌───────────────────┬──────────────────────────────────────┬─────────┬───────┐
|
||||||
|
│ Name │ ID │ Release │ Patch │
|
||||||
|
├───────────────────┼──────────────────────────────────────┼─────────┼───────┤
|
||||||
|
│ Shorebird Counter │ 30370f27-dbf1-4673-8b20-fb096e38dffa │ 1.0.0 │ 1 │
|
||||||
|
├───────────────────┼──────────────────────────────────────┼─────────┼───────┤
|
||||||
|
│ Shorebird Clock │ 05b45471-a5f3-48cd-b26a-da29d95914a7 │ -- │ -- │
|
||||||
|
└───────────────────┴──────────────────────────────────────┴─────────┴───────┘
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run
|
### Run
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:barbecue/barbecue.dart';
|
||||||
import 'package:mason_logger/mason_logger.dart';
|
import 'package:mason_logger/mason_logger.dart';
|
||||||
import 'package:shorebird_cli/src/command.dart';
|
import 'package:shorebird_cli/src/command.dart';
|
||||||
import 'package:shorebird_cli/src/shorebird_config_mixin.dart';
|
import 'package:shorebird_cli/src/shorebird_config_mixin.dart';
|
||||||
@@ -40,7 +41,7 @@ class ListAppsCommand extends ShorebirdCommand with ShorebirdConfigMixin {
|
|||||||
hostedUri: hostedUri,
|
hostedUri: hostedUri,
|
||||||
);
|
);
|
||||||
|
|
||||||
late final List<AppMetadata> apps;
|
final List<AppMetadata> apps;
|
||||||
try {
|
try {
|
||||||
apps = await client.getApps();
|
apps = await client.getApps();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -48,25 +49,56 @@ class ListAppsCommand extends ShorebirdCommand with ShorebirdConfigMixin {
|
|||||||
return ExitCode.software.code;
|
return ExitCode.software.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info('📱 Apps');
|
||||||
|
|
||||||
if (apps.isEmpty) {
|
if (apps.isEmpty) {
|
||||||
logger.info('(empty)');
|
logger.info('(empty)');
|
||||||
return ExitCode.success.code;
|
return ExitCode.success.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final app in apps) {
|
logger.info(apps.prettyPrint());
|
||||||
logger.info(app.prettyPrint());
|
|
||||||
}
|
|
||||||
|
|
||||||
return ExitCode.success.code;
|
return ExitCode.success.code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on AppMetadata {
|
extension on List<AppMetadata> {
|
||||||
String prettyPrint() {
|
String prettyPrint() {
|
||||||
final latestReleasePart =
|
const cellStyle = CellStyle(
|
||||||
latestReleaseVersion != null ? 'v$latestReleaseVersion' : '(empty)';
|
paddingLeft: 1,
|
||||||
final latestPatchPart =
|
paddingRight: 1,
|
||||||
latestPatchNumber != null ? ' (patch #$latestPatchNumber)' : '';
|
borderBottom: true,
|
||||||
return '$displayName: $latestReleasePart$latestPatchPart ($appId)';
|
borderTop: true,
|
||||||
|
borderLeft: true,
|
||||||
|
borderRight: true,
|
||||||
|
);
|
||||||
|
return Table(
|
||||||
|
cellStyle: cellStyle,
|
||||||
|
header: const TableSection(
|
||||||
|
rows: [
|
||||||
|
Row(
|
||||||
|
cells: [
|
||||||
|
Cell('Name'),
|
||||||
|
Cell('ID'),
|
||||||
|
Cell('Release'),
|
||||||
|
Cell('Patch'),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: TableSection(
|
||||||
|
rows: [
|
||||||
|
for (final app in this)
|
||||||
|
Row(
|
||||||
|
cells: [
|
||||||
|
Cell(app.displayName),
|
||||||
|
Cell(app.appId),
|
||||||
|
Cell(app.latestReleaseVersion ?? '--'),
|
||||||
|
Cell(app.latestPatchNumber?.toString() ?? '--'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,12 +65,23 @@ void main() {
|
|||||||
latestReleaseVersion: '1.0.0',
|
latestReleaseVersion: '1.0.0',
|
||||||
latestPatchNumber: 1,
|
latestPatchNumber: 1,
|
||||||
),
|
),
|
||||||
|
const AppMetadata(
|
||||||
|
appId: '05b45471-a5f3-48cd-b26a-da29d95914a7',
|
||||||
|
displayName: 'Shorebird Clock',
|
||||||
|
),
|
||||||
];
|
];
|
||||||
when(() => codePushClient.getApps()).thenAnswer((_) async => apps);
|
when(() => codePushClient.getApps()).thenAnswer((_) async => apps);
|
||||||
expect(await command.run(), ExitCode.success.code);
|
expect(await command.run(), ExitCode.success.code);
|
||||||
verify(
|
verify(
|
||||||
() => logger.info(
|
() => logger.info(
|
||||||
'''Shorebird Counter: v1.0.0 (patch #1) (30370f27-dbf1-4673-8b20-fb096e38dffa)''',
|
'''
|
||||||
|
┌───────────────────┬──────────────────────────────────────┬─────────┬───────┐
|
||||||
|
│ Name │ ID │ Release │ Patch │
|
||||||
|
├───────────────────┼──────────────────────────────────────┼─────────┼───────┤
|
||||||
|
│ Shorebird Counter │ 30370f27-dbf1-4673-8b20-fb096e38dffa │ 1.0.0 │ 1 │
|
||||||
|
├───────────────────┼──────────────────────────────────────┼─────────┼───────┤
|
||||||
|
│ Shorebird Clock │ 05b45471-a5f3-48cd-b26a-da29d95914a7 │ -- │ -- │
|
||||||
|
└───────────────────┴──────────────────────────────────────┴─────────┴───────┘''',
|
||||||
),
|
),
|
||||||
).called(1);
|
).called(1);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user