From f691942c44d3faa0d0e2c17956e7d4c122dbd94a Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Tue, 11 Jul 2017 11:29:56 +0200 Subject: [PATCH] added cpuFlags() to getStaticData(), bug fix graphics() (Win) --- CHANGELOG.md | 3 ++- CODE_OF_CONDICT.md | 22 +++++++++++++++++ CONTRIBUTING.md | 11 +++++++++ README.md | 1 + lib/graphics.js | 60 ++++++++++++++++++++++++++++++++++++---------- lib/index.js | 23 ++++++++++-------- 6 files changed, 97 insertions(+), 23 deletions(-) create mode 100644 CODE_OF_CONDICT.md create mode 100644 CONTRIBUTING.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 44eb826..d11198c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,6 +98,7 @@ Other changes | Version | Date | Comment | | -------------- | -------------- | -------- | +| 3.23.6 | 2017-07-11 | added cpuFlags() to getStaticData(), bug fix `graphics()` (Win) | | 3.23.5 | 2017-06-29 | bug fix `inetChecksite()` | | 3.23.4 | 2017-06-24 | bug fix `getDynamicData(), getAllData() - mem` | | 3.23.3 | 2017-06-23 | updated docs | @@ -107,7 +108,7 @@ Other changes | 3.22.0 | 2017-06-19 | extended windows support (`users`, `inetLatency`) | | 3.21.0 | 2017-06-18 | extended time (timezone), extended windows support (battery, getAll...) | | 3.20.1 | 2017-06-17 | updated docs | -| 3.20.0 | 2017-06-16 | extend windows support (cpu, cpuCache, cpuCurrentspeed, mem, networkInterfaces, docker) | +| 3.20.0 | 2017-06-16 | extend WIN support (cpu, cpuCache, cpuCurrentspeed, mem, networkInterfaces, docker) | | 3.19.0 | 2017-06-12 | OSX temperature now an optional dependency | | 3.18.0 | 2017-05-27 | extended `cpu` info (vendor, family, model, stepping, revision, cache, speedmin/max) | | 3.17.3 | 2017-04-29 | minor fix (blockDevices data array, Windows) | diff --git a/CODE_OF_CONDICT.md b/CODE_OF_CONDICT.md new file mode 100644 index 0000000..01b8644 --- /dev/null +++ b/CODE_OF_CONDICT.md @@ -0,0 +1,22 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery +* Personal attacks +* Trolling or insulting/derogatory comments +* Public or private harassment +* Publishing other's private information, such as physical or electronic addresses, without explicit permission +* Other unethical or unprofessional conduct. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. + +This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. + +This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..16ee3e5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +## You want to contribute some code? + +We are always looking for quality contributions and will be happy to accept your Pull Requests as long as they adhere to some basic rules: + +* Please make sure that your contribution fits well in the project's context: + * we are aiming to provide a high quality multi platform system information library, without any dependencies on any external JavaScript library; + * the only dependency should be bootstrap CSS and its markup structure +* Please assure that you are submitting quality code, specifically make sure that: + * your commits should not be braking changes - if possible. + * your PR are well testet - if possible on multiple platforms / machines + * if your commit needs a major version bump (breaking change), please leave a clear message in your comments diff --git a/README.md b/README.md index c59f412..a5dc8e6 100644 --- a/README.md +++ b/README.md @@ -500,6 +500,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra - lapsio [lapsio](https://github.com/lapsio) - csy [csy](https://github.com/csy1983) - Tiago Roldão [tiagoroldao](https://github.com/tiagoroldao) +- dragonjet [dragonjet](https://github.com/dragonjet) OSX Temperature: Credits here are going to: diff --git a/lib/graphics.js b/lib/graphics.js index c236cc5..38afcba 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -315,24 +315,60 @@ function graphics(callback) { // https://blogs.technet.microsoft.com/heyscriptingguy/2013/10/03/use-powershell-to-discover-multi-monitor-information/ exec("wmic path win32_VideoController get AdapterCompatibility, AdapterDACType, name, PNPDeviceID, CurrentVerticalResolution, CurrentHorizontalResolution, CurrentNumberOfColors, AdapterRAM, CurrentBitsPerPixel, CurrentRefreshRate, MinRefreshRate, MaxRefreshRate /value", function (error, stdout) { if (!error) { - let lines = stdout.split('\r\n'); - result.controllers.push({}); - result.displays.push({}); - result.controllers[0].model = getValue(lines, 'name', '='); - result.controllers[0].vendor = getValue(lines, 'AdapterCompatibility', '='); - result.controllers[0].bus = getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : ''; - result.controllers[0].vram = getValue(lines, 'AdapterRAM', '='); - - result.displays[0].resolutionx = getValue(lines, 'CurrentHorizontalResolution', '='); - result.displays[0].resolutiony = getValue(lines, 'CurrentVerticalResolution', '='); - result.displays[0].depth = getValue(lines, 'CurrentBitsPerPixel', '='); + let csections = stdout.split(/\n\s*\n/); + result.controllers = parseLinesWindowsControllers(csections); + exec("wmic path win32_desktopmonitor get MonitorManufacturer, ScreenWidth, ScreenHeight /value", function (error, stdout) { + let dsections = stdout.split(/\n\s*\n/); + if (!error) { + result.displays = parseLinesWindowsDisplays(dsections); + } + if (callback) { + callback(result) + } + resolve(result); + }) } - resolve(result); }) } }); }); + + function parseLinesWindowsControllers(sections){ + let controllers = []; + for (let i in sections) { + if (sections.hasOwnProperty(i)) { + if (sections[i].trim() !== "") { + + let lines = sections[i].trim().split('\r\n'); + controllers.push({ + model: getValue(lines, 'name', '='), + vendor: getValue(lines, 'AdapterCompatibility', '='), + bus: getValue(lines, 'PNPDeviceID', '=').startsWith('PCI') ? 'PCI' : '', + vram: getValue(lines, 'AdapterRAM', '=') + }); + } + } + } + return controllers; + } + + function parseLinesWindowsDisplays(sections){ + let displays = []; + for (let i in sections) { + if (sections.hasOwnProperty(i)) { + if (sections[i].trim() !== "") { + let lines = sections[i].trim().split('\r\n'); + displays.push({ + model: getValue(lines, 'MonitorManufacturer', '='), + resolutionx: getValue(lines, 'ScreenWidth', '='), + resolutiony: getValue(lines, 'ScreenHeight', '=') + }); + } + } + } + return displays; + } } exports.graphics = graphics; diff --git a/lib/index.js b/lib/index.js index 579b2eb..94c2563 100644 --- a/lib/index.js +++ b/lib/index.js @@ -138,16 +138,19 @@ function getStaticData(callback) { data.versions = res; cpu.cpu().then(res => { data.cpu = res; - graphics.graphics().then(res => { - data.graphics = res; - network.networkInterfaces().then(res => { - data.net = res; - mem.memLayout().then(res => { - data.memLayout = res; - filesystem.diskLayout().then(res => { - data.diskLayout = res; - if (callback) { callback(data) } - resolve(data); + cpu.cpuFlags().then(res => { + data.cpu.flags = res; + graphics.graphics().then(res => { + data.graphics = res; + network.networkInterfaces().then(res => { + data.net = res; + mem.memLayout().then(res => { + data.memLayout = res; + filesystem.diskLayout().then(res => { + data.diskLayout = res; + if (callback) { callback(data) } + resolve(data); + }) }) }) })