@traces-sh/traces 0.1.23
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.
- package/bin/traces +67 -0
- package/package.json +18 -0
- package/postinstall.mjs +37 -0
package/bin/traces
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const { createRequire } = require("module");
|
|
8
|
+
|
|
9
|
+
function run(target) {
|
|
10
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
11
|
+
stdio: "inherit",
|
|
12
|
+
});
|
|
13
|
+
if (result.error) {
|
|
14
|
+
console.error(result.error.message);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const code = typeof result.status === "number" ? result.status : 0;
|
|
18
|
+
process.exit(code);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const envPath = process.env.TRACES_BIN_PATH;
|
|
22
|
+
if (envPath) {
|
|
23
|
+
run(envPath);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const platformMap = {
|
|
27
|
+
darwin: "darwin",
|
|
28
|
+
linux: "linux",
|
|
29
|
+
win32: "windows",
|
|
30
|
+
};
|
|
31
|
+
const archMap = {
|
|
32
|
+
x64: "x64",
|
|
33
|
+
arm64: "arm64",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const platform = platformMap[os.platform()] ?? os.platform();
|
|
37
|
+
const arch = archMap[os.arch()] ?? os.arch();
|
|
38
|
+
|
|
39
|
+
if (!platformMap[os.platform()] || !archMap[os.arch()]) {
|
|
40
|
+
console.error(`Unsupported platform: ${os.platform()} ${os.arch()}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const packageName = `@traces-sh/traces-${platform}-${arch}`;
|
|
45
|
+
const binaryName = platform === "windows" ? "traces.exe" : "traces";
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const require = createRequire(__filename);
|
|
49
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
50
|
+
const packageDir = path.dirname(packageJsonPath);
|
|
51
|
+
const binaryPath = path.join(packageDir, "bin", binaryName);
|
|
52
|
+
|
|
53
|
+
if (!fs.existsSync(binaryPath)) {
|
|
54
|
+
throw new Error(`Binary not found at ${binaryPath}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
run(binaryPath);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error(
|
|
60
|
+
`Unable to locate the ${packageName} binary package. ` +
|
|
61
|
+
`Try reinstalling @traces-sh/traces or set TRACES_BIN_PATH to a valid binary.`
|
|
62
|
+
);
|
|
63
|
+
if (error && error.message) {
|
|
64
|
+
console.error(error.message);
|
|
65
|
+
}
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@traces-sh/traces",
|
|
3
|
+
"version": "0.1.23",
|
|
4
|
+
"description": "Traces CLI",
|
|
5
|
+
"bin": {
|
|
6
|
+
"traces": "./bin/traces"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node ./postinstall.mjs"
|
|
10
|
+
},
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"@traces-sh/traces-darwin-x64": "0.1.23",
|
|
13
|
+
"@traces-sh/traces-darwin-arm64": "0.1.23",
|
|
14
|
+
"@traces-sh/traces-linux-x64": "0.1.23",
|
|
15
|
+
"@traces-sh/traces-linux-arm64": "0.1.23",
|
|
16
|
+
"@traces-sh/traces-windows-x64": "0.1.23"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import os from "os";
|
|
4
|
+
import { createRequire } from "module";
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
const platformMap = {
|
|
9
|
+
darwin: "darwin",
|
|
10
|
+
linux: "linux",
|
|
11
|
+
win32: "windows",
|
|
12
|
+
};
|
|
13
|
+
const archMap = {
|
|
14
|
+
x64: "x64",
|
|
15
|
+
arm64: "arm64",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const platform = platformMap[os.platform()] ?? os.platform();
|
|
19
|
+
const arch = archMap[os.arch()] ?? os.arch();
|
|
20
|
+
|
|
21
|
+
if (!platformMap[os.platform()] || !archMap[os.arch()]) {
|
|
22
|
+
console.error(`Unsupported platform: ${os.platform()} ${os.arch()}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const packageName = `@traces-sh/traces-${platform}-${arch}`;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
require.resolve(`${packageName}/package.json`);
|
|
30
|
+
console.log(`Verified ${packageName}`);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(`Failed to locate ${packageName}.`);
|
|
33
|
+
if (error && error.message) {
|
|
34
|
+
console.error(error.message);
|
|
35
|
+
}
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|