"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isFromLibrary = exports.getAvailableStats = void 0;
/*
 * Copyright 2018, collaboration Factory AG. All rights reserved.
 */
const os = require("os");
const fs_1 = require("fs");
const path_1 = require("path");
const PACKAGE_JSON_PATH = path_1.resolve(__dirname, '../../package.json');
/**
 * Returns a human-readable info line with the number of cpus/cores
 * and the current memory details
 */
function getAvailableStats() {
    const packageJson_String = fs_1.readFileSync(PACKAGE_JSON_PATH, 'utf8');
    const packageJson = JSON.parse(packageJson_String);
    const versionString = packageJson.version;
    let op = [];
    op.push(`Currently running version: ${versionString}`);
    op.push(`Available cpus/cores: ${os.cpus().length}`);
    let memoryUsage = process.memoryUsage();
    for (let key in memoryUsage) {
        // @ts-ignore
        op.push(`${key}: ${Math.round((memoryUsage[key] / 1024 / 1024) * 100) / 100}MB`);
    }
    return op.join(', ');
}
exports.getAvailableStats = getAvailableStats;
const LIB_TEST_RE = /@([a-zA-Z0-9.]+)\/.+/;
function isFromLibrary(file) {
    return LIB_TEST_RE.test(file);
}
exports.isFromLibrary = isFromLibrary;
//# sourceMappingURL=utils.js.map