chassis() type, assetTag, sku improved parsing (macOS)
This commit is contained in:
parent
f1f2ccd927
commit
1744982db0
@ -83,6 +83,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||
| 5.22.1 | 2024-03-14 | `chassis()` type, assetTag, sku improved parsing (macOS) |
|
||||
| 5.22.1 | 2024-03-12 | `wifiConnections()` patch for mac OS Sonome 14.4 (macOS) |
|
||||
| 5.22.0 | 2024-02-18 | `wifiConnections()` added signal quality attribute |
|
||||
| 5.21.25 | 2024-02-17 | `wifiConnections()` fixed signal strength (windows) |
|
||||
|
||||
@ -57,6 +57,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">5.22.2</th>
|
||||
<td>2024-03-14</td>
|
||||
<td><span class="code">chassis()</span> type, assetTag, sku improved parsing (macOS)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">5.22.1</th>
|
||||
<td>2024-03-12</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.22.1</span></div>
|
||||
<div class="version">New Version: <span id="version">5.22.2</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">
|
||||
|
||||
@ -215,12 +215,14 @@ function system(callback) {
|
||||
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
||||
const model = splitByNumber(util.getValue(lines, 'model', '=', true));
|
||||
const version = util.getValue(lines, 'version', '=', true);
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
||||
result.model = util.getValue(lines, 'model', '=', true, true);
|
||||
result.version = util.getValue(lines, 'version', '=', true);
|
||||
result.model = version ? util.getValue(lines, 'model', '=', true) : model[0];
|
||||
result.version = version || model[1];
|
||||
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
|
||||
result.uuid = util.getValue(lines, 'ioplatformuuid', '=', true).toLowerCase();
|
||||
result.sku = util.getValue(lines, 'board-id', '=', true);
|
||||
result.sku = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-sub-type', '=', true);
|
||||
}
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
@ -602,6 +604,33 @@ function baseboard(callback) {
|
||||
|
||||
exports.baseboard = baseboard;
|
||||
|
||||
function macOsChassisType(model) {
|
||||
model = model.toLowerCase();
|
||||
if (model.startsWith('macbookair')) { return 'Notebook'; }
|
||||
if (model.startsWith('macbookpro')) { return 'Laptop'; }
|
||||
if (model.startsWith('macbook')) { return 'Notebook'; }
|
||||
if (model.startsWith('macmini')) { return 'Desktop'; }
|
||||
if (model.startsWith('imac')) { return 'Desktop'; }
|
||||
if (model.startsWith('macstudio')) { return 'Desktop'; }
|
||||
if (model.startsWith('macpro')) { return 'Tower'; }
|
||||
return 'Other';
|
||||
}
|
||||
|
||||
function splitByNumber(str) {
|
||||
let numberStarted = false;
|
||||
let num = '';
|
||||
let cpart = '';
|
||||
for (const c of str) {
|
||||
if ((c >= '0' && c <= '9') || numberStarted) {
|
||||
numberStarted = true;
|
||||
num += c;
|
||||
} else {
|
||||
cpart += c;
|
||||
}
|
||||
}
|
||||
return [cpart, num];
|
||||
}
|
||||
|
||||
function chassis(callback) {
|
||||
const chassisTypes = ['Other',
|
||||
'Unknown',
|
||||
@ -680,11 +709,16 @@ function chassis(callback) {
|
||||
exec('ioreg -c IOPlatformExpertDevice -d 2', function (error, stdout) {
|
||||
if (!error) {
|
||||
let lines = stdout.toString().replace(/[<>"]/g, '').split('\n');
|
||||
const model = util.getValue(lines, 'model', '=', true);
|
||||
const modelParts = splitByNumber(model);
|
||||
const version = util.getValue(lines, 'version', '=', true);
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
|
||||
result.model = util.getValue(lines, 'model', '=', true);
|
||||
result.version = util.getValue(lines, 'version', '=', true);
|
||||
result.model = version ? util.getValue(lines, 'model', '=', true) : modelParts[0];
|
||||
result.type = macOsChassisType(result.model);
|
||||
result.version = version || model;
|
||||
result.serial = util.getValue(lines, 'ioplatformserialnumber', '=', true);
|
||||
result.assetTag = util.getValue(lines, 'board-id', '=', true);
|
||||
result.assetTag = util.getValue(lines, 'board-id', '=', true) || util.getValue(lines, 'target-type', '=', true);
|
||||
result.sku = util.getValue(lines, 'target-sub-type', '=', true);
|
||||
}
|
||||
|
||||
if (callback) { callback(result); }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user