Skip to content

Commit

Permalink
Merge pull request #64 from eatdrinksleepcode/update-rev
Browse files Browse the repository at this point in the history
Specify revision to use when updating protocol
  • Loading branch information
wirepair authored Mar 28, 2023
2 parents deb0da3 + 3fbe9c2 commit 08cf63a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions v2/gcdapigen/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"bytes"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
Expand All @@ -38,8 +39,8 @@ const (
channel = "stable" // appears only stable is in github/devtools-protocol.
revisionOS = "win64" // doesn't really matter
revisionEndpoint = "https://omahaproxy.appspot.com/all.json" // get release level info
browserProtocolFile = "https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/master/json/browser_protocol.json"
jsProtocolFile = "https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/master/json/js_protocol.json"
browserProtocolFile = "https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/%s/json/browser_protocol.json"
jsProtocolFile = "https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/%s/json/js_protocol.json"
)

type ChromiumRevision []struct {
Expand Down Expand Up @@ -70,12 +71,12 @@ type RevisionInfo struct {
JsBranch string
}

func getApiRevision() *RevisionInfo {
func getApiRevision(rev string) *RevisionInfo {
versionInfo := getRevisionData(channel)
if versionInfo == nil {
log.Fatalf("Error finding version information from %s", revisionEndpoint)
}
download(browserProtocolFile, jsProtocolFile)
download(fmt.Sprintf(browserProtocolFile, rev), fmt.Sprintf(jsProtocolFile, rev))
return versionInfo
}

Expand Down
4 changes: 3 additions & 1 deletion v2/gcdapigen/gcdapigen.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ const CHROME_VERSION = "%s"`

var file string
var update bool
var rev string
var templates *template.Template // for code generation
var funcMap template.FuncMap // helper funcs
var revisionInfo *RevisionInfo

func init() {
flag.BoolVar(&update, "update", false, "download and merge js_protocol.json and browser_protocol.json into protocol.json")
flag.StringVar(&rev, "rev", "master", "with -update, the revision (branch/tag/commit) from which to download protocol files")
flag.StringVar(&file, "file", "protocol.json", "open remote debugger protocol file, if -update the filename to write to.")
funcMap := template.FuncMap{
"Title": strings.Title,
Expand All @@ -91,7 +93,7 @@ func main() {
flag.Parse()

if update {
revisionInfo = getApiRevision()
revisionInfo = getApiRevision(rev)
}

protocolData := openFile()
Expand Down

0 comments on commit 08cf63a

Please sign in to comment.