@sibyllinesoft/valknut 1.4.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/valknut +108 -0
  2. package/package.json +35 -0
package/bin/valknut ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const path = require("path");
5
+ const fs = require("fs");
6
+
7
+ const PLATFORMS = {
8
+ "linux-x64-gnu": "@sibyllinesoft/valknut-linux-x64-gnu",
9
+ "darwin-x64": "@sibyllinesoft/valknut-darwin-x64",
10
+ "darwin-arm64": "@sibyllinesoft/valknut-darwin-arm64",
11
+ "win32-x64": "@sibyllinesoft/valknut-win32-x64",
12
+ };
13
+
14
+ function getPlatformKey() {
15
+ const platform = process.platform;
16
+ const arch = process.arch;
17
+
18
+ if (platform === "win32" && arch === "x64") {
19
+ return "win32-x64";
20
+ }
21
+
22
+ if (platform === "darwin") {
23
+ return `darwin-${arch}`;
24
+ }
25
+
26
+ if (platform === "linux" && arch === "x64") {
27
+ // Only x86_64 glibc Linux is supported via npm
28
+ // For ARM Linux or musl, compile from source:
29
+ // cargo install --git https://github.com/NathanRiceDev/valknut
30
+ return "linux-x64-gnu";
31
+ }
32
+
33
+ return null;
34
+ }
35
+
36
+ function findBinary() {
37
+ const platformKey = getPlatformKey();
38
+
39
+ if (!platformKey) {
40
+ console.error(
41
+ `Unsupported platform: ${process.platform}-${process.arch}`
42
+ );
43
+ console.error("Supported platforms: " + Object.keys(PLATFORMS).join(", "));
44
+ process.exit(1);
45
+ }
46
+
47
+ const packageName = PLATFORMS[platformKey];
48
+ const binaryName = process.platform === "win32" ? "valknut.exe" : "valknut";
49
+
50
+ // Try to find the binary in node_modules
51
+ const possiblePaths = [
52
+ // Installed as dependency
53
+ path.join(__dirname, "..", "..", packageName, binaryName),
54
+ // Hoisted in node_modules
55
+ path.join(__dirname, "..", "..", "..", packageName, binaryName),
56
+ // pnpm/yarn PnP style
57
+ path.join(
58
+ __dirname,
59
+ "..",
60
+ "node_modules",
61
+ packageName,
62
+ binaryName
63
+ ),
64
+ ];
65
+
66
+ for (const binPath of possiblePaths) {
67
+ if (fs.existsSync(binPath)) {
68
+ return binPath;
69
+ }
70
+ }
71
+
72
+ // Try require.resolve as fallback
73
+ try {
74
+ const packagePath = require.resolve(`${packageName}/package.json`);
75
+ const binPath = path.join(path.dirname(packagePath), binaryName);
76
+ if (fs.existsSync(binPath)) {
77
+ return binPath;
78
+ }
79
+ } catch {
80
+ // Package not installed
81
+ }
82
+
83
+ console.error(`Could not find valknut binary for ${platformKey}`);
84
+ console.error(`Expected package: ${packageName}`);
85
+ console.error("");
86
+ console.error("This may happen if:");
87
+ console.error(" 1. Your platform is not supported");
88
+ console.error(" 2. The optional dependency failed to install");
89
+ console.error("");
90
+ console.error("Try reinstalling with:");
91
+ console.error(" npm install @sibyllinesoft/valknut");
92
+ process.exit(1);
93
+ }
94
+
95
+ const binary = findBinary();
96
+ const args = process.argv.slice(2);
97
+
98
+ try {
99
+ const result = execFileSync(binary, args, {
100
+ stdio: "inherit",
101
+ encoding: "utf8",
102
+ });
103
+ } catch (e) {
104
+ if (e.status !== undefined) {
105
+ process.exit(e.status);
106
+ }
107
+ throw e;
108
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@sibyllinesoft/valknut",
3
+ "version": "1.4.0",
4
+ "description": "High-performance Rust-native code analysis platform for refactorability scoring",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/NathanRiceDev/valknut.git"
8
+ },
9
+ "homepage": "https://github.com/NathanRiceDev/valknut",
10
+ "license": "MIT",
11
+ "author": "Nathan Rice <nathan@sibylline.dev>",
12
+ "keywords": [
13
+ "code-analysis",
14
+ "static-analysis",
15
+ "complexity",
16
+ "refactoring",
17
+ "ast",
18
+ "metrics"
19
+ ],
20
+ "bin": {
21
+ "valknut": "bin/valknut"
22
+ },
23
+ "files": [
24
+ "bin"
25
+ ],
26
+ "engines": {
27
+ "node": ">=14"
28
+ },
29
+ "optionalDependencies": {
30
+ "@sibyllinesoft/valknut-linux-x64-gnu": "1.4.0",
31
+ "@sibyllinesoft/valknut-darwin-x64": "1.4.0",
32
+ "@sibyllinesoft/valknut-darwin-arm64": "1.4.0",
33
+ "@sibyllinesoft/valknut-win32-x64": "1.4.0"
34
+ }
35
+ }