forked from chromedp/chromedp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·57 lines (41 loc) · 1.33 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# updates protocol.json to the latest from the chromium source tree
OUT=protocol.json
HAR_PROTO=har.json
BASE_URL="https://chromium.googlesource.com"
SRC=$(realpath $(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
BROWSER_VER=${1:-"master"}
JS_VER=${2:-"master"}
set -e
pushd $SRC &> /dev/null
UPDATE=0
LASTUPDATE=0
if [ -f .last ]; then
LASTUPDATE=$(cat .last)
fi
NOW=$(date +%s)
if (( "$NOW" >= $(($LASTUPDATE + 86400*5)) )); then
UPDATE=1
fi
if [[ "$UPDATE" == 1 ]]; then
go get -u \
golang.org/x/tools/cmd/goimports \
github.com/mailru/easyjson/easyjson \
github.com/valyala/quicktemplate/qtc
date +%s > .last
fi
BROWSER_PROTO="$BASE_URL/chromium/src/+/$BROWSER_VER/third_party/WebKit/Source/core/inspector/browser_protocol.json?format=TEXT"
JS_PROTO="$BASE_URL/v8/v8/+/$JS_VER/src/inspector/js_protocol.json?format=TEXT"
TMP=$(mktemp -d /tmp/chromedp-gen.XXXXXX)
BROWSER_TMP="$TMP/browser_protocol.json"
JS_TMP="$TMP/js_protocol.json"
echo "BROWSER_PROTO: $BROWSER_PROTO"
echo "JS_PROTO: $JS_PROTO"
# download
curl -s $BROWSER_PROTO | base64 -d > $BROWSER_TMP
curl -s $JS_PROTO | base64 -d > $JS_TMP
# merge browser, js and har definition files
jq \
-s '[.[] | to_entries] | flatten | reduce .[] as $dot ({}; .[$dot.key] += $dot.value)' \
$BROWSER_TMP $JS_TMP $HAR_PROTO > $OUT
popd &> /dev/null