From 90060bc79e9c64b8172d30c8a1769a567dc47418 Mon Sep 17 00:00:00 2001 From: Research Assistant Date: Mon, 11 May 2026 18:10:56 +0800 Subject: [PATCH] feat(plugin): add console logs showing PyPI vs git install source --- paperforge/plugin/main.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/paperforge/plugin/main.js b/paperforge/plugin/main.js index 82cd91c1..f2ab6078 100644 --- a/paperforge/plugin/main.js +++ b/paperforge/plugin/main.js @@ -2505,17 +2505,22 @@ class PaperForgeSettingTab extends PluginSettingTab { btn.setDisabled(true); btn.setButtonText(t('runtime_health_syncing')); - const tryInstall = (args) => runSubprocess(installCmd.cmd, args, vp, installCmd.timeout, undefined, paperforgeEnrichedEnv()); + const tryInstall = (args, label) => { + console.log(`[PaperForge] Sync Runtime: trying ${label}`); + return runSubprocess(installCmd.cmd, args, vp, installCmd.timeout, undefined, paperforgeEnrichedEnv()); + }; - tryInstall(installCmd.pypiArgs).then((result) => { + tryInstall(installCmd.pypiArgs, 'PyPI').then((result) => { if (result.exitCode === 0) { + console.log('[PaperForge] Sync Runtime: installed via PyPI'); new Notice(t('runtime_health_sync_done').replace('{0}', ver), 5000); this.display(); return; } - console.warn('[PaperForge] PyPI install failed, falling back to git...'); - tryInstall(installCmd.gitArgs).then((r2) => { + console.warn('[PaperForge] Sync Runtime: PyPI failed, falling back to git...'); + tryInstall(installCmd.gitArgs, 'git').then((r2) => { if (r2.exitCode === 0) { + console.log('[PaperForge] Sync Runtime: installed via git'); new Notice(t('runtime_health_sync_done').replace('{0}', ver), 5000); this.display(); } else { @@ -3092,13 +3097,15 @@ class PaperForgeSetupModal extends Modal { if (!hasPaperforge) { this._log(t('install_bootstrapping')); const ver = this.plugin.manifest.version; + this._log(`[install] Trying PyPI: pip install paperforge==${ver}`); const pypiArgs = ['-m', 'pip', 'install', '--upgrade']; if (process.platform !== 'win32') pypiArgs.push('--user'); pypiArgs.push(`paperforge==${ver}`); try { await runPython(pypiArgs, { logStdout: true }); } catch (pypiErr) { - this._log('PyPI install failed, falling back to git...'); + this._log(`[install] PyPI failed, falling back to git: git+https://...@v${ver}`); + console.warn('[PaperForge] PyPI install failed, falling back to git:', pypiErr.message?.slice(0, 200)); const gitArgs = ['-m', 'pip', 'install', '--upgrade']; if (process.platform !== 'win32') gitArgs.push('--user'); gitArgs.push(`git+https://github.com/LLLin000/PaperForge.git@v${ver}`); @@ -3343,10 +3350,12 @@ module.exports = class PaperForgePlugin extends Plugin { const { execFile } = require('node:child_process'); execFile(pythonExe, [...extraArgs, '-c', 'import paperforge; print(paperforge.__version__)'], { cwd: vp, timeout: 10000 }, (err, stdout) => { const install = (label) => { + console.log(`[PaperForge] Auto-update: trying PyPI (paperforge==${ver})`); doInstall(pypiPkg, (ok) => { - if (ok) { new Notice(`[OK] PaperForge CLI ${label}`, 5000); return; } + if (ok) { console.log('[PaperForge] Auto-update: installed via PyPI'); new Notice(`[OK] PaperForge CLI ${label}`, 5000); return; } + console.warn('[PaperForge] Auto-update: PyPI failed, falling back to git...'); doInstall(gitUrl, (ok2) => { - if (ok2) new Notice(`[OK] PaperForge CLI ${label} (via git)`, 5000); + if (ok2) { console.log('[PaperForge] Auto-update: installed via git'); new Notice(`[OK] PaperForge CLI ${label} (via git)`, 5000); } }); }); };