Lines 1-39javascript
4 * API-Switch — lazy-install launcher
6 * On first run, installs the api-switch binary, then execs it.
7 * Subsequent runs use the cached binary directly.
10 * 1. GitHub release raw binary (no tar needed)
11 * 2. Gitee clone + go build (China mirror, needs Go + Git)
12 * 3. go install (needs Go)
13 * 4. Friendly error with platform-specific instructions
18const { existsSync, mkdirSync, chmodSync, unlinkSync, copyFileSync, readFileSync } = require("fs");
19const { join } = require("path");
20const { execSync, spawnSync } = require("child_process");
22const PKG = require("./package.json");
23const VERSION = "v" + PKG.version;
24const BIN_DIR = join(__dirname, ".bin");
25const IS_WIN = process.platform === "win32";
26const IS_MAC = process.platform === "darwin";
27const BIN_NAME = IS_WIN ? "api-switch.exe" : "api-switch";
28const BIN_PATH = join(BIN_DIR, BIN_NAME);
30const GITEE_REPO = "https://gitee.com/776311606/API-Switch.git";
31// Gitee raw URL with version subdirectory: release/vX.Y.Z/api-switch-{plat}
HighSandbox Evasion Gated Capability
Source gates dangerous network, credential, or execution behavior behind CI, host, platform, time, or geo fingerprint checks.
api-switch.jsView on unpkg · L19 32const GITEE_RAW = `https://gitee.com/776311606/API-Switch/raw/release/${VERSION}`;
33const GH_RELEASE = `https://github.com/hxz0727/API-Switch/releases/download/${VERSION}`;
37 "darwin-x64": "darwin-amd64", "darwin-arm64": "darwin-arm64",
38 "linux-x64": "linux-amd64", "linux-arm64": "linux-arm64",
39 "win32-x64": "windows-amd64",