fix: Clean up build system and resolve Docker Chromium persistence issue

- Remove redundant prestart hook (no more "Build not found" message)
- Add prebuild hook for automatic Chromium installation
- Fix Docker Chromium persistence (copy @playwright from builder)
- Simplify npm scripts (11 → 9 commands, better naming)
- Add comprehensive build system documentation
- Add Docker deployment guide with troubleshooting

Fixes: Docker "Chromium not installed" error on subsequent runs
Closes: #[issue-number]
This commit is contained in:
2025-11-13 15:34:02 +01:00
parent 3b06b4ae83
commit 8e2e7fae84
4 changed files with 635 additions and 8 deletions

View File

@@ -17,23 +17,22 @@
"homepage": "https://github.com/Obsidian-wtf/Microsoft-Rewards-Bot#readme",
"scripts": {
"clean": "rimraf dist",
"install-deps": "npm install && npx playwright install chromium",
"postinstall": "npm run build",
"typecheck": "tsc --noEmit",
"build": "tsc",
"postbuild": "node -e \"console.log('\\n Build complete! Run \\\"npm start\\\" to launch the bot.\\n')\"",
"postbuild": "node -e \"console.log('\\n Build complete! Run \\\"npm start\\\" to launch the bot.\\n')\"",
"postinstall": "npm run build",
"prebuild": "node -e \"const fs = require('fs'); if (!fs.existsSync('node_modules/@playwright/browser-chromium') && process.env.SKIP_BROWSER_INSTALL !== '1') { console.log('📦 Installing Chromium browser...'); require('child_process').execSync('npx playwright install chromium --with-deps', {stdio: 'inherit'}); }\"",
"test": "node --test --loader ts-node/esm tests/**/*.test.ts",
"prestart": "node -e \"const fs = require('fs'); if (!fs.existsSync('./dist/index.js')) { console.log('⚠️ Build not found, building now...'); require('child_process').execSync('npm run build', {stdio: 'inherit'}); }\"",
"start": "node --enable-source-maps ./dist/index.js",
"ts-start": "node --loader ts-node/esm ./src/index.ts",
"dev": "ts-node ./src/index.ts -dev",
"creator": "ts-node ./src/account-creation/cli.ts",
"dashboard": "node --enable-source-maps ./dist/index.js -dashboard",
"dashboard-dev": "ts-node ./src/index.ts -dashboard",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"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 ."
"kill-chrome": "node -e \"const { execSync } = require('child_process'); const isWin = process.platform === 'win32'; try { execSync(isWin ? 'taskkill /F /IM chrome.exe 2>nul || exit 0' : 'pkill -f chrome || true', {stdio: 'inherit'}); } catch(e) {}\"",
"docker:build": "docker build -t microsoft-rewards-bot .",
"docker:run": "docker run -d --name ms-rewards microsoft-rewards-bot"
},
"keywords": [
"Bing Rewards",
@@ -83,4 +82,4 @@
"ts-node": "^10.9.2",
"ws": "^8.18.3"
}
}
}