1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import os from 'node:os';
import isDocker from 'is-docker';
import isWSL from 'is-wsl';
import { isCI, name as ciName } from 'ci-info';
type AnonymousMeta = {
systemPlatform: NodeJS.Platform;
systemRelease: string;
systemArchitecture: string;
cpuCount: number;
cpuModel: string | null;
cpuSpeed: number | null;
memoryInMb: number;
isDocker: boolean;
isWSL: boolean;
isCI: boolean;
ciName: string | null;
astroVersion: string;
};
let meta: AnonymousMeta | undefined;
export function getAnonymousMeta(astroVersion: string): AnonymousMeta {
if (meta) {
return meta;
}
const cpus = os.cpus() || [];
meta = {
// Software information
systemPlatform: os.platform(),
systemRelease: os.release(),
systemArchitecture: os.arch(),
// Machine information
cpuCount: cpus.length,
cpuModel: cpus.length ? cpus[0].model : null,
cpuSpeed: cpus.length ? cpus[0].speed : null,
memoryInMb: Math.trunc(os.totalmem() / Math.pow(1024, 2)),
// Environment information
isDocker: isDocker(),
isWSL,
isCI,
ciName,
astroVersion,
};
return meta!;
}
|