private validateStacksInApp()

in src/riff-raff-yaml-file/index.ts [156:187]


  private validateStacksInApp(): void {
    type Found = "✅";
    type NotFound = "❌";
    type AppValidation = Record<StackTag, Record<StageTag, Found | NotFound>>;

    const { allStackTags, allStageTags } = this;

    const checks: AppValidation = allStackTags.reduce((accStackTag, stackTag) => {
      return {
        ...accStackTag,
        [stackTag]: allStageTags.reduce((accStageTag, stageTag) => {
          return {
            ...accStageTag,
            [stageTag]: this.isCdkStackPresent(stackTag, stageTag) ? "✅" : "❌",
          };
        }, {}),
      };
    }, {});

    const missingDefinitions: Array<Found | NotFound> = Object.values(checks).flatMap((groupedByStackTag) => {
      return Object.values(groupedByStackTag).filter((_) => _ === "❌");
    });

    if (missingDefinitions.length > 0) {
      const message = `Unable to produce a working riff-raff.yaml file; missing ${missingDefinitions.length} definitions`;

      console.log(`${message} (details below)`);
      console.table(checks);

      throw new Error(message);
    }
  }