mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 01:06:17 +00:00
New structure 2
This commit is contained in:
17
.github/copilot-instructions.md
vendored
17
.github/copilot-instructions.md
vendored
@@ -95,17 +95,19 @@ docker/ # Docker deployment files
|
|||||||
├── entrypoint.sh # Container initialization script
|
├── entrypoint.sh # Container initialization script
|
||||||
├── run_daily.sh # Daily execution wrapper (cron)
|
├── run_daily.sh # Daily execution wrapper (cron)
|
||||||
└── crontab.template # Cron schedule template
|
└── crontab.template # Cron schedule template
|
||||||
scripts/ # Utility scripts
|
scripts/ # Automation scripts
|
||||||
└── run.sh # Nix development environment launcher
|
└── installer/ # Setup and update automation
|
||||||
setup/
|
├── 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.bat # Windows setup script
|
||||||
├── setup.sh # Linux/Mac setup script
|
├── setup.sh # Linux/Mac setup script
|
||||||
|
├── run.sh # Nix development environment launcher
|
||||||
├── nix/ # NixOS configuration
|
├── nix/ # NixOS configuration
|
||||||
│ ├── flake.nix # Nix flake definition
|
│ ├── flake.nix # Nix flake definition
|
||||||
│ └── flake.lock # Nix flake lock file
|
│ └── flake.lock # Nix flake lock file
|
||||||
└── update/
|
└── README.md # Setup guide
|
||||||
├── setup.mjs # Initial setup automation
|
|
||||||
└── update.mjs # GitHub ZIP-based auto-updater (NO GIT REQUIRED!)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -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)
|
- **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
|
- **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):**
|
**update.mjs (600+ LINES - CRITICAL FEATURE):**
|
||||||
- **Purpose:** Git-free update system using GitHub ZIP downloads (NO merge conflicts!)
|
- **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
|
- **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`
|
- **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
|
- **Workflow:** Check version → Create backups → Download ZIP → Extract → Selective copy → Restore protected → npm ci → npm install → npm build → Verify integrity → Create marker → Clean temp
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
"dashboard": "node --enable-source-maps ./dist/index.js -dashboard",
|
"dashboard": "node --enable-source-maps ./dist/index.js -dashboard",
|
||||||
"dashboard-dev": "ts-node ./src/index.ts -dashboard",
|
"dashboard-dev": "ts-node ./src/index.ts -dashboard",
|
||||||
"lint": "eslint \"src/**/*.{ts,tsx}\"",
|
"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 }\"",
|
"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 ."
|
"create-docker": "docker build -t microsoft-rewards-bot ."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,22 +1,32 @@
|
|||||||
# Scripts Directory
|
# Scripts Directory
|
||||||
|
|
||||||
This directory contains utility scripts for development and deployment.
|
This directory contains automation scripts for the Microsoft Rewards Bot.
|
||||||
|
|
||||||
## Available Scripts
|
## Available Scripts
|
||||||
|
|
||||||
### `run.sh`
|
### `installer/`
|
||||||
**Purpose:** Nix development environment launcher
|
**Purpose:** Automated setup and update scripts
|
||||||
**Usage:** `./run.sh`
|
**Description:** Contains Node.js scripts for initial setup and GitHub-based updates.
|
||||||
**Description:** Launches the bot using Nix develop environment with xvfb-run for headless browser support.
|
|
||||||
|
|
||||||
**Requirements:**
|
#### `installer/setup.mjs`
|
||||||
- Nix package manager
|
**Purpose:** Initial project setup automation
|
||||||
- xvfb (X Virtual Framebuffer)
|
**Usage:** `npm run setup` or `node scripts/installer/setup.mjs`
|
||||||
|
**Description:** Automates initial project configuration, dependency installation, and first-time setup.
|
||||||
|
|
||||||
**Environment:**
|
#### `installer/update.mjs`
|
||||||
This script is designed for NixOS or systems with Nix installed. It provides a reproducible development environment as defined in `setup/nix/flake.nix`.
|
**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 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.
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ These files are **conditionally protected** (based on config):
|
|||||||
Run the update manually:
|
Run the update manually:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
node setup/update/update.mjs
|
node scripts/installer/update.mjs
|
||||||
```
|
```
|
||||||
|
|
||||||
## Update Detection
|
## Update Detection
|
||||||
@@ -95,8 +95,9 @@ If no updates are available, **no marker is created** and the bot won't restart.
|
|||||||
|
|
||||||
### File Structure
|
### File Structure
|
||||||
```
|
```
|
||||||
setup/update/
|
scripts/installer/
|
||||||
├── update.mjs # Main update script (468 lines)
|
├── update.mjs # Main update script (auto-updater)
|
||||||
|
├── setup.mjs # Initial setup wizard
|
||||||
└── README.md # This file
|
└── README.md # This file
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
* - TypeScript rebuild
|
* - TypeScript rebuild
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* node setup/update/update.mjs # Run update
|
* node scripts/installer/update.mjs # Run update
|
||||||
* npm run start # Bot runs this automatically if enabled
|
* npm run start # Bot runs this automatically if enabled
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ function stripJsonComments(input) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (char === '"' || char === "'") {
|
if (char === '"' || char === '\'') {
|
||||||
inString = true
|
inString = true
|
||||||
stringChar = char
|
stringChar = char
|
||||||
result += char
|
result += char
|
||||||
@@ -221,8 +221,8 @@ function isDocker() {
|
|||||||
|
|
||||||
// Method 3: Check environment variables
|
// Method 3: Check environment variables
|
||||||
if (process.env.DOCKER === 'true' ||
|
if (process.env.DOCKER === 'true' ||
|
||||||
process.env.CONTAINER === 'docker' ||
|
process.env.CONTAINER === 'docker' ||
|
||||||
process.env.KUBERNETES_SERVICE_HOST) {
|
process.env.KUBERNETES_SERVICE_HOST) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,15 +41,12 @@ npm start
|
|||||||
**Usage:**
|
**Usage:**
|
||||||
```bash
|
```bash
|
||||||
# Run update manually
|
# 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).
|
**Automatic updates:** The bot checks for updates on startup (controlled by `update.enabled` in config.jsonc).
|
||||||
|
|
||||||
### update/setup.mjs
|
**Note:** Installer scripts have been moved to `scripts/installer/` directory. See `scripts/README.md` for details.
|
||||||
**Interactive setup wizard** used by setup.bat/setup.sh.
|
|
||||||
|
|
||||||
This is typically not run directly - use the wrapper scripts instead.
|
|
||||||
|
|
||||||
## Quick Start Guide
|
## Quick Start Guide
|
||||||
|
|
||||||
|
|||||||
@@ -751,7 +751,7 @@ export class MicrosoftRewardsBot {
|
|||||||
return 0
|
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)
|
const scriptAbs = path.join(process.cwd(), scriptRel)
|
||||||
|
|
||||||
if (!fs.existsSync(scriptAbs)) {
|
if (!fs.existsSync(scriptAbs)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user