mirror of https://github.com/coder/coder.git
chore: add icons.json file (#10085)
This commit is contained in:
parent
36f3151b71
commit
71ad5909f2
8
Makefile
8
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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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)
|
||||
}
|
|
@ -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"
|
||||
]
|
Loading…
Reference in New Issue