yoop 0.1.0 → 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.
Files changed (2) hide show
  1. package/bin.js +70 -70
  2. 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
- "linux-x64": {
12
- packages: ["@sanchxt/yoop-linux-x64-musl", "@sanchxt/yoop-linux-x64-gnu"],
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
- },
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
- const platform = process.platform;
33
- const arch = process.arch;
34
- const key = `${platform}-${arch}`;
29
+ const platform = process.platform;
30
+ const arch = process.arch;
31
+ const key = `${platform}-${arch}`;
35
32
 
36
- const platformConfig = PLATFORMS[key];
37
- if (!platformConfig) {
38
- console.error(`Error: Unsupported platform: ${platform}-${arch}`);
39
- console.error("Supported platforms: linux-x64, linux-arm64, darwin-x64, darwin-arm64, win32-x64");
40
- process.exit(1);
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
- const binName = platform === "win32" ? "yoop.exe" : "yoop";
42
+ const binName = platform === "win32" ? "yoop.exe" : "yoop";
44
43
 
45
- // Try each package in order (musl first for Linux, as it's more portable)
46
- for (const packageName of platformConfig.packages) {
47
- try {
48
- const packagePath = require.resolve(`${packageName}/package.json`);
49
- const binPath = path.join(path.dirname(packagePath), "bin", binName);
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
- if (fs.existsSync(binPath)) {
52
- return binPath;
53
- }
54
- } catch {
55
- // Package not installed, try next
56
- continue;
53
+ if (fs.existsSync(binPath)) {
54
+ return binPath;
55
+ }
56
+ } catch {
57
+ continue;
58
+ }
57
59
  }
58
- }
59
60
 
60
- console.error(`Error: Could not find yoop binary for ${platform}-${arch}`);
61
- console.error("");
62
- console.error("This usually means the platform-specific package failed to install.");
63
- console.error("Try reinstalling:");
64
- console.error(" npm install -g yoop");
65
- console.error("");
66
- console.error("If the problem persists, please file an issue at:");
67
- console.error(" https://github.com/sanchxt/yoop/issues");
68
- process.exit(1);
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
- const binPath = getBinaryPath();
75
+ const binPath = getBinaryPath();
76
76
 
77
- const child = spawn(binPath, process.argv.slice(2), {
78
- stdio: "inherit",
79
- shell: false,
80
- });
77
+ const child = spawn(binPath, process.argv.slice(2), {
78
+ stdio: "inherit",
79
+ shell: false,
80
+ });
81
81
 
82
- child.on("error", (err) => {
83
- console.error(`Error: Failed to execute yoop: ${err.message}`);
84
- process.exit(1);
85
- });
82
+ child.on("error", (err) => {
83
+ console.error(`Error: Failed to execute yoop: ${err.message}`);
84
+ process.exit(1);
85
+ });
86
86
 
87
- child.on("exit", (code, signal) => {
88
- if (signal) {
89
- process.exit(1);
90
- }
91
- process.exit(code ?? 0);
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.0",
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.0",
37
- "@sanchxt/yoop-linux-x64-musl": "0.1.0",
38
- "@sanchxt/yoop-linux-arm64-gnu": "0.1.0",
39
- "@sanchxt/yoop-darwin-x64": "0.1.0",
40
- "@sanchxt/yoop-darwin-arm64": "0.1.0",
41
- "@sanchxt/yoop-win32-x64-msvc": "0.1.0"
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
  }