osInfo() added OS code name (windows)
This commit is contained in:
parent
95ed380879
commit
d2acfba582
19
.github/workflows/release.yml
vendored
Normal file
19
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
generate_release_notes: true
|
||||
|
||||
@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||
| 5.29.0 | 2026-01-04 | `osInfo()` added OS code name (windows) |
|
||||
| 5.28.10 | 2026-01-03 | `graphics()` fix logging nvidia-smi error (windows) |
|
||||
| 5.28.9 | 2026-01-02 | `fsSize()` fix df parsing missing mount points (linux) |
|
||||
| 5.28.8 | 2026-01-01 | `bluetooth()` `battery()` improved enumeration (windows) |
|
||||
|
||||
@ -185,6 +185,7 @@ si.cpu()
|
||||
|
||||
(last 7 major and minor version releases)
|
||||
|
||||
- Version 5.29.0: `osInfo()` added OS code name (windows)
|
||||
- Version 5.28.0: `cpuTemperature()` added suppurt for macos-temperature-sensor (macOS)
|
||||
- Version 5.27.0: `mem()` added reclaimable memory
|
||||
- Version 5.26.0: `getStatic()`, `getAll()` added usb, audio, bluetooth, printer
|
||||
@ -453,7 +454,7 @@ Full function reference with examples can be found at
|
||||
| | platform | X | X | X | X | X | 'linux', 'darwin', 'Windows', ... |
|
||||
| | distro | X | X | X | X | X | |
|
||||
| | release | X | X | X | X | X | |
|
||||
| | codename | X | | X | | | |
|
||||
| | codename | X | | X | X | | |
|
||||
| | kernel | X | X | X | X | X | kernel release - same as os.release() |
|
||||
| | arch | X | X | X | X | X | same as os.arch() |
|
||||
| | hostname | X | X | X | X | X | same as os.hostname() |
|
||||
|
||||
@ -57,6 +57,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">5.29.0</th>
|
||||
<td>2026-01-04</td>
|
||||
<td><span class="code">osInfo()</span> added OS code name (windows)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">5.28.10</th>
|
||||
<td>2026-01-03</td>
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
<img class="logo" src="assets/logo.png" alt="logo">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span> </div>
|
||||
<div class="version">New Version: <span id="version">5.28.10</span></div>
|
||||
<div class="version">New Version: <span id="version">5.29.0</span></div>
|
||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||
</div>
|
||||
<div class="down">
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td>X</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
185
lib/osinfo.js
185
lib/osinfo.js
@ -19,7 +19,7 @@ const util = require('./util');
|
||||
const exec = require('child_process').exec;
|
||||
const execSync = require('child_process').execSync;
|
||||
|
||||
let _platform = process.platform;
|
||||
const _platform = process.platform;
|
||||
|
||||
const _linux = _platform === 'linux' || _platform === 'android';
|
||||
const _darwin = _platform === 'darwin';
|
||||
@ -33,7 +33,7 @@ const _sunos = _platform === 'sunos';
|
||||
// Get current time and OS uptime
|
||||
|
||||
function time() {
|
||||
let t = new Date().toString().split(' ');
|
||||
const t = new Date().toString().split(' ');
|
||||
let timezoneName = '';
|
||||
try {
|
||||
timezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
@ -63,7 +63,7 @@ function time() {
|
||||
timezone: lines[1] ? timezone + lines[1] : timezone,
|
||||
timezoneName: lines[2] && lines[2].indexOf('/zoneinfo/') > 0 ? lines[2].split('/zoneinfo/')[1] || '' : ''
|
||||
};
|
||||
} catch (e) {
|
||||
} catch {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
@ -161,6 +161,30 @@ function getLogoFile(distro) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const WINDOWS_RELEASES = [
|
||||
[26200, '25H2'],
|
||||
[26100, '24H2'],
|
||||
[22631, '23H2'],
|
||||
[22621, '22H2'],
|
||||
[19045, '22H2'],
|
||||
[22000, '21H2'],
|
||||
[19044, '21H2'],
|
||||
[19043, '21H1'],
|
||||
[19042, '20H2'],
|
||||
[19041, '2004'],
|
||||
[18363, '1909'],
|
||||
[18362, '1903'],
|
||||
[17763, '1809'],
|
||||
[17134, '1803']
|
||||
];
|
||||
|
||||
function getWindowsRelease(build) {
|
||||
for (const [minBuild, label] of WINDOWS_RELEASES) {
|
||||
if (build >= minBuild) return label;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// --------------------------
|
||||
// FQDN
|
||||
|
||||
@ -170,7 +194,7 @@ function getFQDN() {
|
||||
try {
|
||||
const stdout = execSync('hostname -f 2>/dev/null', util.execOptsLinux);
|
||||
fqdn = stdout.toString().split(os.EOL)[0];
|
||||
} catch (e) {
|
||||
} catch {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
@ -178,7 +202,7 @@ function getFQDN() {
|
||||
try {
|
||||
const stdout = execSync('hostname 2>/dev/null');
|
||||
fqdn = stdout.toString().split(os.EOL)[0];
|
||||
} catch (e) {
|
||||
} catch {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
@ -186,7 +210,7 @@ function getFQDN() {
|
||||
try {
|
||||
const stdout = execSync('echo %COMPUTERNAME%.%USERDNSDOMAIN%', util.execOptsWin);
|
||||
fqdn = stdout.toString().replace('.%USERDNSDOMAIN%', '').split(os.EOL)[0];
|
||||
} catch (e) {
|
||||
} catch {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
@ -217,7 +241,7 @@ function osInfo(callback) {
|
||||
};
|
||||
|
||||
if (_linux) {
|
||||
exec('cat /etc/*-release; cat /usr/lib/os-release; cat /etc/openwrt_release', function (error, stdout) {
|
||||
exec('cat /etc/*-release; cat /usr/lib/os-release; cat /etc/openwrt_release', (error, stdout) => {
|
||||
/**
|
||||
* @namespace
|
||||
* @property {string} DISTRIB_ID
|
||||
@ -228,7 +252,7 @@ function osInfo(callback) {
|
||||
*/
|
||||
let release = {};
|
||||
let lines = stdout.toString().split('\n');
|
||||
lines.forEach(function (line) {
|
||||
lines.forEach((line) => {
|
||||
if (line.indexOf('=') !== -1) {
|
||||
release[line.split('=')[0].trim().toUpperCase()] = line.split('=')[1].trim();
|
||||
}
|
||||
@ -262,7 +286,7 @@ function osInfo(callback) {
|
||||
});
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid machdep.bootmethod kern.geom.confxml', function (error, stdout) {
|
||||
exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid machdep.bootmethod kern.geom.confxml', (error, stdout) => {
|
||||
let lines = stdout.toString().split('\n');
|
||||
const distro = util.getValue(lines, 'kern.ostype');
|
||||
const logofile = getLogoFile(distro);
|
||||
@ -285,7 +309,7 @@ function osInfo(callback) {
|
||||
});
|
||||
}
|
||||
if (_darwin) {
|
||||
exec('sw_vers; sysctl kern.ostype kern.osrelease kern.osrevision kern.uuid', function (error, stdout) {
|
||||
exec('sw_vers; sysctl kern.ostype kern.osrelease kern.osrevision kern.uuid', (error, stdout) => {
|
||||
let lines = stdout.toString().split('\n');
|
||||
result.serial = util.getValue(lines, 'kern.uuid');
|
||||
result.distro = util.getValue(lines, 'ProductName');
|
||||
@ -321,8 +345,8 @@ function osInfo(callback) {
|
||||
}
|
||||
if (_sunos) {
|
||||
result.release = result.kernel;
|
||||
exec('uname -o', function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
exec('uname -o', (error, stdout) => {
|
||||
const lines = stdout.toString().split('\n');
|
||||
result.distro = lines[0];
|
||||
result.logofile = getLogoFile(result.distro);
|
||||
if (callback) {
|
||||
@ -339,8 +363,9 @@ function osInfo(callback) {
|
||||
workload.push(util.powerShell('Get-CimInstance Win32_OperatingSystem | select Caption,SerialNumber,BuildNumber,ServicePackMajorVersion,ServicePackMinorVersion | fl'));
|
||||
workload.push(util.powerShell('(Get-CimInstance Win32_ComputerSystem).HypervisorPresent'));
|
||||
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SystemInformation]::TerminalServerSession'));
|
||||
workload.push(util.powerShell('reg query "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" /v DisplayVersion'));
|
||||
util.promiseAll(workload).then((data) => {
|
||||
let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
||||
const lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
|
||||
result.distro = util.getValue(lines, 'Caption', ':').trim();
|
||||
result.serial = util.getValue(lines, 'SerialNumber', ':').trim();
|
||||
result.build = util.getValue(lines, 'BuildNumber', ':').trim();
|
||||
@ -349,6 +374,14 @@ function osInfo(callback) {
|
||||
const hyperv = data.results[1] ? data.results[1].toString().toLowerCase() : '';
|
||||
result.hypervisor = hyperv.indexOf('true') !== -1;
|
||||
const term = data.results[2] ? data.results[2].toString() : '';
|
||||
if (data.results[3]) {
|
||||
const codenameParts = data.results[3].split('REG_SZ');
|
||||
result.codename = codenameParts.length > 1 ? codenameParts[1].trim() : '';
|
||||
}
|
||||
if (!result.codename) {
|
||||
const buildNum = parseInt(result.build, 10);
|
||||
result.codename = getWindowsRelease(buildNum);
|
||||
}
|
||||
result.remoteSession = term.toString().toLowerCase().indexOf('true') >= 0;
|
||||
isUefiWindows().then((uefi) => {
|
||||
result.uefi = uefi;
|
||||
@ -358,7 +391,7 @@ function osInfo(callback) {
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
@ -374,11 +407,11 @@ exports.osInfo = osInfo;
|
||||
function isUefiLinux() {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
fs.stat('/sys/firmware/efi', function (err) {
|
||||
fs.stat('/sys/firmware/efi', (err) => {
|
||||
if (!err) {
|
||||
return resolve(true);
|
||||
} else {
|
||||
exec('dmesg | grep -E "EFI v"', function (error, stdout) {
|
||||
exec('dmesg | grep -E "EFI v"', (error, stdout) => {
|
||||
if (!error) {
|
||||
const lines = stdout.toString().split('\n');
|
||||
return resolve(lines.length > 0);
|
||||
@ -395,12 +428,12 @@ function isUefiWindows() {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
try {
|
||||
exec('findstr /C:"Detected boot environment" "%windir%\\Panther\\setupact.log"', util.execOptsWin, function (error, stdout) {
|
||||
exec('findstr /C:"Detected boot environment" "%windir%\\Panther\\setupact.log"', util.execOptsWin, (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n\r')[0];
|
||||
return resolve(line.toLowerCase().indexOf('efi') >= 0);
|
||||
} else {
|
||||
exec('echo %firmware_type%', util.execOptsWin, function (error, stdout) {
|
||||
exec('echo %firmware_type%', util.execOptsWin, (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString() || '';
|
||||
return resolve(line.toLowerCase().indexOf('efi') >= 0);
|
||||
@ -410,7 +443,7 @@ function isUefiWindows() {
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return resolve(false);
|
||||
}
|
||||
});
|
||||
@ -513,8 +546,8 @@ function versions(apps, callback) {
|
||||
const appsObj = checkVersionParam(apps);
|
||||
let totalFunctions = appsObj.counter;
|
||||
|
||||
let functionProcessed = (function () {
|
||||
return function () {
|
||||
let functionProcessed = (() => {
|
||||
return () => {
|
||||
if (--totalFunctions === 0) {
|
||||
if (callback) {
|
||||
callback(appsObj.versions);
|
||||
@ -528,7 +561,7 @@ function versions(apps, callback) {
|
||||
try {
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'openssl')) {
|
||||
appsObj.versions.openssl = process.versions.openssl;
|
||||
exec('openssl version', function (error, stdout) {
|
||||
exec('openssl version', (error, stdout) => {
|
||||
if (!error) {
|
||||
let openssl_string = stdout.toString().split('\n')[0].trim();
|
||||
let openssl = openssl_string.split(' ');
|
||||
@ -539,7 +572,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'npm')) {
|
||||
exec('npm -v', function (error, stdout) {
|
||||
exec('npm -v', (error, stdout) => {
|
||||
if (!error) {
|
||||
appsObj.versions.npm = stdout.toString().split('\n')[0];
|
||||
}
|
||||
@ -551,7 +584,7 @@ function versions(apps, callback) {
|
||||
if (_windows) {
|
||||
cmd += '.cmd';
|
||||
}
|
||||
exec(`${cmd} -v`, function (error, stdout) {
|
||||
exec(`${cmd} -v`, (error, stdout) => {
|
||||
if (!error) {
|
||||
let pm2 = stdout.toString().split('\n')[0].trim();
|
||||
if (!pm2.startsWith('[PM2]')) {
|
||||
@ -562,7 +595,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'yarn')) {
|
||||
exec('yarn --version', function (error, stdout) {
|
||||
exec('yarn --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
appsObj.versions.yarn = stdout.toString().split('\n')[0];
|
||||
}
|
||||
@ -574,7 +607,7 @@ function versions(apps, callback) {
|
||||
if (_windows) {
|
||||
cmd += '.cmd';
|
||||
}
|
||||
exec(`${cmd} --version`, function (error, stdout) {
|
||||
exec(`${cmd} --version`, (error, stdout) => {
|
||||
if (!error) {
|
||||
const gulp = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.gulp = (gulp.toLowerCase().split('version')[1] || '').trim();
|
||||
@ -584,7 +617,7 @@ function versions(apps, callback) {
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'homebrew')) {
|
||||
cmd = 'brew';
|
||||
exec(`${cmd} --version`, function (error, stdout) {
|
||||
exec(`${cmd} --version`, (error, stdout) => {
|
||||
if (!error) {
|
||||
const brew = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.homebrew = (brew.toLowerCase().split(' ')[1] || '').trim();
|
||||
@ -597,7 +630,7 @@ function versions(apps, callback) {
|
||||
if (_windows) {
|
||||
cmd += '.cmd';
|
||||
}
|
||||
exec(`${cmd} --version`, function (error, stdout) {
|
||||
exec(`${cmd} --version`, (error, stdout) => {
|
||||
if (!error) {
|
||||
const tsc = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.tsc = (tsc.toLowerCase().split('version')[1] || '').trim();
|
||||
@ -610,7 +643,7 @@ function versions(apps, callback) {
|
||||
if (_windows) {
|
||||
cmd += '.cmd';
|
||||
}
|
||||
exec(`${cmd} --version`, function (error, stdout) {
|
||||
exec(`${cmd} --version`, (error, stdout) => {
|
||||
if (!error) {
|
||||
const grunt = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.grunt = (grunt.toLowerCase().split('cli v')[1] || '').trim();
|
||||
@ -622,7 +655,7 @@ function versions(apps, callback) {
|
||||
if (_darwin) {
|
||||
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git') || fs.existsSync('/opt/homebrew/bin/git');
|
||||
if (util.darwinXcodeExists() || gitHomebrewExists) {
|
||||
exec('git --version', function (error, stdout) {
|
||||
exec('git --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
let git = stdout.toString().split('\n')[0] || '';
|
||||
git = (git.toLowerCase().split('version')[1] || '').trim();
|
||||
@ -634,7 +667,7 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('git --version', function (error, stdout) {
|
||||
exec('git --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
let git = stdout.toString().split('\n')[0] || '';
|
||||
git = (git.toLowerCase().split('version')[1] || '').trim();
|
||||
@ -645,7 +678,7 @@ function versions(apps, callback) {
|
||||
}
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'apache')) {
|
||||
exec('apachectl -v 2>&1', function (error, stdout) {
|
||||
exec('apachectl -v 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const apache = (stdout.toString().split('\n')[0] || '').split(':');
|
||||
appsObj.versions.apache = apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').split('(')[0].trim() : '';
|
||||
@ -654,7 +687,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'nginx')) {
|
||||
exec('nginx -v 2>&1', function (error, stdout) {
|
||||
exec('nginx -v 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const nginx = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.nginx = (nginx.toLowerCase().split('/')[1] || '').trim();
|
||||
@ -663,7 +696,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'mysql')) {
|
||||
exec('mysql -V', function (error, stdout) {
|
||||
exec('mysql -V', (error, stdout) => {
|
||||
if (!error) {
|
||||
let mysql = stdout.toString().split('\n')[0] || '';
|
||||
mysql = mysql.toLowerCase();
|
||||
@ -682,7 +715,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'php')) {
|
||||
exec('php -v', function (error, stdout) {
|
||||
exec('php -v', (error, stdout) => {
|
||||
if (!error) {
|
||||
const php = stdout.toString().split('\n')[0] || '';
|
||||
let parts = php.split('(');
|
||||
@ -695,7 +728,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'redis')) {
|
||||
exec('redis-server --version', function (error, stdout) {
|
||||
exec('redis-server --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const redis = stdout.toString().split('\n')[0] || '';
|
||||
const parts = redis.split(' ');
|
||||
@ -705,7 +738,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'docker')) {
|
||||
exec('docker --version', function (error, stdout) {
|
||||
exec('docker --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const docker = stdout.toString().split('\n')[0] || '';
|
||||
const parts = docker.split(' ');
|
||||
@ -715,7 +748,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'postfix')) {
|
||||
exec('postconf -d | grep mail_version', function (error, stdout) {
|
||||
exec('postconf -d | grep mail_version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const postfix = stdout.toString().split('\n') || [];
|
||||
appsObj.versions.postfix = util.getValue(postfix, 'mail_version', '=', true);
|
||||
@ -724,7 +757,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'mongodb')) {
|
||||
exec('mongod --version', function (error, stdout) {
|
||||
exec('mongod --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const mongodb = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.mongodb = (mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
|
||||
@ -734,11 +767,11 @@ function versions(apps, callback) {
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'postgresql')) {
|
||||
if (_linux) {
|
||||
exec('locate bin/postgres', function (error, stdout) {
|
||||
exec('locate bin/postgres', (error, stdout) => {
|
||||
if (!error) {
|
||||
const postgresqlBin = stdout.toString().split('\n').sort();
|
||||
if (postgresqlBin.length) {
|
||||
exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', function (error, stdout) {
|
||||
exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', (error, stdout) => {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
@ -749,7 +782,7 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('psql -V', function (error, stdout) {
|
||||
exec('psql -V', (error, stdout) => {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
@ -778,12 +811,12 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
exec('postgres -V', function (error, stdout) {
|
||||
exec('postgres -V', (error, stdout) => {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
} else {
|
||||
exec('pg_config --version', function (error, stdout) {
|
||||
exec('pg_config --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
@ -796,7 +829,7 @@ function versions(apps, callback) {
|
||||
}
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'perl')) {
|
||||
exec('perl -v', function (error, stdout) {
|
||||
exec('perl -v', (error, stdout) => {
|
||||
if (!error) {
|
||||
const perl = stdout.toString().split('\n') || '';
|
||||
while (perl.length > 0 && perl[0].trim() === '') {
|
||||
@ -819,7 +852,7 @@ function versions(apps, callback) {
|
||||
const gitHomebrewExists2 = fs.existsSync('/opt/homebrew/bin/python');
|
||||
if ((util.darwinXcodeExists() && util.semverCompare('12.0.1', osVersion) < 0) || gitHomebrewExists1 || gitHomebrewExists2) {
|
||||
const cmd = gitHomebrewExists1 ? '/usr/local/Cellar/python -V 2>&1' : gitHomebrewExists2 ? '/opt/homebrew/bin/python -V 2>&1' : 'python -V 2>&1';
|
||||
exec(cmd, function (error, stdout) {
|
||||
exec(cmd, (error, stdout) => {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.python = python.toLowerCase().replace('python', '').trim();
|
||||
@ -829,11 +862,11 @@ function versions(apps, callback) {
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('python -V 2>&1', function (error, stdout) {
|
||||
exec('python -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.python = python.toLowerCase().replace('python', '').trim();
|
||||
@ -846,7 +879,7 @@ function versions(apps, callback) {
|
||||
if (_darwin) {
|
||||
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/python3') || fs.existsSync('/opt/homebrew/bin/python3');
|
||||
if (util.darwinXcodeExists() || gitHomebrewExists) {
|
||||
exec('python3 -V 2>&1', function (error, stdout) {
|
||||
exec('python3 -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim();
|
||||
@ -857,7 +890,7 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('python3 -V 2>&1', function (error, stdout) {
|
||||
exec('python3 -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim();
|
||||
@ -870,7 +903,7 @@ function versions(apps, callback) {
|
||||
if (_darwin) {
|
||||
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/pip') || fs.existsSync('/opt/homebrew/bin/pip');
|
||||
if (util.darwinXcodeExists() || gitHomebrewExists) {
|
||||
exec('pip -V 2>&1', function (error, stdout) {
|
||||
exec('pip -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
@ -882,7 +915,7 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('pip -V 2>&1', function (error, stdout) {
|
||||
exec('pip -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
@ -896,7 +929,7 @@ function versions(apps, callback) {
|
||||
if (_darwin) {
|
||||
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/pip3') || fs.existsSync('/opt/homebrew/bin/pip3');
|
||||
if (util.darwinXcodeExists() || gitHomebrewExists) {
|
||||
exec('pip3 -V 2>&1', function (error, stdout) {
|
||||
exec('pip3 -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
@ -908,7 +941,7 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('pip3 -V 2>&1', function (error, stdout) {
|
||||
exec('pip3 -V 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
@ -921,10 +954,10 @@ function versions(apps, callback) {
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'java')) {
|
||||
if (_darwin) {
|
||||
// check if any JVM is installed but avoid dialog box that Java needs to be installed
|
||||
exec('/usr/libexec/java_home -V 2>&1', function (error, stdout) {
|
||||
exec('/usr/libexec/java_home -V 2>&1', (error, stdout) => {
|
||||
if (!error && stdout.toString().toLowerCase().indexOf('no java runtime') === -1) {
|
||||
// now this can be done savely
|
||||
exec('java -version 2>&1', function (error, stdout) {
|
||||
exec('java -version 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const java = stdout.toString().split('\n')[0] || '';
|
||||
const parts = java.split('"');
|
||||
@ -937,7 +970,7 @@ function versions(apps, callback) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
exec('java -version 2>&1', function (error, stdout) {
|
||||
exec('java -version 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const java = stdout.toString().split('\n')[0] || '';
|
||||
const parts = java.split('"');
|
||||
@ -949,14 +982,14 @@ function versions(apps, callback) {
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'gcc')) {
|
||||
if ((_darwin && util.darwinXcodeExists()) || !_darwin) {
|
||||
exec('gcc -dumpversion', function (error, stdout) {
|
||||
exec('gcc -dumpversion', (error, stdout) => {
|
||||
if (!error) {
|
||||
appsObj.versions.gcc = stdout.toString().split('\n')[0].trim() || '';
|
||||
}
|
||||
if (appsObj.versions.gcc.indexOf('.') > -1) {
|
||||
functionProcessed();
|
||||
} else {
|
||||
exec('gcc --version', function (error, stdout) {
|
||||
exec('gcc --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const gcc = stdout.toString().split('\n')[0].trim();
|
||||
if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
|
||||
@ -973,7 +1006,7 @@ function versions(apps, callback) {
|
||||
}
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'virtualbox')) {
|
||||
exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) {
|
||||
exec(util.getVboxmanage() + ' -v 2>&1', (error, stdout) => {
|
||||
if (!error) {
|
||||
const vbox = stdout.toString().split('\n')[0] || '';
|
||||
const parts = vbox.split('r');
|
||||
@ -983,7 +1016,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'bash')) {
|
||||
exec('bash --version', function (error, stdout) {
|
||||
exec('bash --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n')[0];
|
||||
const parts = line.split(' version ');
|
||||
@ -995,7 +1028,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'zsh')) {
|
||||
exec('zsh --version', function (error, stdout) {
|
||||
exec('zsh --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n')[0];
|
||||
const parts = line.split('zsh ');
|
||||
@ -1007,7 +1040,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'fish')) {
|
||||
exec('fish --version', function (error, stdout) {
|
||||
exec('fish --version', (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n')[0];
|
||||
const parts = line.split(' version ');
|
||||
@ -1019,7 +1052,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'bun')) {
|
||||
exec('bun -v', function (error, stdout) {
|
||||
exec('bun -v', (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n')[0].trim();
|
||||
appsObj.versions.bun = line;
|
||||
@ -1028,7 +1061,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'deno')) {
|
||||
exec('deno -v', function (error, stdout) {
|
||||
exec('deno -v', (error, stdout) => {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n')[0].trim();
|
||||
const parts = line.split(' ');
|
||||
@ -1040,7 +1073,7 @@ function versions(apps, callback) {
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'node')) {
|
||||
exec('node -v', function (error, stdout) {
|
||||
exec('node -v', (error, stdout) => {
|
||||
if (!error) {
|
||||
let line = stdout.toString().split('\n')[0].trim();
|
||||
if (line.startsWith('v')) {
|
||||
@ -1089,7 +1122,7 @@ function versions(apps, callback) {
|
||||
functionProcessed();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
if (callback) {
|
||||
callback(appsObj.versions);
|
||||
}
|
||||
@ -1127,7 +1160,7 @@ function shell(callback) {
|
||||
}
|
||||
} else {
|
||||
let result = '';
|
||||
exec('echo $SHELL', function (error, stdout) {
|
||||
exec('echo $SHELL', (error, stdout) => {
|
||||
if (!error) {
|
||||
result = stdout.toString().split('\n')[0];
|
||||
}
|
||||
@ -1149,7 +1182,7 @@ function getUniqueMacAdresses() {
|
||||
const ifaces = os.networkInterfaces();
|
||||
for (let dev in ifaces) {
|
||||
if ({}.hasOwnProperty.call(ifaces, dev)) {
|
||||
ifaces[dev].forEach(function (details) {
|
||||
ifaces[dev].forEach((details) => {
|
||||
if (details && details.mac && details.mac !== '00:00:00:00:00:00') {
|
||||
const mac = details.mac.toLowerCase();
|
||||
if (macs.indexOf(mac) === -1) {
|
||||
@ -1159,7 +1192,7 @@ function getUniqueMacAdresses() {
|
||||
});
|
||||
}
|
||||
}
|
||||
macs = macs.sort(function (a, b) {
|
||||
macs = macs.sort((a, b) => {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
@ -1168,7 +1201,7 @@ function getUniqueMacAdresses() {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
} catch (e) {
|
||||
} catch {
|
||||
macs.push('00:00:00:00:00:00');
|
||||
}
|
||||
return macs;
|
||||
@ -1185,7 +1218,7 @@ function uuid(callback) {
|
||||
let parts;
|
||||
|
||||
if (_darwin) {
|
||||
exec('system_profiler SPHardwareDataType -json', function (error, stdout) {
|
||||
exec('system_profiler SPHardwareDataType -json', (error, stdout) => {
|
||||
if (!error) {
|
||||
try {
|
||||
const jsonObj = JSON.parse(stdout.toString());
|
||||
@ -1194,7 +1227,7 @@ function uuid(callback) {
|
||||
result.os = spHardware.platform_UUID.toLowerCase();
|
||||
result.hardware = spHardware.serial_number;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
@ -1208,7 +1241,7 @@ function uuid(callback) {
|
||||
const cmd = `echo -n "os: "; cat /var/lib/dbus/machine-id 2> /dev/null ||
|
||||
cat /etc/machine-id 2> /dev/null; echo;
|
||||
echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||
exec(cmd, function (error, stdout) {
|
||||
exec(cmd, (error, stdout) => {
|
||||
const lines = stdout.toString().split('\n');
|
||||
result.os = util.getValue(lines, 'os').toLowerCase();
|
||||
result.hardware = util.getValue(lines, 'hardware').toLowerCase();
|
||||
@ -1224,7 +1257,7 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||
});
|
||||
}
|
||||
if (_freebsd || _openbsd || _netbsd) {
|
||||
exec('sysctl -i kern.hostid kern.hostuuid', function (error, stdout) {
|
||||
exec('sysctl -i kern.hostid kern.hostuuid', (error, stdout) => {
|
||||
const lines = stdout.toString().split('\n');
|
||||
result.hardware = util.getValue(lines, 'kern.hostid', ':').toLowerCase();
|
||||
result.os = util.getValue(lines, 'kern.hostuuid', ':').toLowerCase();
|
||||
@ -1248,7 +1281,7 @@ echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;`;
|
||||
util.powerShell('Get-CimInstance Win32_ComputerSystemProduct | select UUID | fl').then((stdout) => {
|
||||
let lines = stdout.split('\r\n');
|
||||
result.hardware = util.getValue(lines, 'uuid', ':').toLowerCase();
|
||||
exec(`${sysdir}\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid`, util.execOptsWin, function (error, stdout) {
|
||||
exec(`${sysdir}\\reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid`, util.execOptsWin, (error, stdout) => {
|
||||
parts = stdout.toString().split('\n\r')[0].split('REG_SZ');
|
||||
result.os = parts.length > 1 ? parts[1].replace(/\r+|\n+|\s+/gi, '').toLowerCase() : '';
|
||||
if (callback) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user