From ee28e92866808c06c27cb505663cd6556f32bf0a Mon Sep 17 00:00:00 2001 From: LightZirconite Date: Wed, 5 Nov 2025 22:12:40 +0100 Subject: [PATCH] Fix auto update github api --- src/index.ts | 27 ++++++++++++++++++++++++--- src/interface/Config.ts | 4 +++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 13cb76d..36bad6f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1217,15 +1217,36 @@ export class MicrosoftRewardsBot { private async runAutoUpdate(): Promise { const upd = this.config.update if (!upd) return 0 + + // Check if updates are enabled + if (upd.enabled === false) { + log('main', 'UPDATE', 'Updates disabled in config (update.enabled = false)') + return 0 + } + const scriptRel = upd.scriptPath || 'setup/update/update.mjs' const scriptAbs = path.join(process.cwd(), scriptRel) if (!fs.existsSync(scriptAbs)) return 0 const args: string[] = [] - // Git update is enabled by default (unless explicitly set to false) - if (upd.git !== false) args.push('--git') + + // Determine update method from config + const method = upd.method || 'github-api' // Default to github-api (recommended) + + if (method === 'git') { + // Use Git method (traditional, can have conflicts) + args.push('--git') + } else if (method === 'github-api' || method === 'api' || method === 'zip') { + // Use GitHub API method (no Git needed, no conflicts) + args.push('--no-git') + } else { + // Unknown method, default to github-api + log('main', 'UPDATE', `Unknown update method "${method}", using github-api`, 'warn') + args.push('--no-git') + } + + // Add Docker flag if enabled if (upd.docker) args.push('--docker') - if (args.length === 0) return 0 // Run update script as a child process and capture exit code return new Promise((resolve) => { diff --git a/src/interface/Config.ts b/src/interface/Config.ts index ceb3f26..374cc94 100644 --- a/src/interface/Config.ts +++ b/src/interface/Config.ts @@ -82,7 +82,9 @@ export interface ConfigProxy { } export interface ConfigUpdate { - git?: boolean; // if true, run git pull + npm ci + npm run build after completion + enabled?: boolean; // Master toggle for auto-updates (default: true) + method?: 'git' | 'github-api' | 'api' | 'zip'; // Update method: "git" or "github-api" (default: "github-api") + git?: boolean; // Legacy support: if true, use git method (deprecated, use method instead) docker?: boolean; // if true, run docker update routine (compose pull/up) after completion scriptPath?: string; // optional custom path to update script relative to repo root autoUpdateConfig?: boolean; // if true, allow auto-update of config.jsonc when remote changes it (default: false to preserve user settings)