renderPlanJson function

String renderPlanJson(
  1. ChangePlan plan,
  2. String? destination,
  3. PlanAvailability availability
)

Implementation

String renderPlanJson(
  ChangePlan plan,
  String? destination,
  PlanAvailability availability,
) {
  final operations = plan.operations
      .map((operation) => operation.toJson())
      .toList();
  verifyOperationFidelity(plan, operations);
  return renderEnvelope(
    command: 'plan show',
    ok: true,
    exitCode: ExitReporter.success,
    result: {
      'planId': plan.planId,
      'state': plan.state.name,
      'schemaVersion': plan.schemaVersion,
      'blueprintHash': plan.blueprintHash,
      'manifestHash': plan.manifestHash,
      'targetPath': destination,
      'targetPaths': plan.targetPaths,
      'summary': {
        'recipeVersion': plan.recipeVersion,
        'engineVersion': plan.engineVersion,
      },
      'tree': plan.operations
          .map((operation) => operation.logicalPath)
          .toList(),
      'operations': operations,
      'operationCount': plan.operations.length,
      'contents': availability.contentReviewAvailable
          ? availability.contents
          : null,
      'dependencies': plan.dependencies,
      'stagingCommands': plan.stagingCommands
          .map((command) => command.toJson())
          .toList(),
      'regenerationCommands': plan.regenerationCommands
          .map((command) => command.toJson())
          .toList(),
      'regenerationPathSet': plan.regenerationPathSet,
      'toolchainExceptions': plan.toolchainExceptions
          .map((exception) => exception.toJson())
          .toList(),
      'validationCommands': plan.validationCommands
          .map((command) => command.toJson())
          .toList(),
      'warnings': plan.warnings,
      'manualSteps': plan.manualSteps,
      'rollbackCapability': plan.rollbackCapability.name,
      'generationAlreadyRan': true,
      'contentReviewAvailable': availability.contentReviewAvailable,
    },
    warnings: plan.warnings,
  );
}