mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 12:29:24 +00:00
Compile openapi client in background when django runserver is reloading
This commit is contained in:
@ -95,7 +95,7 @@ class JSBundler:
|
||||
def compile():
|
||||
"""Bundle js files with the javascript bundler for production."""
|
||||
process = subprocess.Popen(["npm", "run", "compile"])
|
||||
process.wait()
|
||||
_ = process.wait()
|
||||
if process.returncode:
|
||||
raise RuntimeError(f"Bundler failed with returncode {process.returncode}")
|
||||
|
||||
@ -163,7 +163,7 @@ class OpenApi:
|
||||
OPENAPI_DIR = GENERATED_ROOT / "openapi"
|
||||
|
||||
@classmethod
|
||||
def compile(cls):
|
||||
def compile(cls) -> subprocess.Popen[bytes] | None:
|
||||
"""Compile a TS client for the sith API. Only generates it if it changed."""
|
||||
logging.getLogger("django").info("Compiling open api typescript client")
|
||||
out = cls.OPENAPI_DIR / "schema.json"
|
||||
@ -191,4 +191,4 @@ class OpenApi:
|
||||
with open(out, "w") as f:
|
||||
_ = f.write(schema)
|
||||
|
||||
subprocess.run(["npx", "openapi-ts"], check=True)
|
||||
return subprocess.Popen(["npm", "run", "openapi"])
|
||||
|
Reference in New Issue
Block a user