Skip to content

Commit

Permalink
versions() added deno and bun
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Dec 31, 2024
1 parent f5d308f commit 3a8b3b6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 39 deletions.
77 changes: 50 additions & 27 deletions lib/osinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,47 +452,49 @@ function isUefiWindows() {
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: '',
apache: '',
bash: '',
bun: '',
deno: '',
docker: '',
dotnet: '',
fish: '',
gcc: '',
git: '',
tsc: '',
mysql: '',
redis: '',
grunt: '',
gulp: '',
java: '',
mongodb: '',
apache: '',
mysql: '',
nginx: '',
node: process.versions.node,
npm: '',
openssl: '',
perl: '',
php: '',
docker: '',
pip3: '',
pip: '',
pm2: '',
postfix: '',
postgresql: '',
perl: '',
python: '',
powershell: '',
python3: '',
pip: '',
pip3: '',
java: '',
gcc: '',
python: '',
redis: '',
systemOpenssl: '',
systemOpensslLib: '',
tsc: '',
v8: process.versions.v8,
virtualbox: '',
bash: '',
zsh: '',
fish: '',
powershell: '',
dotnet: ''
yarn: '',
zsh: ''
};

function checkVersionParam(apps) {
if (apps === '*') {
return {
versions: versionObject,
counter: 30
counter: 32
};
}
if (!Array.isArray(apps)) {
Expand Down Expand Up @@ -1027,6 +1029,27 @@ function versions(apps, callback) {
functionProcessed();
});
}
if ({}.hasOwnProperty.call(appsObj.versions, 'bun')) {
exec('bun -v', function (error, stdout) {
if (!error) {
const line = stdout.toString().split('\n')[0].trim();
appsObj.versions.fish = line;
}
functionProcessed();
});
}
if ({}.hasOwnProperty.call(appsObj.versions, 'deno')) {
exec('deno -v', function (error, stdout) {
if (!error) {
const line = stdout.toString().split('\n')[0].trim();
const parts = line.split(' ');
if (parts.length > 1) {
appsObj.versions.fish = parts[1];
}
}
functionProcessed();
});
}
if ({}.hasOwnProperty.call(appsObj.versions, 'powershell')) {
if (_windows) {
util.powerShell('$PSVersionTable').then(stdout => {
Expand Down
24 changes: 12 additions & 12 deletions lib/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ function system(callback) {
let lines = stdout.toString().split('\n');
result.manufacturer = util.getValue(lines, 'manufacturer');
result.model = util.getValue(lines, 'product name');
result.version = util.getValue(lines, 'version');
result.serial = util.getValue(lines, 'serial number');
result.uuid = util.getValue(lines, 'uuid').toLowerCase();
result.sku = util.getValue(lines, 'sku number');
result.version = cleanDefaults(util.getValue(lines, 'version'));
result.serial = cleanDefaults(util.getValue(lines, 'serial number'));
result.uuid = cleanDefaults((util.getValue(lines, 'uuid').toLowerCase()));
result.sku = cleanDefaults(util.getValue(lines, 'sku number'));
// Non-Root values
const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
Expand All @@ -64,17 +64,17 @@ function system(callback) {
lines = execSync(cmd, util.execOptsLinux).toString().split('\n');
result.manufacturer = result.manufacturer === '' ? util.getValue(lines, 'sys_vendor') : result.manufacturer;
result.model = result.model === '' ? util.getValue(lines, 'product_name') : result.model;
result.version = result.version === '' ? util.getValue(lines, 'product_version') : result.version;
result.serial = result.serial === '' ? util.getValue(lines, 'product_serial') : result.serial;
result.uuid = result.uuid === '' ? util.getValue(lines, 'product_uuid').toLowerCase() : result.uuid;
result.version = cleanDefaults(result.version === '' ? util.getValue(lines, 'product_version') : result.version);
result.serial = cleanDefaults(result.serial === '' ? util.getValue(lines, 'product_serial') : result.serial);
result.uuid = cleanDefaults(result.uuid === '' ? util.getValue(lines, 'product_uuid').toLowerCase() : result.uuid);
} catch (e) {
util.noop();
}
if (!result.serial || result.serial.toLowerCase().indexOf('o.e.m.') !== -1) { result.serial = '-'; }
if (!result.manufacturer || result.manufacturer.toLowerCase().indexOf('o.e.m.') !== -1) { result.manufacturer = ''; }
if (!result.model || result.model.toLowerCase().indexOf('o.e.m.') !== -1) { result.model = 'Computer'; }
if (!result.version || result.version.toLowerCase().indexOf('o.e.m.') !== -1) { result.version = ''; }
if (!result.sku || result.sku.toLowerCase().indexOf('o.e.m.') !== -1) { result.sku = '-'; }
if (!result.serial) { result.serial = '-'; }
if (!result.manufacturer) { result.manufacturer = ''; }
if (!result.model) { result.model = 'Computer'; }
if (!result.version) { result.version = ''; }
if (!result.sku) { result.sku = '-'; }

// detect virtual (1)
if (result.model.toLowerCase() === 'virtualbox' || result.model.toLowerCase() === 'kvm' || result.model.toLowerCase() === 'virtual machine' || result.model.toLowerCase() === 'bochs' || result.model.toLowerCase().startsWith('vmware') || result.model.toLowerCase().startsWith('droplet')) {
Expand Down

0 comments on commit 3a8b3b6

Please sign in to comment.