#!/usr/bin/env bash

# Users may configure custom resource icons in resource_customizations. This script generates a list of those icons so
# that the UI knows which icons are available.

{
  echo "// Code generated by hack/generate-icons-typescript.sh; DO NOT EDIT.";
  echo "/* eslint-disable prettier/prettier */";
  echo "";
  echo "// resourceIconGroups is a map of resource kind globs to whether or not a custom icon exists for that kind.";
  echo "// Each glob corresponds to a directory under ui/src/assets/images/resources, where any asterisk is represented as an underscore (_).";
  echo "export const resourceIconGroups = {";
  find ui/src/assets/images/resources -name icon.svg | sort | sed "s/ui\/src\/assets\/images\/resources\//    '/" | sed "s/\/icon.svg/': true,/" | sed 's/_/*/';
  echo "};";
} > ui/src/app/applications/components/resource-customizations.ts
