@librefang/cli 0.7.0

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/librefang.js +55 -0
  2. package/package.json +29 -0
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { execFileSync } = require("child_process");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+
8
+ const PLATFORM_MAP = {
9
+ linux: "linux",
10
+ darwin: "darwin",
11
+ win32: "win32",
12
+ };
13
+
14
+ const ARCH_MAP = {
15
+ x64: "x64",
16
+ arm64: "arm64",
17
+ };
18
+
19
+ function getBinaryPath() {
20
+ const platform = PLATFORM_MAP[process.platform];
21
+ const arch = ARCH_MAP[process.arch];
22
+
23
+ if (!platform || !arch) {
24
+ console.error(`Unsupported platform: ${process.platform} ${process.arch}`);
25
+ process.exit(1);
26
+ }
27
+
28
+ // Try glibc variant first, then musl for Linux
29
+ const candidates = [`@librefang/cli-${platform}-${arch}`];
30
+ if (platform === "linux") {
31
+ candidates.push(`@librefang/cli-${platform}-${arch}-musl`);
32
+ }
33
+
34
+ const exe = process.platform === "win32" ? "librefang.exe" : "librefang";
35
+
36
+ for (const pkg of candidates) {
37
+ try {
38
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
39
+ const bin = path.join(pkgDir, "bin", exe);
40
+ if (fs.existsSync(bin)) return bin;
41
+ } catch {}
42
+ }
43
+
44
+ console.error(
45
+ `Could not find librefang binary for ${process.platform}-${process.arch}.\n` +
46
+ `Try: npm install @librefang/cli-${platform}-${arch}`
47
+ );
48
+ process.exit(1);
49
+ }
50
+
51
+ try {
52
+ execFileSync(getBinaryPath(), process.argv.slice(2), { stdio: "inherit" });
53
+ } catch (err) {
54
+ process.exit(err.status ?? 1);
55
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@librefang/cli",
3
+ "version": "0.7.0",
4
+ "description": "LibreFang Agent OS — CLI binary distribution",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/librefang/librefang"
9
+ },
10
+ "bin": {
11
+ "librefang": "./bin/librefang.js"
12
+ },
13
+ "files": [
14
+ "bin/librefang.js"
15
+ ],
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "optionalDependencies": {
20
+ "@librefang/cli-linux-x64": "0.7.0",
21
+ "@librefang/cli-linux-arm64": "0.7.0",
22
+ "@librefang/cli-linux-x64-musl": "0.7.0",
23
+ "@librefang/cli-linux-arm64-musl": "0.7.0",
24
+ "@librefang/cli-darwin-x64": "0.7.0",
25
+ "@librefang/cli-darwin-arm64": "0.7.0",
26
+ "@librefang/cli-win32-x64": "0.7.0",
27
+ "@librefang/cli-win32-arm64": "0.7.0"
28
+ }
29
+ }