diff --git a/scripts/update.sh b/scripts/update.sh index 5c63246..5e364e2 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -115,10 +115,8 @@ frontend_build_quiet() { echo "[i] Frontend: vorbereiten …" as_app "mkdir -p '${APP_DIR}/public/build' '${APP_DIR}/node_modules' '${APP_DIR}/.vite' '${APP_DIR}/.npm-cache'" chown -R "$APP_USER":"$APP_GROUP" "${APP_DIR}/node_modules" "${APP_DIR}/.vite" "${APP_DIR}/.npm-cache" 2>/dev/null || true - # npm-Cache im Home-Dir des APP_USER korrigieren (root-Läufe hinterlassen root-Dateien) - local npm_home_cache - npm_home_cache="$(eval echo "~${APP_USER}")/.npm" - [[ -d "${npm_home_cache}" ]] && chown -R "${APP_USER}":"${APP_GROUP}" "${npm_home_cache}" 2>/dev/null || true + # npm-Cache explizit im App-Verzeichnis setzen — verhindert Schreibfehler ins HOME + local NPM_CACHE_FLAG="--cache '${APP_DIR}/.npm-cache'" # Altes Build-Verzeichnis sichern — wird erst nach erfolgreichem Build ersetzt local BUILD_DIR="${APP_DIR}/public/build" @@ -132,8 +130,8 @@ frontend_build_quiet() { as_app "printf 'fund=false\naudit=false\ncache=${APP_DIR}/.npm-cache\n' > ~/.npmrc" >>"$LOG" 2>&1 || true echo "[i] Frontend: Dependencies … (Details: $LOG)" - if ! as_app "cd '${APP_DIR}' && ${NPM_ENV} npm ci --no-audit --no-fund --no-progress" >>"$LOG" 2>&1; then - if ! as_app "cd '${APP_DIR}' && ${NPM_ENV} npm install --no-audit --no-fund --no-progress" >>"$LOG" 2>&1; then + if ! as_app "cd '${APP_DIR}' && ${NPM_ENV} npm ci --no-audit --no-fund --no-progress ${NPM_CACHE_FLAG}" >>"$LOG" 2>&1; then + if ! as_app "cd '${APP_DIR}' && ${NPM_ENV} npm install --no-audit --no-fund --no-progress ${NPM_CACHE_FLAG}" >>"$LOG" 2>&1; then echo "[!] npm install fehlgeschlagen — altes Build wird wiederhergestellt." [[ -d "${BUILD_BAK}" ]] && cp -a "${BUILD_BAK}/." "${BUILD_DIR}/" 2>/dev/null || true tail -n 60 "$LOG" || true @@ -142,7 +140,7 @@ frontend_build_quiet() { fi echo "[i] Frontend: Build … (Details: $LOG)" - if ! as_app "cd '${APP_DIR}' && ${NPM_ENV} npm run build --silent --loglevel=warn" >>"$LOG" 2>&1; then + if ! as_app "cd '${APP_DIR}' && ${NPM_ENV} npm run build --silent --loglevel=warn ${NPM_CACHE_FLAG}" >>"$LOG" 2>&1; then echo "[!] Build fehlgeschlagen — altes Build wird wiederhergestellt." [[ -d "${BUILD_BAK}" ]] && cp -a "${BUILD_BAK}/." "${BUILD_DIR}/" 2>/dev/null || true tail -n 80 "$LOG" || true