versions() added param to specify which program/lib versions to detect
This commit is contained in:
parent
8f5babb29c
commit
add6dd4d2a
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| -------------- | -------------- | -------- |
|
||||
| 4.23.0 | 2020-03-08 | `versions()` added param to specify which program/lib versions to detect |
|
||||
| 4.22.7 | 2020-03-08 | `diskLayout()` fixed linux |
|
||||
| 4.22.6 | 2020-03-08 | `network()` fixed DHCP linux|
|
||||
| 4.22.5 | 2020-03-04 | `graphics()` fixed vram macOS |
|
||||
|
||||
@ -85,13 +85,13 @@ si.cpu()
|
||||
|
||||
(last 7 major and minor version releases)
|
||||
|
||||
- Version 4.23.0: `versions()` added param to specify which program/lib versions to detect
|
||||
- Version 4.22.0: `services()` added pids (windows)
|
||||
- Version 4.21.0: added npx copmpatibility
|
||||
- Version 4.20.0: `battery()` added designcapacity, voltage, unit
|
||||
- Version 4.19.0: `osInfo()` added uefi (OS uses UEFI during startup)
|
||||
- Version 4.18.0: `networkInterfaces()` added dhcp for mac os, added dhcp linux fallback
|
||||
- Version 4.17.0: `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState
|
||||
- Version 4.16.0: `networkGatewayDefault()` added
|
||||
- ...
|
||||
|
||||
You can find all changes here: [detailed changelog][changelog-url]
|
||||
@ -296,7 +296,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
||||
| | uefi | X | X | X | X | | OS started via UEFI |
|
||||
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
|
||||
| | os | X | X | X | X | | os specific UUID |
|
||||
| si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) |
|
||||
| si.versions(apps, cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...)<br />apps param is optional for detecting<br />only specific apps/libs<br />(string, comma separated) |
|
||||
| si.shell(cb) | : string | X | X | X | | | standard shell |
|
||||
| si.users(cb) | [{...}] | X | X | X | X | X | array of users online |
|
||||
| | [0].user | X | X | X | X | X | user name |
|
||||
|
||||
@ -83,6 +83,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">4.23.0</th>
|
||||
<td>2020-03-08</td>
|
||||
<td><span class="code">versions()</span> added param to specify which program/lib versions to detect</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">4.22.7</th>
|
||||
<td>2020-03-08</td>
|
||||
|
||||
@ -168,7 +168,7 @@
|
||||
<img class="logo" src="assets/logo.png">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span></div>
|
||||
<div class="version">Current Version: <span id="version">4.22.7</span></div>
|
||||
<div class="version">Current Version: <span id="version">4.23.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">
|
||||
|
||||
13
docs/os.html
13
docs/os.html
@ -259,14 +259,14 @@ si.osInfo().then(data => console.log(data));</code></pre class="example">
|
||||
<td>standard shell</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>si.versions(cb)</td>
|
||||
<td>si.versions(apps, cb)</td>
|
||||
<td>{...}</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>X</td>
|
||||
<td>version information of<br>node and dev software packages</td>
|
||||
<td>version information of<br>node and dev software packages<br>optional apps param (string, <br>comma or space seperated)<br>only those apps are detected</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
@ -586,6 +586,15 @@ si.versions().then(data => console.log(data));</code></pre class="example">
|
||||
java: '',
|
||||
gcc: '4.2.1',
|
||||
virtualbox: ''
|
||||
}</pre>
|
||||
<h5>Example 2</h5>
|
||||
<pre><code class="js">const si = require('systeminformation');
|
||||
si.versions('npm, php, postgresql').then(data => console.log(data));</code></pre class="example">
|
||||
<pre class="example">
|
||||
{
|
||||
npm: '6.13.6',
|
||||
php: '7.3.11',
|
||||
postgresql: '12.1'
|
||||
}</pre>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
712
lib/osinfo.js
712
lib/osinfo.js
@ -351,357 +351,461 @@ function isUefiWindows() {
|
||||
});
|
||||
}
|
||||
|
||||
function versions(callback) {
|
||||
function versions(apps, callback) {
|
||||
let versionObject = {
|
||||
kernel: os.release(),
|
||||
openssl: '',
|
||||
systemOpenssl: '',
|
||||
systemOpensslLib: '',
|
||||
node: process.versions.node,
|
||||
v8: process.versions.v8,
|
||||
npm: '',
|
||||
yarn: '',
|
||||
pm2: '',
|
||||
gulp: '',
|
||||
grunt: '',
|
||||
git: '',
|
||||
tsc: '',
|
||||
mysql: '',
|
||||
redis: '',
|
||||
mongodb: '',
|
||||
apache: '',
|
||||
nginx: '',
|
||||
php: '',
|
||||
docker: '',
|
||||
postfix: '',
|
||||
postgresql: '',
|
||||
perl: '',
|
||||
python: '',
|
||||
python3: '',
|
||||
pip: '',
|
||||
pip3: '',
|
||||
java: '',
|
||||
gcc: '',
|
||||
virtualbox: '',
|
||||
dotnet: ''
|
||||
};
|
||||
|
||||
function checkVersionParam(apps) {
|
||||
if (apps === '*') {
|
||||
return {
|
||||
versions: versionObject,
|
||||
counter: 26
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(apps)) {
|
||||
apps = apps.trim().toLowerCase().replace(/,+/g, '|').replace(/ /g, '|');
|
||||
apps = apps.split('|');
|
||||
const result = {
|
||||
versions: {},
|
||||
counter: 0
|
||||
}
|
||||
apps.forEach(el => {
|
||||
if (el) {
|
||||
for (let key in versionObject) {
|
||||
if ({}.hasOwnProperty.call(versionObject, key)) {
|
||||
if (key.toLowerCase() === el.toLowerCase() && !{}.hasOwnProperty.call(result.versions, key)) {
|
||||
result.versions[key] = versionObject[key];
|
||||
if (key === 'openssl') {
|
||||
result.versions.systemOpenssl = '';
|
||||
result.versions.systemOpensslLib = '';
|
||||
}
|
||||
|
||||
if (!result.versions[key]) { result.counter++; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
let result = {
|
||||
kernel: os.release(),
|
||||
openssl: process.versions.openssl,
|
||||
systemOpenssl: '',
|
||||
systemOpensslLib: '',
|
||||
node: process.versions.node,
|
||||
v8: process.versions.v8,
|
||||
npm: '',
|
||||
yarn: '',
|
||||
pm2: '',
|
||||
gulp: '',
|
||||
grunt: '',
|
||||
git: '',
|
||||
tsc: '',
|
||||
mysql: '',
|
||||
redis: '',
|
||||
mongodb: '',
|
||||
apache: '',
|
||||
nginx: '',
|
||||
php: '',
|
||||
docker: '',
|
||||
postfix: '',
|
||||
postgresql: '',
|
||||
perl: '',
|
||||
python: '',
|
||||
python3: '',
|
||||
pip: '',
|
||||
pip3: '',
|
||||
java: '',
|
||||
gcc: '',
|
||||
virtualbox: '',
|
||||
dotnet: ''
|
||||
};
|
||||
if (util.isFunction(apps) && !callback) {
|
||||
callback = apps;
|
||||
apps = '*';
|
||||
} else {
|
||||
apps = apps || '*';
|
||||
}
|
||||
const appsObj = checkVersionParam(apps);
|
||||
let totalFunctions = appsObj.counter;
|
||||
|
||||
let functionProcessed = (function () {
|
||||
let totalFunctions = 26;
|
||||
return function () {
|
||||
if (--totalFunctions === 0) {
|
||||
if (callback) {
|
||||
callback(result);
|
||||
callback(appsObj.versions);
|
||||
}
|
||||
resolve(result);
|
||||
resolve(appsObj.versions);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
try {
|
||||
exec('openssl version', function (error, stdout) {
|
||||
if (!error) {
|
||||
let openssl_string = stdout.toString().split('\n')[0].trim();
|
||||
let openssl = openssl_string.split(' ');
|
||||
result.systemOpenssl = openssl.length > 0 ? openssl[1] : openssl[0];
|
||||
result.systemOpensslLib = openssl.length > 0 ? openssl[0] : 'openssl';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('npm -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
result.npm = stdout.toString().split('\n')[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('pm2 -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
let pm2 = stdout.toString().split('\n')[0].trim();
|
||||
if (!pm2.startsWith('[PM2]')) {
|
||||
result.pm2 = pm2;
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('yarn --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
result.yarn = stdout.toString().split('\n')[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('gulp --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const gulp = stdout.toString().split('\n')[0] || '';
|
||||
result.gulp = (gulp.toLowerCase().split('version')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('tsc --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const tsc = stdout.toString().split('\n')[0] || '';
|
||||
result.tsc = (tsc.toLowerCase().split('version')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('grunt --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const grunt = stdout.toString().split('\n')[0] || '';
|
||||
result.grunt = (grunt.toLowerCase().split('cli v')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
if (_darwin) {
|
||||
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git');
|
||||
if (util.darwinXcodeExists() || gitHomebrewExists) {
|
||||
exec('git --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
let git = stdout.toString().split('\n')[0] || '';
|
||||
git = (git.toLowerCase().split('version')[1] || '').trim();
|
||||
result.git = (git.split(' ')[0] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('git --version', function (error, stdout) {
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'openssl')) {
|
||||
appsObj.versions.openssl = process.versions.openssl;
|
||||
exec('openssl version', function (error, stdout) {
|
||||
if (!error) {
|
||||
let git = stdout.toString().split('\n')[0] || '';
|
||||
git = (git.toLowerCase().split('version')[1] || '').trim();
|
||||
result.git = (git.split(' ')[0] || '').trim();
|
||||
let openssl_string = stdout.toString().split('\n')[0].trim();
|
||||
let openssl = openssl_string.split(' ');
|
||||
appsObj.versions.systemOpenssl = openssl.length > 0 ? openssl[1] : openssl[0];
|
||||
appsObj.versions.systemOpensslLib = openssl.length > 0 ? openssl[0] : 'openssl';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
exec('apachectl -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const apache = (stdout.toString().split('\n')[0] || '').split(':');
|
||||
result.apache = (apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').trim() : '');
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('nginx -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const nginx = stdout.toString().split('\n')[0] || '';
|
||||
result.nginx = (nginx.toLowerCase().split('/')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('mysql -V', function (error, stdout) {
|
||||
if (!error) {
|
||||
let mysql = stdout.toString().split('\n')[0] || '';
|
||||
mysql = mysql.toLowerCase();
|
||||
if (mysql.indexOf(',') > -1) {
|
||||
mysql = (mysql.split(',')[0] || '').trim();
|
||||
const parts = mysql.split(' ');
|
||||
result.mysql = (parts[parts.length - 1] || '').trim();
|
||||
} else {
|
||||
if (mysql.indexOf(' ver ') > -1) {
|
||||
mysql = mysql.split(' ver ')[1];
|
||||
result.mysql = mysql.split(' ')[0];
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'npm')) {
|
||||
exec('npm -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
appsObj.versions.npm = stdout.toString().split('\n')[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'pm2')) {
|
||||
exec('pm2 -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
let pm2 = stdout.toString().split('\n')[0].trim();
|
||||
if (!pm2.startsWith('[PM2]')) {
|
||||
appsObj.versions.pm2 = pm2;
|
||||
}
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('php -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
const php = stdout.toString().split('\n')[0] || '';
|
||||
let parts = php.split('(');
|
||||
if (parts[0].indexOf('-')) {
|
||||
parts = parts[0].split('-');
|
||||
}
|
||||
result.php = parts[0].replace(/[^0-9.]/g, '');
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('redis-server --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const redis = stdout.toString().split('\n')[0] || '';
|
||||
const parts = redis.split(' ');
|
||||
result.redis = util.getValue(parts, 'v', '=', true);
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('docker --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const docker = stdout.toString().split('\n')[0] || '';
|
||||
const parts = docker.split(' ');
|
||||
result.docker = parts.length > 2 && parts[2].endsWith(',') ? parts[2].slice(0, -1) : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('postconf -d | grep mail_version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postfix = stdout.toString().split('\n') || [];
|
||||
result.postfix = util.getValue(postfix, 'mail_version', '=', true);
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('mongod --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const mongodb = stdout.toString().split('\n')[0] || '';
|
||||
result.mongodb = (mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
if (_linux) {
|
||||
exec('locate bin/postgres', function (error, stdout) {
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'yarn')) {
|
||||
exec('yarn --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postgresqlBin = stdout.toString().split('\n').sort();
|
||||
if (postgresqlBin.length) {
|
||||
exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', function (error, stdout) {
|
||||
appsObj.versions.yarn = stdout.toString().split('\n')[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'gulp')) {
|
||||
exec('gulp --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const gulp = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.gulp = (gulp.toLowerCase().split('version')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'tsc')) {
|
||||
exec('tsc --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const tsc = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.tsc = (tsc.toLowerCase().split('version')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'grunt')) {
|
||||
exec('grunt --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const grunt = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.grunt = (grunt.toLowerCase().split('cli v')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'git')) {
|
||||
if (_darwin) {
|
||||
const gitHomebrewExists = fs.existsSync('/usr/local/Cellar/git');
|
||||
if (util.darwinXcodeExists() || gitHomebrewExists) {
|
||||
exec('git --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
let git = stdout.toString().split('\n')[0] || '';
|
||||
git = (git.toLowerCase().split('version')[1] || '').trim();
|
||||
appsObj.versions.git = (git.split(' ')[0] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('git --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
let git = stdout.toString().split('\n')[0] || '';
|
||||
git = (git.toLowerCase().split('version')[1] || '').trim();
|
||||
appsObj.versions.git = (git.split(' ')[0] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'apache')) {
|
||||
exec('apachectl -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const apache = (stdout.toString().split('\n')[0] || '').split(':');
|
||||
appsObj.versions.apache = (apache.length > 1 ? apache[1].replace('Apache', '').replace('/', '').trim() : '');
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'nginx')) {
|
||||
exec('nginx -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const nginx = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.nginx = (nginx.toLowerCase().split('/')[1] || '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'mysql')) {
|
||||
exec('mysql -V', function (error, stdout) {
|
||||
if (!error) {
|
||||
let mysql = stdout.toString().split('\n')[0] || '';
|
||||
mysql = mysql.toLowerCase();
|
||||
if (mysql.indexOf(',') > -1) {
|
||||
mysql = (mysql.split(',')[0] || '').trim();
|
||||
const parts = mysql.split(' ');
|
||||
appsObj.versions.mysql = (parts[parts.length - 1] || '').trim();
|
||||
} else {
|
||||
if (mysql.indexOf(' ver ') > -1) {
|
||||
mysql = mysql.split(' ver ')[1];
|
||||
appsObj.versions.mysql = mysql.split(' ')[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'php')) {
|
||||
exec('php -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
const php = stdout.toString().split('\n')[0] || '';
|
||||
let parts = php.split('(');
|
||||
if (parts[0].indexOf('-')) {
|
||||
parts = parts[0].split('-');
|
||||
}
|
||||
appsObj.versions.php = parts[0].replace(/[^0-9.]/g, '');
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'redis')) {
|
||||
exec('redis-server --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const redis = stdout.toString().split('\n')[0] || '';
|
||||
const parts = redis.split(' ');
|
||||
appsObj.versions.redis = util.getValue(parts, 'v', '=', true);
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'docker')) {
|
||||
exec('docker --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const docker = stdout.toString().split('\n')[0] || '';
|
||||
const parts = docker.split(' ');
|
||||
appsObj.versions.docker = parts.length > 2 && parts[2].endsWith(',') ? parts[2].slice(0, -1) : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'postfix')) {
|
||||
exec('postconf -d | grep mail_version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postfix = stdout.toString().split('\n') || [];
|
||||
appsObj.versions.postfix = util.getValue(postfix, 'mail_version', '=', true);
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'mongodb')) {
|
||||
exec('mongod --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const mongodb = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.mongodb = (mongodb.toLowerCase().split(',')[0] || '').replace(/[^0-9.]/g, '');
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'postgresql')) {
|
||||
if (_linux) {
|
||||
exec('locate bin/postgres', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postgresqlBin = stdout.toString().split('\n').sort();
|
||||
if (postgresqlBin.length) {
|
||||
exec(postgresqlBin[postgresqlBin.length - 1] + ' -V', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
exec('psql -V', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
appsObj.versions.postgresql = appsObj.versions.postgresql.split('-')[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
functionProcessed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (_windows) {
|
||||
util.wmic('service get /value').then((stdout) => {
|
||||
let serviceSections = stdout.split(/\n\s*\n/);
|
||||
for (let i = 0; i < serviceSections.length; i++) {
|
||||
if (serviceSections[i].trim() !== '') {
|
||||
let lines = serviceSections[i].trim().split('\r\n');
|
||||
let srvCaption = util.getValue(lines, 'caption', '=', true).toLowerCase();
|
||||
if (srvCaption.indexOf('postgresql') > -1) {
|
||||
const parts = srvCaption.split(' server ');
|
||||
if (parts.length > 1) {
|
||||
appsObj.versions.postgresql = parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
exec('postgres -V', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'perl')) {
|
||||
exec('perl -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
const perl = stdout.toString().split('\n') || '';
|
||||
while (perl.length > 0 && perl[0].trim() === '') {
|
||||
perl.shift();
|
||||
}
|
||||
if (perl.length > 0) {
|
||||
appsObj.versions.perl = perl[0].split('(').pop().split(')')[0].replace('v', '');
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'python')) {
|
||||
exec('python -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.python = python.toLowerCase().replace('python', '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'python3')) {
|
||||
exec('python3 -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.python3 = python.toLowerCase().replace('python', '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'pip')) {
|
||||
exec('pip -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
appsObj.versions.pip = parts.length >= 2 ? parts[1] : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'pip3')) {
|
||||
exec('pip3 -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
appsObj.versions.pip3 = parts.length >= 2 ? parts[1] : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
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) {
|
||||
if (!error && stdout.toString().toLowerCase().indexOf('no java runtime') === -1) {
|
||||
// now this can be done savely
|
||||
exec('java -version 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const java = stdout.toString().split('\n')[0] || '';
|
||||
const parts = java.split('"');
|
||||
appsObj.versions.java = parts.length === 3 ? parts[1].trim() : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (_windows) {
|
||||
util.wmic('service get /value').then((stdout) => {
|
||||
let serviceSections = stdout.split(/\n\s*\n/);
|
||||
for (let i = 0; i < serviceSections.length; i++) {
|
||||
if (serviceSections[i].trim() !== '') {
|
||||
let lines = serviceSections[i].trim().split('\r\n');
|
||||
let srvCaption = util.getValue(lines, 'caption', '=', true).toLowerCase();
|
||||
if (srvCaption.indexOf('postgresql') > -1) {
|
||||
const parts = srvCaption.split(' server ');
|
||||
if (parts.length > 1) {
|
||||
result.postgresql = parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
exec('postgres -V', function (error, stdout) {
|
||||
exec('java -version 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const postgresql = stdout.toString().split('\n')[0].split(' ') || [];
|
||||
result.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
|
||||
const java = stdout.toString().split('\n')[0] || '';
|
||||
const parts = java.split('"');
|
||||
appsObj.versions.java = parts.length === 3 ? parts[1].trim() : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
}
|
||||
exec('perl -v', function (error, stdout) {
|
||||
if (!error) {
|
||||
const perl = stdout.toString().split('\n') || '';
|
||||
while (perl.length > 0 && perl[0].trim() === '') {
|
||||
perl.shift();
|
||||
}
|
||||
if (perl.length > 0) {
|
||||
result.perl = perl[0].split('(').pop().split(')')[0].replace('v', '');
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('python -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
result.python = python.toLowerCase().replace('python', '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('python3 -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const python = stdout.toString().split('\n')[0] || '';
|
||||
result.python3 = python.toLowerCase().replace('python', '').trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('pip -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
result.pip = parts.length >= 2 ? parts[1] : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('pip3 -V 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const pip = stdout.toString().split('\n')[0] || '';
|
||||
const parts = pip.split(' ');
|
||||
result.pip3 = parts.length >= 2 ? parts[1] : '';
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
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) {
|
||||
if (!error && stdout.toString().toLowerCase().indexOf('no java runtime') === -1) {
|
||||
// now this can be done savely
|
||||
exec('java -version 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const java = stdout.toString().split('\n')[0] || '';
|
||||
const parts = java.split('"');
|
||||
result.java = parts.length === 3 ? parts[1].trim() : '';
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'gcc')) {
|
||||
if ((_darwin && util.darwinXcodeExists()) || !_darwin) {
|
||||
exec('gcc -dumpversion', function (error, stdout) {
|
||||
if (!error) {
|
||||
appsObj.versions.gcc = stdout.toString().split('\n')[0].trim() || '';
|
||||
}
|
||||
if (appsObj.versions.gcc.indexOf('.') > -1) {
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
exec('java -version 2>&1', function (error, stdout) {
|
||||
} else {
|
||||
exec('gcc --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const gcc = stdout.toString().split('\n')[0].trim();
|
||||
if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
|
||||
const parts = gcc.split(')');
|
||||
appsObj.versions.gcc = parts[1].trim() || appsObj.versions.gcc;
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
}
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'virtualbox')) {
|
||||
exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const java = stdout.toString().split('\n')[0] || '';
|
||||
const parts = java.split('"');
|
||||
result.java = parts.length === 3 ? parts[1].trim() : '';
|
||||
const vbox = stdout.toString().split('\n')[0] || '';
|
||||
const parts = vbox.split('r');
|
||||
appsObj.versions.virtualbox = parts[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
}
|
||||
if ((_darwin && util.darwinXcodeExists()) || !_darwin) {
|
||||
exec('gcc -dumpversion', function (error, stdout) {
|
||||
if ({}.hasOwnProperty.call(appsObj.versions, 'dotnet')) {
|
||||
exec('dotnet --version 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
result.gcc = stdout.toString().split('\n')[0].trim() || '';
|
||||
}
|
||||
if (result.gcc.indexOf('.') > -1) {
|
||||
functionProcessed();
|
||||
} else {
|
||||
exec('gcc --version', function (error, stdout) {
|
||||
if (!error) {
|
||||
const gcc = stdout.toString().split('\n')[0].trim();
|
||||
if (gcc.indexOf('gcc') > -1 && gcc.indexOf(')') > -1) {
|
||||
const parts = gcc.split(')');
|
||||
result.gcc = parts[1].trim() || result.gcc;
|
||||
}
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
const dotnet = stdout.toString().split('\n')[0] || '';
|
||||
appsObj.versions.dotnet = dotnet.trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} else {
|
||||
functionProcessed();
|
||||
}
|
||||
exec(util.getVboxmanage() + ' -v 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const vbox = stdout.toString().split('\n')[0] || '';
|
||||
const parts = vbox.split('r');
|
||||
result.virtualbox = parts[0];
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
exec('dotnet --version 2>&1', function (error, stdout) {
|
||||
if (!error) {
|
||||
const dotnet = stdout.toString().split('\n')[0] || '';
|
||||
result.dotnet = dotnet.trim();
|
||||
}
|
||||
functionProcessed();
|
||||
});
|
||||
} catch (e) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user