Lines 1-41javascript
2 * @fileoverview CMake Installation & Resolution for MoBrowser
4 * This module handles automatic CMake installation and version management.
5 * It checks for system CMake, downloads and caches CMake if needed, and
6 * provides a unified interface for resolving the CMake executable path.
8import { spawnSync, execSync } from "node:child_process";
9import https from "node:https";
10import http from "node:http";
11import fs from "node:fs";
12import path from "node:path";
13import { createWriteStream, createReadStream } from "node:fs";
14import { createGunzip } from "node:zlib";
15import { fileURLToPath } from "node:url";
17// Check and install dependencies if needed.
18const __dirname = path.dirname(fileURLToPath(import.meta.url));
19const depsInstalled = fs.existsSync(path.join(__dirname, "node_modules", "tar-stream"));
21 console.log("Installing @mobrowser/cli dependencies...");
22 execSync("npm install --omit=optional --no-save", { cwd: __dirname, stdio: "inherit" });
23}
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
cmake.jsView on unpkg · L21 25// Dynamic imports to allow dependency installation first.
26const { extract: tarExtract } = await import("tar-stream");
27const AdmZipModule = await import("adm-zip");
28const AdmZip = AdmZipModule.default;
30const CMAKE_VERSION = "3.26.4";
31const CMAKE_MIN_VERSION = "3.21";
33const isWindows = process.platform === "win32";
36 * Finds the node_modules directory by walking up from the project root.
38function getCacheDir(projectRoot) {
39 // Find node_modules directory by looking up from the project root.
40 let currentDir = projectRoot;
41 let nodeModulesPath = null;