From 8c2a87c93e8ab1ee48f79f814949835e8ce3796f Mon Sep 17 00:00:00 2001 From: SethBurkart123 Date: Sun, 3 Dec 2023 12:05:42 +1100 Subject: [PATCH 1/4] add build, dev and install scripts for windows, mac and linux --- scripts/build.bat | 10 +++++++ scripts/build.sh | 12 ++++++++ scripts/dev.bat | 7 +++++ scripts/dev.sh | 9 ++++++ scripts/install.bat | 34 +++++++++++++++++++++++ scripts/install.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100644 scripts/build.bat create mode 100644 scripts/build.sh create mode 100644 scripts/dev.bat create mode 100644 scripts/dev.sh create mode 100644 scripts/install.bat create mode 100644 scripts/install.sh diff --git a/scripts/build.bat b/scripts/build.bat new file mode 100644 index 00000000..977bc4cb --- /dev/null +++ b/scripts/build.bat @@ -0,0 +1,10 @@ +@echo off +REM Running install script +call install.bat + +REM Building projects +cd .. +cd interface +npm run build +cd .. +npm run build \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 00000000..ab5d97aa --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Running install script +./install.sh + +cd .. + +# Building projects +cd ./interface +npm run build +cd .. +npm run build \ No newline at end of file diff --git a/scripts/dev.bat b/scripts/dev.bat new file mode 100644 index 00000000..73040d8f --- /dev/null +++ b/scripts/dev.bat @@ -0,0 +1,7 @@ +@echo off +REM Running npm run dev in both directories +cd .. +cd interface +START cmd /k "npm run dev" +cd .. +npm run dev \ No newline at end of file diff --git a/scripts/dev.sh b/scripts/dev.sh new file mode 100644 index 00000000..86240dd4 --- /dev/null +++ b/scripts/dev.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd .. + +# Running npm run dev in both directories +cd ./interface +npm run dev & +cd .. +npm run dev \ No newline at end of file diff --git a/scripts/install.bat b/scripts/install.bat new file mode 100644 index 00000000..1e701ed2 --- /dev/null +++ b/scripts/install.bat @@ -0,0 +1,34 @@ +@echo off +setlocal + +:: Function to check if a program exists +CALL :check_program_existence npm HAS_NPM +CALL :check_program_existence pnpm HAS_PNPM + +:: Checking and installing Node.js and npm if not present +IF "%HAS_NPM%"=="false" ( + ECHO npm is not detected. Please install Node.js from https://nodejs.org/ and rerun this script. + EXIT /B 1 +) + +:: Checking and installing pnpm if not present +IF "%HAS_PNPM%"=="false" ( + ECHO pnpm is not detected. Installing pnpm... + npm install -g pnpm +) + +:: Installing dependencies using pnpm +pnpm install +CD interface +pnpm install +CD .. + +ECHO Success! All dependencies installed. +GOTO :EOF + +:: Function to check if a program exists +:check_program_existence +SET "program=%~1" +FOR /F "tokens=*" %%i IN ('where %program% 2^>NUL') DO (SET "%~2=true" & GOTO :EOF) +SET "%~2=false" +GOTO :EOF diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 00000000..774d522e --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Function to install pnpm +install_pnpm() { + if ! command -v pnpm >/dev/null 2>&1; then + npm install -g pnpm + fi + pnpm_install +} + +# Function to install Node.js and npm +install_npm() { + # Detecting OS + OS="unknown" + case "$(uname -s)" in + Darwin) OS="mac" ;; + Linux) OS="linux" ;; + esac + + # Downloading and installing Node.js + if [ "$OS" = "mac" ]; then + # Install NVM (Node Version Manager) and Node.js + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install node + elif [ "$OS" = "linux" ]; then + # Using NodeSource Node.js Binary Distributions script for Linux + curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash - + sudo apt-get install -y nodejs + fi +} + +# Function to install packages using pnpm +pnpm_install() { + pnpm install + cd ./interface + pnpm install + cd .. +} + +# Function to install packages using npm +npm_install() { + npm install + cd ./interface + npm install + cd .. +} + +cd .. + +# Check for npm installation +if ! command -v npm >/dev/null 2>&1; then + echo "npm is not installed. Installing npm and Node.js..." + install_npm +fi + +# Ask user for package manager preference +echo "npm is installed." +read -p "Do you wish to use pnpm? (y/n) " yn +case $yn in + [Yy]* ) install_pnpm;; + [Nn]* ) npm_install;; + * ) echo "Please answer yes or no."; exit 1;; +esac + +echo "Success! All dependencies installed." From f6fe716abf422737d66ac8c7e51aacd61ac21544 Mon Sep 17 00:00:00 2001 From: Seth Burkart <108050083+SethBurkart123@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:21:00 +1100 Subject: [PATCH 2/4] Update Getting Started tutorial in README.md --- README.md | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6278969a..c0c63457 100644 --- a/README.md +++ b/README.md @@ -47,32 +47,26 @@ git clone https://github.com/SethBurkart123/EvenBetterSEQTA ``` -2. Install dependencies +### Windows +Open the `install.bat` file located inside the `scripts` folder. Then after that is finished, open the `dev.bat` file. + +### Mac & Linux + +1. cd into the folder ``` -npm install +cd EvenBetterSEQTA/scripts +``` +2. Make the scripts in the folder executable +``` +chmod a+x * +``` +3. Run the install and dev scripts +``` +sh install.sh +sh dev.sh ``` -3. Install webpack - -``` -npm install -g webpack -``` - -4. Run the dev script (it updates as you save files) - -``` -npm run dev -``` - -5. Install and run the dev script for the interface **at the same time** (all custom react components are a separate sub-repository) - -``` -cd interface - -npm install -npm run dev -``` ## Folder Structure From aa303d6725301021dacd3517ef3e16ca8b3d3911 Mon Sep 17 00:00:00 2001 From: Seth Burkart <108050083+SethBurkart123@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:21:27 +1100 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0c63457..3f67239e 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Open the `install.bat` file located inside the `scripts` folder. Then after that ### Mac & Linux -1. cd into the folder +1. `cd` into the folder ``` cd EvenBetterSEQTA/scripts ``` From 3cc3acfd91c7da1c79487e3ad4a004f111ebfa2e Mon Sep 17 00:00:00 2001 From: SethBurkart123 Date: Sun, 3 Dec 2023 12:23:47 +1100 Subject: [PATCH 4/4] update scripts to auto check for pnpm and npm --- scripts/build.bat | 24 +++++++++++++++++++----- scripts/build.sh | 22 +++++++++++++++++----- scripts/dev.bat | 24 +++++++++++++++++++----- scripts/dev.sh | 22 +++++++++++++++++----- scripts/install.bat | 0 scripts/install.sh | 0 6 files changed, 72 insertions(+), 20 deletions(-) mode change 100644 => 100755 scripts/build.bat mode change 100644 => 100755 scripts/build.sh mode change 100644 => 100755 scripts/dev.bat mode change 100644 => 100755 scripts/dev.sh mode change 100644 => 100755 scripts/install.bat mode change 100644 => 100755 scripts/install.sh diff --git a/scripts/build.bat b/scripts/build.bat old mode 100644 new mode 100755 index 977bc4cb..1276a916 --- a/scripts/build.bat +++ b/scripts/build.bat @@ -1,10 +1,24 @@ @echo off + REM Running install script call install.bat -REM Building projects cd .. -cd interface -npm run build -cd .. -npm run build \ No newline at end of file + +REM Try to get the version of pnpm +pnpm --version > NUL 2>&1 + +REM Check the exit status of the previous command +IF %ERRORLEVEL% EQU 0 ( + REM Running pnpm run build in both directories + cd ./interface + pnpm run build + cd .. + pnpm run build +) ELSE ( + REM Running npm run build in both directories + cd ./interface + npm run build + cd .. + npm run build +) diff --git a/scripts/build.sh b/scripts/build.sh old mode 100644 new mode 100755 index ab5d97aa..470a7e9a --- a/scripts/build.sh +++ b/scripts/build.sh @@ -5,8 +5,20 @@ cd .. -# Building projects -cd ./interface -npm run build -cd .. -npm run build \ No newline at end of file +# Try to get the version of pnpm +pnpm --version > /dev/null 2>&1 + +# Check the exit status of the previous command +if [ $? -eq 0 ]; then + # Running npm run dev in both directories + cd ./interface + pnpm run build + cd .. + pnpm run build +else + # Running npm run dev in both directories + cd ./interface + npm run build + cd .. + npm run build +fi \ No newline at end of file diff --git a/scripts/dev.bat b/scripts/dev.bat old mode 100644 new mode 100755 index 73040d8f..7964eacc --- a/scripts/dev.bat +++ b/scripts/dev.bat @@ -1,7 +1,21 @@ @echo off -REM Running npm run dev in both directories + cd .. -cd interface -START cmd /k "npm run dev" -cd .. -npm run dev \ No newline at end of file + +REM Try to get the version of pnpm +pnpm --version >nul 2>&1 + +REM Check the exit status of the previous command +if %ERRORLEVEL% == 0 ( + REM Running pnpm run dev in both directories + cd interface + start /b pnpm run dev + cd .. + pnpm run dev +) else ( + REM Running npm run dev in both directories + cd interface + start /b npm run dev + cd .. + npm run dev +) diff --git a/scripts/dev.sh b/scripts/dev.sh old mode 100644 new mode 100755 index 86240dd4..5307018a --- a/scripts/dev.sh +++ b/scripts/dev.sh @@ -2,8 +2,20 @@ cd .. -# Running npm run dev in both directories -cd ./interface -npm run dev & -cd .. -npm run dev \ No newline at end of file +# Try to get the version of pnpm +pnpm --version > /dev/null 2>&1 + +# Check the exit status of the previous command +if [ $? -eq 0 ]; then + # Running npm run dev in both directories + cd ./interface + pnpm run dev & + cd .. + pnpm run dev +else + # Running npm run dev in both directories + cd ./interface + npm run dev & + cd .. + npm run dev +fi \ No newline at end of file diff --git a/scripts/install.bat b/scripts/install.bat old mode 100644 new mode 100755 diff --git a/scripts/install.sh b/scripts/install.sh old mode 100644 new mode 100755