UNPKG

node-system-bridge

Version:

A cross-platform system automation library for Node.js and Electron, written in Rust

71 lines (65 loc) 1.97 kB
/** * System Information - Complete Example and Documentation * * Features demonstrated: * - Get detailed system information * * API Reference: * - System.getSystemInfo() - Get system information * * Return value: * SystemInfo object contains: * - hostname: Hostname * - platform: Platform (win32, darwin, linux) * - arch: Architecture (x64, arm64) * - release: System version * - manufacturer: Manufacturer * - model: Model * - sysVersion: System version description * - serial: Serial number * - cpuManufacturer: CPU manufacturer * - cpuBrand: CPU brand * - cpuVendor: CPU vendor * - distro: Distribution name (Linux) * - osUuid: Operating system UUID * - hardwareUuid: Hardware UUID * - macs: MAC addresses list * - primaryInterface: Primary network interface * - isVirtual: Whether virtual machine * - source: Data source (wmi, wmic, basic) * * Description: * Automatically uses best method to get system information with multi-layer fallback: * - Windows: WMI API -> wmic command -> basic info * - macOS: sysctl/IOKit -> basic info * - Linux: procfs/sysfs -> basic info */ import { System } from '../index.js' async function demo() { console.log('System Information\n') const info = await System.getSystemInfo() console.log({ hostname: info.hostname, platform: info.platform, arch: info.arch, release: info.release, manufacturer: info.manufacturer, model: info.model, sysVersion: info.sysVersion, serial: info.serial, cpuManufacturer: info.cpuManufacturer, cpuBrand: info.cpuBrand, cpuVendor: info.cpuVendor, distro: info.distro, osUuid: info.osUuid, hardwareUuid: info.hardwareUuid, macs: info.macs, primaryInterface: info.primaryInterface, isVirtual: info.isVirtual, source: info.source }) } demo().catch(err => { console.error('Error:', err.message) process.exit(1) })