Add --lint to build script

This commit is contained in:
Dima Gerasimov 2019-12-09 20:53:08 +00:00 committed by Dmitrii Gerasimov
parent 73fb8aa3dd
commit 7ab240947d
2 changed files with 25 additions and 14 deletions

View file

@ -79,7 +79,7 @@ The only test(s) that don't run on CI at the moment (e.g. due to lack of X serve
Extra tests (not integrated in CI yet): Extra tests (not integrated in CI yet):
- `(cd dist && web-ext lint)` - `./build --lint`
- `scripts/test_with_browser.py` - `scripts/test_with_browser.py`

37
build
View file

@ -13,19 +13,27 @@ def main():
# TODO rename to --production?? # TODO rename to --production??
p.add_argument('--release', action='store_true') p.add_argument('--release', action='store_true')
p.add_argument('--sign', action='store_true') p.add_argument('--sign', action='store_true')
# TODO --lint? p.add_argument('--lint', action='store_true')
tg = p.add_mutually_exclusive_group() tg = p.add_mutually_exclusive_group(required=True)
tg.add_argument('--target', type=str, choices=TARGETS) tg.add_argument('--target', type=str, choices=TARGETS)
for b in TARGETS: for b in TARGETS:
tg.add_argument('--' + b, action='store_const', const=b, dest='target') tg.add_argument('--' + b, action='store_const', const=b, dest='target')
args = p.parse_args() args = p.parse_args()
target = args.target target = args.target
assert target is not None
dist_dir = Path(__file__).absolute().parent / 'dist'
def webext(*args, **kwargs):
src_dir = dist_dir # / target
src_dir = src_dir.resolve() # TODO ugh. webext can't into symlinks???
check_call([
'web-ext',
'--source-dir', str(src_dir),
*args,
], **kwargs)
maybe_release = {'NODE_ENV': 'production'} if args.release else {} maybe_release = {'NODE_ENV': 'production'} if args.release else {}
env = { env = {
'TARGET': target, 'TARGET': target,
**maybe_release, **maybe_release,
@ -35,24 +43,27 @@ def main():
'npm', 'run', 'build', 'npm', 'run', 'build',
], env=env, cwd=str(Path(__file__).absolute().parent)) ], env=env, cwd=str(Path(__file__).absolute().parent))
if args.lint:
# TODO --self-hosted
# TODO warnings as errors??
webext('lint')
if args.release:
assert args.lint # TODO not sure..
if args.sign: if args.sign:
assert args.release assert args.release
if target not in ['firefox', 'firefox-mobile']: if target not in ['firefox', 'firefox-mobile']:
raise RuntimeError("{target} is not supported for signing yet".format(target=target)) raise RuntimeError("{target} is not supported for signing yet".format(target=target))
dist_dir = Path(__file__).absolute().parent / 'dist'
src_dir = dist_dir / target
from firefox_dev_secrets import API_KEY, API_SECRET from firefox_dev_secrets import API_KEY, API_SECRET
check_call([ webext(
'web-ext',
'--source-dir' , str(src_dir),
'--artifacts-dir', str(dist_dir), '--artifacts-dir', str(dist_dir),
'--api-key' , API_KEY, '--api-key' , API_KEY,
'--api-secret' , API_SECRET, '--api-secret', API_SECRET,
'sign', 'sign',
]) )
if __name__ == '__main__': if __name__ == '__main__':
main() main()