Files
coder/scripts/gensite/generate_icon_list.go
T
Jake Howell d1b0722034 feat: standardise sizes of ./site/static/icon/*.svg (#21347)
Related to #21320

This pull-request ensures that all the icons are now `256px * 256px` so
that they're standardised across all rendering situations.

| Previous | Now |
| --- | --- |
| <img width="886" height="1652" alt="CleanShot 2025-12-21 at 12 25
03@2x"
src="https://github.com/user-attachments/assets/c298325c-4419-485b-97e2-bb54e6ccc8c0"
/> | <img width="962" height="980" alt="CleanShot 2025-12-21 at 12 26
35@2x"
src="https://github.com/user-attachments/assets/c9cef5ee-115d-4318-8e12-188ea79cc88b"
/> |

* All `*.svg` files are now `256px * 256px` and..
  * Added a `do.svg` file.
  * Added a `ruby.svg` file.
  * Added a `gcp.svg` file.
* All `*.png` files are now `256px * 256px` and..
  * Updated the `aws.png` file to match `aws.svg` (deprecated).
  * Updated the `azure.png` file to match `azure.svg` (deprecated).
  * Updated the `docker.png` file to match `docker.svg` (deprecated).
  * Updated the `do.png` file to fill the full `256px` width.
  * Deprecated the `do.png`.
  * Deprecated the `ruby.png`.
  * Deprecated the `gcp.png`.
2026-01-08 13:39:31 +11:00

61 lines
1.1 KiB
Go

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
}