From f77327634c9a2796ee67f48d5725802661ccbf31 Mon Sep 17 00:00:00 2001 From: Matteo Luppi <100372313+lups2000@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:54:22 +0200 Subject: [PATCH] Sync consts backend-frontend (#7016) * remove version from state and create new script to extract version * fix lint * [autofix.ci] apply automated fixes * fix web/gen script to error on file permissions * [autofix.ci] apply automated fixes * add version to footer * adjust tests * [autofix.ci] apply automated fixes * update changelog * move version back into state * [autofix.ci] apply automated fixes * nits --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Maximilian Hils --- test/mitmproxy/test_version.py | 4 ++-- web/gen/all | 3 ++- web/gen/backend_consts.py | 19 +++++++++++++++++++ web/src/js/backends/consts.ts | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100755 web/gen/backend_consts.py create mode 100644 web/src/js/backends/consts.ts diff --git a/test/mitmproxy/test_version.py b/test/mitmproxy/test_version.py index 1e72ab4ed..21c89ead1 100644 --- a/test/mitmproxy/test_version.py +++ b/test/mitmproxy/test_version.py @@ -16,8 +16,8 @@ def test_version(capsys): assert stdout.strip() == version.VERSION -def test_get_version(): - version.VERSION = "3.0.0rc2" +def test_get_version(monkeypatch): + monkeypatch.setattr(version, "VERSION", "3.0.0rc2") with mock.patch("subprocess.check_output") as m, mock.patch("subprocess.run") as m2: m2.return_value = True diff --git a/web/gen/all b/web/gen/all index b95734da8..f314d2e1d 100755 --- a/web/gen/all +++ b/web/gen/all @@ -1,8 +1,9 @@ #!/bin/bash +set -euxo pipefail + script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" for file in "$script_dir"/*.py; do - echo "$file..." "$file" done diff --git a/web/gen/backend_consts.py b/web/gen/backend_consts.py new file mode 100755 index 000000000..403edd2d1 --- /dev/null +++ b/web/gen/backend_consts.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import asyncio +from pathlib import Path + +here = Path(__file__).parent.absolute() + +filename = here / "../src/js/backends/consts.ts" + + +async def make() -> str: + # language=TypeScript + content = "/** Auto-generated by web/gen/backend_consts.py */\n" + + return content + + +if __name__ == "__main__": + filename.write_bytes(asyncio.run(make()).encode()) diff --git a/web/src/js/backends/consts.ts b/web/src/js/backends/consts.ts new file mode 100644 index 000000000..df055a50a --- /dev/null +++ b/web/src/js/backends/consts.ts @@ -0,0 +1 @@ +/** Auto-generated by web/gen/backend_consts.py */