arklint 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/package.json +20 -0
  2. package/run.js +90 -0
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "arklint",
3
+ "version": "0.2.0",
4
+ "description": "The architectural rulebook for your codebase. Prevention, not detection.",
5
+ "bin": {
6
+ "arklint": "./run.js"
7
+ },
8
+ "files": [
9
+ "run.js"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/Kaushik13k/arklint"
14
+ },
15
+ "keywords": ["architecture", "linting", "cli", "code-quality", "ai"],
16
+ "license": "MIT",
17
+ "engines": {
18
+ "node": ">=16"
19
+ }
20
+ }
package/run.js ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const https = require("https");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const { spawnSync } = require("child_process");
8
+
9
+ const VERSION = require("./package.json").version;
10
+
11
+ const PLATFORM_MAP = {
12
+ "linux-x64": "arklint-linux-x86_64",
13
+ "darwin-x64": "arklint-darwin-x86_64",
14
+ "darwin-arm64": "arklint-darwin-arm64",
15
+ "win32-x64": "arklint-windows-x86_64.exe",
16
+ };
17
+
18
+ function getBinaryName() {
19
+ const key = `${process.platform}-${process.arch}`;
20
+ const name = PLATFORM_MAP[key];
21
+ if (!name) {
22
+ throw new Error(
23
+ `arklint does not have a prebuilt binary for ${key}.\n` +
24
+ `Please install via pip: pip install arklint`
25
+ );
26
+ }
27
+ return name;
28
+ }
29
+
30
+ function getLocalBinaryPath() {
31
+ const ext = process.platform === "win32" ? ".exe" : "";
32
+ return path.join(__dirname, "bin", `arklint${ext}`);
33
+ }
34
+
35
+ function download(url, dest) {
36
+ return new Promise((resolve, reject) => {
37
+ const file = fs.createWriteStream(dest);
38
+
39
+ function get(url) {
40
+ https.get(url, (res) => {
41
+ if (res.statusCode === 301 || res.statusCode === 302) {
42
+ get(res.headers.location);
43
+ return;
44
+ }
45
+ if (res.statusCode !== 200) {
46
+ file.close();
47
+ fs.unlinkSync(dest);
48
+ reject(new Error(`Download failed with status ${res.statusCode}`));
49
+ return;
50
+ }
51
+ res.pipe(file);
52
+ file.on("finish", () => file.close(resolve));
53
+ }).on("error", (err) => {
54
+ file.close();
55
+ fs.unlinkSync(dest);
56
+ reject(err);
57
+ });
58
+ }
59
+
60
+ get(url);
61
+ });
62
+ }
63
+
64
+ async function main() {
65
+ const binaryPath = getLocalBinaryPath();
66
+
67
+ if (!fs.existsSync(binaryPath)) {
68
+ const binaryName = getBinaryName();
69
+ const url = `https://github.com/Kaushik13k/arklint/releases/download/v${VERSION}/${binaryName}`;
70
+
71
+ process.stderr.write(`Downloading arklint v${VERSION} for ${process.platform}-${process.arch}...\n`);
72
+
73
+ fs.mkdirSync(path.join(__dirname, "bin"), { recursive: true });
74
+ await download(url, binaryPath);
75
+
76
+ if (process.platform !== "win32") {
77
+ fs.chmodSync(binaryPath, 0o755);
78
+ }
79
+
80
+ process.stderr.write(`Done.\n`);
81
+ }
82
+
83
+ const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
84
+ process.exit(result.status ?? 1);
85
+ }
86
+
87
+ main().catch((err) => {
88
+ process.stderr.write(`arklint error: ${err.message}\n`);
89
+ process.exit(1);
90
+ });