launchWithTui static method
Future<void>
launchWithTui(
- Client cloudApiClient,
- FileUploaderFactory fileUploaderFactory, {
- required CommandLogger logger,
- required String baseCommand,
- required ProjectLaunch projectSetup,
- required String consoleServer,
- required bool openBrowser,
- required int deployConcurrency,
- required bool wetRun,
- required bool deployShowFiles,
- String? deployOutputPath,
- bool deploySkipTailingStatus = false,
Implementation
static Future<void> launchWithTui(
Client cloudApiClient,
FileUploaderFactory fileUploaderFactory, {
required CommandLogger logger,
required String baseCommand,
required ProjectLaunch projectSetup,
required String consoleServer,
required bool openBrowser,
required int deployConcurrency,
required bool wetRun,
required bool deployShowFiles,
String? deployOutputPath,
bool deploySkipTailingStatus = false,
}) async {
final defaultProjectId = _getDefaultProjectId(projectSetup);
final existingProjects = await _fetchExistingUndeployedProjects(
cloudApiClient,
);
final existingProjectIds = existingProjects
.map((p) => p.cloudProjectId)
.toList();
final state = LaunchConfigState(
projectSetup: projectSetup,
defaultProjectId: defaultProjectId,
existingProjectIds: existingProjectIds,
);
final holder = LaunchAppStateHolder(state);
final tuiWriter = TuiLogWriter()..attach(holder);
final tuiLogger = ServerpodCliLogger(tuiWriter);
// Hook up the TUI logger for structured logs in the TUI.
logger.initializeWith(tuiLogger);
await runTuiApp(
ScloudLaunchApp(
holder: holder,
onLaunch: () async {
// Update UI to show logs from the launch
state.markLaunchingProject();
holder.markDirty();
final stdoutController = StreamController<List<int>>();
stdoutController.stream
.transform(const Utf8Decoder(allowMalformed: true))
.transform(const LineSplitter())
.listen(logger.debug);
final toDebugLog = IOSink(stdoutController);
final stderrController = StreamController<List<int>>();
stderrController.stream
.transform(const Utf8Decoder(allowMalformed: true))
.transform(const LineSplitter())
.listen(logger.error);
final toErrorLog = IOSink(stderrController);
await performLaunch(
cloudApiClient,
fileUploaderFactory,
logger,
baseCommand,
state.projectSetup,
consoleServer: consoleServer,
openBrowser: openBrowser,
stdout: toDebugLog,
stderr: toErrorLog,
deployConcurrency: deployConcurrency,
wetRun: wetRun,
deployShowFiles: deployShowFiles,
deployOutputPath: deployOutputPath,
deploySkipTailingStatus: deploySkipTailingStatus,
);
},
onQuit: () {
/// Reset to the default logger for post-tui logs.
logger.reset();
shutdownTuiApp();
},
),
);
}