yoop 0.1.2 → 0.1.4
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.js +70 -70
- package/package.json +7 -7
package/bin.js
CHANGED
|
@@ -4,92 +4,92 @@ const { spawn } = require("child_process");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Platform to npm package name mapping
|
|
9
|
-
*/
|
|
10
7
|
const PLATFORMS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
"linux-x64": {
|
|
9
|
+
packages: [
|
|
10
|
+
"@sanchxt/yoop-linux-x64-musl",
|
|
11
|
+
"@sanchxt/yoop-linux-x64-gnu",
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
"linux-arm64": {
|
|
15
|
+
packages: ["@sanchxt/yoop-linux-arm64-gnu"],
|
|
16
|
+
},
|
|
17
|
+
"darwin-x64": {
|
|
18
|
+
packages: ["@sanchxt/yoop-darwin-x64"],
|
|
19
|
+
},
|
|
20
|
+
"darwin-arm64": {
|
|
21
|
+
packages: ["@sanchxt/yoop-darwin-arm64"],
|
|
22
|
+
},
|
|
23
|
+
"win32-x64": {
|
|
24
|
+
packages: ["@sanchxt/yoop-win32-x64-msvc"],
|
|
25
|
+
},
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
* Find the binary path for the current platform
|
|
30
|
-
*/
|
|
31
28
|
function getBinaryPath() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const platform = process.platform;
|
|
30
|
+
const arch = process.arch;
|
|
31
|
+
const key = `${platform}-${arch}`;
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const platformConfig = PLATFORMS[key];
|
|
34
|
+
if (!platformConfig) {
|
|
35
|
+
console.error(`Error: Unsupported platform: ${platform}-${arch}`);
|
|
36
|
+
console.error(
|
|
37
|
+
"Supported platforms: linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64"
|
|
38
|
+
);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
42
41
|
|
|
43
|
-
|
|
42
|
+
const binName = platform === "win32" ? "yoop.exe" : "yoop";
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
for (const packageName of platformConfig.packages) {
|
|
45
|
+
try {
|
|
46
|
+
const packagePath = require.resolve(`${packageName}/package.json`);
|
|
47
|
+
const binPath = path.join(
|
|
48
|
+
path.dirname(packagePath),
|
|
49
|
+
"bin",
|
|
50
|
+
binName
|
|
51
|
+
);
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
if (fs.existsSync(binPath)) {
|
|
54
|
+
return binPath;
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
57
59
|
}
|
|
58
|
-
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
console.error(`Error: Could not find yoop binary for ${platform}-${arch}`);
|
|
62
|
+
console.error("");
|
|
63
|
+
console.error(
|
|
64
|
+
"This usually means the platform-specific package failed to install."
|
|
65
|
+
);
|
|
66
|
+
console.error("Try reinstalling:");
|
|
67
|
+
console.error(" npm install -g yoop");
|
|
68
|
+
console.error("");
|
|
69
|
+
console.error("If the problem persists, please file an issue at:");
|
|
70
|
+
console.error(" https://github.com/sanchxt/yoop/issues");
|
|
71
|
+
process.exit(1);
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
/**
|
|
72
|
-
* Run the binary with the given arguments
|
|
73
|
-
*/
|
|
74
74
|
function run() {
|
|
75
|
-
|
|
75
|
+
const binPath = getBinaryPath();
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const child = spawn(binPath, process.argv.slice(2), {
|
|
78
|
+
stdio: "inherit",
|
|
79
|
+
shell: false,
|
|
80
|
+
});
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
child.on("error", (err) => {
|
|
83
|
+
console.error(`Error: Failed to execute yoop: ${err.message}`);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
child.on("exit", (code, signal) => {
|
|
88
|
+
if (signal) {
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
process.exit(code ?? 0);
|
|
92
|
+
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yoop",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Cross-platform local network file sharing - transfer files between devices on the same network using simple codes",
|
|
5
5
|
"bin": {
|
|
6
6
|
"yoop": "bin.js"
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"node": ">=16"
|
|
34
34
|
},
|
|
35
35
|
"optionalDependencies": {
|
|
36
|
-
"@sanchxt/yoop-linux-x64-gnu": "0.1.
|
|
37
|
-
"@sanchxt/yoop-linux-x64-musl": "0.1.
|
|
38
|
-
"@sanchxt/yoop-linux-arm64-gnu": "0.1.
|
|
39
|
-
"@sanchxt/yoop-darwin-x64": "0.1.
|
|
40
|
-
"@sanchxt/yoop-darwin-arm64": "0.1.
|
|
41
|
-
"@sanchxt/yoop-win32-x64-msvc": "0.1.
|
|
36
|
+
"@sanchxt/yoop-linux-x64-gnu": "0.1.4",
|
|
37
|
+
"@sanchxt/yoop-linux-x64-musl": "0.1.4",
|
|
38
|
+
"@sanchxt/yoop-linux-arm64-gnu": "0.1.4",
|
|
39
|
+
"@sanchxt/yoop-darwin-x64": "0.1.4",
|
|
40
|
+
"@sanchxt/yoop-darwin-arm64": "0.1.4",
|
|
41
|
+
"@sanchxt/yoop-win32-x64-msvc": "0.1.4"
|
|
42
42
|
}
|
|
43
43
|
}
|