@mettlelabs/mettle 0.0.0-beta.2-win32-x64 → 0.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/bin/mettle.exe +5 -4
  3. package/package.json +29 -11
  4. package/postinstall.mjs +174 -0
  5. package/THIRD_PARTY_NOTICES.md +0 -11974
  6. package/harness/audit-investigation.mjs +0 -203
  7. package/harness/chunk-1sygmp11.mjs +0 -18142
  8. package/harness/chunk-1ykxpmaz.mjs +0 -7887
  9. package/harness/chunk-2pm2sayw.mjs +0 -248
  10. package/harness/chunk-3m7jn5ac.mjs +0 -16242
  11. package/harness/chunk-3wt8a8fq.mjs +0 -1716
  12. package/harness/chunk-3wvjs93w.mjs +0 -538
  13. package/harness/chunk-49ytr8d5.mjs +0 -33761
  14. package/harness/chunk-4bepyxmq.mjs +0 -113
  15. package/harness/chunk-4vx34w5h.mjs +0 -2357
  16. package/harness/chunk-50sbrf09.mjs +0 -18972
  17. package/harness/chunk-56csr8sw.mjs +0 -322
  18. package/harness/chunk-5wgmv4np.mjs +0 -585
  19. package/harness/chunk-65eyq32y.mjs +0 -225
  20. package/harness/chunk-6fnh6qhk.mjs +0 -195
  21. package/harness/chunk-6kgqw9ny.mjs +0 -32303
  22. package/harness/chunk-7b242j0n.mjs +0 -14
  23. package/harness/chunk-9dg1btk1.mjs +0 -2818
  24. package/harness/chunk-ageqxj9v.mjs +0 -63008
  25. package/harness/chunk-b0qbt5jd.mjs +0 -14
  26. package/harness/chunk-b5g1r3fz.mjs +0 -4785
  27. package/harness/chunk-b71gpkxg.mjs +0 -1514
  28. package/harness/chunk-bdv1rx4a.mjs +0 -20364
  29. package/harness/chunk-c1631s2x.mjs +0 -12241
  30. package/harness/chunk-c7dx5mdd.mjs +0 -10807
  31. package/harness/chunk-d5xgxsnp.mjs +0 -74
  32. package/harness/chunk-erg1fbh0.mjs +0 -0
  33. package/harness/chunk-fh78v9vn.mjs +0 -19366
  34. package/harness/chunk-fjx29qvp.mjs +0 -50
  35. package/harness/chunk-gryka6kg.mjs +0 -39
  36. package/harness/chunk-h1td5kq9.mjs +0 -422
  37. package/harness/chunk-jb0r19et.mjs +0 -180
  38. package/harness/chunk-jp69h6sj.mjs +0 -95
  39. package/harness/chunk-mfn574ss.mjs +0 -179
  40. package/harness/chunk-nz5sv9as.mjs +0 -1642
  41. package/harness/chunk-p9d3cgvq.mjs +0 -452
  42. package/harness/chunk-pq6wvwxr.mjs +0 -12
  43. package/harness/chunk-qcm9arf8.mjs +0 -7736
  44. package/harness/chunk-qr8zfqjd.mjs +0 -24
  45. package/harness/chunk-rd80vvc5.mjs +0 -22047
  46. package/harness/chunk-rz2tz6jp.mjs +0 -26
  47. package/harness/chunk-sbkgc3kn.mjs +0 -8
  48. package/harness/chunk-v66qvpnb.mjs +0 -169
  49. package/harness/chunk-vjaxzab3.mjs +0 -136
  50. package/harness/chunk-vr1n5nza.mjs +0 -1045
  51. package/harness/chunk-vsf2zajv.mjs +0 -3867
  52. package/harness/chunk-w0qwc5z2.mjs +0 -41
  53. package/harness/chunk-wq253fj4.mjs +0 -19041
  54. package/harness/chunk-wyv7ceq4.mjs +0 -0
  55. package/harness/chunk-xnqknk2r.mjs +0 -198
  56. package/harness/chunk-z6n9thea.mjs +0 -45146
  57. package/harness/chunk-zty0d3bw.mjs +0 -0
  58. package/harness/chunk-zvkxtj82.mjs +0 -42
  59. package/harness/issue-api-token.mjs +0 -35
  60. package/harness/launcher.mjs +0 -459
  61. package/harness/sandbox.mjs +0 -133
  62. package/harness/server.mjs +0 -87314
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mettle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/mettle.exe CHANGED
@@ -1,4 +1,5 @@
1
- [diffend] Oversized file quarantined before diffing.
2
- name: package/bin/mettle.exe
3
- size: 100172800 bytes
4
- sha256: f21502816c0c81406e0b678f9f2563d371ea8f20666d5644b710e044517283c8
1
+ echo "Error: @mettlelabs/mettle's postinstall script was not run." >&2
2
+ echo "" >&2
3
+ echo "This occurs when installation scripts are disabled." >&2
4
+ echo "Run the package postinstall script or reinstall with scripts enabled." >&2
5
+ exit 1
package/package.json CHANGED
@@ -1,20 +1,38 @@
1
1
  {
2
2
  "name": "@mettlelabs/mettle",
3
- "version": "0.0.0-beta.2-win32-x64",
4
- "license": "UNLICENSED",
3
+ "version": "0.0.0-beta.3",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/prolabsinc/mettle-cli.git"
8
+ },
9
+ "bin": {
10
+ "mettle": "./bin/mettle.exe"
11
+ },
12
+ "scripts": {
13
+ "postinstall": "node ./postinstall.mjs"
14
+ },
5
15
  "os": [
16
+ "darwin",
17
+ "linux",
6
18
  "win32"
7
19
  ],
8
20
  "cpu": [
21
+ "arm64",
9
22
  "x64"
10
23
  ],
11
- "files": [
12
- "bin",
13
- "harness",
14
- "THIRD_PARTY_NOTICES.md"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/prolabsinc/mettle-cli.git"
24
+ "optionalDependencies": {
25
+ "@mettlelabs/mettle-darwin-arm64": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.darwin-arm64",
26
+ "@mettlelabs/mettle-darwin-x64": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.darwin-x64",
27
+ "@mettlelabs/mettle-darwin-x64-baseline": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.darwin-x64-baseline",
28
+ "@mettlelabs/mettle-linux-arm64": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.linux-arm64",
29
+ "@mettlelabs/mettle-linux-arm64-musl": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.linux-arm64-musl",
30
+ "@mettlelabs/mettle-linux-x64": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.linux-x64",
31
+ "@mettlelabs/mettle-linux-x64-baseline": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.linux-x64-baseline",
32
+ "@mettlelabs/mettle-linux-x64-baseline-musl": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.linux-x64-baseline-musl",
33
+ "@mettlelabs/mettle-linux-x64-musl": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.linux-x64-musl",
34
+ "@mettlelabs/mettle-windows-arm64": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.windows-arm64",
35
+ "@mettlelabs/mettle-windows-x64": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.windows-x64",
36
+ "@mettlelabs/mettle-windows-x64-baseline": "npm:@mettlelabs/mettle@0.0.0-0.beta.3.windows-x64-baseline"
19
37
  }
20
- }
38
+ }
@@ -0,0 +1,174 @@
1
+ #!/usr/bin/env node
2
+
3
+ import childProcess from "node:child_process"
4
+ import fs from "node:fs"
5
+ import { createRequire } from "node:module"
6
+ import os from "node:os"
7
+ import path from "node:path"
8
+ import { fileURLToPath } from "node:url"
9
+
10
+ const directory = path.dirname(fileURLToPath(import.meta.url))
11
+ const require = createRequire(import.meta.url)
12
+ const packageJson = JSON.parse(fs.readFileSync(path.join(directory, "package.json"), "utf8"))
13
+ const command = Object.keys(packageJson.bin ?? {})[0]
14
+ if (!command) throw new Error("mettle package does not declare a binary")
15
+ const sourceCommand = packageJson.mettleSourceBinary ?? command
16
+
17
+ const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] ?? os.platform()
18
+ const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] ?? os.arch()
19
+ const sourceBinary = platform === "windows" ? `${sourceCommand}.exe` : sourceCommand
20
+ const targetBinary = path.resolve(directory, packageJson.bin[command])
21
+ const dependencies = packageJson.optionalDependencies ?? {}
22
+ const base = Object.keys(dependencies).find((name) => name.endsWith(`-${platform}-${arch}`))
23
+ if (!base) throw new Error(`mettle does not provide a binary for ${platform}-${arch}`)
24
+
25
+ function supportsAvx2() {
26
+ if (arch !== "x64") return false
27
+ if (platform === "linux") {
28
+ try {
29
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
30
+ } catch {
31
+ return false
32
+ }
33
+ }
34
+ if (platform === "darwin") {
35
+ try {
36
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
37
+ encoding: "utf8",
38
+ timeout: 1500,
39
+ })
40
+ return result.status === 0 && (result.stdout || "").trim() === "1"
41
+ } catch {
42
+ return false
43
+ }
44
+ }
45
+ if (platform === "windows") {
46
+ const script =
47
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
48
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
49
+ try {
50
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", script], {
51
+ encoding: "utf8",
52
+ timeout: 3000,
53
+ windowsHide: true,
54
+ })
55
+ if (result.status !== 0) continue
56
+ const output = (result.stdout || "").trim().toLowerCase()
57
+ if (output === "true" || output === "1") return true
58
+ if (output === "false" || output === "0") return false
59
+ } catch {}
60
+ }
61
+ }
62
+ return false
63
+ }
64
+
65
+ function isMusl() {
66
+ if (platform !== "linux") return false
67
+ try {
68
+ if (fs.existsSync("/etc/alpine-release")) return true
69
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
70
+ return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
71
+ } catch {
72
+ return false
73
+ }
74
+ }
75
+
76
+ function packageNames() {
77
+ const baseline = arch === "x64" && !supportsAvx2()
78
+ const names =
79
+ platform === "linux"
80
+ ? isMusl()
81
+ ? arch === "x64"
82
+ ? baseline
83
+ ? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
84
+ : [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
85
+ : [`${base}-musl`, base]
86
+ : arch === "x64"
87
+ ? baseline
88
+ ? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
89
+ : [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
90
+ : [base, `${base}-musl`]
91
+ : arch === "x64"
92
+ ? baseline
93
+ ? [`${base}-baseline`, base]
94
+ : [base, `${base}-baseline`]
95
+ : [base]
96
+ return names.filter((name) => dependencies[name])
97
+ }
98
+
99
+ function copyBinary(source) {
100
+ if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
101
+ fs.mkdirSync(path.dirname(targetBinary), { recursive: true })
102
+ if (fs.existsSync(targetBinary)) {
103
+ try {
104
+ fs.unlinkSync(targetBinary)
105
+ } catch {}
106
+ }
107
+ try {
108
+ fs.linkSync(source, targetBinary)
109
+ } catch {
110
+ fs.copyFileSync(source, targetBinary)
111
+ }
112
+ fs.chmodSync(targetBinary, 0o755)
113
+ }
114
+
115
+ function resolveBinary(name) {
116
+ const packagePath = require.resolve(`${name}/package.json`)
117
+ return path.join(path.dirname(packagePath), "bin", sourceBinary)
118
+ }
119
+
120
+ function installPackage(name) {
121
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), "mettle-install-"))
122
+ try {
123
+ const result = childProcess.spawnSync(
124
+ "npm",
125
+ [
126
+ "install",
127
+ "--ignore-scripts",
128
+ "--no-save",
129
+ "--loglevel=error",
130
+ "--prefix",
131
+ temp,
132
+ `${name}@${dependencies[name]}`,
133
+ ],
134
+ { stdio: "inherit", windowsHide: true },
135
+ )
136
+ if (result.status !== 0) return false
137
+ copyBinary(path.join(temp, "node_modules", name, "bin", sourceBinary))
138
+ return true
139
+ } finally {
140
+ fs.rmSync(temp, { recursive: true, force: true })
141
+ }
142
+ }
143
+
144
+ function verifyBinary() {
145
+ return (
146
+ childProcess.spawnSync(targetBinary, ["--version"], {
147
+ stdio: "ignore",
148
+ windowsHide: true,
149
+ }).status === 0
150
+ )
151
+ }
152
+
153
+ function main() {
154
+ const names = packageNames()
155
+ for (const name of names) {
156
+ try {
157
+ copyBinary(resolveBinary(name))
158
+ if (verifyBinary()) return
159
+ } catch {
160
+ if (installPackage(name) && verifyBinary()) return
161
+ }
162
+ }
163
+
164
+ throw new Error(
165
+ `Failed to install mettle. Try manually installing ${names.map((name) => JSON.stringify(name)).join(" or ")}.`,
166
+ )
167
+ }
168
+
169
+ try {
170
+ main()
171
+ } catch (error) {
172
+ console.error(error instanceof Error ? error.message : String(error))
173
+ process.exit(1)
174
+ }