feat: add icon list generation script
this is used to validate icons for custom preferences. it generates both typescript and c# code
This commit is contained in:
parent
f435ad4cf5
commit
71b59dbb00
6 changed files with 2116 additions and 0 deletions
|
@ -3,3 +3,6 @@
|
|||
resharper_entity_framework_model_validation_unlimited_string_length_highlighting = none
|
||||
# This is raised for every single property of records returned by endpoints
|
||||
resharper_not_accessed_positional_property_local_highlighting = none
|
||||
|
||||
[*generated.cs]
|
||||
generated_code = true
|
||||
|
|
2060
Foxnouns.Backend/Utils/BootstrapIcons.Icons.generated.cs
Normal file
2060
Foxnouns.Backend/Utils/BootstrapIcons.Icons.generated.cs
Normal file
File diff suppressed because it is too large
Load diff
6
Foxnouns.Backend/Utils/BootstrapIcons.cs
Normal file
6
Foxnouns.Backend/Utils/BootstrapIcons.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Foxnouns.Backend.Utils;
|
||||
|
||||
public static partial class BootstrapIcons
|
||||
{
|
||||
public static bool IsValid(string icon) => Icons.Contains(icon);
|
||||
}
|
|
@ -2,3 +2,4 @@
|
|||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
src/lib/icons.ts
|
||||
|
|
42
Foxnouns.Frontend/icons.js
Normal file
42
Foxnouns.Frontend/icons.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
// This script regenerates the list of icons for the frontend (Foxnouns.Frontend/src/lib/icons.ts)
|
||||
// and the backend (Foxnouns.Backend/Utils/BootstrapIcons.Icons.cs) from the currently installed version of Bootstrap Icons.
|
||||
// Run with `pnpm node icons.js` in the frontend directory.
|
||||
|
||||
import { writeFileSync } from "fs";
|
||||
import icons from "bootstrap-icons/font/bootstrap-icons.json" with { type: "json" };
|
||||
|
||||
const keys = Object.keys(icons);
|
||||
|
||||
console.log(`Found ${keys.length} icons`);
|
||||
const output = JSON.stringify(keys);
|
||||
console.log(`Saving file as src/icons.ts`);
|
||||
|
||||
writeFileSync(
|
||||
"src/lib/icons.ts",
|
||||
`// Generated code: DO NOT EDIT\n\nconst icons = ${output};\nexport default icons;`,
|
||||
);
|
||||
|
||||
const csCode1 = `// <auto-generated />
|
||||
|
||||
namespace Foxnouns.Backend.Utils;
|
||||
|
||||
public static partial class BootstrapIcons
|
||||
{
|
||||
private static readonly HashSet<string> Icons =
|
||||
[
|
||||
`;
|
||||
|
||||
const csCode2 = ` ];
|
||||
}
|
||||
`;
|
||||
|
||||
let csOutput = csCode1;
|
||||
|
||||
keys.forEach((element) => {
|
||||
csOutput += ` "${element}",\n`;
|
||||
});
|
||||
|
||||
csOutput += csCode2;
|
||||
|
||||
console.log("Writing C# code");
|
||||
writeFileSync("../Foxnouns.Backend/Utils/BootstrapIcons.Icons.generated.cs", csOutput);
|
4
Foxnouns.Frontend/src/lib/icons.ts
Normal file
4
Foxnouns.Frontend/src/lib/icons.ts
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue