performLaunch static method

Future<void> performLaunch(
  1. Client cloudApiClient,
  2. FileUploaderFactory fileUploaderFactory,
  3. CommandLogger logger,
  4. String baseCommand,
  5. ProjectLaunch projectSetup, {
  6. required String consoleServer,
  7. required bool openBrowser,
  8. required int deployConcurrency,
  9. required bool wetRun,
  10. required bool deployShowFiles,
  11. String? deployOutputPath,
  12. bool deploySkipTailingStatus = false,
  13. IOSink? stdout,
  14. IOSink? stderr,
})

Implementation

static Future<void> performLaunch(
  Client cloudApiClient,
  FileUploaderFactory fileUploaderFactory,
  CommandLogger logger,
  String baseCommand,
  ProjectLaunch projectSetup, {
  required String consoleServer,
  required bool openBrowser,
  required int deployConcurrency,
  required bool wetRun,
  required bool deployShowFiles,
  String? deployOutputPath,
  bool deploySkipTailingStatus = false,
  IOSink? stdout,
  IOSink? stderr,
}) async {
  final projectId = projectSetup.projectId;
  if (projectId == null) {
    throw StateError('Project ID not set in project setup.');
  }

  final projectDir = projectSetup.projectDir;
  final configFilePath = projectSetup.configFilePath;
  final performDeploy = projectSetup.performDeploy;

  await logger.progress(
    'Writing cloud configuration files',
    successMessage: 'Configuration files written.',
    padRight: StatusCommands.progressMessagePadLength,
    () async {
      await ProjectCommands.linkProject(
        cloudApiClient,
        projectId: projectId,
        projectDirectory: projectDir.path,
        configFilePath: configFilePath,
        dartVersionOverride: projectSetup.dartVersionOverride,
        preDeployScripts: projectSetup.suggestedPreDeployScripts,
      );
      return true;
    },
  );

  await _populateCustomPasswords(
    cloudApiClient,
    logger,
    projectId: projectId,
    passwords: projectSetup.selectedPasswords,
  );

  if (!performDeploy) {
    logger.terminalCommand(
      '$baseCommand launch',
      message:
          'Deployment skipped. Run this command again to deploy to the cloud:',
      newParagraph: true,
    );
    return;
  }

  await Deploy.deploy(
    cloudApiClient,
    fileUploaderFactory,
    logger: logger,
    baseCommand: baseCommand,
    projectId: projectId,
    projectDir: projectDir.path,
    projectConfigFilePath: configFilePath,
    concurrency: deployConcurrency,
    wetRun: wetRun,
    showFiles: deployShowFiles,
    outputPath: deployOutputPath,
    skipTailingStatus: deploySkipTailingStatus,
    suppressCommandMessages: true,
    dartVersionOverride: projectSetup.dartVersionOverride,
    stdout: stdout,
    stderr: stderr,
  );

  if (wetRun) return;

  _displayProjectInfo(logger: logger, actualProjectId: projectId);

  logger.terminalCommand(
    '$baseCommand help status',
    message: 'To see how to view deployment statuses, run this command:',
    newParagraph: true,
  );
}