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."