| 1 | #!/usr/bin/env node |
| 2 | const { execFileSync, execSync } = require("child_process"); |
| 3 | const path = require("path"); |
| 4 | |
| 5 | function findPython() { |
| 6 | for (const cmd of ["python3", "python"]) { |
| 7 | try { |
| 8 | const version = execSync(`${cmd} --version`, { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] }).trim(); |
| 9 | const major = parseInt(version.split(" ")[1]); |
| 10 | if (major >= 3) return cmd; |
| 11 | } catch {} |
| 12 | } |
| 13 | return null; |
| 14 | } |
| 15 | |
| 16 | const python = findPython(); |
| 17 | |
| 18 | if (!python) { |
| 19 | console.error( |
| 20 | "Error: Python 3 is required but was not found.\n\n" + |
| 21 | "Install it from https://www.python.org/downloads/ or via your package manager:\n" + |
| 22 | " macOS: brew install python3\n" + |
| 23 | " Ubuntu: sudo apt install python3\n" + |
| 24 | " Windows: winget install Python.Python.3" |
| 25 | ); |
| 26 | process.exit(1); |
| 27 | } |
| 28 | |
| 29 | const script = path.join(__dirname, "upgrade-check.py"); |
| 30 | |
| 31 | try { |
| 32 | execFileSync(python, [script, ...process.argv.slice(2)], { stdio: "inherit" }); |
| 33 | } catch (e) { |
| 34 | process.exit(e.status || 1); |
| 35 | } |