|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +/** |
| 4 | + * This script is intended to be independnet of the rest of |
| 5 | + * the codebase. It is used to determine if the native logic |
| 6 | + * works before making wider modifications throughout the codebase. |
| 7 | + */ |
| 8 | + |
| 9 | +import { statfs } from 'node:fs/promises'; |
| 10 | +import os from 'node:os'; |
| 11 | + |
| 12 | +const convertBytesToGB = (bytes: number) => (bytes / Math.pow(1024, 3)).toFixed(2); |
| 13 | + |
| 14 | +console.group('CI Information'); |
| 15 | +console.log('CI:', process.env.CI); |
| 16 | +console.log('GITHUB_ACTION:', process.env.GITHUB_ACTION); |
| 17 | +console.log('GITHUB_WORKSPACE:', process.env.GITHUB_WORKSPACE); |
| 18 | +console.groupEnd(); |
| 19 | + |
| 20 | +console.group('Memory') |
| 21 | +console.log('Free memory:', convertBytesToGB(os.freemem()), 'GB'); |
| 22 | +console.log('Total memory:', convertBytesToGB(os.totalmem()), 'GB'); |
| 23 | +console.groupEnd(); |
| 24 | + |
| 25 | +console.group('Processor') |
| 26 | +console.log('CPU architecture:', os.machine()); |
| 27 | +console.log('Number of CPU cores:', os.cpus().length); |
| 28 | +console.log('Parallelism Cores:', os.availableParallelism()); |
| 29 | +console.groupEnd(); |
| 30 | + |
| 31 | +console.group('Operating System') |
| 32 | +console.log('Type:', os.type()); |
| 33 | +console.log('Release:', os.release()); |
| 34 | +console.log('Version:', os.version()); |
| 35 | +console.groupEnd(); |
| 36 | + |
| 37 | +console.group('User'); |
| 38 | +const userInfo = os.userInfo(); |
| 39 | +console.log('Username:', userInfo.username); |
| 40 | +console.log('Home directory:', userInfo.homedir); |
| 41 | +console.log('Shell:', userInfo.shell); |
| 42 | +console.log('UID:', userInfo.uid); |
| 43 | +console.log('GID:', userInfo.gid); |
| 44 | +console.groupEnd(); |
| 45 | + |
| 46 | +console.group('Disk'); |
| 47 | +let storagePath = process.env.RESOURCE_COLLECTION_STORAGE_PATH; |
| 48 | +switch (os.platform()) { |
| 49 | + case 'win32': |
| 50 | + storagePath ??= 'C:\\'; |
| 51 | + break; |
| 52 | + case 'darwin': |
| 53 | + storagePath ??= '/System/Volumes/Data'; |
| 54 | + break; |
| 55 | + case 'linux': |
| 56 | + storagePath ??= '/'; |
| 57 | + break; |
| 58 | + default: |
| 59 | + break; |
| 60 | +} |
| 61 | + |
| 62 | +if (!storagePath) { |
| 63 | + console.warn('No storage path specified or discovered for disk information. Skipping disk information.'); |
| 64 | + console.groupEnd(); |
| 65 | + process.exit(0); |
| 66 | +} |
| 67 | + |
| 68 | +console.log(await statfs(storagePath, { |
| 69 | + bigint: true, |
| 70 | +})); |
| 71 | +console.groupEnd(); |
0 commit comments