From f97e0be4c34dd393baf3d827e7791eed66ffab47 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 19 Mar 2026 21:03:20 +0100 Subject: [PATCH] Do not push transient steps --- kobopatch-wasm/setup.sh | 5 +++++ nixpacks.toml | 3 --- test.sh | 8 ++++++++ web/src/js/app.js | 44 +++++++++++++++++++---------------------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/kobopatch-wasm/setup.sh b/kobopatch-wasm/setup.sh index c2f4525..0837dc8 100755 --- a/kobopatch-wasm/setup.sh +++ b/kobopatch-wasm/setup.sh @@ -4,6 +4,11 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" KOBOPATCH_DIR="$SCRIPT_DIR/kobopatch-src" +if ! command -v go &>/dev/null; then + echo "Go not found, downloading..." + curl -fsSL https://go.dev/dl/go1.23.12.linux-amd64.tar.gz | tar -xz -C /usr/local +fi + if [ -d "$KOBOPATCH_DIR" ]; then echo "Updating kobopatch source..." cd "$KOBOPATCH_DIR" diff --git a/nixpacks.toml b/nixpacks.toml index 7ba7b38..5d5ccae 100644 --- a/nixpacks.toml +++ b/nixpacks.toml @@ -3,9 +3,6 @@ providers = ["node"] [phases.setup] nixPkgs = ["git", "curl", "zip", "gnutar", "nginx"] paths = ["/usr/local/go/bin"] -cmds = [ - "curl -sSfL https://go.dev/dl/go1.23.12.linux-amd64.tar.gz | tar -xz -C /usr/local", -] [phases.build] cmds = [ diff --git a/test.sh b/test.sh index 66b0f68..18be28b 100755 --- a/test.sh +++ b/test.sh @@ -3,6 +3,14 @@ set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +echo "=== Installing web dependencies ===" +cd "$SCRIPT_DIR/web" && npm install + +echo "" +echo "=== Building web app ===" +cd "$SCRIPT_DIR/web" && node build.mjs + +echo "" echo "=== Building WASM ===" "$SCRIPT_DIR/kobopatch-wasm/build.sh" diff --git a/web/src/js/app.js b/web/src/js/app.js index 83e9b99..689f4b3 100644 --- a/web/src/js/app.js +++ b/web/src/js/app.js @@ -138,13 +138,17 @@ import JSZip from 'jszip'; const stepHistory = [stepConnect]; - function pushStep(step) { - stepHistory.push(step); - } - - function popStep() { - stepHistory.pop(); - return stepHistory[stepHistory.length - 1]; + function showStep(step, push = true) { + for (const s of allSteps) { + s.hidden = (s !== step); + } + if (!push) return; + const idx = stepHistory.indexOf(step); + if (idx >= 0) { + stepHistory.length = idx + 1; + } else { + stepHistory.push(step); + } } function setNavLabels(labels) { @@ -158,15 +162,6 @@ import JSZip from 'jszip'; } } - function showStep(step, updateHistory = true) { - for (const s of allSteps) { - s.hidden = (s !== step); - } - if (updateHistory) { - stepHistory[stepHistory.length - 1] = step; - } - } - function setNavStep(num) { const items = $qa('li', stepNav); items.forEach((li, i) => { @@ -704,12 +699,11 @@ import JSZip from 'jszip'; } populateSelectedPatchesList(); setNavStep(4); - showStep(stepFirmware); + showStep(stepFirmware, false); } btnBuildBack.addEventListener('click', () => { if (isRestore) { - // Restore was triggered directly from the device step isRestore = false; setNavLabels(NAV_DEFAULT); setNavStep(1); @@ -836,7 +830,7 @@ import JSZip from 'jszip'; } btnBuild.addEventListener('click', async () => { - showStep(stepBuilding); + showStep(stepBuilding, false); buildLog.textContent = ''; buildProgress.textContent = 'Starting...'; $('build-wait-hint').textContent = isRestore @@ -909,7 +903,7 @@ import JSZip from 'jszip'; errorLog.hidden = true; } - const hasBackStep = stepHistory[stepHistory.length - 1] === stepPatches; + const hasBackStep = stepHistory.includes(stepPatches); if (hasBackStep) { errorTitle.textContent = 'The patch failed to apply'; errorHint.hidden = false; @@ -922,16 +916,18 @@ import JSZip from 'jszip'; btnRetry.classList.remove('danger'); } hideNav(); - pushStep(stepError); - showStep(stepError, false); + showStep(stepError); } btnErrorBack.addEventListener('click', () => { btnErrorBack.hidden = true; btnRetry.classList.remove('danger'); - const prev = popStep(); + stepHistory.pop(); + while (stepHistory.length > 0 && stepHistory[stepHistory.length - 1] !== stepPatches) { + stepHistory.pop(); + } showNav(); - showStep(prev); + showStep(stepPatches); }); btnRetry.addEventListener('click', () => {