mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 01:06:17 +00:00
feat: Enhance update mechanism with anti-loop protection and improved logging
- Implemented a restart counter to prevent infinite update loops. - Added checks for update success using marker files. - Improved logging for update attempts and failures. - Created comprehensive documentation for npm commands and setup processes. - Introduced a new update system using GitHub API for seamless updates. - Added troubleshooting guidelines for common issues.
This commit is contained in:
@@ -1,35 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Wrapper to run setup via npm (Linux/macOS)
|
||||
# ========================================
|
||||
# Microsoft Rewards Bot - Setup (Linux/macOS)
|
||||
# ========================================
|
||||
# This script performs first-time setup:
|
||||
# 1. Check prerequisites (Node.js, npm, Git)
|
||||
# 2. Run setup wizard (accounts + config)
|
||||
# 3. Install dependencies
|
||||
# 4. Build TypeScript project
|
||||
#
|
||||
# After setup, run the bot with: npm start
|
||||
# ========================================
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||
|
||||
echo "=== Prerequisite Check ==="
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " Microsoft Rewards Bot - Setup"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
|
||||
# Check prerequisites
|
||||
echo "=== Prerequisites Check ==="
|
||||
echo ""
|
||||
|
||||
if command -v npm >/dev/null 2>&1; then
|
||||
NPM_VERSION="$(npm -v 2>/dev/null || true)"
|
||||
echo "npm detected: ${NPM_VERSION}"
|
||||
NPM_VERSION="$(npm -v 2>/dev/null || echo 'unknown')"
|
||||
echo "[OK] npm detected: v${NPM_VERSION}"
|
||||
else
|
||||
echo "[ERROR] npm not detected."
|
||||
echo " Install Node.js and npm from nodejs.org or your package manager"
|
||||
echo "[ERROR] npm not found!"
|
||||
echo ""
|
||||
echo "Please install Node.js from: https://nodejs.org/"
|
||||
echo "Recommended version: v20 or newer"
|
||||
echo ""
|
||||
echo "Alternatively, use your package manager:"
|
||||
echo " • Ubuntu/Debian: sudo apt install nodejs npm"
|
||||
echo " • macOS: brew install node"
|
||||
echo " • Fedora: sudo dnf install nodejs npm"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
GIT_VERSION="$(git --version 2>/dev/null || true)"
|
||||
echo "Git detected: ${GIT_VERSION}"
|
||||
GIT_VERSION="$(git --version 2>/dev/null | cut -d' ' -f3)"
|
||||
echo "[OK] Git detected: v${GIT_VERSION}"
|
||||
else
|
||||
echo "[WARN] Git not detected."
|
||||
echo " Install (Linux): e.g. 'sudo apt install git' (or your distro equivalent)."
|
||||
echo "[WARN] Git not detected (optional for setup, required for updates)"
|
||||
echo " • Ubuntu/Debian: sudo apt install git"
|
||||
echo " • macOS: brew install git"
|
||||
echo " • Fedora: sudo dnf install git"
|
||||
fi
|
||||
|
||||
if [ ! -f "${PROJECT_ROOT}/package.json" ]; then
|
||||
echo ""
|
||||
echo "[ERROR] package.json not found at ${PROJECT_ROOT}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "=== Running setup script via npm ==="
|
||||
echo ""
|
||||
echo "=== Running Setup Wizard ==="
|
||||
echo ""
|
||||
|
||||
cd "${PROJECT_ROOT}"
|
||||
exec npm run setup
|
||||
npm run setup
|
||||
EXITCODE=$?
|
||||
|
||||
echo ""
|
||||
if [ $EXITCODE -eq 0 ]; then
|
||||
echo "========================================"
|
||||
echo " Setup Complete!"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
echo "To start the bot: npm start"
|
||||
echo ""
|
||||
else
|
||||
echo "========================================"
|
||||
echo " Setup Failed (Exit Code: $EXITCODE)"
|
||||
echo "========================================"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
exit $EXITCODE
|
||||
|
||||
Reference in New Issue
Block a user