From 802fbdebd1333dfcfe6586f35ddd4ddc4e08bdb9 Mon Sep 17 00:00:00 2001 From: voldemort <5692900+yell0wsuit@users.noreply.github.com> Date: Tue, 22 Jul 2025 20:20:47 +0700 Subject: [PATCH] Enhance build process by adding OS-specific npm command handling, update README with clearer installation instructions and prerequisites --- README.md | 59 +++++++++++++++++++++++++++++++++++-------------------- build.py | 19 ++++++++++++++---- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d2243ed..7d7a35e 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,51 @@ -## CDRM-Project +# CDRM-Project + ![forthebadge](https://forthebadge.com/images/badges/uses-html.svg) ![forthebadge](https://forthebadge.com/images/badges/uses-css.svg) ![forthebadge](https://forthebadge.com/images/badges/uses-javascript.svg) ![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg) -## Prerequisites (from source only) +## Prerequisites (from source only) - - [Python](https://www.python.org/downloads/) version [3.12](https://www.python.org/downloads/release/python-3120/)+ with PIP and VENV installed - - > Python 3.13 was used at the time of writing +- [Python](https://www.python.org/downloads/) version 3.12+ with PIP installed -## Installation (Automatic) - Recommended -- Extract contents of CDRM-Project 2.0 git contents into a new folder + Python 3.13 was used at the time of writing + +- [Node.js](https://nodejs.org/en/download/) v20+ + +## Installation (Automatic) - Recommended + +- Extract contents of CDRM-Project into a new folder - Open a terminal and change directory into the new folder -- Run `python main.py` +- Run `python build.py && python main.py` - Follow the on-screen prompts ## Installation (From binary) + - Download the latest release from the [releases](https://cdm-project.com/tpd94/CDRM-Project/releases) page and run the `.exe` - ## Installation (Manual) - - Open your terminal and navigate to where you'd like to store the application - - Create a new python virtual environment using `python -m venv CDRM-Project` - - Change directory into the new `CDRM-Project` folder - - Activate the virtual environment +## Installation (Manual) + +- Open your terminal and navigate to where you'd like to store the application +- Clone the project with `git clone https://cdm-project.com/tpd94/CDRM-Project.git` +- Navigate to the `CDRM-Project` folder +- Create a new python virtual environment using `python -m venv venv` +- Activate the virtual environment + + - Windows: - > Windows - change directory into the `Scripts` directory then `activate.bat` - > - > Linux - `source bin/activate` + ```bash + .\venv\Scripts\activate + ``` + + - Linux: - - Extract CDRM-Project 2.0 git contents into the newly created `CDRM-Project` folder - - Install python dependencies `pip install -r requirements.txt` - - (Optional) Create the folder structure `/configs/CDMs/WV` and place your .WVD file into `/configs/CDMs/WV` - - (Optional) Create the folder structure `/config/CDMs/PR` and place your .PRD file into `/configs/CDMs/PR` - - Run the application with `python main.py` + ```bash + source venv/bin/activate + ``` + + Verify that the virtual environment is activated by seeing the `(venv)` prefix in your terminal + +- Install python dependencies `pip install -r requirements.txt` +- (Optional) Create the folder structure `/configs/CDMs/WV` and place your .WVD file into `/configs/CDMs/WV` +- (Optional) Create the folder structure `/config/CDMs/PR` and place your .PRD file into `/configs/CDMs/PR` +- Build the frontend with `python build.py` +- And finally, run the application with `python main.py` diff --git a/build.py b/build.py index 250b4b8..0eaf4ee 100644 --- a/build.py +++ b/build.py @@ -3,18 +3,29 @@ import os import subprocess import shutil +import sys + + +def get_npm_command(): + """Get the appropriate npm command for the current OS.""" + if sys.platform == "win32": + return "npm.cmd" + return "npm" def build_frontend(): """Build the frontend.""" frontend_dir = "cdrm-frontend" + npm_cmd = get_npm_command() - # Check and run npm commands if needed + # Check and install dependencies if node_modules doesn't exist if not os.path.exists(f"{frontend_dir}/node_modules"): - subprocess.run(["npm", "install"], cwd=frontend_dir, check=False) + print("📦 Installing dependencies...") + subprocess.run([npm_cmd, "install"], cwd=frontend_dir, check=True) - if not os.path.exists(f"{frontend_dir}/dist"): - subprocess.run(["npm", "run", "build"], cwd=frontend_dir, check=False) + # Always build the frontend to ensure it's up to date + print("🔨 Building frontend...") + subprocess.run([npm_cmd, "run", "build"], cwd=frontend_dir, check=True) # Move dist to frontend-dist if os.path.exists("frontend-dist"):