Compare commits

...

4 Commits

5 changed files with 57 additions and 18 deletions

View File

@@ -1,5 +1,19 @@
# Changelog # Changelog
## 2025-03-26 - 2.6.3 - fix(setup)
Update setup script to install only net-snmp dependency and create a minimal package-lock.json for better dependency control.
- Removed full production dependency install in favor of installing only net-snmp@3.20.0
- Added verification step to confirm net-snmp installation
- Generate a minimal package-lock.json if one does not exist
## 2025-03-26 - 2.6.2 - fix(setup/readme)
Improve force update instructions and dependency installation process in setup.sh and readme.md
- Clarify force update commands with explicit paths in readme.md
- Remove existing node_modules before installing dependencies in setup.sh
- Switch from 'npm ci --only=production' to 'npm install --omit=dev' with updated error instructions
## 2025-03-26 - 2.6.1 - fix(setup) ## 2025-03-26 - 2.6.1 - fix(setup)
Update setup.sh to temporarily add vendor Node.js binary to PATH for dependency installation, log Node and npm versions, and restore the original PATH afterwards. Update setup.sh to temporarily add vendor Node.js binary to PATH for dependency installation, log Node and npm versions, and restore the original PATH afterwards.

View File

@@ -1,6 +1,6 @@
{ {
"name": "@serve.zone/nupst", "name": "@serve.zone/nupst",
"version": "2.6.1", "version": "2.6.3",
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices", "description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
"main": "dist/index.js", "main": "dist/index.js",
"bin": { "bin": {

View File

@@ -234,7 +234,11 @@ This will:
You can also manually run the setup script with the force flag to update Node.js and dependencies without updating the application code: You can also manually run the setup script with the force flag to update Node.js and dependencies without updating the application code:
```bash ```bash
bash setup.sh --force # If you're in the nupst directory:
bash ./setup.sh --force
# If you're in another directory, specify the full path:
bash /opt/nupst/setup.sh --force
``` ```
## Security ## Security

View File

@@ -244,27 +244,48 @@ NODE_BIN_DIR="$SCRIPT_DIR/vendor/$NODE_DIR/bin"
OLD_PATH="$PATH" OLD_PATH="$PATH"
export PATH="$NODE_BIN_DIR:$PATH" export PATH="$NODE_BIN_DIR:$PATH"
# Install production dependencies # Remove existing node_modules directory
echo "Installing production dependencies..." echo "Removing existing node_modules directory..."
rm -rf "$SCRIPT_DIR/node_modules"
# Install ONLY the net-snmp production dependency
echo "Installing ONLY net-snmp production dependency..."
echo "Using Node.js binary from: $NODE_BIN_DIR" echo "Using Node.js binary from: $NODE_BIN_DIR"
echo "Node version: $(node --version)" echo "Node version: $(node --version)"
echo "NPM version: $(npm --version)" echo "NPM version: $(npm --version)"
npm --prefix "$SCRIPT_DIR" ci --only=production --no-audit --no-fund # Install just net-snmp directly, don't rely on package.json
npm --prefix "$SCRIPT_DIR" install --no-save net-snmp@3.20.0 --no-audit --no-fund
if [ $? -ne 0 ]; then # Verify only net-snmp is installed
echo "Warning: Failed to install dependencies with 'npm ci'. Trying 'npm install'..." echo "Verifying only net-snmp is installed in node_modules..."
npm --prefix "$SCRIPT_DIR" install --only=production --no-audit --no-fund find "$SCRIPT_DIR/node_modules" -maxdepth 1 -type d | sort
if [ $? -ne 0 ]; then INSTALL_STATUS=$?
echo "Error: Failed to install dependencies. NUPST may not function correctly." if [ $INSTALL_STATUS -ne 0 ]; then
echo "Error: Failed to install net-snmp dependency. NUPST may not function correctly."
echo "You can try to install dependencies manually by running:" echo "You can try to install dependencies manually by running:"
echo "cd $SCRIPT_DIR && npm install --only=production" echo "cd $SCRIPT_DIR && npm install net-snmp@3.20.0"
else
echo "Dependencies installed successfully with 'npm install'."
fi
else else
echo "Dependencies installed successfully with 'npm ci'." echo "net-snmp dependency installed successfully."
# Create minimal package-lock.json if it doesn't exist
if [ ! -f "$SCRIPT_DIR/package-lock.json" ]; then
echo "Creating minimal package-lock.json..."
echo '{
"name": "@serve.zone/nupst",
"version": "2.6.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"dependencies": {
"net-snmp": "3.20.0"
}
}
}
}' > "$SCRIPT_DIR/package-lock.json"
fi
fi fi
# Restore the original PATH # Restore the original PATH

View File

@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@serve.zone/nupst', name: '@serve.zone/nupst',
version: '2.6.1', version: '2.6.3',
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices' description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
} }