add bundler stuff
This commit is contained in:
@@ -23,11 +23,9 @@ var faStyleDirs = map[string]string{
|
||||
"fas": "solid",
|
||||
}
|
||||
|
||||
// faIconsDir holds the FontAwesome SVGs (the kit's svgs-full/, relocated here),
|
||||
// grouped by style. Only the styles in faStyleDirs are read; the rest are unused.
|
||||
const faIconsDir = "frontend/icons"
|
||||
|
||||
var faOutFile = filepath.Join(frontendDir, "src", "ui", "generated", "faIcons.ts")
|
||||
// The FA SVG source dir (iconsDir) and the generated registry output path
|
||||
// (faOutPath) are resolved from Config — see config.go. Only the styles in
|
||||
// faStyleDirs are read; the rest of the kit is unused.
|
||||
|
||||
var (
|
||||
// icon="name" / icon: "name"
|
||||
@@ -44,11 +42,13 @@ var (
|
||||
// generateFAIcons regenerates the icon registry from the FontAwesome kit. It's a
|
||||
// no-op when the kit isn't present (CI builds use the committed registry).
|
||||
func generateFAIcons() error {
|
||||
if _, err := os.Stat(faIconsDir); err != nil {
|
||||
if _, err := os.Stat(iconsDir()); err != nil {
|
||||
return nil // SVGs absent — keep the committed registry
|
||||
}
|
||||
|
||||
names, custom, err := scanIconNames(filepath.Join(frontendDir, "src"))
|
||||
// Scan both the app pages and the shared kit so every icon either tree
|
||||
// references ends up in this app's registry.
|
||||
names, custom, err := scanIconNames([]string{filepath.Join(frontendDir, "src"), kitSrcDir()})
|
||||
if err != nil {
|
||||
return fmt.Errorf("scanning icon names: %w", err)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func generateFAIcons() error {
|
||||
for _, name := range names {
|
||||
found := false
|
||||
for prefix, dir := range faStyleDirs {
|
||||
svg, err := os.ReadFile(filepath.Join(faIconsDir, dir, name+".svg"))
|
||||
svg, err := os.ReadFile(filepath.Join(iconsDir(), dir, name+".svg"))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -90,10 +90,10 @@ func generateFAIcons() error {
|
||||
}
|
||||
b.WriteString("};\n")
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(faOutFile), 0755); err != nil {
|
||||
if err := os.MkdirAll(filepath.Dir(faOutPath()), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(faOutFile, []byte(b.String()), 0644); err != nil {
|
||||
if err := os.WriteFile(faOutPath(), []byte(b.String()), 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -126,10 +126,10 @@ func generateFAIcons() error {
|
||||
// inside `icon={...}` expressions), and the set of custom icon names registered
|
||||
// via registerIcon("name", …). The latter lets the caller tell a legitimate
|
||||
// custom icon apart from a typo when a referenced name isn't in the FA kit.
|
||||
func scanIconNames(dir string) (names []string, custom map[string]bool, err error) {
|
||||
func scanIconNames(dirs []string) (names []string, custom map[string]bool, err error) {
|
||||
set := map[string]bool{}
|
||||
custom = map[string]bool{}
|
||||
err = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
|
||||
walk := func(path string, d os.DirEntry, err error) error {
|
||||
if err != nil || d.IsDir() {
|
||||
return err
|
||||
}
|
||||
@@ -155,9 +155,14 @@ func scanIconNames(dir string) (names []string, custom map[string]bool, err erro
|
||||
custom[m[1]] = true
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
for _, dir := range dirs {
|
||||
if _, e := os.Stat(dir); e != nil {
|
||||
continue // tree not present (e.g. no separate kit in single-tree mode)
|
||||
}
|
||||
if err = filepath.WalkDir(dir, walk); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
names = make([]string, 0, len(set))
|
||||
for n := range set {
|
||||
|
||||
Reference in New Issue
Block a user