Skip to content

Commit 07961c9

Browse files
committed
import icons.json statically
1 parent c3b4e5b commit 07961c9

File tree

8 files changed

+37
-20
lines changed

8 files changed

+37
-20
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ site/e2e/test-results/*
2929
site/e2e/states/*.json
3030
site/e2e/.auth.json
3131
site/playwright-report/*
32-
site/static/icons.json
32+
site/src/theme/icons.json
3333
site/.swc
3434

3535
# Make target for updating golden files (any dir).

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ site/e2e/test-results/*
3232
site/e2e/states/*.json
3333
site/e2e/.auth.json
3434
site/playwright-report/*
35-
site/static/icons.json
35+
site/src/theme/icons.json
3636
site/.swc
3737

3838
# Make target for updating golden files (any dir).

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ gen: \
472472
site/.prettierignore \
473473
site/.eslintignore \
474474
site/e2e/provisionerGenerated.ts \
475-
site/static/icons.json \
475+
site/src/theme/icons.json \
476476
examples/examples.gen.json
477477
.PHONY: gen
478478

@@ -496,7 +496,7 @@ gen/mark-fresh:
496496
site/.prettierignore \
497497
site/.eslintignore \
498498
site/e2e/provisionerGenerated.ts \
499-
site/static/icons.json \
499+
site/src/theme/icons.json \
500500
examples/examples.gen.json \
501501
"
502502
for file in $$files; do
@@ -549,8 +549,8 @@ site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisio
549549
../scripts/pnpm_install.sh
550550
pnpm run gen:provisioner
551551

552-
site/static/icons.json: $(wildcard site/static/icon/*)
553-
go run ./scripts/sitestatic/
552+
site/src/theme/icons.json: $(wildcard site/static/icon/*)
553+
go run ./scripts/gensite/ -icons $@
554554

555555
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
556556
go run ./scripts/examplegen/main.go > examples/examples.gen.json

scripts/sitestatic/generateIconList.go renamed to scripts/gensite/generateIconList.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ import (
66
"os"
77
)
88

9-
func generateIconList() int {
10-
files, err := os.ReadDir("site/static/icon")
9+
func generateIconList(path string) int {
10+
if path == "" {
11+
return 0 // skip
12+
}
13+
14+
files, err := os.ReadDir("site/static/icon/")
1115
if err != nil {
12-
_, _ = fmt.Println("failed to read icon/ directory")
16+
_, _ = fmt.Println("failed to read site/static/icon/ directory")
1317
_, _ = fmt.Println("err:", err.Error())
1418
return 71 // OSERR
1519
}
@@ -26,7 +30,7 @@ func generateIconList() int {
2630
}
2731
icons = icons[:i]
2832

29-
outputFile, err := os.Create("./site/static/icons.json")
33+
outputFile, err := os.Create(path)
3034
if err != nil {
3135
_, _ = fmt.Println("failed to create file")
3236
_, _ = fmt.Println("err:", err.Error())
@@ -50,5 +54,7 @@ func generateIconList() int {
5054
return 74 // IOERR
5155
}
5256

57+
_, _ = fmt.Println(green.Sprintf("==>"), path)
58+
5359
return 0
5460
}

scripts/gensite/main.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"os"
6+
7+
"github.com/fatih/color"
8+
)
9+
10+
var green = color.New(color.FgGreen).Add(color.Bold)
11+
12+
func main() {
13+
var iconsPath string
14+
flag.StringVar(&iconsPath, "icons", "", "the path to place icons.json at")
15+
flag.Parse()
16+
17+
status := generateIconList(iconsPath)
18+
os.Exit(status)
19+
}

scripts/sitestatic/main.go

Lines changed: 0 additions & 8 deletions
This file was deleted.

site/.eslintignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ e2e/test-results/*
3232
e2e/states/*.json
3333
e2e/.auth.json
3434
playwright-report/*
35-
static/icons.json
35+
src/theme/icons.json
3636
.swc
3737

3838
# Make target for updating golden files (any dir).

site/.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ e2e/test-results/*
3232
e2e/states/*.json
3333
e2e/.auth.json
3434
playwright-report/*
35-
static/icons.json
35+
src/theme/icons.json
3636
.swc
3737

3838
# Make target for updating golden files (any dir).

0 commit comments

Comments
 (0)