Compare commits
No commits in common. "6ddcff5275b5723459ee2cc8a988d64e2146f13f" and "714572994abd381f348b4f5d9b8ec920d90b304a" have entirely different histories.
6ddcff5275
...
714572994a
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,2 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
build.json
|
|
||||||
22
kit/build.js
22
kit/build.js
@ -1,22 +0,0 @@
|
|||||||
// build-time.js
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
// 生成当前时间的 yyyyMMdd 格式
|
|
||||||
const now = new Date();
|
|
||||||
const year = now.getFullYear();
|
|
||||||
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(now.getDate()).padStart(2, '0');
|
|
||||||
const buildTime = `${year}${month}${day}`;
|
|
||||||
|
|
||||||
// 创建 JSON 对象
|
|
||||||
const buildData = {
|
|
||||||
buildTime: buildTime,
|
|
||||||
timestamp: now.toISOString()
|
|
||||||
};
|
|
||||||
|
|
||||||
// 写入文件
|
|
||||||
const filePath = path.join(__dirname, 'build.json');
|
|
||||||
fs.writeFileSync(filePath, JSON.stringify(buildData, null, 2));
|
|
||||||
|
|
||||||
console.log(`Build time ${buildTime} written to build.json`);
|
|
||||||
12
kit/package-lock.json
generated
12
kit/package-lock.json
generated
@ -10,13 +10,14 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"auto-launch": "^5.0.6",
|
"auto-launch": "^5.0.6",
|
||||||
"cross-port-killer": "^1.4.0",
|
"cross-port-killer": "^1.4.0",
|
||||||
|
"diskusage-ng": "^1.0.4",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"get-port": "^7.0.0",
|
"get-port": "^7.0.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"log4js": "^6.9.1",
|
"log4js": "^6.9.1",
|
||||||
"physical-cpu-count": "^2.0.0",
|
"physical-cpu-count": "^2.0.0",
|
||||||
"sm-crypto": "^0.3.13",
|
"sm-crypto": "^0.3.13",
|
||||||
"systeminformation": "^5.30.6",
|
"systeminformation": "^5.25.11",
|
||||||
"webdav": "^5.3.1"
|
"webdav": "^5.3.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -157,6 +158,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/diskusage-ng": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/diskusage-ng/-/diskusage-ng-1.0.4.tgz",
|
||||||
|
"integrity": "sha512-30qT0Bn2dNGii6dAXllGgYRaIt+7gPhwCJks+byhutkCOCgsqfqvXmAV2zTDOvU1ylnGHUjZMMaKhM95FyQQrg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/end-of-stream": {
|
"node_modules/end-of-stream": {
|
||||||
"version": "1.4.4",
|
"version": "1.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",
|
||||||
|
|||||||
@ -4,23 +4,24 @@
|
|||||||
"bin": "src/index.js",
|
"bin": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "bun src/index.js",
|
"test": "bun src/index.js",
|
||||||
"linux": "bun build.js && bun build ./src/index.js --compile --bytecode --minify --target=bun-linux-x64-baseline --outfile=./dist/linux/kit",
|
"linux": "bun build ./src/index.js --compile --bytecode --minify --target=bun-linux-x64-baseline --outfile=./dist/linux/kit",
|
||||||
"windows": "bun build.js && bun build ./src/index.js --compile --bytecode --minify --target=bun-windows-x64-baseline --outfile=./dist/windows/kit.exe",
|
"windows": "bun build ./src/index.js --compile --bytecode --minify --target=bun-windows-x64-baseline --outfile=./dist/windows/kit.exe",
|
||||||
"pkg-alpine": "bun build.js && pkg --compress GZip . -t node14-alpine-arm64 -o ./dist/alpine/kit",
|
"pkg-alpine": "pkg --compress GZip . -t node14-alpine-arm64 -o ./dist/alpine/kit",
|
||||||
"pkg-windows": "bun build.js && pkg --compress GZip . -t win -o ./dist/windows/kit.exe",
|
"pkg-windows": "pkg --compress GZip . -t win -o ./dist/windows/kit.exe",
|
||||||
"pkg-arm64": "bun build.js && pkg --compress GZip . -t node14-linux-arm64 -o ./dist/linux/kit",
|
"pkg-arm64": "pkg --compress GZip . -t node14-linux-arm64 -o ./dist/linux/kit",
|
||||||
"pkg-linux": "bun build.js && pkg --compress GZip . -t node14-linux-x64 -o ./dist/linux/kit"
|
"pkg-linux": "pkg --compress GZip . -t node14-linux-x64 -o ./dist/linux/kit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"auto-launch": "^5.0.6",
|
"auto-launch": "^5.0.6",
|
||||||
"cross-port-killer": "^1.4.0",
|
"cross-port-killer": "^1.4.0",
|
||||||
|
"diskusage-ng": "^1.0.4",
|
||||||
"extract-zip": "^2.0.1",
|
"extract-zip": "^2.0.1",
|
||||||
"get-port": "^7.0.0",
|
"get-port": "^7.0.0",
|
||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"log4js": "^6.9.1",
|
"log4js": "^6.9.1",
|
||||||
"physical-cpu-count": "^2.0.0",
|
"physical-cpu-count": "^2.0.0",
|
||||||
"sm-crypto": "^0.3.13",
|
"sm-crypto": "^0.3.13",
|
||||||
"systeminformation": "^5.30.6",
|
"systeminformation": "^5.25.11",
|
||||||
"webdav": "^5.3.1"
|
"webdav": "^5.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
require("./init")
|
require("./init")
|
||||||
const { CliCmdParser } = require("../../argv")
|
const { CliCmdParser } = require("../../argv")
|
||||||
const parser = new CliCmdParser("kit V" + $version + " build " + $build);
|
const parser = new CliCmdParser("kit V" + $version);
|
||||||
const net = require("./net")
|
const net = require("./net")
|
||||||
const shell = require("./shell")
|
const shell = require("./shell")
|
||||||
const {sm4en3, sm4de3} = require("./crypto");
|
const {sm4en3, sm4de3} = require("./crypto");
|
||||||
@ -138,19 +138,15 @@ parser.addCmdLine("platform", "平台信息", function (cli) {
|
|||||||
}
|
}
|
||||||
table.push({ '项' : 'Mem ' + k, '值' : info.memory[k]})
|
table.push({ '项' : 'Mem ' + k, '值' : info.memory[k]})
|
||||||
}
|
}
|
||||||
|
for ( let k in info.disk ){
|
||||||
|
if ( k.endsWith("Size") ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
table.push({ '项' : 'Disk' + k, '值' : info.disk[k]})
|
||||||
|
}
|
||||||
|
|
||||||
console.table(table);
|
console.table(table);
|
||||||
const disks = info.disk;
|
|
||||||
disks.forEach(disk => {
|
|
||||||
console.log(`磁盘 ${disk.mount}:`);
|
|
||||||
console.log(` 总空间: ${(disk.size / 1024 / 1024 / 1024).toFixed(2)} GB`);
|
|
||||||
console.log(` 已用空间: ${(disk.used / 1024 / 1024 / 1024).toFixed(2)} GB`);
|
|
||||||
console.log(` 可用空间: ${(disk.available / 1024 / 1024 / 1024).toFixed(2)} GB`);
|
|
||||||
console.log(` 使用率: ${disk.use}%`);
|
|
||||||
});
|
|
||||||
console.log( JSON.stringify(info, null, 4));
|
console.log( JSON.stringify(info, null, 4));
|
||||||
|
|
||||||
|
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('Error getting device information:', error);
|
console.error('Error getting device information:', error);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -14,9 +14,6 @@ function init(){
|
|||||||
const package = require("../package.json")
|
const package = require("../package.json")
|
||||||
global.$version = package.version
|
global.$version = package.version
|
||||||
|
|
||||||
const builder = require("../build.json")
|
|
||||||
global.$build = builder.buildTime
|
|
||||||
|
|
||||||
// 上下文模块
|
// 上下文模块
|
||||||
global.$context = new Context();
|
global.$context = new Context();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const si = require('systeminformation');
|
const diskusage = require('diskusage-ng');
|
||||||
|
const { physicalCpuCount } = require('physical-cpu-count');
|
||||||
const { formatBytes } = require("./util/convutil")
|
const { formatBytes } = require("./util/convutil")
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
const { promisify } = require('util');
|
const { promisify } = require('util');
|
||||||
@ -13,7 +14,6 @@ const readFilePromise = promisify(fs.readFile);
|
|||||||
|
|
||||||
// 获取操作系统信息
|
// 获取操作系统信息
|
||||||
async function getOSInfo() {
|
async function getOSInfo() {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: os.type(),
|
type: os.type(),
|
||||||
platform: os.platform(),
|
platform: os.platform(),
|
||||||
@ -26,7 +26,6 @@ async function getOSInfo() {
|
|||||||
// 获取 CPU 信息
|
// 获取 CPU 信息
|
||||||
function getCPUInfo() {
|
function getCPUInfo() {
|
||||||
const cpus = os.cpus();
|
const cpus = os.cpus();
|
||||||
const physicalCpuCount = require('physical-cpu-count')
|
|
||||||
return {
|
return {
|
||||||
model: cpus[0].model,
|
model: cpus[0].model,
|
||||||
speed: cpus[0].speed,
|
speed: cpus[0].speed,
|
||||||
@ -48,13 +47,38 @@ function getMemoryInfo() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取硬盘信息
|
||||||
|
async function getDiskInfo() {
|
||||||
|
try {
|
||||||
|
const path = os.platform() === 'win32' ? 'C:' : '/';
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
diskusage(path, function (err, usage) {
|
||||||
|
if (err) {
|
||||||
|
console.error('Error getting disk information:', err);
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve({
|
||||||
|
totalSize: usage.total,
|
||||||
|
freeSize: usage.available,
|
||||||
|
total : formatBytes(usage.total),
|
||||||
|
free : formatBytes(usage.available),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error getting disk information:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 主函数,调用上述函数获取所有信息
|
// 主函数,调用上述函数获取所有信息
|
||||||
async function getAllDeviceInfo() {
|
async function getAllDeviceInfo() {
|
||||||
const osInfo = await getOSInfo();
|
const osInfo = await getOSInfo();
|
||||||
const cpuInfo = getCPUInfo();
|
const cpuInfo = getCPUInfo();
|
||||||
const memoryInfo = getMemoryInfo();
|
const memoryInfo = getMemoryInfo();
|
||||||
const diskInfo = await si.fsSize();
|
const diskInfo = await getDiskInfo();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
os: osInfo,
|
os: osInfo,
|
||||||
@ -107,5 +131,6 @@ module.exports = {
|
|||||||
getOSInfo,
|
getOSInfo,
|
||||||
getCPUInfo,
|
getCPUInfo,
|
||||||
getMemoryInfo,
|
getMemoryInfo,
|
||||||
|
getDiskInfo,
|
||||||
getAllDeviceInfo
|
getAllDeviceInfo
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user