@depup/systeminformation 5.31.4-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli.js ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict';
4
+ // @ts-check
5
+ // ==================================================================================
6
+ // cli.js
7
+ // ----------------------------------------------------------------------------------
8
+ // Description: System Information - library
9
+ // for Node.js
10
+ // Copyright: (c) 2014 - 2026
11
+ // Author: Sebastian Hildebrandt
12
+ // ----------------------------------------------------------------------------------
13
+ // License: MIT
14
+ // ==================================================================================
15
+
16
+ // ----------------------------------------------------------------------------------
17
+ // Dependencies
18
+ // ----------------------------------------------------------------------------------
19
+ const si = require('./index');
20
+ const lib_version = require('../package.json').version;
21
+
22
+ function capFirst(string) {
23
+ return string[0].toUpperCase() + string.slice(1);
24
+ }
25
+
26
+ function getValue(value) {
27
+ if (value === null || value === undefined) {
28
+ return '';
29
+ }
30
+ if (typeof value === 'object') {
31
+ return JSON.stringify(value);
32
+ }
33
+ return value.toString();
34
+ }
35
+
36
+ function printLines(obj) {
37
+ for (const property in obj) {
38
+ console.log(`${capFirst(property) + ' '.substring(0, 17 - property.length)}: ${getValue(obj[property])}`);
39
+ }
40
+ console.log();
41
+ }
42
+
43
+ function info() {
44
+ console.log('┌─────────────────────────────────────────────────────────────────────────────────────────┐');
45
+ console.log(
46
+ `${'│ SYSTEMINFORMATION '.substring(0, 80 - lib_version.length)}Version: ${lib_version} │`
47
+ );
48
+ console.log('└─────────────────────────────────────────────────────────────────────────────────────────┘');
49
+
50
+ si.osInfo().then((res) => {
51
+ console.log();
52
+ console.log('Operating System:');
53
+ console.log('──────────────────────────────────────────────────────────────────────────────────────────');
54
+ delete res.serial;
55
+ delete res.servicepack;
56
+ delete res.logofile;
57
+ delete res.fqdn;
58
+ delete res.uefi;
59
+ printLines(res);
60
+ si.system().then((res) => {
61
+ console.log('System:');
62
+ console.log('──────────────────────────────────────────────────────────────────────────────────────────');
63
+ delete res.serial;
64
+ delete res.uuid;
65
+ delete res.sku;
66
+ delete res.uuid;
67
+ printLines(res);
68
+ si.cpu().then((res) => {
69
+ console.log('CPU:');
70
+ console.log('──────────────────────────────────────────────────────────────────────────────────────────');
71
+ delete res.cache;
72
+ delete res.governor;
73
+ delete res.flags;
74
+ delete res.virtualization;
75
+ delete res.revision;
76
+ delete res.voltage;
77
+ delete res.vendor;
78
+ delete res.speedMin;
79
+ delete res.speedMax;
80
+ printLines(res);
81
+ });
82
+ });
83
+ });
84
+ }
85
+
86
+ // ----------------------------------------------------------------------------------
87
+ // Main
88
+ // ----------------------------------------------------------------------------------
89
+ (() => {
90
+ const args = process.argv.slice(2);
91
+
92
+ if (args[0] === 'info') {
93
+ info();
94
+ } else {
95
+ si.getStaticData().then((data) => {
96
+ data.time = si.time();
97
+ console.log(JSON.stringify(data, null, 2));
98
+ });
99
+ }
100
+ })();