protected addActivity()

in packages/@aws-cdk/toolkit-lib/lib/private/activity-printer/base.ts [86:131]


  protected addActivity(activity: StackActivity) {
    const status = activity.event.ResourceStatus;
    const hookStatus = activity.event.HookStatus;
    const hookType = activity.event.HookType;
    if (!status || !activity.event.LogicalResourceId) {
      return;
    }

    this.stackProgress = activity.progress;

    if (status === 'ROLLBACK_IN_PROGRESS' || status === 'UPDATE_ROLLBACK_IN_PROGRESS') {
      // Only triggered on the stack once we've started doing a rollback
      this.rollingBack = true;
    }

    if (status.endsWith('_IN_PROGRESS')) {
      this.resourcesInProgress[activity.event.LogicalResourceId] = activity;
    }

    if (stackEventHasErrorMessage(status)) {
      const isCancelled = (activity.event.ResourceStatusReason ?? '').indexOf('cancelled') > -1;

      // Cancelled is not an interesting failure reason
      if (!isCancelled) {
        this.failures.push(activity);
      }
    }

    if (status.endsWith('_COMPLETE') || status.endsWith('_FAILED')) {
      delete this.resourcesInProgress[activity.event.LogicalResourceId];
    }

    if (
      hookStatus !== undefined &&
        hookStatus.endsWith('_COMPLETE_FAILED') &&
        activity.event.LogicalResourceId !== undefined &&
        hookType !== undefined
    ) {
      if (this.hookFailureMap.has(activity.event.LogicalResourceId)) {
        this.hookFailureMap.get(activity.event.LogicalResourceId)?.set(hookType, activity.event.HookStatusReason ?? '');
      } else {
        this.hookFailureMap.set(activity.event.LogicalResourceId, new Map<string, string>());
        this.hookFailureMap.get(activity.event.LogicalResourceId)?.set(hookType, activity.event.HookStatusReason ?? '');
      }
    }
  }