docbrain 0.1.3
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.
- package/install.js +62 -0
- package/package.json +36 -0
- package/run.js +18 -0
package/install.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const os = require("os");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const VERSION = require("./package.json").version;
|
|
10
|
+
|
|
11
|
+
const PLATFORM_MAP = { darwin: "darwin", linux: "linux" };
|
|
12
|
+
const ARCH_MAP = { x64: "amd64", arm64: "arm64" };
|
|
13
|
+
|
|
14
|
+
const platform = PLATFORM_MAP[os.platform()];
|
|
15
|
+
const arch = ARCH_MAP[os.arch()];
|
|
16
|
+
|
|
17
|
+
if (!platform || !arch) {
|
|
18
|
+
console.error(
|
|
19
|
+
`Unsupported platform: ${os.platform()}-${os.arch()}. DocBrain CLI supports macOS and Linux (x64, arm64).`
|
|
20
|
+
);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const binaryName = `docbrain-${platform}-${arch}`;
|
|
25
|
+
const url = `https://github.com/docbrain-ai/docbrain/releases/download/v${VERSION}/${binaryName}`;
|
|
26
|
+
const binDir = path.join(__dirname, "bin");
|
|
27
|
+
const dest = path.join(binDir, "docbrain");
|
|
28
|
+
|
|
29
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
30
|
+
|
|
31
|
+
function download(url) {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
https
|
|
34
|
+
.get(url, (res) => {
|
|
35
|
+
// GitHub releases redirect to S3
|
|
36
|
+
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
37
|
+
return download(res.headers.location).then(resolve).catch(reject);
|
|
38
|
+
}
|
|
39
|
+
if (res.statusCode !== 200) {
|
|
40
|
+
reject(new Error(`Download failed: HTTP ${res.statusCode}`));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const file = fs.createWriteStream(dest);
|
|
44
|
+
res.pipe(file);
|
|
45
|
+
file.on("finish", () => {
|
|
46
|
+
file.close();
|
|
47
|
+
fs.chmodSync(dest, 0o755);
|
|
48
|
+
resolve();
|
|
49
|
+
});
|
|
50
|
+
file.on("error", reject);
|
|
51
|
+
})
|
|
52
|
+
.on("error", reject);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
download(url)
|
|
57
|
+
.then(() => console.log(`DocBrain CLI v${VERSION} installed (${platform}/${arch})`))
|
|
58
|
+
.catch((err) => {
|
|
59
|
+
console.error(`Failed to install DocBrain CLI: ${err.message}`);
|
|
60
|
+
console.error(`You can download manually from: https://github.com/docbrain-ai/docbrain/releases`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docbrain",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "AI-powered documentation intelligence CLI",
|
|
5
|
+
"homepage": "https://github.com/docbrain-ai/docbrain",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/docbrain-ai/docbrain.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "BSL-1.1",
|
|
11
|
+
"bin": {
|
|
12
|
+
"docbrain": "run.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node install.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"docbrain",
|
|
19
|
+
"documentation",
|
|
20
|
+
"rag",
|
|
21
|
+
"ai",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"os": [
|
|
25
|
+
"darwin",
|
|
26
|
+
"linux"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=16"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"run.js",
|
|
33
|
+
"install.js",
|
|
34
|
+
"bin/"
|
|
35
|
+
]
|
|
36
|
+
}
|
package/run.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
|
|
7
|
+
const binary = path.join(__dirname, "bin", "docbrain");
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
11
|
+
} catch (err) {
|
|
12
|
+
if (err.status !== null) {
|
|
13
|
+
process.exit(err.status);
|
|
14
|
+
}
|
|
15
|
+
console.error(`Failed to run DocBrain CLI: ${err.message}`);
|
|
16
|
+
console.error("Try reinstalling: npm install -g docbrain");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|