diff --git a/changelog.md b/changelog.md index 864409c..2b64347 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-03-26 - 2.6.0 - feat(setup) +Add --force update flag to setup script and update installation instructions + +- Implemented --force option in setup.sh to force-update Node.js binary and dependencies +- Updated readme.md to document the --force flag and revised update steps +- Modified ts/cli.ts update command to pass the --force flag to setup.sh + ## 2025-03-26 - 2.5.2 - fix(installer) Improve Node.js binary detection, dependency management, and SNMPv3 fallback logic diff --git a/readme.md b/readme.md index bf99923..d43d9c1 100644 --- a/readme.md +++ b/readme.md @@ -227,8 +227,15 @@ sudo nupst update This will: 1. Pull the latest changes from the git repository 2. Run the installation scripts -3. Refresh the systemd service configuration -4. Restart the service if it was running +3. Force-update Node.js and all dependencies, even if they already exist +4. Refresh the systemd service configuration +5. Restart the service if it was running + +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 +``` ## Security diff --git a/setup.sh b/setup.sh index 70fb6b8..1bf1fc5 100644 --- a/setup.sh +++ b/setup.sh @@ -2,6 +2,22 @@ # NUPST Setup Script # Downloads the appropriate Node.js binary for the current platform +# and installs production dependencies + +# Parse command line arguments +FORCE_UPDATE=0 + +for arg in "$@"; do + case $arg in + --force|-f) + FORCE_UPDATE=1 + shift + ;; + *) + # Unknown option + ;; + esac +done # Find the directory where this script is located SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" @@ -74,8 +90,9 @@ case "$OS" in esac # Check if we already have the Node.js binary -if [ -f "$SCRIPT_DIR/vendor/$NODE_DIR/bin/node" ]; then +if [ -f "$SCRIPT_DIR/vendor/$NODE_DIR/bin/node" ] && [ $FORCE_UPDATE -eq 0 ]; then echo "Node.js binary already exists for $OS-$ARCH. Skipping download." + echo "Use --force or -f to force update Node.js." else echo "Downloading Node.js v$NODE_VERSION for $OS-$ARCH..." diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index dea7a37..f0b02c9 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@serve.zone/nupst', - version: '2.5.2', + version: '2.6.0', description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices' } diff --git a/ts/cli.ts b/ts/cli.ts index 9d051d3..48d13fc 100644 --- a/ts/cli.ts +++ b/ts/cli.ts @@ -418,9 +418,9 @@ Options: console.log('│ Running install.sh to update NUPST...'); execSync(`cd ${installDir} && bash ./install.sh`, { stdio: 'pipe' }); - // 3. Run the setup.sh script - console.log('│ Running setup.sh to update dependencies...'); - execSync(`cd ${installDir} && bash ./setup.sh`, { stdio: 'pipe' }); + // 3. Run the setup.sh script with force flag to update Node.js and dependencies + console.log('│ Running setup.sh to update Node.js and dependencies...'); + execSync(`cd ${installDir} && bash ./setup.sh --force`, { stdio: 'pipe' }); // 4. Refresh the systemd service console.log('│ Refreshing systemd service...');