From 3e6b883b38a1f2effb20423309b41a9db82db2da Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Wed, 26 Mar 2025 13:54:49 +0000 Subject: [PATCH] fix(setup/readme): Improve force update instructions and dependency installation process in setup.sh and readme.md --- changelog.md | 7 +++++++ readme.md | 6 +++++- setup.sh | 21 +++++++++------------ ts/00_commitinfo_data.ts | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/changelog.md b/changelog.md index cc7d1b8..1e1f0ec 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 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. diff --git a/readme.md b/readme.md index d43d9c1..3142569 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/setup.sh b/setup.sh index b7a12eb..d5b533e 100644 --- a/setup.sh +++ b/setup.sh @@ -244,27 +244,24 @@ NODE_BIN_DIR="$SCRIPT_DIR/vendor/$NODE_DIR/bin" OLD_PATH="$PATH" export PATH="$NODE_BIN_DIR:$PATH" +# Remove existing node_modules directory +echo "Removing existing node_modules directory..." +rm -rf "$SCRIPT_DIR/node_modules" + # Install production dependencies echo "Installing production dependencies..." echo "Using Node.js binary from: $NODE_BIN_DIR" echo "Node version: $(node --version)" echo "NPM version: $(npm --version)" -npm --prefix "$SCRIPT_DIR" ci --only=production --no-audit --no-fund +npm --prefix "$SCRIPT_DIR" install --omit=dev --no-audit --no-fund if [ $? -ne 0 ]; then - echo "Warning: Failed to install dependencies with 'npm ci'. Trying 'npm install'..." - 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 + 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 --omit=dev" else - echo "Dependencies installed successfully with 'npm ci'." + echo "Dependencies installed successfully." fi # Restore the original PATH diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index adc14bd..1412c40 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.6.1', + version: '2.6.2', description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices' }