Skip to content

Commit 91dd1af

Browse files
author
serverpod_cloud
committed
fix(scloud): 887445568b78ec899e6152acfd7e311bdf1c7f5a
1 parent 897416a commit 91dd1af

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

serverpod_cloud_cli/lib/command_runner/cloud_cli_command_runner.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
4343
/// If true, analytics will be not be suppressed for non-production usage.
4444
final bool _enableAnalyticsForAllEnvs;
4545

46+
/// If true, the admin subcommands are enabled.
47+
final bool _adminUserMode;
48+
4649
final VersionCommand _versionCommand;
4750

4851
GlobalConfiguration? _globalConfiguration;
@@ -85,11 +88,13 @@ class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
8588
required this.version,
8689
required final CloudCliServiceProvider serviceProvider,
8790
required final bool enableAnalyticsForAllEnvs,
91+
required final bool adminUserMode,
8892
super.onAnalyticsEvent,
8993
super.setLogLevel,
9094
}) : _serviceProvider = serviceProvider,
9195
_versionCommand = VersionCommand(logger: logger),
9296
_enableAnalyticsForAllEnvs = enableAnalyticsForAllEnvs,
97+
_adminUserMode = adminUserMode,
9398
super(
9499
'scloud',
95100
'Manage your Serverpod Cloud projects',
@@ -111,11 +116,19 @@ class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
111116
final bool enableAnalyticsForAllEnvs = false,
112117
bool? adminUserMode,
113118
}) {
119+
adminUserMode ??=
120+
bool.tryParse(
121+
Platform.environment['SERVERPOD_CLOUD_ADMIN_USER_MODE'] ?? 'false',
122+
caseSensitive: false,
123+
) ??
124+
false;
125+
114126
final runner = CloudCliCommandRunner._(
115127
logger: logger,
116128
version: version ?? cliVersion,
117129
serviceProvider: serviceProvider ?? CloudCliServiceProvider(),
118130
enableAnalyticsForAllEnvs: enableAnalyticsForAllEnvs,
131+
adminUserMode: adminUserMode,
119132
onAnalyticsEvent: onAnalyticsEvent,
120133
setLogLevel:
121134
({
@@ -128,13 +141,6 @@ class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
128141
),
129142
);
130143

131-
adminUserMode ??=
132-
bool.tryParse(
133-
Platform.environment['SERVERPOD_CLOUD_ADMIN_USER_MODE'] ?? 'false',
134-
caseSensitive: false,
135-
) ??
136-
false;
137-
138144
// Add commands (which may in turn have their own options and subcommands)
139145
runner.addCommands([
140146
runner._versionCommand,
@@ -237,6 +243,9 @@ class CloudCliCommandRunner extends BetterCommandRunner<GlobalOption, void> {
237243

238244
/// Returns true if the user likely is a production tenant user.
239245
bool _isTenantUser() {
246+
if (_adminUserMode) {
247+
return false;
248+
}
240249
if (!isActivatedFromPub()) {
241250
return false;
242251
}

0 commit comments

Comments
 (0)