minor changes to yarn

This commit is contained in:
proddy
2023-02-12 15:35:51 +01:00
parent 4ca25fcfc2
commit 096336042e
2 changed files with 10 additions and 6 deletions

View File

@@ -3,11 +3,12 @@ from shutil import copytree, rmtree, copyfileobj
import os
import gzip
# brotli has better compression than gzip but requires https so leaving here for future
# brotli has better compression than gzip but requires https so leaving here for future
# import brotli
Import("env")
def gzipFile(file):
with open(file, 'rb') as f_in:
with gzip.open(file + '.gz', 'wb') as f_out:
@@ -20,27 +21,29 @@ def gzipFile(file):
# f_out.write(brotli.compress(f_in.read(), quality=11))
# os.remove(file)
def flagExists(flag):
buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
for define in buildFlags.get("CPPDEFINES"):
if (define == flag or (isinstance(define, list) and define[0] == flag)):
return True
def buildWeb():
os.chdir("interface")
print("Building web interface...")
try:
env.Execute("yarn install")
env.Execute("yarn")
env.Execute("yarn run typesafe-i18n --no-watch")
with open("./src/i18n/i18n-util.ts") as r:
text = r.read().replace("Locales = 'pl'", "Locales = 'en'")
with open("./src/i18n/i18n-util.ts", "w") as w:
w.write(text)
env.Execute("yarn run build")
buildPath = Path("build")
wwwPath = Path("../data/www")
if wwwPath.exists() and wwwPath.is_dir():
rmtree(wwwPath)
@@ -53,7 +56,8 @@ def buildWeb():
finally:
os.chdir("..")
if (len(BUILD_TARGETS) == 0 or "upload" in BUILD_TARGETS):
buildWeb()
else:
print("Skipping build web interface for target(s): " + ", ".join(BUILD_TARGETS))
print("Skipping build web interface for target(s): " + ", ".join(BUILD_TARGETS))