litellm/ui/litellm-dashboard/build_ui.sh
Mateo Wang 72bcb748b9
chore: remove _experimental/out (#31546)
* chore: remove _experimental/out

* fix(ci): recreate _experimental/out before copying UI build output

The build scripts cp the Next.js output into litellm/proxy/_experimental/out,
which was removed from git. cp failed because the target directory no longer
existed; mkdir -p recreates it before the copy.

* fix(proxy): make UI serving resilient to a missing _experimental/out

Removing the committed UI export means the source/test tree no longer
ships litellm/proxy/_experimental/out. Three things assumed it was always
present and broke once it was gone:

- get_favicon hard-coded the built favicon path and 404'd without it; it
  now falls back to the bundled swagger/favicon.ico
- the /_next and /ui static mounts raised at construction when the export
  was absent, so the whole UI-setup block was swallowed and no mounts
  registered; they now use check_dir=False
- _restructure_ui_html_files was a nested function only exposed as a
  module attribute when that block happened to succeed; it is now a real
  module-level function

test_admin_ui_export_serves_nested_extensionless_routes validated the
committed artifact, whose premise this PR removes; it now drives the same
MCP OAuth callback restructure guarantee through a synthetic export.

* chore(greptile): ignore generated _experimental/out so review fits the file limit

* Revert "chore(greptile): ignore generated _experimental/out so review fits the file limit"

ignorePatterns is applied after Greptile counts the files changed, so it
does not bring the diff under the file limit; the config had no effect.
2026-06-29 21:42:58 -07:00

64 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
# Check if nvm is not installed
if ! command -v nvm &> /dev/null; then
# Install nvm with checksum verification
NVM_VERSION="v0.40.4"
NVM_CHECKSUM="4b7412c49960c7d31e8df72da90c1fb5b8cccb419ac99537b737028d497aba4f"
NVM_SCRIPT=$(mktemp)
trap 'rm -f "$NVM_SCRIPT"' EXIT
curl -fsSL "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh" -o "$NVM_SCRIPT"
if command -v sha256sum &>/dev/null; then
echo "${NVM_CHECKSUM} ${NVM_SCRIPT}" | sha256sum -c -
elif command -v shasum &>/dev/null; then
echo "${NVM_CHECKSUM} ${NVM_SCRIPT}" | shasum -a 256 -c -
else
echo "No sha256 tool found; cannot verify nvm checksum"; exit 1
fi || { echo "nvm checksum verification failed"; exit 1; }
bash "$NVM_SCRIPT"
# Source nvm script in the current session
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi
# Use nvm to set the required Node.js version
nvm use v20
# Check if nvm use was successful
if [ $? -ne 0 ]; then
echo "Error: Failed to switch to Node.js v20. Deployment aborted."
exit 1
fi
# print contents of ui_colors.json
echo "Contents of ui_colors.json:"
cat ui_colors.json
# Run npm build
npm run build
# Check if the build was successful
if [ $? -eq 0 ]; then
echo "Build successful. Copying files..."
# echo current dir
echo
pwd
# Specify the destination directory
destination_dir="../../litellm/proxy/_experimental/out"
# Ensure the destination directory exists, then clear it
mkdir -p "$destination_dir"
rm -rf "$destination_dir"/*
# Copy the contents of the output directory to the specified destination
cp -r ./out/* "$destination_dir"
rm -rf ./out
echo "Deployment completed."
else
echo "Build failed. Deployment aborted."
fi