@cliz/os-info
Version:
Nobot CLI
61 lines (60 loc) • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const cli_1 = require("@cliz/cli");
const nobot_1 = require("@znode/nobot");
(0, cli_1.createSingleCommandProgram)(__dirname, {
autoOutputHelp: false,
disableAutoCreateGlobalConfig: true,
}, async (program, { api }) => {
program
.option('--type <type>', 'Specify provider type, now support dingtalk,feishu,wecom,slack, env: TYPE', {
default: api.env.get('OS_INFO_TYPE', 'feishu'),
})
.option('-u, --url <url>', 'Specify provider url, env: URL', {
default: api.env.get('OS_INFO_URL'),
})
.action(async ({ options }) => {
const config = options;
const type = config.type;
const url = config.url;
const info = {
os: await api.system.getOsInfo(),
node: await api.system.getNodeInfo(),
};
const message = `Runtime (Node.js):
Version: ${info.node.version}
NPM Version: ${info.node.npm}
YARN Version: ${info.node.yarn}
Registry: ${await api.$ `npm config get registry --loglevel=error`}
V8: ${info.node.v8}
Openssl: ${info.node.openssl}
Zlib: ${process.versions.zlib}
Bin: ${process.execPath}
OS:
Kernel Version: ${info.os.kernel}
Operating System: ${info.os.distribution}
OSType: ${info.os.platform}
Architecture: ${info.os.arch}
CPUs: ${info.os.cpus}
Total Memory: ${Math.ceil(info.os.totalMemory / 1024 ** 3)}Gi
Name: ${api.env.get('USER', 'nobody')}
Home: ${info.os.homedir}
HostName: ${info.os.hostname}
Shell: ${info.os.shell}
Uptime: ${info.os.uptime}
`;
console.log(message);
if (type && url) {
(0, nobot_1.sendMessage)(type, url, {
title: 'Node Runtime Info',
content: message
.replace(/\\n/g, '\n')
.split('\n'),
})
.catch(err => {
});
}
});
});
//# sourceMappingURL=cli.js.map