rust-doctor 0.1.1

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.
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const { spawnSync } = require("child_process");
6
+
7
+ const PLATFORM_PACKAGES = {
8
+ "darwin-x64": "@rust-doctor/darwin-x64",
9
+ "darwin-arm64": "@rust-doctor/darwin-arm64",
10
+ "linux-x64": "@rust-doctor/linux-x64",
11
+ "linux-arm64": "@rust-doctor/linux-arm64",
12
+ "win32-x64": "@rust-doctor/win32-x64",
13
+ };
14
+
15
+ function getBinaryPath() {
16
+ const key = `${process.platform}-${process.arch}`;
17
+ const pkg = PLATFORM_PACKAGES[key];
18
+ if (!pkg) {
19
+ throw new Error(
20
+ `rust-doctor: unsupported platform ${key}. Supported: ${Object.keys(PLATFORM_PACKAGES).join(", ")}`
21
+ );
22
+ }
23
+
24
+ const binaryName =
25
+ process.platform === "win32" ? "rust-doctor.exe" : "rust-doctor";
26
+ try {
27
+ return require.resolve(`${pkg}/bin/${binaryName}`);
28
+ } catch {
29
+ throw new Error(
30
+ `rust-doctor: could not find native binary for ${key}.\n` +
31
+ `Try reinstalling: npm install ${pkg}\n` +
32
+ `Or install directly: cargo install rust-doctor`
33
+ );
34
+ }
35
+ }
36
+
37
+ const result = spawnSync(getBinaryPath(), process.argv.slice(2), {
38
+ stdio: "inherit",
39
+ env: process.env,
40
+ });
41
+
42
+ if (result.error) {
43
+ console.error(`rust-doctor: failed to execute binary: ${result.error.message}`);
44
+ process.exit(1);
45
+ }
46
+
47
+ process.exit(result.status ?? 1);
package/install.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ // Postinstall script: verifies the native binary is available.
4
+ // The binary is provided by platform-specific optionalDependencies.
5
+
6
+ const { execFileSync } = require("child_process");
7
+
8
+ const PLATFORM_PACKAGES = {
9
+ "darwin-x64": "@rust-doctor/darwin-x64",
10
+ "darwin-arm64": "@rust-doctor/darwin-arm64",
11
+ "linux-x64": "@rust-doctor/linux-x64",
12
+ "linux-arm64": "@rust-doctor/linux-arm64",
13
+ "win32-x64": "@rust-doctor/win32-x64",
14
+ };
15
+
16
+ const key = `${process.platform}-${process.arch}`;
17
+ const pkg = PLATFORM_PACKAGES[key];
18
+
19
+ if (!pkg) {
20
+ console.warn(
21
+ `rust-doctor: no pre-built binary for ${key}. ` +
22
+ `Install from source: cargo install rust-doctor`
23
+ );
24
+ process.exit(0);
25
+ }
26
+
27
+ const binaryName =
28
+ process.platform === "win32" ? "rust-doctor.exe" : "rust-doctor";
29
+
30
+ try {
31
+ const binaryPath = require.resolve(`${pkg}/bin/${binaryName}`);
32
+ execFileSync(binaryPath, ["--version"], { stdio: "pipe" });
33
+ console.log(`rust-doctor: using native binary for ${key}`);
34
+ } catch {
35
+ console.warn(
36
+ `rust-doctor: native binary not found for ${key}. ` +
37
+ `The JS shim will attempt to locate it at runtime.`
38
+ );
39
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "rust-doctor",
3
+ "version": "0.1.1",
4
+ "description": "A unified code health tool for Rust — scan, score, and fix your codebase",
5
+ "license": "MIT OR Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/ArthurDEV44/rust-doctor"
9
+ },
10
+ "homepage": "https://github.com/ArthurDEV44/rust-doctor",
11
+ "keywords": [
12
+ "rust",
13
+ "linting",
14
+ "code-quality",
15
+ "health",
16
+ "diagnostics",
17
+ "mcp",
18
+ "clippy"
19
+ ],
20
+ "bin": {
21
+ "rust-doctor": "bin/rust-doctor.js"
22
+ },
23
+ "scripts": {
24
+ "postinstall": "node install.js"
25
+ },
26
+ "optionalDependencies": {
27
+ "@rust-doctor/darwin-x64": "0.1.1",
28
+ "@rust-doctor/darwin-arm64": "0.1.1",
29
+ "@rust-doctor/linux-x64": "0.1.1",
30
+ "@rust-doctor/linux-arm64": "0.1.1",
31
+ "@rust-doctor/win32-x64": "0.1.1"
32
+ },
33
+ "engines": {
34
+ "node": ">=16"
35
+ },
36
+ "files": [
37
+ "bin/",
38
+ "install.js"
39
+ ]
40
+ }