Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
83ba9c2611 | |||
22ab472e58 | |||
9a77030377 | |||
ceff285ff5 | |||
d8bfbf0be3 | |||
3e6b883b38 | |||
47ef918128 | |||
5951638967 |
30
changelog.md
30
changelog.md
@ -1,5 +1,35 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-03-26 - 2.6.4 - fix(setup)
|
||||
Improve installation process in setup script by cleaning up package files and ensuring a minimal net-snmp dependency installation.
|
||||
|
||||
- Remove existing package-lock.json along with node_modules to prevent stale artifacts.
|
||||
- Back up the original package.json before modifying it.
|
||||
- Create a minimal package.json with only the net-snmp dependency based on the backed-up version.
|
||||
- Use a clean install to guarantee that only net-snmp is installed.
|
||||
- Restore the original package.json if the installation fails.
|
||||
|
||||
## 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)
|
||||
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.
|
||||
|
||||
- Temporarily prepend vendor Node.js binary directory to PATH to ensure proper npm execution.
|
||||
- Log Node.js and npm versions for debugging purposes.
|
||||
- Restore the original PATH after installing dependencies.
|
||||
|
||||
## 2025-03-26 - 2.6.0 - feat(setup)
|
||||
Add --force update flag to setup script and update installation instructions
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@serve.zone/nupst",
|
||||
"version": "2.6.0",
|
||||
"version": "2.6.4",
|
||||
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
|
||||
"main": "dist/index.js",
|
||||
"bin": {
|
||||
|
@ -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:
|
||||
|
||||
```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
|
||||
|
78
setup.sh
78
setup.sh
@ -239,25 +239,71 @@ echo "dist_ts directory successfully downloaded from npm registry."
|
||||
# Make launcher script executable
|
||||
chmod +x "$SCRIPT_DIR/bin/nupst"
|
||||
|
||||
# Install production dependencies
|
||||
echo "Installing production dependencies..."
|
||||
"$SCRIPT_DIR/vendor/$NODE_DIR/bin/npm" --prefix "$SCRIPT_DIR" ci --only=production --no-audit --no-fund
|
||||
# Add our Node.js bin directory to the PATH temporarily
|
||||
NODE_BIN_DIR="$SCRIPT_DIR/vendor/$NODE_DIR/bin"
|
||||
OLD_PATH="$PATH"
|
||||
export PATH="$NODE_BIN_DIR:$PATH"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Warning: Failed to install dependencies with 'npm ci'. Trying 'npm install'..."
|
||||
"$SCRIPT_DIR/vendor/$NODE_DIR/bin/npm" --prefix "$SCRIPT_DIR" install --only=production --no-audit --no-fund
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error: Failed to install dependencies. NUPST may not function correctly."
|
||||
echo "You can try to install dependencies manually by running:"
|
||||
echo "cd $SCRIPT_DIR && npm install --only=production"
|
||||
else
|
||||
echo "Dependencies installed successfully with 'npm install'."
|
||||
fi
|
||||
else
|
||||
echo "Dependencies installed successfully with 'npm ci'."
|
||||
# Remove existing node_modules directory and package files
|
||||
echo "Cleaning up existing installation..."
|
||||
rm -rf "$SCRIPT_DIR/node_modules"
|
||||
rm -f "$SCRIPT_DIR/package-lock.json"
|
||||
|
||||
# Back up existing package.json if it exists
|
||||
if [ -f "$SCRIPT_DIR/package.json" ]; then
|
||||
echo "Backing up existing package.json..."
|
||||
cp "$SCRIPT_DIR/package.json" "$SCRIPT_DIR/package.json.bak"
|
||||
fi
|
||||
|
||||
# Create a clean minimal package.json with ONLY net-snmp dependency
|
||||
echo "Creating minimal package.json with only net-snmp dependency..."
|
||||
VERSION=$(grep -o '"version": "[^"]*"' "$SCRIPT_DIR/package.json.bak" | head -1 | cut -d'"' -f4 || echo "2.6.3")
|
||||
echo '{
|
||||
"name": "@serve.zone/nupst",
|
||||
"version": "'$VERSION'",
|
||||
"description": "Node.js UPS Shutdown Tool for SNMP-enabled UPS devices",
|
||||
"main": "dist_ts/index.js",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"nupst": "bin/nupst"
|
||||
},
|
||||
"dependencies": {
|
||||
"net-snmp": "3.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"private": true
|
||||
}' > "$SCRIPT_DIR/package.json"
|
||||
|
||||
# Install ONLY net-snmp
|
||||
echo "Installing ONLY net-snmp dependency..."
|
||||
echo "Using Node.js binary from: $NODE_BIN_DIR"
|
||||
echo "Node version: $(node --version)"
|
||||
echo "NPM version: $(npm --version)"
|
||||
|
||||
# Use clean install to ensure only net-snmp is installed
|
||||
npm --prefix "$SCRIPT_DIR" install --no-audit --no-fund
|
||||
|
||||
INSTALL_STATUS=$?
|
||||
if [ $INSTALL_STATUS -ne 0 ]; then
|
||||
echo "Error: Failed to install net-snmp dependency. NUPST may not function correctly."
|
||||
echo "Restoring original package.json..."
|
||||
mv "$SCRIPT_DIR/package.json.bak" "$SCRIPT_DIR/package.json"
|
||||
exit 1
|
||||
else
|
||||
echo "net-snmp dependency installed successfully."
|
||||
# Show what's actually installed
|
||||
echo "Installed modules:"
|
||||
find "$SCRIPT_DIR/node_modules" -maxdepth 1 -type d | grep -v "^$SCRIPT_DIR/node_modules$" | sort
|
||||
|
||||
# Remove backup if successful
|
||||
rm -f "$SCRIPT_DIR/package.json.bak"
|
||||
fi
|
||||
|
||||
# Restore the original PATH
|
||||
export PATH="$OLD_PATH"
|
||||
|
||||
echo "NUPST setup completed successfully."
|
||||
echo "You can now run NUPST using: $SCRIPT_DIR/bin/nupst"
|
||||
echo "To install NUPST globally, run: sudo ln -s $SCRIPT_DIR/bin/nupst /usr/local/bin/nupst"
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@serve.zone/nupst',
|
||||
version: '2.6.0',
|
||||
version: '2.6.4',
|
||||
description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices'
|
||||
}
|
||||
|
Reference in New Issue
Block a user