run method

Future run()

Implementation

Future run() async {
  parent.logger.detail("Starting build from $stage");
  parent.buildStartController.add(stage);
  var config = readConfig();
  if (stage <= BuildStages.sharedLibrary) {
    await runBuildRunner(
        parent.logger,
        getPathFromRoot(config.structure.sharedLibrary).path,
        "shared library",
        throwOnFail: true, cancellationToken: cancellationToken);
  }
  if (hasBeenCancelled) return; // Yield
  if (stage <= BuildStages.server) {
    await runBuildRunner(
        parent.logger, getPathFromRoot(config.structure.server).path, "server",
        throwOnFail: true, cancellationToken: cancellationToken);
    if (hasBeenCancelled) return; // Yield
    await buildOpenapiDocumentProgress(parent.logger, cancellationToken);
  }
  if (hasBeenCancelled) return; // Yield
  var apiDefHash = currentApiDefHash;
  var hasApiChanged = parent.latestApiDefHash != apiDefHash;
  if (hasApiChanged) {
    await buildGeneratedClient(parent.logger, config, throwOnFail: true, cancellationToken: cancellationToken);
    parent.latestApiDefHash = apiDefHash;
  }
  if (hasBeenCancelled) return; // Yield
  if (stage <= BuildStages.application && hasApiChanged && (config.dev?.appBuildRunner ?? true)) {
    await runBuildRunner(parent.logger,
        getPathFromRoot(config.structure.application).path, "application",
        throwOnFail: true, cancellationToken: cancellationToken);
  }
  if (hasBeenCancelled) return; // Yield
  parent.logger.success("Completed build from $stage");
  parent.buildController.add(stage);
}