File indexing completed on 2025-09-17 08:08:09
0001 import os
0002 import shutil
0003 import subprocess
0004 import sys
0005
0006
0007 def main():
0008
0009 script_path = os.path.dirname(os.path.abspath(__file__))
0010
0011
0012 firebird_ng_path = os.path.abspath(os.path.join(script_path, '..', 'firebird-ng'))
0013 dist_path = os.path.join(firebird_ng_path, 'dist', 'firebird', 'browser')
0014 static_path = os.path.join(script_path, 'pyrobird', 'server', 'static')
0015
0016 print(f"Script Path: {script_path}")
0017 print(f"Firebird NG Path: {firebird_ng_path}")
0018 print(f"Dist Path: {dist_path}")
0019 print(f"Static Path: {static_path}")
0020
0021
0022
0023
0024 try:
0025 print("Running build at firebird-ng")
0026 proc = subprocess.Popen(
0027 ["npm", "run", "build"],
0028 cwd=firebird_ng_path,
0029 text=True,
0030 stdout=subprocess.PIPE,
0031 stderr=subprocess.STDOUT,
0032 )
0033
0034 for line in proc.stdout:
0035 print("[ng] " + line, end="")
0036
0037 proc.wait()
0038 if proc.returncode:
0039 sys.exit(proc.returncode)
0040 except subprocess.CalledProcessError as e:
0041 print(f"Error running 'build' phase: {e}")
0042 sys.exit(1)
0043
0044
0045 print("removing existing pyrobird/server/static")
0046 if os.path.exists(static_path):
0047 shutil.rmtree(static_path)
0048 os.makedirs(static_path)
0049
0050
0051 print("copying firebird-ng/dist/firebird/browser to pyrobird/server/static")
0052 if os.path.exists(dist_path):
0053 for item in os.listdir(dist_path):
0054 s = os.path.join(dist_path, item)
0055 d = os.path.join(static_path, item)
0056 if os.path.isdir(s):
0057 shutil.copytree(s, d)
0058 else:
0059 shutil.copy2(s, d)
0060 else:
0061 print(f"Source directory {dist_path} does not exist.")
0062 sys.exit(1)
0063
0064
0065 if __name__ == "__main__":
0066 main()