runWithConfig method
Runs this command with prepared configuration (options). Subclasses should override this method.
Implementation
@override
Future<void> runWithConfig(final Configuration commandConfig) async {
final localStoragePath = globalConfiguration.scloudDir;
final cloudData = await ResourceManager.tryFetchServerpodCloudData(
localStoragePath: localStoragePath.path,
logger: logger,
);
if (cloudData == null) {
logger.info('No stored Serverpod Cloud credentials found.');
return;
}
final cloudClient = runner.serviceProvider.cloudApiClient;
ErrorExitException? exitException;
try {
await cloudClient.auth.logoutDevice();
} on Exception catch (e) {
// TODO: warning logging can be removed when we are out of the beta phase
logger.warning('Ignoring error response from server: $e');
}
try {
await ResourceManager.removeServerpodCloudData(
localStoragePath: localStoragePath.path,
);
} on Exception catch (e) {
logger.error(
'Failed to remove stored credentials',
exception: e,
hint: 'Please remove these manually. '
'They should be located in $localStoragePath.',
);
exitException = ErrorExitException();
}
if (exitException != null) {
throw exitException;
}
logger.success('Successfully logged out from Serverpod cloud.');
}