-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
roll-to-devtools.sh
executable file
·76 lines (58 loc) · 2.77 KB
/
roll-to-devtools.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
##
# @license Copyright 2017 The Lighthouse Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
##
# You will need a DevTools Frontend checkout
# See https://chromium.googlesource.com/devtools/devtools-frontend/+/HEAD/docs/workflows.md
# usage:
# default to checkout at ~/src/devtools/devtools-frontend
# yarn devtools
# with a custom devtools location (could be path to standalone checkout):
# yarn devtools ~/code/devtools/devtools-frontend
check="\033[96m ✓\033[39m"
if [[ -n "$1" ]]; then
dt_dir="$1"
else
dt_dir="$HOME/src/devtools/devtools-frontend"
fi
if [[ ! -d "$dt_dir" || ! -a "$dt_dir/front_end/OWNERS" ]]; then
echo -e "\033[31m✖ Error!\033[39m"
echo "This script requires a devtools frontend folder. We didn't find one here:"
echo " $dt_dir"
exit 1
else
echo -e "$check Chromium folder in place."
fi
fe_lh_dir="$dt_dir/front_end/third_party/lighthouse"
mkdir -p "$fe_lh_dir"
lh_bg_js="dist/lighthouse-dt-bundle.js"
yarn build-report
yarn build-devtools
# copy lighthouse-dt-bundle
cp -pPR "$lh_bg_js" "$fe_lh_dir/lighthouse-dt-bundle.js"
echo -e "$check lighthouse-dt-bundle copied."
# generate bundle.d.ts
npx tsc --allowJs --declaration --emitDeclarationOnly dist/report/bundle.esm.js
# copy report code $fe_lh_dir
fe_lh_report_dir="$fe_lh_dir/report/"
cp dist/report/bundle.esm.js "$fe_lh_report_dir/bundle.js"
cp dist/report/bundle.esm.d.ts "$fe_lh_report_dir/bundle.d.ts"
echo -e "$check Report code copied."
# copy report generator + cached resources into $fe_lh_dir
fe_lh_report_assets_dir="$fe_lh_dir/report-assets/"
rsync -avh dist/dt-report-resources/ "$fe_lh_report_assets_dir" --delete
echo -e "$check Report resources copied."
# copy locale JSON files (but not the .ctc.json ones)
lh_locales_dir="lighthouse-core/lib/i18n/locales/"
fe_locales_dir="$fe_lh_dir/locales"
rsync -avh "$lh_locales_dir" "$fe_locales_dir" --exclude="*.ctc.json" --delete
echo -e "$check Locale JSON files copied."
# copy webtests
lh_webtests_dir="third-party/chromium-webtests/webtests/http/tests/devtools/lighthouse/"
fe_webtests_dir="$dt_dir/test/webtests/http/tests/devtools/lighthouse"
rsync -avh "$lh_webtests_dir" "$fe_webtests_dir" --exclude="OWNERS" --delete
echo ""
echo "Done. To run the webtests: "
echo " DEVTOOLS_PATH=\"$dt_dir\" yarn test-devtools"