jbs-client 0.0.3 → 0.0.5
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/jbs-client.js +71 -0
- package/package.json +8 -10
- package/bin/jbs-client +0 -70
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
|
|
8
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
shell: false,
|
|
12
|
+
});
|
|
13
|
+
if (result.error) {
|
|
14
|
+
console.error(result.error.message);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
process.exit(typeof result.status === "number" ? result.status : 0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const envPath = process.env.JBS_CLIENT_BIN_PATH;
|
|
21
|
+
if (envPath) {
|
|
22
|
+
run(envPath);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const scriptPath = fs.realpathSync(__filename);
|
|
26
|
+
const scriptDir = path.dirname(scriptPath);
|
|
27
|
+
const cached = path.join(scriptDir, ".jbs-client");
|
|
28
|
+
if (fs.existsSync(cached)) {
|
|
29
|
+
run(cached);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const platformMap = {
|
|
33
|
+
darwin: "darwin",
|
|
34
|
+
linux: "linux",
|
|
35
|
+
win32: "windows",
|
|
36
|
+
};
|
|
37
|
+
const archMap = {
|
|
38
|
+
x64: "x64",
|
|
39
|
+
arm64: "arm64",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const platform = platformMap[os.platform()] || os.platform();
|
|
43
|
+
const arch = archMap[os.arch()] || os.arch();
|
|
44
|
+
const packageName = `jbs-client-${platform}-${arch}`;
|
|
45
|
+
const binaryName = platform === "windows" ? "jbs-client.exe" : "jbs-client";
|
|
46
|
+
|
|
47
|
+
function findBinary(startDir) {
|
|
48
|
+
let current = startDir;
|
|
49
|
+
for (;;) {
|
|
50
|
+
const modules = path.join(current, "node_modules");
|
|
51
|
+
if (fs.existsSync(modules)) {
|
|
52
|
+
const candidate = path.join(modules, packageName, "bin", binaryName);
|
|
53
|
+
if (fs.existsSync(candidate)) {
|
|
54
|
+
return candidate;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const parent = path.dirname(current);
|
|
58
|
+
if (parent === current) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
current = parent;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const resolved = findBinary(scriptDir);
|
|
66
|
+
if (!resolved) {
|
|
67
|
+
console.error(`Unable to find installed binary package "${packageName}".`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
run(resolved);
|
package/package.json
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jbs-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "JBS Client terminal UI powered by OpenTUI",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/sunwu51/jbs-client-opentui.git"
|
|
9
9
|
},
|
|
10
|
-
"bin":
|
|
11
|
-
"jbs-client": "./bin/jbs-client"
|
|
12
|
-
},
|
|
10
|
+
"bin": "./bin/jbs-client.js",
|
|
13
11
|
"scripts": {
|
|
14
12
|
"postinstall": "node ./postinstall.mjs"
|
|
15
13
|
},
|
|
16
14
|
"optionalDependencies": {
|
|
17
|
-
"jbs-client-windows-x64": "0.0.
|
|
18
|
-
"jbs-client-windows-arm64": "0.0.
|
|
19
|
-
"jbs-client-linux-x64": "0.0.
|
|
20
|
-
"jbs-client-linux-arm64": "0.0.
|
|
21
|
-
"jbs-client-darwin-x64": "0.0.
|
|
22
|
-
"jbs-client-darwin-arm64": "0.0.
|
|
15
|
+
"jbs-client-windows-x64": "0.0.5",
|
|
16
|
+
"jbs-client-windows-arm64": "0.0.5",
|
|
17
|
+
"jbs-client-linux-x64": "0.0.5",
|
|
18
|
+
"jbs-client-linux-arm64": "0.0.5",
|
|
19
|
+
"jbs-client-darwin-x64": "0.0.5",
|
|
20
|
+
"jbs-client-darwin-arm64": "0.0.5"
|
|
23
21
|
}
|
|
24
22
|
}
|
package/bin/jbs-client
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const childProcess = require("child_process")
|
|
4
|
-
const fs = require("fs")
|
|
5
|
-
const path = require("path")
|
|
6
|
-
const os = require("os")
|
|
7
|
-
|
|
8
|
-
function run(target) {
|
|
9
|
-
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
-
stdio: "inherit",
|
|
11
|
-
})
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error(result.error.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
process.exit(typeof result.status === "number" ? result.status : 0)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const envPath = process.env.JBS_CLIENT_BIN_PATH
|
|
20
|
-
if (envPath) {
|
|
21
|
-
run(envPath)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
25
|
-
const scriptDir = path.dirname(scriptPath)
|
|
26
|
-
const cached = path.join(scriptDir, ".jbs-client")
|
|
27
|
-
if (fs.existsSync(cached)) {
|
|
28
|
-
run(cached)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const platformMap = {
|
|
32
|
-
darwin: "darwin",
|
|
33
|
-
linux: "linux",
|
|
34
|
-
win32: "windows",
|
|
35
|
-
}
|
|
36
|
-
const archMap = {
|
|
37
|
-
x64: "x64",
|
|
38
|
-
arm64: "arm64",
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const platform = platformMap[os.platform()] || os.platform()
|
|
42
|
-
const arch = archMap[os.arch()] || os.arch()
|
|
43
|
-
const packageName = `jbs-client-${platform}-${arch}`
|
|
44
|
-
const binaryName = platform === "windows" ? "jbs-client.exe" : "jbs-client"
|
|
45
|
-
|
|
46
|
-
function findBinary(startDir) {
|
|
47
|
-
let current = startDir
|
|
48
|
-
for (;;) {
|
|
49
|
-
const modules = path.join(current, "node_modules")
|
|
50
|
-
if (fs.existsSync(modules)) {
|
|
51
|
-
const candidate = path.join(modules, packageName, "bin", binaryName)
|
|
52
|
-
if (fs.existsSync(candidate)) {
|
|
53
|
-
return candidate
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
const parent = path.dirname(current)
|
|
57
|
-
if (parent === current) {
|
|
58
|
-
return undefined
|
|
59
|
-
}
|
|
60
|
-
current = parent
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const resolved = findBinary(scriptDir)
|
|
65
|
-
if (!resolved) {
|
|
66
|
-
console.error(`Unable to find installed binary package "${packageName}".`)
|
|
67
|
-
process.exit(1)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
run(resolved)
|