Refactor deploy script to replace npm ci with npm install for both backend and frontend setups, enhancing reliability when package-lock.json is missing. Implement fallback mechanism to ensure successful dependency installation, improving overall script robustness.
This commit is contained in:
53
deploy.sh
53
deploy.sh
@@ -203,12 +203,7 @@ setup_backend() {
|
|||||||
npm config set progress false >/dev/null 2>&1 || true
|
npm config set progress false >/dev/null 2>&1 || true
|
||||||
npm config set loglevel warn >/dev/null 2>&1 || true
|
npm config set loglevel warn >/dev/null 2>&1 || true
|
||||||
# Backend braucht alle Dependencies (auch dev für Build-Tools)
|
# Backend braucht alle Dependencies (auch dev für Build-Tools)
|
||||||
timeout 600 bash -lc "npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress" || {
|
npm install --no-audit --no-fund --loglevel=warn
|
||||||
print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..."
|
|
||||||
npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress || {
|
|
||||||
print_error "npm ci (Backend) fehlgeschlagen"; exit 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -f .env ]; then
|
if [ ! -f .env ]; then
|
||||||
print_warning ".env Datei nicht gefunden!"
|
print_warning ".env Datei nicht gefunden!"
|
||||||
@@ -240,12 +235,7 @@ setup_frontend() {
|
|||||||
npm config set progress false >/dev/null 2>&1 || true
|
npm config set progress false >/dev/null 2>&1 || true
|
||||||
npm config set loglevel warn >/dev/null 2>&1 || true
|
npm config set loglevel warn >/dev/null 2>&1 || true
|
||||||
# Frontend braucht dev-Dependencies für den Build (vite, etc.)
|
# Frontend braucht dev-Dependencies für den Build (vite, etc.)
|
||||||
timeout 600 bash -lc "npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress" || {
|
npm install --no-audit --no-fund --loglevel=warn
|
||||||
print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..."
|
|
||||||
npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress || {
|
|
||||||
print_error "npm ci (Frontend) fehlgeschlagen"; exit 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# .env.production erstellen falls nicht vorhanden
|
# .env.production erstellen falls nicht vorhanden
|
||||||
if [ ! -f ".env.production" ]; then
|
if [ ! -f ".env.production" ]; then
|
||||||
@@ -487,17 +477,27 @@ do_update() {
|
|||||||
# Backend aktualisieren
|
# Backend aktualisieren
|
||||||
print_info "Aktualisiere Backend Dependencies..."
|
print_info "Aktualisiere Backend Dependencies..."
|
||||||
cd $BACKEND_DIR
|
cd $BACKEND_DIR
|
||||||
|
|
||||||
|
# Prüfe ob package-lock.json existiert
|
||||||
|
if [ ! -f "package-lock.json" ]; then
|
||||||
|
print_warning "package-lock.json fehlt! Verwende npm install statt npm ci"
|
||||||
|
npm install --no-audit --no-fund --loglevel=warn
|
||||||
|
else
|
||||||
npm config set fund false >/dev/null 2>&1 || true
|
npm config set fund false >/dev/null 2>&1 || true
|
||||||
npm config set audit false >/dev/null 2>&1 || true
|
npm config set audit false >/dev/null 2>&1 || true
|
||||||
npm config set progress false >/dev/null 2>&1 || true
|
npm config set progress false >/dev/null 2>&1 || true
|
||||||
npm config set loglevel warn >/dev/null 2>&1 || true
|
npm config set loglevel warn >/dev/null 2>&1 || true
|
||||||
|
|
||||||
# Backend braucht alle Dependencies (auch dev für Build-Tools)
|
# Backend braucht alle Dependencies (auch dev für Build-Tools)
|
||||||
timeout 600 bash -lc "npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress" || {
|
if ! npm ci --no-audit --no-fund --loglevel=warn 2>&1; then
|
||||||
print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..."
|
print_warning "npm ci fehlgeschlagen. Fallback auf npm install..."
|
||||||
npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress || {
|
rm -rf node_modules
|
||||||
print_error "npm ci (Backend Update) fehlgeschlagen"; exit 1;
|
npm install --no-audit --no-fund --loglevel=warn || {
|
||||||
}
|
print_error "npm install (Backend Update) fehlgeschlagen"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Frontend aktualisieren
|
# Frontend aktualisieren
|
||||||
print_info "Aktualisiere Frontend..."
|
print_info "Aktualisiere Frontend..."
|
||||||
@@ -512,17 +512,26 @@ VITE_API_URL=/api
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Prüfe ob package-lock.json existiert
|
||||||
|
if [ ! -f "package-lock.json" ]; then
|
||||||
|
print_warning "package-lock.json fehlt! Verwende npm install statt npm ci"
|
||||||
|
npm install --no-audit --no-fund --loglevel=warn
|
||||||
|
else
|
||||||
npm config set fund false >/dev/null 2>&1 || true
|
npm config set fund false >/dev/null 2>&1 || true
|
||||||
npm config set audit false >/dev/null 2>&1 || true
|
npm config set audit false >/dev/null 2>&1 || true
|
||||||
npm config set progress false >/dev/null 2>&1 || true
|
npm config set progress false >/dev/null 2>&1 || true
|
||||||
npm config set loglevel warn >/dev/null 2>&1 || true
|
npm config set loglevel warn >/dev/null 2>&1 || true
|
||||||
|
|
||||||
# Frontend braucht dev-Dependencies für den Build (vite, etc.)
|
# Frontend braucht dev-Dependencies für den Build (vite, etc.)
|
||||||
timeout 600 bash -lc "npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress" || {
|
if ! npm ci --no-audit --no-fund --loglevel=warn 2>&1; then
|
||||||
print_warning "npm ci ist fehlgeschlagen oder hat zu lange gedauert. Versuche fallback ohne timeout..."
|
print_warning "npm ci fehlgeschlagen. Fallback auf npm install..."
|
||||||
npm ci --no-audit --no-fund --silent --loglevel=warn --no-progress || {
|
rm -rf node_modules
|
||||||
print_error "npm ci (Frontend Update) fehlgeschlagen"; exit 1;
|
npm install --no-audit --no-fund --loglevel=warn || {
|
||||||
}
|
print_error "npm install (Frontend Update) fehlgeschlagen"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Sauberer Build
|
# Sauberer Build
|
||||||
rm -rf dist/
|
rm -rf dist/
|
||||||
|
|||||||
Reference in New Issue
Block a user