code-guardrails 0.2.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/guardrails +61 -0
  2. package/package.json +29 -0
package/bin/guardrails ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process");
4
+ const path = require("path");
5
+
6
+ const PLATFORMS = {
7
+ "darwin-arm64": "code-guardrails-darwin-arm64",
8
+ "darwin-x64": "code-guardrails-darwin-x64",
9
+ "linux-x64": "code-guardrails-linux-x64",
10
+ "linux-arm64": "code-guardrails-linux-arm64",
11
+ "win32-x64": "code-guardrails-win32-x64",
12
+ };
13
+
14
+ function getBinaryPath() {
15
+ // Allow override via environment variable
16
+ const override = process.env.GUARDRAILS_BINARY;
17
+ if (override) {
18
+ return override;
19
+ }
20
+
21
+ const platformKey = `${process.platform}-${process.arch}`;
22
+ const pkg = PLATFORMS[platformKey];
23
+
24
+ if (!pkg) {
25
+ console.error(
26
+ `Unsupported platform: ${platformKey}\n` +
27
+ `code-guardrails does not ship a prebuilt binary for your platform.\n\n` +
28
+ `You can install from source with:\n` +
29
+ ` cargo install guardrails\n`
30
+ );
31
+ process.exit(1);
32
+ }
33
+
34
+ const binaryName = process.platform === "win32" ? "guardrails.exe" : "guardrails";
35
+
36
+ try {
37
+ return require.resolve(path.join(pkg, binaryName));
38
+ } catch {
39
+ console.error(
40
+ `Could not find the binary for ${pkg}.\n` +
41
+ `This usually means the optional dependency was not installed.\n\n` +
42
+ `Try reinstalling:\n` +
43
+ ` npm install -g code-guardrails\n\n` +
44
+ `Or install from source:\n` +
45
+ ` cargo install guardrails\n`
46
+ );
47
+ process.exit(1);
48
+ }
49
+ }
50
+
51
+ const binary = getBinaryPath();
52
+ const result = spawnSync(binary, process.argv.slice(2), {
53
+ stdio: "inherit",
54
+ });
55
+
56
+ if (result.error) {
57
+ console.error(`Failed to execute guardrails: ${result.error.message}`);
58
+ process.exit(1);
59
+ }
60
+
61
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "code-guardrails",
3
+ "version": "0.2.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/guardrails"
9
+ },
10
+ "bin": {
11
+ "guardrails": "bin/guardrails"
12
+ },
13
+ "files": [
14
+ "bin/guardrails"
15
+ ],
16
+ "optionalDependencies": {
17
+ "code-guardrails-darwin-arm64": "0.2.0",
18
+ "code-guardrails-darwin-x64": "0.2.0",
19
+ "code-guardrails-linux-x64": "0.2.0",
20
+ "code-guardrails-linux-arm64": "0.2.0",
21
+ "code-guardrails-win32-x64": "0.2.0"
22
+ },
23
+ "keywords": [
24
+ "linter",
25
+ "tailwind",
26
+ "react",
27
+ "code-quality"
28
+ ]
29
+ }