Refactor Homebrew formula generator to correctly format class names and file paths for font installation. Update glob patterns to remove unnecessary font_name variable and ensure proper directory structure for font files.

This commit is contained in:
Matt Troutman 2025-05-19 12:10:53 -05:00
parent 263f3c2c54
commit bc8845fc96
No known key found for this signature in database

View file

@ -16,10 +16,12 @@ class HomebrewFormulaGenerator:
# This file was generated by the font folder cleanup script # This file was generated by the font folder cleanup script
# Do not edit this file directly # Do not edit this file directly
class {formula_name.capitalize()} < Formula class Font{formula_name.capitalize()} < Formula
desc "Font: {formula_name}" desc "Font: {formula_name}"
homepage "http://clancy.genet-godzilla.ts.net:3002/Fonts/homebrew-fonts" homepage "http://clancy.genet-godzilla.ts.net:3002/Fonts/homebrew-fonts"
url "http://clancy.genet-godzilla.ts.net:3002/Fonts/homebrew-fonts/raw/main/font_files/{font_name}"
version "1.0.0" version "1.0.0"
sha256 "" # This will need to be filled in after the first build
def install def install
# Create font directories # Create font directories
@ -29,23 +31,23 @@ class {formula_name.capitalize()} < Formula
(share/"fonts/webfonts").mkpath (share/"fonts/webfonts").mkpath
# Install TTF fonts # Install TTF fonts
Dir.glob("{font_name}/ttf/*.ttf").each do |font| Dir.glob("ttf/*.ttf").each do |font|
system "cp", font, share/"fonts/truetype" system "cp", font, share/"fonts/truetype"
end end
# Install OTF fonts # Install OTF fonts
Dir.glob("{font_name}/otf/*.otf").each do |font| Dir.glob("otf/*.otf").each do |font|
system "cp", font, share/"fonts/opentype" system "cp", font, share/"fonts/opentype"
end end
# Install web fonts # Install web fonts
Dir.glob("{font_name}/web/*.{{woff,woff2,eot,svg}}").each do |font| Dir.glob("web/*.{{woff,woff2,eot,svg}}").each do |font|
system "cp", font, share/"fonts/webfonts" system "cp", font, share/"fonts/webfonts"
end end
# Install documentation and other files # Install documentation and other files
(share/"{formula_name}").mkpath (share/"{formula_name}").mkpath
Dir.glob("{font_name}/other_files/*").each do |file| Dir.glob("other_files/*").each do |file|
system "cp", "-r", file, share/"{formula_name}" system "cp", "-r", file, share/"{formula_name}"
end end
end end
@ -81,9 +83,9 @@ end
formula_name = font_name.replace('font-', '') formula_name = font_name.replace('font-', '')
formula_content = self.generate_formula_content(font_name, formula_name) formula_content = self.generate_formula_content(font_name, formula_name)
formula_path = self.formula_dir / f"{formula_name}.rb" formula_path = self.formula_dir / f"font-{formula_name}.rb"
formula_path.write_text(formula_content) formula_path.write_text(formula_content)
print(f"Generated formula for {formula_name}") print(f"Generated formula for font-{formula_name}")
def main(): def main():
# Get the absolute path to the font_files directory # Get the absolute path to the font_files directory