Skip to content

Commit 12f620c

Browse files
author
serverpod_cloud
committed
feat: bc091965471adfcffeb1b40d10ad1b730cce7e05
1 parent 95e564c commit 12f620c

7 files changed

Lines changed: 208 additions & 118 deletions

File tree

ground_control_client/lib/src/protocol/client.dart

Lines changed: 98 additions & 83 deletions
Large diffs are not rendered by default.

ground_control_client/lib/src/protocol/protocol.dart

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ import 'package:ground_control_client/src/protocol/features/project/models/proje
7171
as _i53;
7272
import 'package:ground_control_client/src/protocol/features/project/models/project_info/project_info.dart'
7373
as _i54;
74-
import 'package:ground_control_client/src/protocol/domains/users/models/user.dart'
74+
import 'package:ground_control_client/src/protocol/domains/status/models/deploy_attempt.dart'
7575
as _i55;
76-
import 'package:ground_control_client/src/protocol/features/auth/models/required_terms.dart'
76+
import 'package:ground_control_client/src/protocol/domains/users/models/user.dart'
7777
as _i56;
78-
import 'package:ground_control_client/src/protocol/features/auth/models/accepted_terms_dto.dart'
78+
import 'package:ground_control_client/src/protocol/features/auth/models/required_terms.dart'
7979
as _i57;
80-
import 'package:ground_control_client/src/protocol/domains/billing/models/payment_method.dart'
80+
import 'package:ground_control_client/src/protocol/features/auth/models/accepted_terms_dto.dart'
8181
as _i58;
82-
import 'package:ground_control_client/src/protocol/features/environment_variables/models/environment_variable.dart'
82+
import 'package:ground_control_client/src/protocol/domains/billing/models/payment_method.dart'
8383
as _i59;
84-
import 'package:ground_control_client/src/protocol/features/project/models/role.dart'
84+
import 'package:ground_control_client/src/protocol/features/environment_variables/models/environment_variable.dart'
8585
as _i60;
86-
import 'package:ground_control_client/src/protocol/domains/status/models/deploy_attempt.dart'
86+
import 'package:ground_control_client/src/protocol/features/project/models/role.dart'
8787
as _i61;
8888
import 'package:ground_control_client/src/protocol/domains/status/models/deploy_attempt_stage.dart'
8989
as _i62;
@@ -574,49 +574,49 @@ class Protocol extends _i1.SerializationManager {
574574
.map((e) => deserialize<_i54.ProjectInfo>(e))
575575
.toList() as T;
576576
}
577-
if (t == List<_i55.User>) {
578-
return (data as List).map((e) => deserialize<_i55.User>(e)).toList() as T;
577+
if (t == List<_i55.DeployAttempt>) {
578+
return (data as List)
579+
.map((e) => deserialize<_i55.DeployAttempt>(e))
580+
.toList() as T;
581+
}
582+
if (t == List<_i56.User>) {
583+
return (data as List).map((e) => deserialize<_i56.User>(e)).toList() as T;
579584
}
580-
if (t == List<_i56.RequiredTerms>) {
585+
if (t == List<_i57.RequiredTerms>) {
581586
return (data as List)
582-
.map((e) => deserialize<_i56.RequiredTerms>(e))
587+
.map((e) => deserialize<_i57.RequiredTerms>(e))
583588
.toList() as T;
584589
}
585-
if (t == List<_i57.AcceptedTermsDTO>) {
590+
if (t == List<_i58.AcceptedTermsDTO>) {
586591
return (data as List)
587-
.map((e) => deserialize<_i57.AcceptedTermsDTO>(e))
592+
.map((e) => deserialize<_i58.AcceptedTermsDTO>(e))
588593
.toList() as T;
589594
}
590595
if (t == List<String>) {
591596
return (data as List).map((e) => deserialize<String>(e)).toList() as T;
592597
}
593-
if (t == List<_i58.PaymentMethod>) {
598+
if (t == List<_i59.PaymentMethod>) {
594599
return (data as List)
595-
.map((e) => deserialize<_i58.PaymentMethod>(e))
600+
.map((e) => deserialize<_i59.PaymentMethod>(e))
596601
.toList() as T;
597602
}
598-
if (t == List<_i59.EnvironmentVariable>) {
603+
if (t == List<_i60.EnvironmentVariable>) {
599604
return (data as List)
600-
.map((e) => deserialize<_i59.EnvironmentVariable>(e))
605+
.map((e) => deserialize<_i60.EnvironmentVariable>(e))
601606
.toList() as T;
602607
}
603608
if (t == _i1.getType<List<String>?>()) {
604609
return (data != null
605610
? (data as List).map((e) => deserialize<String>(e)).toList()
606611
: null) as T;
607612
}
608-
if (t == List<_i60.Role>) {
609-
return (data as List).map((e) => deserialize<_i60.Role>(e)).toList() as T;
613+
if (t == List<_i61.Role>) {
614+
return (data as List).map((e) => deserialize<_i61.Role>(e)).toList() as T;
610615
}
611616
if (t == Map<String, String>) {
612617
return (data as Map).map((k, v) =>
613618
MapEntry(deserialize<String>(k), deserialize<String>(v))) as T;
614619
}
615-
if (t == List<_i61.DeployAttempt>) {
616-
return (data as List)
617-
.map((e) => deserialize<_i61.DeployAttempt>(e))
618-
.toList() as T;
619-
}
620620
if (t == List<_i62.DeployAttemptStage>) {
621621
return (data as List)
622622
.map((e) => deserialize<_i62.DeployAttemptStage>(e))

serverpod_cloud_cli/lib/command_logger/command_logger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class CommandLogger {
398398
/// Example:
399399
/// ```bash
400400
/// Run the following command to see all projects:
401-
/// $ scloud projects list
401+
/// $ scloud project list
402402
/// ```
403403
void terminalCommand(
404404
final String command, {

serverpod_cloud_cli/lib/command_runner/commands/admin/admin_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CloudAdminCommand extends CloudCliCommand {
2424
}) {
2525
addSubcommand(AdminListUsersCommand(logger: logger));
2626
addSubcommand(AdminInviteUserCommand(logger: logger));
27-
addSubcommand(AdminListProjectsCommand(logger: logger));
27+
addSubcommand(AdminProjectCommand(logger: logger));
2828
addSubcommand(AdminRedeployCommand(logger: logger));
2929
addSubcommand(AdminProductCommand(logger: logger));
3030
}

serverpod_cloud_cli/lib/command_runner/commands/admin/admin_projects_commands.dart

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ import 'package:config/config.dart';
22
import 'package:serverpod_cloud_cli/command_runner/cloud_cli_command.dart';
33
import 'package:serverpod_cloud_cli/command_runner/helpers/command_options.dart';
44
import 'package:serverpod_cloud_cli/commands/admin/project_admin.dart';
5+
import 'package:serverpod_cloud_cli/commands/status/status.dart'
6+
show DeployStatusTable;
7+
8+
class AdminProjectCommand extends CloudCliCommand {
9+
@override
10+
final name = 'project';
11+
12+
@override
13+
final description = 'Inspect Serverpod Cloud projects.';
14+
15+
AdminProjectCommand({required super.logger}) {
16+
addSubcommand(AdminListProjectsCommand(logger: logger));
17+
addSubcommand(AdminProjectStatusCommand(logger: logger));
18+
}
19+
}
520

621
enum AdminListProjectsOption<V> implements OptionDefinition<V> {
722
includeArchived(FlagOption(
@@ -21,7 +36,7 @@ enum AdminListProjectsOption<V> implements OptionDefinition<V> {
2136
class AdminListProjectsCommand
2237
extends CloudCliCommand<AdminListProjectsOption> {
2338
@override
24-
final name = 'list-projects';
39+
final name = 'list';
2540

2641
@override
2742
final description = 'List Serverpod Cloud projects.';
@@ -45,3 +60,56 @@ class AdminListProjectsCommand
4560
);
4661
}
4762
}
63+
64+
enum AdminProjectStatusOption<V> implements OptionDefinition<V> {
65+
projectId(StringOption(
66+
argName: 'project',
67+
argAbbrev: 'p',
68+
argPos: 0,
69+
mandatory: true,
70+
helpText: 'The ID of the project. '
71+
'Can be passed as the first argument.',
72+
)),
73+
limit(IntOption(
74+
argName: 'limit',
75+
helpText: 'The maximum number of records to fetch.',
76+
defaultsTo: 10,
77+
min: 1,
78+
)),
79+
utc(UtcOption());
80+
81+
const AdminProjectStatusOption(this.option);
82+
83+
@override
84+
final ConfigOptionBase<V> option;
85+
}
86+
87+
class AdminProjectStatusCommand
88+
extends CloudCliCommand<AdminProjectStatusOption> {
89+
@override
90+
final name = 'status';
91+
92+
@override
93+
final description = 'Show the status of a project.';
94+
95+
AdminProjectStatusCommand({required super.logger})
96+
: super(options: AdminProjectStatusOption.values);
97+
98+
@override
99+
Future<void> runWithConfig(
100+
final Configuration<AdminProjectStatusOption> commandConfig,
101+
) async {
102+
final projectId = commandConfig.value(AdminProjectStatusOption.projectId);
103+
final limit = commandConfig.value(AdminProjectStatusOption.limit);
104+
final inUtc = commandConfig.value(AdminProjectStatusOption.utc);
105+
106+
final statuses = await runner.serviceProvider.cloudApiClient.adminProjects
107+
.getDeployAttempts(
108+
cloudCapsuleId: projectId,
109+
limit: limit,
110+
);
111+
112+
final table = DeployStatusTable(inUtc: inUtc)..addRows(statuses);
113+
table.writeLines(logger.line);
114+
}
115+
}

serverpod_cloud_cli/lib/command_runner/commands/admin/admin_redeploy_command.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import 'package:config/config.dart';
22
import 'package:serverpod_cloud_cli/command_runner/cloud_cli_command.dart';
3-
import 'package:serverpod_cloud_cli/command_runner/helpers/command_options.dart';
43
import 'package:serverpod_cloud_cli/commands/admin/project_admin.dart';
54

65
enum AdminRedeployOption<V> implements OptionDefinition<V> {
7-
projectId(ProjectIdOption(asFirstArg: true));
6+
projectId(StringOption(
7+
argName: 'project',
8+
argAbbrev: 'p',
9+
argPos: 0,
10+
mandatory: true,
11+
helpText: 'The ID of the project. '
12+
'Can be passed as the first argument.',
13+
));
814

915
const AdminRedeployOption(this.option);
1016

serverpod_cloud_cli/test_integration/commands/admin/admin_project_list_cmd_test.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ void main() {
3030
logger.clear();
3131
});
3232

33-
test(
34-
'Given admin list-projects command when instantiated then requires login',
33+
test('Given admin project list command when instantiated then requires login',
3534
() {
3635
expect(AdminListProjectsCommand(logger: logger).requireLogin, isTrue);
3736
});
3837

3938
group('Given unauthenticated', () {
40-
group('when executing admin list-projects', () {
39+
group('when executing admin project list', () {
4140
late Future commandResult;
4241
setUp(() async {
4342
commandResult = cli.run([
4443
'admin',
45-
'list-projects',
44+
'project',
45+
'list',
4646
]);
4747
});
4848

@@ -68,7 +68,7 @@ void main() {
6868
await keyManager.put('mock-token');
6969
});
7070

71-
group('when executing admin list-projects', () {
71+
group('when executing admin project list', () {
7272
late Future commandResult;
7373
setUp(() async {
7474
when(() => client.adminProjects.listProjectsInfo(
@@ -102,7 +102,8 @@ void main() {
102102

103103
commandResult = cli.run([
104104
'admin',
105-
'list-projects',
105+
'project',
106+
'list',
106107
'--include-archived',
107108
]);
108109
});

0 commit comments

Comments
 (0)