Skip to content

Commit ba13abe

Browse files
refactor(generator): make raw variable font download explicit opt-in flag
Agent-Logs-Url: https://github.com/MudBlazor/MudBlazor.Icons/sessions/3c0e8544-4165-4605-8415-d3c9d13179e5 Co-authored-by: danielchalmers <7112040+danielchalmers@users.noreply.github.com>
1 parent e8fd0fe commit ba13abe

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

src/GoogleMaterialDesignIconsGenerator/Program.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public static async Task Main(string[] args)
2020

2121
codeGenerator.GenerateCsFilesUsingRoslyn(iconType, groupedIcons, folder: outputFolder);
2222

23-
if (iconType == IconType.MaterialSymbols)
23+
if (iconType == IconType.MaterialSymbols && ShouldDownloadRawVariableFonts(args))
2424
{
25-
await client.DownloadMaterialSymbolsFontsAsync(Path.Combine(outputFolder, "wwwroot", "font")).ConfigureAwait(false);
25+
await client.DownloadMaterialSymbolsVariableFontsAsync(Path.Combine(outputFolder, "wwwroot", "font")).ConfigureAwait(false);
2626
}
2727
}
2828

@@ -69,8 +69,31 @@ private static bool TryGetIconTypeFromArgs(IReadOnlyList<string> args, out IconT
6969
return true;
7070
}
7171

72-
iconType = ParseIconType(args[0]);
73-
return true;
72+
foreach (var arg in args)
73+
{
74+
if (arg.StartsWith("-", StringComparison.Ordinal))
75+
{
76+
continue;
77+
}
78+
79+
iconType = ParseIconType(arg);
80+
return true;
81+
}
82+
83+
return false;
84+
}
85+
86+
private static bool ShouldDownloadRawVariableFonts(IReadOnlyList<string> args)
87+
{
88+
foreach (var arg in args)
89+
{
90+
if (arg.Equals("--download-raw-variable-fonts", StringComparison.OrdinalIgnoreCase))
91+
{
92+
return true;
93+
}
94+
}
95+
96+
return false;
7497
}
7598

7699
private static IconType ParseIconType(string value)

src/GoogleMaterialDesignIconsGenerator/Service/IconHttpClientService.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,14 @@ public async Task<IconsMetadata> ParseIconsAsync()
4848
}
4949

5050
/// <summary>
51-
/// Downloads Material Symbols font files into <paramref name="destinationFolderPath"/>.
51+
/// Downloads raw Material Symbols variable font files into <paramref name="destinationFolderPath"/>.
5252
/// </summary>
5353
/// <param name="destinationFolderPath">Destination folder for downloaded font files.</param>
54-
/// <param name="includeRawVariableFonts">
55-
/// When <see langword="true"/>, downloads raw variable fonts from the upstream repository.
56-
/// When <see langword="false"/> (default), raw variable font downloads are skipped.
57-
/// </param>
5854
/// <param name="cancellationToken">Token used to cancel download and file write operations.</param>
59-
public async Task DownloadMaterialSymbolsFontsAsync(string destinationFolderPath, bool includeRawVariableFonts = false, CancellationToken cancellationToken = default)
55+
public async Task DownloadMaterialSymbolsVariableFontsAsync(string destinationFolderPath, CancellationToken cancellationToken = default)
6056
{
6157
ArgumentException.ThrowIfNullOrWhiteSpace(destinationFolderPath);
6258

63-
if (!includeRawVariableFonts)
64-
{
65-
return;
66-
}
67-
6859
try
6960
{
7061
Directory.CreateDirectory(destinationFolderPath);

0 commit comments

Comments
 (0)