HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/insiders/wp-load/wp-content/plugins/affiliatex/scripts/generate-icons.js
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');

// Read the Font Awesome metadata
const iconsYml = fs.readFileSync(
  path.join(process.cwd(), 'node_modules/@fortawesome/fontawesome-free/metadata/icons.yml'),
  'utf8'
);

// Parse YAML
const iconsData = yaml.load(iconsYml);

// Style priority for sorting
const stylePriority = {
  'solid': 1,
  'regular': 2,
  'brands': 3
};

// Process icons into our format
const processedIcons = Object.entries(iconsData)
  .filter(([name, data]) => {
    // Filter out icons that don't have any styles
    return data.styles && data.styles.length > 0;
  })
  .map(([name, data]) => {
    // Get all available styles for this icon
    const styles = data.styles;
    
    // Create entries for each style
    return styles.map(style => {
      const prefix = style === 'regular' ? 'far' : 
                    style === 'solid' ? 'fas' : 
                    style === 'brands' ? 'fab' : 'fa';
      
      // Use the label for display name, fallback to the name
      const displayName = data.label || name;
      
      // Create a unique name by combining the display name and style
      const uniqueName = `${displayName}-${style}`;
      
      return {
        name: uniqueName,
        baseName: displayName,
        value: `${prefix} fa-${name}`,
        unicode: data.unicode,
        searchTerms: data.search?.terms || [],
        style: style,
        stylePriority: stylePriority[style] || 4
      };
    });
  })
  .flat();

// Write the processed icons to a JSON file
fs.writeFileSync(
  path.join(process.cwd(), 'src/blocks/ui-components/icon-picker/icons.json'),
  JSON.stringify(processedIcons, null, 2)
);

console.log(`Generated ${processedIcons.length} icons successfully!`);