@runaic/aic 0.1.0-rc.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.
- package/README.md +6 -0
- package/bin/aic.js +7 -0
- package/install.js +59 -0
- package/package.json +35 -0
package/README.md
ADDED
package/bin/aic.js
ADDED
package/install.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const { execSync } = require("child_process");
|
|
6
|
+
const zlib = require("zlib");
|
|
7
|
+
const tar = require("tar");
|
|
8
|
+
|
|
9
|
+
const pkg = require("./package.json");
|
|
10
|
+
const REPO = "learners-superpumped/aic";
|
|
11
|
+
const VERSION = `v${pkg.version}`;
|
|
12
|
+
const BIN_DIR = path.join(__dirname, "bin");
|
|
13
|
+
|
|
14
|
+
function platformTarget() {
|
|
15
|
+
const os = { darwin: "darwin", linux: "linux" }[process.platform];
|
|
16
|
+
const arch = { x64: "x86_64", arm64: "arm64" }[process.arch];
|
|
17
|
+
if (!os || !arch) {
|
|
18
|
+
throw new Error(`unsupported platform: ${process.platform}/${process.arch}`);
|
|
19
|
+
}
|
|
20
|
+
return { os, arch };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function download(url, dest) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
https.get(url, { headers: { "User-Agent": "aic-npm-installer" } }, (res) => {
|
|
26
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
27
|
+
return download(res.headers.location, dest).then(resolve, reject);
|
|
28
|
+
}
|
|
29
|
+
if (res.statusCode !== 200) {
|
|
30
|
+
return reject(new Error(`HTTP ${res.statusCode} from ${url}`));
|
|
31
|
+
}
|
|
32
|
+
const file = fs.createWriteStream(dest);
|
|
33
|
+
res.pipe(file);
|
|
34
|
+
file.on("finish", () => file.close(resolve));
|
|
35
|
+
file.on("error", reject);
|
|
36
|
+
}).on("error", reject);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
const { os, arch } = platformTarget();
|
|
42
|
+
const archive = `aic_${pkg.version}_${os}_${arch}.tar.gz`;
|
|
43
|
+
const url = `https://github.com/${REPO}/releases/download/${VERSION}/${archive}`;
|
|
44
|
+
const tmpArchive = path.join(BIN_DIR, archive);
|
|
45
|
+
|
|
46
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
47
|
+
console.log(`aic: downloading ${url}`);
|
|
48
|
+
await download(url, tmpArchive);
|
|
49
|
+
|
|
50
|
+
await tar.x({ file: tmpArchive, cwd: BIN_DIR, filter: (p) => p === "aic" });
|
|
51
|
+
fs.chmodSync(path.join(BIN_DIR, "aic"), 0o755);
|
|
52
|
+
fs.unlinkSync(tmpArchive);
|
|
53
|
+
console.log("aic: install complete");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
main().catch((err) => {
|
|
57
|
+
console.error("aic: install failed:", err.message);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@runaic/aic",
|
|
3
|
+
"version": "0.1.0-rc.1",
|
|
4
|
+
"description": "Run AI Company CLI — npm wrapper around the official aic Go binary",
|
|
5
|
+
"bin": {
|
|
6
|
+
"aic": "bin/aic.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node install.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"install.js",
|
|
13
|
+
"bin/",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/learners-superpumped/aic.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"os": [
|
|
25
|
+
"darwin",
|
|
26
|
+
"linux"
|
|
27
|
+
],
|
|
28
|
+
"cpu": [
|
|
29
|
+
"x64",
|
|
30
|
+
"arm64"
|
|
31
|
+
],
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"tar": "^7.4.3"
|
|
34
|
+
}
|
|
35
|
+
}
|