code-baseline 1.0.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/baseline +75 -0
  2. package/package.json +29 -0
package/bin/baseline ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process");
4
+ const { existsSync, chmodSync, statSync } = require("fs");
5
+ const path = require("path");
6
+
7
+ const PLATFORMS = {
8
+ "darwin-arm64": "code-baseline-darwin-arm64",
9
+ "darwin-x64": "code-baseline-darwin-x64",
10
+ "linux-x64": "code-baseline-linux-x64",
11
+ "linux-arm64": "code-baseline-linux-arm64",
12
+ "win32-x64": "code-baseline-win32-x64",
13
+ };
14
+
15
+ function getBinaryPath() {
16
+ // Allow override via environment variable
17
+ const override = process.env.BASELINE_BINARY;
18
+ if (override) {
19
+ return override;
20
+ }
21
+
22
+ const platformKey = `${process.platform}-${process.arch}`;
23
+ const pkg = PLATFORMS[platformKey];
24
+
25
+ if (!pkg) {
26
+ console.error(
27
+ `Unsupported platform: ${platformKey}\n` +
28
+ `code-baseline does not ship a prebuilt binary for your platform.\n\n` +
29
+ `You can install from source with:\n` +
30
+ ` cargo install code-baseline\n`
31
+ );
32
+ process.exit(1);
33
+ }
34
+
35
+ const binaryName = process.platform === "win32" ? "baseline.exe" : "baseline";
36
+
37
+ // Both packages live as siblings in the same node_modules directory
38
+ // __dirname = .../node_modules/code-baseline/bin
39
+ // sibling = .../node_modules/<platform-pkg>/baseline
40
+ const nodeModulesDir = path.resolve(__dirname, "..", "..");
41
+ const binaryPath = path.join(nodeModulesDir, pkg, binaryName);
42
+
43
+ if (existsSync(binaryPath)) {
44
+ // Ensure the binary is executable (npm tarballs may not preserve permissions)
45
+ if (process.platform !== "win32") {
46
+ const mode = statSync(binaryPath).mode;
47
+ if (!(mode & 0o111)) {
48
+ chmodSync(binaryPath, mode | 0o755);
49
+ }
50
+ }
51
+ return binaryPath;
52
+ }
53
+
54
+ console.error(
55
+ `Could not find the binary for ${pkg}.\n` +
56
+ `This usually means the optional dependency was not installed.\n\n` +
57
+ `Try reinstalling:\n` +
58
+ ` npm install -g code-baseline\n\n` +
59
+ `Or install from source:\n` +
60
+ ` cargo install code-baseline\n`
61
+ );
62
+ process.exit(1);
63
+ }
64
+
65
+ const binary = getBinaryPath();
66
+ const result = spawnSync(binary, process.argv.slice(2), {
67
+ stdio: "inherit",
68
+ });
69
+
70
+ if (result.error) {
71
+ console.error(`Failed to execute baseline: ${result.error.message}`);
72
+ process.exit(1);
73
+ }
74
+
75
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "code-baseline",
3
+ "version": "1.0.0",
4
+ "description": "Enforce architectural decisions AI coding tools keep ignoring",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/stewartjarod/baseline"
9
+ },
10
+ "bin": {
11
+ "baseline": "bin/baseline"
12
+ },
13
+ "files": [
14
+ "bin/baseline"
15
+ ],
16
+ "optionalDependencies": {
17
+ "code-baseline-darwin-arm64": "1.0.0",
18
+ "code-baseline-darwin-x64": "1.0.0",
19
+ "code-baseline-linux-x64": "1.0.0",
20
+ "code-baseline-linux-arm64": "1.0.0",
21
+ "code-baseline-win32-x64": "1.0.0"
22
+ },
23
+ "keywords": [
24
+ "linter",
25
+ "tailwind",
26
+ "react",
27
+ "code-quality"
28
+ ]
29
+ }