runWithOutput method

  1. @override
Future<void> runWithOutput(
  1. Configuration<DeployCommandOption> commandConfig,
  2. CommandOutput output
)
override

Runs this command with prepared configuration and output.

Subclasses should override this method.

Implementation

@override
Future<void> runWithOutput(
  final Configuration<DeployCommandOption> commandConfig,
  final CommandOutput output,
) async {
  final projectId = commandConfig.value(DeployCommandOption.projectId);
  final concurrency = commandConfig.value(DeployCommandOption.concurrency);
  final wetRun = commandConfig.value(DeployCommandOption.wetRun);
  final showFiles = commandConfig.value(DeployCommandOption.showFiles);
  final redeploy = commandConfig.value(DeployCommandOption.redeploy);
  final outputPath = commandConfig.optionalValue(DeployCommandOption.output);
  final wait = commandConfig.value(DeployCommandOption.wait);
  final dartVersionOverride = commandConfig.optionalValue(
    DeployCommandOption.dartVersion,
  );
  final skipDartPubGet = commandConfig.value(
    DeployCommandOption.skipDartPubGet,
  );

  if (redeploy) {
    if (wetRun ||
        showFiles ||
        outputPath != null ||
        dartVersionOverride != null) {
      throw CloudCliUsageException(
        'The --redeploy option cannot be combined with '
        '--wet-run, --show-files, --output, or --dart-version.',
      );
    }

    await Deploy.redeploy(
      runner.serviceProvider.cloudApiClient,
      logger: logger,
      projectId: projectId,
    );
    return;
  }

  final projectDirectory = runner.verifiedProjectDirectory();
  logger.debug('Project directory is: ${projectDirectory.path}');
  final configFilePath =
      globalConfiguration.projectConfigFile?.path ??
      p.join(
        projectDirectory.path,
        ProjectConfigFileConstants.defaultFileName,
      );

  await Deploy.deploy(
    runner.serviceProvider.cloudApiClient,
    runner.serviceProvider.fileUploaderFactory,
    logger: logger,
    baseCommand: baseCommand,
    projectId: projectId,
    projectDir: projectDirectory.path,
    projectConfigFilePath: configFilePath,
    concurrency: concurrency,
    wetRun: wetRun,
    showFiles: showFiles,
    skipDartPubGet: skipDartPubGet,
    skipTailingStatus: !wait,
    outputPath: outputPath?.path,
    dartVersionOverride: dartVersionOverride,
  );
}