Skip to content

Commit

Permalink
Update docs client
Browse files Browse the repository at this point in the history
  • Loading branch information
chokoswitch committed Aug 25, 2023
1 parent d27b6ea commit a8ec150
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 0 deletions.
Binary file modified docsclient/editor.worker.js.gz
Binary file not shown.
Binary file modified docsclient/graphql.worker.worker.js.gz
Binary file not shown.
Binary file modified docsclient/index.html.gz
Binary file not shown.
Binary file modified docsclient/json.worker.js.gz
Binary file not shown.
Binary file removed docsclient/main.16ceee542617fe59512a.js.gz
Binary file not shown.
Binary file added docsclient/main.680dc52304c22666afc6.js.gz
Binary file not shown.
Binary file removed docsclient/main.js.gz
Binary file not shown.
66 changes: 66 additions & 0 deletions magefiles/magefile.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package main

import (
"archive/zip"
"bytes"
"fmt"
"io"
"io/fs"
"net/http"
"os"
"path/filepath"
"strings"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
Expand Down Expand Up @@ -41,6 +48,65 @@ func Check() {
mg.SerialDeps(Lint, Test)
}

func FetchDocsClient() error {
resp, err := http.Get("https://repo1.maven.org/maven2/com/linecorp/armeria/armeria/1.25.1/armeria-1.25.1.jar")
if err != nil {
return err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}

zipReader, err := zip.NewReader(bytes.NewReader(body), int64(len(body)))
if err != nil {
return err
}

if err := fs.WalkDir(os.DirFS("docsclient"), ".", func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
return nil
}
switch path {
case "NOTICE.txt", "web-licenses.txt", ".":
return nil
}
return os.Remove(filepath.Join("docsclient", path))
}); err != nil {
return err
}

for _, f := range zipReader.File {
path := f.Name
if !strings.HasPrefix(path, "com/linecorp/armeria/server/docs/") || strings.HasSuffix(path, ".class") {
continue
}
if f.Name[len(f.Name)-1] == '/' {
// Directory
continue
}
path = path[len("com/linecorp/armeria/server/docs/"):]
// Windows compatibility
if path == "assets/favicon.png" {
path = filepath.Join("assets", "favicon.png")
}
file, err := f.Open()
if err != nil {
return err
}
content, err := io.ReadAll(file)
if err != nil {
return err
}
if err := os.WriteFile(filepath.Join("docsclient", path), content, 0o644); err != nil {
return err
}
}

return nil
}

func getProjects() []string {
goWork, err := os.ReadFile("go.work")
if err != nil {
Expand Down

0 comments on commit a8ec150

Please sign in to comment.