mirror of
https://github.com/unraid/api.git
synced 2026-01-01 06:01:18 -06:00
fix(api): redirect benign pnpm postinstall warning to log file (#1290)
which lives at `/var/log/unraid-api/build-scripts.log`
This commit is contained in:
@@ -12,10 +12,10 @@ pnpm_store_dir="/usr/.pnpm-store"
|
|||||||
|
|
||||||
# Placeholder functions for plugin installation/uninstallation
|
# Placeholder functions for plugin installation/uninstallation
|
||||||
install() {
|
install() {
|
||||||
true;
|
true
|
||||||
}
|
}
|
||||||
uninstall() {
|
uninstall() {
|
||||||
true;
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Creates a backup of the global pnpm store directory
|
# Creates a backup of the global pnpm store directory
|
||||||
@@ -102,6 +102,24 @@ restore_pnpm_store() {
|
|||||||
echo "pnpm store restored successfully."
|
echo "pnpm store restored successfully."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Executes pnpm install with production dependencies and offline preference
|
||||||
|
# Captures and logs build script warnings to a dedicated log file at /var/log/unraid-api/build-scripts.log
|
||||||
|
# Args: none
|
||||||
|
# Output: Streams install progress and logs build script warnings
|
||||||
|
run_pnpm_install() {
|
||||||
|
local log_file="/var/log/unraid-api/build-scripts.log"
|
||||||
|
stdbuf -oL pnpm install --prod --prefer-offline 2>&1 | while IFS= read -r line; do
|
||||||
|
if echo "$line" | grep -q "Ignored build scripts:"; then
|
||||||
|
mkdir -p "$(dirname "$log_file")"
|
||||||
|
echo "Note: This warning is expected. Build scripts are intentionally ignored for security and performance reasons." > "$log_file"
|
||||||
|
echo "$line" >> "$log_file"
|
||||||
|
echo "Build scripts completed. See $log_file for details."
|
||||||
|
else
|
||||||
|
echo "$line"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Installs production dependencies for the unraid-api using pnpm. Prefers offline mode.
|
# Installs production dependencies for the unraid-api using pnpm. Prefers offline mode.
|
||||||
# Uses the api_base_directory variable or defaults to /usr/local/unraid-api
|
# Uses the api_base_directory variable or defaults to /usr/local/unraid-api
|
||||||
# Returns:
|
# Returns:
|
||||||
@@ -123,10 +141,9 @@ pnpm_install_unraid_api() {
|
|||||||
echo "Executing 'pnpm install' in $unraid_api_dir"
|
echo "Executing 'pnpm install' in $unraid_api_dir"
|
||||||
rm -rf /usr/local/unraid-api/node_modules
|
rm -rf /usr/local/unraid-api/node_modules
|
||||||
# Run pnpm install in a subshell to prevent changing the current working directory of the script
|
# Run pnpm install in a subshell to prevent changing the current working directory of the script
|
||||||
( cd "$unraid_api_dir" && pnpm install --prod --prefer-offline )
|
(cd "$unraid_api_dir" && run_pnpm_install)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'install')
|
'install')
|
||||||
install "$2"
|
install "$2"
|
||||||
|
|||||||
Reference in New Issue
Block a user