Spaces:
Sleeping
Sleeping
import os | |
import shutil | |
import subprocess | |
APP_DIR = "/app" | |
TMP_DIR = "/tmp/repo_clone" | |
REPO_URL = "https://github.com/abubasith456/Node-WLA.git" | |
def remove_app_directory(): | |
if os.path.exists(APP_DIR): | |
print("β οΈ Removing existing app directory...") | |
shutil.rmtree(APP_DIR, ignore_errors=True) | |
def clone_repository(): | |
print("π Cloning repository...") | |
if os.path.exists(TMP_DIR): | |
shutil.rmtree(TMP_DIR, ignore_errors=True) | |
subprocess.run(["git", "clone", REPO_URL, TMP_DIR], check=True) | |
print("π Moving repository files to app directory...") | |
shutil.move(TMP_DIR, APP_DIR) | |
def install_dependencies(): | |
print("π¦ Installing dependencies...") | |
subprocess.run(["npm", "install"], cwd=APP_DIR, check=True) | |
def start_application(): | |
print("π Starting application...") | |
subprocess.Popen(["npm", "start"], cwd=APP_DIR) | |
def main(): | |
print("π Deployment started...") | |
remove_app_directory() | |
clone_repository() | |
install_dependencies() | |
start_application() | |
print("β Deployment complete.") | |
if __name__ == "__main__": | |
main() | |