New structure 2

This commit is contained in:
2025-11-11 13:07:51 +01:00
parent 89bc226d6b
commit 82e5e71ffe
9 changed files with 123 additions and 112 deletions

View File

@@ -95,17 +95,19 @@ docker/ # Docker deployment files
├── entrypoint.sh # Container initialization script
├── run_daily.sh # Daily execution wrapper (cron)
└── crontab.template # Cron schedule template
scripts/ # Utility scripts
└── run.sh # Nix development environment launcher
setup/
scripts/ # Automation scripts
└── installer/ # Setup and update automation
├── setup.mjs # Initial setup automation
├── update.mjs # GitHub ZIP-based auto-updater (NO GIT REQUIRED!)
└── README.md # Installer documentation
setup/ # Setup and execution scripts
├── setup.bat # Windows setup script
├── setup.sh # Linux/Mac setup script
├── run.sh # Nix development environment launcher
├── nix/ # NixOS configuration
│ ├── flake.nix # Nix flake definition
│ └── flake.lock # Nix flake lock file
└── update/
├── setup.mjs # Initial setup automation
└── update.mjs # GitHub ZIP-based auto-updater (NO GIT REQUIRED!)
└── README.md # Setup guide
```
---
@@ -1115,10 +1117,11 @@ private combinedDeduplication(queries: string[], threshold = 0.65): string[] {
- **Methods:** `generateEmail()` (8 realistic patterns), `generatePassword()` (14-18 chars), `generateBirthdate()` (age 20-45), `generateNames()` (extracts from email)
- **Pattern:** Uses nameDatabase.ts with 100+ first/last names
### Auto-Update System (`setup/update/update.mjs`)
### Auto-Update System (`scripts/installer/update.mjs`)
**update.mjs (600+ LINES - CRITICAL FEATURE):**
- **Purpose:** Git-free update system using GitHub ZIP downloads (NO merge conflicts!)
- **Location:** `scripts/installer/update.mjs` (moved from `setup/update/`)
- **Features:** Version comparison (cache-busting), GitHub API ZIP download, selective file preservation, automatic rollback on build failure, integrity checks, Docker vs Host detection, dependency installation, TypeScript rebuild verification, update marker creation
- **Protected Files:** `src/config.jsonc`, `src/accounts.jsonc`, `sessions/`, `.playwright-chromium-installed`
- **Workflow:** Check version → Create backups → Download ZIP → Extract → Selective copy → Restore protected → npm ci → npm install → npm build → Verify integrity → Create marker → Clean temp

View File

@@ -30,7 +30,7 @@
"dashboard": "node --enable-source-maps ./dist/index.js -dashboard",
"dashboard-dev": "ts-node ./src/index.ts -dashboard",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"setup": "node ./setup/update/setup.mjs",
"setup": "node ./scripts/installer/setup.mjs",
"kill-chrome-win": "powershell -Command \"Get-Process | Where-Object { $_.MainModule.FileVersionInfo.FileDescription -eq 'Google Chrome for Testing' } | ForEach-Object { Stop-Process -Id $_.Id -Force }\"",
"create-docker": "docker build -t microsoft-rewards-bot ."
},

View File

@@ -1,22 +1,32 @@
# Scripts Directory
This directory contains utility scripts for development and deployment.
This directory contains automation scripts for the Microsoft Rewards Bot.
## Available Scripts
### `run.sh`
**Purpose:** Nix development environment launcher
**Usage:** `./run.sh`
**Description:** Launches the bot using Nix develop environment with xvfb-run for headless browser support.
### `installer/`
**Purpose:** Automated setup and update scripts
**Description:** Contains Node.js scripts for initial setup and GitHub-based updates.
**Requirements:**
- Nix package manager
- xvfb (X Virtual Framebuffer)
#### `installer/setup.mjs`
**Purpose:** Initial project setup automation
**Usage:** `npm run setup` or `node scripts/installer/setup.mjs`
**Description:** Automates initial project configuration, dependency installation, and first-time setup.
**Environment:**
This script is designed for NixOS or systems with Nix installed. It provides a reproducible development environment as defined in `setup/nix/flake.nix`.
#### `installer/update.mjs`
**Purpose:** GitHub ZIP-based auto-updater
**Usage:** `node scripts/installer/update.mjs`
**Description:** Downloads and applies updates from GitHub without Git. Preserves user configuration files (`accounts.jsonc`, `config.jsonc`, `sessions/`).
**Features:**
- No Git required
- No merge conflicts
- Selective file preservation
- Automatic rollback on failure
- Dependency installation
- TypeScript rebuild
---
For Docker deployment, see the `docker/` directory.
For setup scripts, see the `setup/` directory.
For shell scripts (setup.bat, setup.sh, run.sh), see the `setup/` directory.

View File

@@ -51,7 +51,7 @@ These files are **conditionally protected** (based on config):
Run the update manually:
```bash
node setup/update/update.mjs
node scripts/installer/update.mjs
```
## Update Detection
@@ -95,8 +95,9 @@ If no updates are available, **no marker is created** and the bot won't restart.
### File Structure
```
setup/update/
├── update.mjs # Main update script (468 lines)
scripts/installer/
├── update.mjs # Main update script (auto-updater)
├── setup.mjs # Initial setup wizard
└── README.md # This file
```

View File

@@ -13,7 +13,7 @@
* - TypeScript rebuild
*
* Usage:
* node setup/update/update.mjs # Run update
* node scripts/installer/update.mjs # Run update
* npm run start # Bot runs this automatically if enabled
*/
@@ -67,7 +67,7 @@ function stripJsonComments(input) {
continue
}
if (char === '"' || char === "'") {
if (char === '"' || char === '\'') {
inString = true
stringChar = char
result += char

View File

@@ -41,15 +41,12 @@ npm start
**Usage:**
```bash
# Run update manually
node setup/update/update.mjs
node scripts/installer/update.mjs
```
**Automatic updates:** The bot checks for updates on startup (controlled by `update.enabled` in config.jsonc).
### update/setup.mjs
**Interactive setup wizard** used by setup.bat/setup.sh.
This is typically not run directly - use the wrapper scripts instead.
**Note:** Installer scripts have been moved to `scripts/installer/` directory. See `scripts/README.md` for details.
## Quick Start Guide

View File

@@ -751,7 +751,7 @@ export class MicrosoftRewardsBot {
return 0
}
const scriptRel = upd.scriptPath || 'setup/update/update.mjs'
const scriptRel = upd.scriptPath || 'scripts/installer/update.mjs'
const scriptAbs = path.join(process.cwd(), scriptRel)
if (!fs.existsSync(scriptAbs)) {