Skip to content

Commit

Permalink
improve install / update / run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rvion committed Dec 5, 2023
1 parent 2773925 commit f5c0da1
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 3 deletions.
1 change: 1 addition & 0 deletions linux_INSTALL.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./macos_INSTALL.sh
1 change: 1 addition & 0 deletions linux_START.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./macos_START.sh
1 change: 1 addition & 0 deletions linux_UPDATE.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./macos_UPDATE.sh
File renamed without changes.
93 changes: 93 additions & 0 deletions macos_START.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/bin/bash

set -e # Exit with nonzero exit code if anything fails
set -u # Treat unset variables as an error
# set -x # Print commands and their arguments as they are executed

# ===//=====//======//======//======//======//======//======//======//======//======//======//==
# ==//=====//======//======//======//======//======//======//======//======//======//======//===

PNPM_VERSION=8.11.0
PNPM_HOME=$(pwd)/.cushy
PNPM_BIN_PATH=$(pwd)/.cushy/pnpm

# Function to install using curl
install_with_curl() {
echo "Installing pnpm with curl..."
curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=$PNPM_VERSION sh -
}

# Function to install using wget
install_with_wget() {
echo "Installing pnpm with wget..."
wget -qO- https://get.pnpm.io/install.sh | env PNPM_VERSION=$PNPM_VERSION sh -
}

install_or_update_pnpm() {
# Check if curl is available
if command -v curl > /dev/null 2>&1; then
install_with_curl
# Check if wget is available
elif command -v wget > /dev/null 2>&1; then
install_with_wget
# If neither curl nor wget is available, exit with error
else
echo "Neither curl nor wget is available. Please install one of these packages and try again."
exit 1
fi
}

# Check if pnpm is already installed
if command -v $PNPM_HOME/pnpm > /dev/null 2>&1; then
INSTALLED_PNPM_VERSION=$($PNPM_BIN_PATH --version)

if [ "$INSTALLED_PNPM_VERSION" != "$PNPM_VERSION" ]; then
echo "⏳ Updating pnpm from version $INSTALLED_PNPM_VERSION to $PNPM_VERSION..."
install_or_update_pnpm
else
echo "🟢 pnpm is already installed and up to date."
fi
else
echo "⏳ pnpm is not installed, proceeding with installation..."
install_or_update_pnpm
fi

# Verify pnpm installation
if ! command -v $PNPM_BIN_PATH > /dev/null 2>&1; then
echo "Failed to install or update pnpm."
exit 1
fi

# Install dependencies using pnpm
echo "Installing dependencies..."
$PNPM_BIN_PATH install

# ===//=====//======//======//======//======//======//======//======//======//======//======//==
# ==//=====//======//======//======//======//======//======//======//======//======//======//===

# ensuring binary dependencies are correctly linked across installed
./node_modules/.bin/electron-builder install-app-deps


# ===//=====//======//======//======//======//======//======//======//======//======//======//==
# ==//=====//======//======//======//======//======//======//======//======//======//======//===

# Define the path to tsconfig.custom.json
tsconfigPath="./tsconfig.custom.json"

# JSON content to write if the file does not exist
defaultTsconfigJSON='{ "include": ["src", "schema/global.d.ts"], "exclude": [] }'

# Check if the file exists
if [ ! -f "$tsconfigPath" ]; then
# Write the JSON content to the file without formatting
echo "$defaultTsconfigJSON" > "$tsconfigPath"
fi


# ===//=====//======//======//======//======//======//======//======//======//======//======//==
# ==//=====//======//======//======//======//======//======//======//======//======//======//===

# Start Vite using Electron's Node
echo "Starting Vite with Electron's Node..."
./node_modules/.bin/electron -i src/shell
File renamed without changes.
3 changes: 0 additions & 3 deletions START_windows.bat → windows_INSTALL.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ SET PNPM_VERSION=8.11.0
SET PNPM_HOME=%CD%\.cushy
SET PNPM_BIN_PATH=%CD%\.cushy\pnpm.exe

:: Function to install using PowerShell
@REM CALL :install_with_powershell

:: Check if pnpm is already installed
IF EXIST "%PNPM_HOME%\pnpm" (
FOR /F "tokens=*" %%i IN ('%PNPM_BIN_PATH% --version') DO SET INSTALLED_PNPM_VERSION=%%i
Expand Down
60 changes: 60 additions & 0 deletions windows_START.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
@echo off
SETLOCAL EnableExtensions
setlocal enabledelayedexpansion

:: Exit with nonzero exit code if anything fails
set errorlevel=

:: Define variables
SET PNPM_VERSION=8.11.0
SET PNPM_HOME=%CD%\.cushy
SET PNPM_BIN_PATH=%CD%\.cushy\pnpm.exe

:: Check if pnpm is already installed
IF EXIST "%PNPM_HOME%\pnpm" (
FOR /F "tokens=*" %%i IN ('%PNPM_BIN_PATH% --version') DO SET INSTALLED_PNPM_VERSION=%%i
IF NOT "%INSTALLED_PNPM_VERSION%"=="%PNPM_VERSION%" (
ECHO Updating pnpm from version %INSTALLED_PNPM_VERSION% to %PNPM_VERSION%...
CALL :install_with_powershell
) ELSE (
ECHO pnpm is already installed and up to date.
)
) ELSE (
ECHO pnpm is not installed, proceeding with installation...
CALL :install_with_powershell
)

:: Verify pnpm installation
IF NOT EXIST "%PNPM_BIN_PATH%" (
ECHO Failed to install or update pnpm.
EXIT /B 1
)

:: Install dependencies using pnpm
ECHO Installing dependencies...
CALL %PNPM_BIN_PATH% install

:: ensuring binary dependencies are correctly linked across installed
CALL .\node_modules\.bin\electron-builder install-app-deps

:: Define the path to tsconfig.custom.json
SET tsconfigPath=.\tsconfig.custom.json

:: JSON content to write if the file does not exist
SET defaultTsconfigJSON={ "include": ["src", "schema/global.d.ts"], "exclude": [] }

:: Check if the file exists
IF NOT EXIST "%tsconfigPath%" (
ECHO %defaultTsconfigJSON% > "%tsconfigPath%"
)

:: Start Vite using Electron's Node
ECHO Starting Vite with Electron's Node...
CALL .\node_modules\.bin\electron -i src\shell

EXIT /B 0

:install_with_powershell
ECHO Installing pnpm with PowerShell...
PowerShell -Command "iwr https://get.pnpm.io/install.ps1 -useb | iex"
EXIT /B 0
File renamed without changes.

0 comments on commit f5c0da1

Please sign in to comment.