From e950e7ea8eab8b53f247b50553cb88bca426a4a0 Mon Sep 17 00:00:00 2001 From: nikomiko Date: Thu, 5 Feb 2026 13:46:51 -0500 Subject: [PATCH] fix: deployment scripts and index.ts problems --- .github/workflows/ssh-deploy.yml | 4 +-- apps/vdb-backend/src/index.ts | 42 ++++++++++++++++++++++++-------- deploy.sh | 13 ++++++---- stage.sh | 12 +++++++++ 4 files changed, 54 insertions(+), 17 deletions(-) create mode 100755 stage.sh diff --git a/.github/workflows/ssh-deploy.yml b/.github/workflows/ssh-deploy.yml index b1fc23c..d7eb96f 100644 --- a/.github/workflows/ssh-deploy.yml +++ b/.github/workflows/ssh-deploy.yml @@ -1,4 +1,4 @@ -name: SSH Deploy +name: SSH Deploy Staged on: push: @@ -20,4 +20,4 @@ jobs: - name: SSH and run deployment script run: | ssh -i ~/.ssh/id_ed25519 ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \ - 'cd ${{ secrets.SOURCE_DIR }} && git pull && sh ./deploy.sh ${{ secrets.SOURCE_DIR }} ${{ secrets.HTML_DIR }}' + 'sh ./stage.sh' diff --git a/apps/vdb-backend/src/index.ts b/apps/vdb-backend/src/index.ts index beac03e..189373a 100644 --- a/apps/vdb-backend/src/index.ts +++ b/apps/vdb-backend/src/index.ts @@ -107,7 +107,7 @@ async function loadSheet() { return; } - const lects = rows.shift()?.split('\t'); + const lect_names = rows.shift()?.split('\t'); const keys = rows.map(row=>row.split('\t')[0]?.split(';')[0]); console.log(keys); @@ -117,25 +117,44 @@ async function loadSheet() { return; } - if (!lects) { + if (!lect_names) { console.error("No lects found"); return; } - for (const lect of lects) { + const lects = Array(); + + for (const lect of lect_names) { let l = new Lect(); l.name = lect; l.save(); + lects.push(l) console.log(l); } - const nikolect = lects.indexOf("Nikomiko"); const lemmas = Array(); + for (let i = 0; i < rows.length; i++) { const row = rows[i]?.split('\t'); + const lect_name = lect_names[i]; + + if(!lect_name){ + console.error("No lect name"); + break; + } + + if(!row){ + console.error("Row doesn't exist"); + continue; + } + + if(row.length !== lect_names.length){ + console.error("Mismatched row size"); + continue; + } + + const lemma_key = row[0]; - // todo - const lemma_key = null; const lemma = new Lemma(); if (lemma_key == null || lemma_key.length == 0) { @@ -151,12 +170,15 @@ async function loadSheet() { lemmas.push(lemma); lemma.word_forms = Array(); - for (let i = 0; i < row.length; i++) { - const cell = row?.[i]; + for (let j = 0; j < row.length; j++) { + const cell = row?.[j]; + const lect = lects[j]; + if ( cell === null || cell === undefined || - (typeof cell === "string" && cell.length === 0) + (typeof cell === "string" && cell.length === 0) || + !lect ) { continue; } @@ -164,7 +186,7 @@ async function loadSheet() { for (let word_form of cell.split(";")) { const f = new WordForm(); f.word_form = word_form; - f.lect = lects[i]; + f.lect = lect; lemma.word_forms.push(f); } } diff --git a/deploy.sh b/deploy.sh index bc8dcd8..ea70fcd 100755 --- a/deploy.sh +++ b/deploy.sh @@ -3,11 +3,14 @@ # # Deployment script to be run remotely on push to master at https://github.com/ViossaDiskordServer/ViossaDotNet/ # -# Usage: sh ./deploy.sh SOURCE_DIR STATIC_DIRECTORY +# Usage: sh ./deploy.sh SOURCE_DIR STATIC_DIR BACKEND_DIR # -pwd -cd $1/apps/vdn-static/ || exit +SOURCE_DIR=$1 +STATIC_DIR=$2 +BACKEND_DIR=$3 -npx turbo build \ - && cp -r ./dist/* $2 +pwd + +cp -r $SOURCE_DIR/apps/vdn-static/dist/* "$STATIC_DIR" || { echo "Can't copy static dist 😓 - code $?"; exit; } +cp -r $SOURCE_DIR/apps/vdb-backend/dist/* "$BACKEND_DIR" || { echo "Can't copy backend dist 😓 - code $?"; exit; } diff --git a/stage.sh b/stage.sh new file mode 100755 index 0000000..858d124 --- /dev/null +++ b/stage.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# +# Deployment script to be run remotely on push to master at https://github.com/ViossaDiskordServer/ViossaDotNet/ +# Stages static content in a folder immediately for testing. run ./deploy.sh to convert main site. +# Usage: sh ./stage.sh SOURCE_DIR +# + +SOURCE_DIR=$1 + +cd "$1"|| { echo "Can't cd 😓"; exit; } +git fetch --all && git branch "backup-$(date +'%s')" && git reset --hard origin/main && npx turbo build \ No newline at end of file