From 9d9703a7c69f2ab3be433237aae38ee67c20de82 Mon Sep 17 00:00:00 2001 From: pxi Date: Tue, 3 Dec 2024 02:13:07 +0100 Subject: [PATCH] =?UTF-8?q?(=EF=BC=BE=E2=96=BD=EF=BC=BE=CA=83=C6=AA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 10 +++++++++- bin/deploy.sh | 32 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a5dd6bc..c98ec21 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # Wakale.casa -This is the repo for the site at https://wakale.casa/ \ No newline at end of file +This is the repo for the site at https://wakale.casa/ + +To deploy use: + +``` + +./bin/deploy.sh + +``` \ No newline at end of file diff --git a/bin/deploy.sh b/bin/deploy.sh index 3fad4dd..c55bd44 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -1,15 +1,15 @@ -#!/bin/bash +#! /bin/bash # Get the full path to the dist directory APP_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Function to check if a command exists command_exists() { - command -v "$1" >/dev/null 2>&1 + command -v "$1" > /dev/null 2>&1 } # Check and install NVM if not present -if ! command_exists nvm; then +if [ ! -d "$HOME/.nvm/.git" ]; then echo "NVM not found. Installing NVM..." # Check if curl is installed @@ -30,15 +30,20 @@ if ! command_exists nvm; then # Install NVM curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash +fi - # Source NVM to make it available in the current script - export NVM_DIR="$HOME/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +# Source NVM to make it available in the current script +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + +if ! command_exists npm; then + echo "NPM not installed, installing." + nvm install node fi # Use Node.js newest version -nvm install node +echo "Using version of node.js" nvm use node # Check and install Wrangler if not present @@ -54,12 +59,17 @@ if ! wrangler whoami &> /dev/null; then fi if [ -f "$APP_PATH/packages.json" ]; then - # Install project dependencies + echo "Install project dependencies" npm install - # Build your project + + echo "Build your project" npm run build fi # Deploy to Cloudflare Pages using the full path to dist -wrangler pages deploy "$APP_PATH/www" \ No newline at end of file +echo "Deploying $APP_PATH/www" + +wrangler pages deploy "$APP_PATH/www" + +echo "DONE."