diff --git a/Makefile b/Makefile index 64615132a5..b15feef634 100644 --- a/Makefile +++ b/Makefile @@ -472,6 +472,7 @@ gen: \ site/.prettierignore \ site/.eslintignore \ site/e2e/provisionerGenerated.ts \ + site/src/theme/icons.json \ examples/examples.gen.json .PHONY: gen @@ -495,6 +496,7 @@ gen/mark-fresh: site/.prettierignore \ site/.eslintignore \ site/e2e/provisionerGenerated.ts \ + site/src/theme/icons.json \ examples/examples.gen.json \ " for file in $$files; do @@ -538,7 +540,7 @@ provisionerd/proto/provisionerd.pb.go: provisionerd/proto/provisionerd.proto ./provisionerd/proto/provisionerd.proto site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go') - go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts + go run ./scripts/apitypings/ > site/src/api/typesGenerated.ts cd site pnpm run format:types ./src/api/typesGenerated.ts @@ -547,6 +549,10 @@ site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisio ../scripts/pnpm_install.sh pnpm run gen:provisioner +site/src/theme/icons.json: $(wildcard site/static/icon/*) + go run ./scripts/gensite/ -icons $@ + pnpm run format:write:only $@ + examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates) go run ./scripts/examplegen/main.go > examples/examples.gen.json diff --git a/scripts/gensite/generateIconList.go b/scripts/gensite/generateIconList.go new file mode 100644 index 0000000000..ec3f91c1ab --- /dev/null +++ b/scripts/gensite/generateIconList.go @@ -0,0 +1,60 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" +) + +func generateIconList(path string) int { + if path == "" { + return 0 // skip + } + + files, err := os.ReadDir("site/static/icon/") + if err != nil { + _, _ = fmt.Println("failed to read site/static/icon/ directory") + _, _ = fmt.Println("err:", err.Error()) + return 71 // OSERR + } + + icons := make([]string, len(files)) + i := 0 + for _, file := range files { + if !file.Type().IsRegular() { + continue + } + + icons[i] = file.Name() + i++ + } + icons = icons[:i] + + outputFile, err := os.Create(path) + if err != nil { + _, _ = fmt.Println("failed to create file") + _, _ = fmt.Println("err:", err.Error()) + return 73 // CANTCREAT + } + defer outputFile.Close() + + iconsJSON, err := json.Marshal(icons) + if err != nil { + _, _ = fmt.Println("failed to serialize JSON") + _, _ = fmt.Println("err:", err.Error()) + return 70 // SOFTWARE + } + + written, err := outputFile.Write(iconsJSON) + if err != nil || written != len(iconsJSON) { + _, _ = fmt.Println("failed to write JSON") + if err != nil { + _, _ = fmt.Println("err:", err.Error()) + } + return 74 // IOERR + } + + _, _ = fmt.Println(green.Sprintf("==>"), path) + + return 0 +} diff --git a/scripts/gensite/main.go b/scripts/gensite/main.go new file mode 100644 index 0000000000..9b30f9224b --- /dev/null +++ b/scripts/gensite/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "flag" + "os" + + "github.com/fatih/color" +) + +var green = color.New(color.FgGreen).Add(color.Bold) + +func main() { + var iconsPath string + flag.StringVar(&iconsPath, "icons", "", "the path to place icons.json at") + flag.Parse() + + status := generateIconList(iconsPath) + os.Exit(status) +} diff --git a/site/src/theme/icons.json b/site/src/theme/icons.json new file mode 100644 index 0000000000..bb62ee8a8b --- /dev/null +++ b/site/src/theme/icons.json @@ -0,0 +1,57 @@ +[ + "android-studio.svg", + "apache-guacamole.svg", + "aws.png", + "azure-devops.svg", + "azure.png", + "bitbucket.svg", + "centos.svg", + "clion.svg", + "code.svg", + "coder.svg", + "conda.svg", + "database.svg", + "datagrip.svg", + "dataspell.svg", + "debian.svg", + "do.png", + "docker.png", + "dotfiles.svg", + "fedora.svg", + "fly.io.svg", + "folder.svg", + "gateway.svg", + "gcp.png", + "git.svg", + "github.svg", + "gitlab.svg", + "goland.svg", + "image.svg", + "intellij.svg", + "java.svg", + "jax.svg", + "jfrog.svg", + "jupyter.svg", + "k8s.png", + "kasmvnc.svg", + "matlab.svg", + "memory.svg", + "node.svg", + "nomad.svg", + "novnc.svg", + "personalize.svg", + "phpstorm.svg", + "projector.svg", + "pycharm.svg", + "pytorch.svg", + "rider.svg", + "rockylinux.svg", + "rstudio.svg", + "rubymine.svg", + "tensorflow.svg", + "terminal.svg", + "theia.svg", + "ubuntu.svg", + "webstorm.svg", + "widgets.svg" +]