-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
index.ts
71 lines (62 loc) · 1.81 KB
/
index.ts
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import os from "node:os";
import process from "node:process";
import childProcess from "child_process";
function getUniqueCpuNames(): string {
return os
.cpus()
.map((cpu) => cpu.model)
.filter((model, index, models) => models.indexOf(model) === index)
.join(", ");
}
function getBinaryVersion(binaryName: string): string {
try {
return childProcess
.execFileSync(binaryName, ["--version"])
.toString()
.trim();
} catch {
return "N/A";
}
}
function getPackageVersion(packageName: string) {
try {
return require(`${packageName}/package.json`).version;
} catch {
return null;
}
}
function interestingPackage(name: string): string | null {
const version = getPackageVersion(name);
if (version) {
return `${name}: ${version}`;
} else {
return null;
}
}
function interestingPackages(names: string[]): string {
return names.map(interestingPackage).filter(Boolean).join("\n ");
}
console.log(`
Operating System:
Platform: ${os.platform()}
Arch: ${os.arch()}
Machine Type: ${os.machine()}
Version: ${os.version()}
CPU: (${os.cpus().length} cores)
Models: ${getUniqueCpuNames()}
Binaries:
Node: ${process.versions.node}
npm: ${getBinaryVersion("npm")}
Yarn: ${getBinaryVersion("yarn")}
pnpm: ${getBinaryVersion("pnpm")}
Relevant Packages:
@swc/core: ${getPackageVersion("@swc/core") ?? "N/A"}
@swc/helpers: ${getPackageVersion("@swc/helpers") ?? "N/A"}
@swc/types: ${getPackageVersion("@swc/types") ?? "N/A"}
${interestingPackages(["typescript", "next"])}
SWC Config:
output: N/A
.swcrc path: N/A
Next.js info:
output: N/A
`);