diff --git a/CHANGELOG.md b/CHANGELOG.md index f590d7e..9675153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) | diff --git a/docs/history.html b/docs/history.html index ef2cf42..7a5f5d9 100644 --- a/docs/history.html +++ b/docs/history.html @@ -57,6 +57,11 @@ + + 5.22.2 + 2024-03-14 + chassis() type, assetTag, sku improved parsing (macOS) + 5.22.1 2024-03-12 diff --git a/docs/index.html b/docs/index.html index f31743c..35fe5dc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.22.1
+
New Version: 5.22.2
diff --git a/lib/system.js b/lib/system.js index 1e90874..5390c0c 100644 --- a/lib/system.js +++ b/lib/system.js @@ -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); }