22import subprocess
33from json import loads
44from time import sleep
5- from shutil import rmtree
5+ from shutil import rmtree , move
66from os .path import exists
77from threading import Thread
88from datetime import datetime
@@ -68,6 +68,7 @@ def client(app_data, build=False, app_name=""):
6868 :return None:
6969 """
7070 if build and 'build' in app_data :
71+ static_dir = f"{ settings .BASE_DIR } /static/{ app_name } "
7172 print (f"\n > { app_name } @ { clients_json [app_name ]['version' ]} " )
7273
7374 console .out (f" { console .wait } Installing" , end = "\r " )
@@ -96,6 +97,13 @@ def client(app_data, build=False, app_name=""):
9697 )
9798 console .out (" ✅ Compiled " , "success" )
9899
100+ if 'export:web' in app_data ['build' ]:
101+ console .out (f" { console .wait } Exporting Static Files" , end = "\r " )
102+ if exists (static_dir ):
103+ rmtree (static_dir )
104+ move (src = f"{ app_data ['src' ]} /web-build" , dst = static_dir )
105+ console .out (f" { console .success } Exported " , "success" )
106+
99107 console .out (f" { console .wait } Post-Processing" , end = "\r " )
100108 update_client_meta_data (app_name , app_data )
101109 console .out (" ✅ Post-Processed " , "success" )
@@ -360,7 +368,7 @@ def update_overlord_configuration():
360368
361369 # De-git repository
362370 console .out (f" { console .wait } Removing .git/*" , end = "\r " )
363- rmtree (f'clients/{ name } /.git' )
371+ rmtree (f'{ settings . BASE_DIR } / clients/{ name } /.git' )
364372 console .out (" ✅ Removed .git/* " , "success" )
365373
366374 # Update meta_data
@@ -370,33 +378,38 @@ def update_overlord_configuration():
370378 console .out (" ✅ Updated meta file " , "success" )
371379
372380 if native :
373- # Update native app.json
381+ # Update app.json
374382 console .out (f" { console .wait } Updating app.json" , end = "\r " )
375383 with open (f'clients/{ name } /app.json' ) as package :
376384 content = package .read ()
377- content = content .replace ('app-name' , name . lower () )
385+ content = content .replace ('app-name' , name )
378386 with open (f'clients/{ name } /app.json' , 'w' ) as new_file :
379387 new_file .write (content )
380388 console .out (" ✅ Updated app.json " , "success" )
381389
382- else :
383- # Update index.html
384- console .out (f" { console .wait } Updating public/index.html" , end = "\r " )
385- with open (f'clients/{ name } /public/index.html' ) as index_content :
386- content = index_content .read ()
387- content = content .replace ('{#app_name#}' , name )
388- with open (f'clients/{ name } /public/index.html' , 'w' ) as new_file :
389- new_file .write (content )
390- console .out (" ✅ Updated public/index.html " , "success" )
391-
392- # Update manifest.json
393- console .out (f" { console .wait } Updating public/manifest.json" , end = "\r " )
394- with open (f'{ settings .BASE_DIR } /clients/{ name } /public/manifest.json' ) as manifest :
395- content = manifest .read ()
396- content = content .replace ('app-name' , name )
397- with open (f'{ settings .BASE_DIR } /clients/{ name } /public/manifest.json' , 'w' ) as new_file :
398- new_file .write (content )
399- console .out (" ✅ Updated public/manifest.json " , "success" )
390+ # Update index.html
391+ index_html_path = \
392+ f'{ settings .BASE_DIR } /clients/{ name } /web/index.html' if native else \
393+ f'{ settings .BASE_DIR } /clients/{ name } /public/index.html'
394+ console .out (f" { console .wait } Updating index.html" , end = "\r " )
395+ with open (index_html_path , 'r' ) as index_content :
396+ content = index_content .read ()
397+ content = content .replace ('{#app_name#}' , name )
398+ with open (index_html_path , 'w' ) as new_file :
399+ new_file .write (content )
400+ console .out (f" { console .success } Updated index.html " , "success" )
401+
402+ # Update manifest.json
403+ manifest_json_path = \
404+ f'{ settings .BASE_DIR } /clients/{ name } /web/manifest.json' if native else \
405+ f'{ settings .BASE_DIR } /clients/{ name } /public/manifest.json'
406+ console .out (f" { console .wait } Updating public/manifest.json" , end = "\r " )
407+ with open (manifest_json_path , 'r' ) as manifest :
408+ content = manifest .read ()
409+ content = content .replace ('app-name' , name )
410+ with open (manifest_json_path , 'w' ) as new_file :
411+ new_file .write (content )
412+ console .out (" ✅ Updated manifest.json " , "success" )
400413
401414 # Update package.json
402415 console .out (f" { console .wait } Updating package.json" , end = "\r " )
@@ -413,12 +426,18 @@ def update_overlord_configuration():
413426 with open (f'{ settings .BASE_DIR } /clients/{ name } /shared.json' ) as shared :
414427 content = shared .read ()
415428 content = content .replace ('overlord_web_client' , name )
429+ content = content .replace ('overlord_native_client' , name )
416430 with open (f'{ settings .BASE_DIR } /clients/{ name } /shared.json' , 'w' ) as new_file :
417431 new_file .write (content )
418432 console .out (" ✅ Updated shared.json " , "success" )
419433
420434 if native :
421- console .input ("npm install -g expo-cli" , cwd = f"{ settings .BASE_DIR } /clients/{ name } " )
435+ console .out (f" { console .wait } Installing expo-cli" , end = "\r " )
436+ console .input ("npm install expo-cli" , cwd = f"{ settings .BASE_DIR } /clients/{ name } " )
437+ console .out (f" { console .success } Installed expo-cli " , "success" )
438+ console .out (f" { console .wait } Installing eas-cli" , end = "\r " )
439+ console .input ("npm install eas-cli" , cwd = f"{ settings .BASE_DIR } /clients/{ name } " )
440+ console .out (f" { console .success } Installed eas-cli " , "success" )
422441
423442 update_overlord_configuration ()
424443 return install (name )
0 commit comments