Skip to content

chore: add icons.json file #10085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ gen: \
site/.prettierignore \
site/.eslintignore \
site/e2e/provisionerGenerated.ts \
site/src/theme/icons.json \
examples/examples.gen.json
.PHONY: gen

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
60 changes: 60 additions & 0 deletions scripts/gensite/generateIconList.go
Original file line number Diff line number Diff line change
@@ -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
}
19 changes: 19 additions & 0 deletions scripts/gensite/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
57 changes: 57 additions & 0 deletions site/src/theme/icons.json
Original file line number Diff line number Diff line change
@@ -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"
]