repo-falcon 0.6.2
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 +77 -0
- package/package.json +34 -0
- package/postinstall.js +12 -0
- package/run.js +26 -0
package/install.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const crypto = require("crypto");
|
|
7
|
+
|
|
8
|
+
const PLATFORM_MAP = { darwin: "darwin", linux: "linux", win32: "windows" };
|
|
9
|
+
const ARCH_MAP = { x64: "amd64", arm64: "arm64" };
|
|
10
|
+
const REPO = "SocialGouv/repo-falcon";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Ensures the falcon binary is downloaded and available.
|
|
14
|
+
* Returns the absolute path to the binary.
|
|
15
|
+
*/
|
|
16
|
+
async function ensureBinary() {
|
|
17
|
+
const goos = PLATFORM_MAP[process.platform];
|
|
18
|
+
const goarch = ARCH_MAP[process.arch];
|
|
19
|
+
if (!goos || !goarch) {
|
|
20
|
+
throw new Error(`unsupported platform ${process.platform}/${process.arch}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { version } = require("./package.json");
|
|
24
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
25
|
+
const binDir = path.join(__dirname, "bin");
|
|
26
|
+
const binPath = path.join(binDir, `falcon${ext}`);
|
|
27
|
+
const versionFile = path.join(binDir, ".version");
|
|
28
|
+
|
|
29
|
+
// Skip if already installed at this version
|
|
30
|
+
if (fs.existsSync(binPath) && fs.existsSync(versionFile)) {
|
|
31
|
+
const installed = fs.readFileSync(versionFile, "utf8").trim();
|
|
32
|
+
if (installed === version) {
|
|
33
|
+
return binPath;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const filename = `falcon-${goos}-${goarch}${ext}`;
|
|
38
|
+
const baseUrl = `https://github.com/${REPO}/releases/download/v${version}`;
|
|
39
|
+
const binaryUrl = `${baseUrl}/${filename}`;
|
|
40
|
+
const checksumUrl = `${binaryUrl}.sha256`;
|
|
41
|
+
|
|
42
|
+
console.error(`repo-falcon: downloading v${version} (${goos}/${goarch})...`);
|
|
43
|
+
|
|
44
|
+
const binaryBuf = await download(binaryUrl);
|
|
45
|
+
|
|
46
|
+
// Verify checksum
|
|
47
|
+
if (process.env.REPO_FALCON_SKIP_CHECKSUM) {
|
|
48
|
+
console.error("repo-falcon: skipping checksum verification (REPO_FALCON_SKIP_CHECKSUM is set)");
|
|
49
|
+
} else {
|
|
50
|
+
const checksumBuf = await download(checksumUrl);
|
|
51
|
+
const expectedHash = checksumBuf.toString("utf8").split(/\s+/)[0];
|
|
52
|
+
const actualHash = crypto.createHash("sha256").update(binaryBuf).digest("hex");
|
|
53
|
+
if (actualHash !== expectedHash) {
|
|
54
|
+
throw new Error(`checksum mismatch (expected ${expectedHash}, got ${actualHash})`);
|
|
55
|
+
}
|
|
56
|
+
console.error("repo-falcon: checksum verified");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Write binary
|
|
60
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
61
|
+
fs.writeFileSync(binPath, binaryBuf);
|
|
62
|
+
fs.chmodSync(binPath, 0o755);
|
|
63
|
+
fs.writeFileSync(versionFile, version);
|
|
64
|
+
|
|
65
|
+
console.error(`repo-falcon: v${version} installed`);
|
|
66
|
+
return binPath;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function download(url) {
|
|
70
|
+
const res = await fetch(url, { redirect: "follow" });
|
|
71
|
+
if (!res.ok) {
|
|
72
|
+
throw new Error(`Failed to download ${url}: ${res.status} ${res.statusText}`);
|
|
73
|
+
}
|
|
74
|
+
return Buffer.from(await res.arrayBuffer());
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { ensureBinary };
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "repo-falcon",
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "RepoFalcon — code knowledge graph CLI for coding agents",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/SocialGouv/repo-falcon.git",
|
|
9
|
+
"directory": "npm"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"repo-falcon": "run.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node postinstall.js"
|
|
16
|
+
},
|
|
17
|
+
"os": [
|
|
18
|
+
"darwin",
|
|
19
|
+
"linux",
|
|
20
|
+
"win32"
|
|
21
|
+
],
|
|
22
|
+
"cpu": [
|
|
23
|
+
"x64",
|
|
24
|
+
"arm64"
|
|
25
|
+
],
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"install.js",
|
|
31
|
+
"postinstall.js",
|
|
32
|
+
"run.js"
|
|
33
|
+
]
|
|
34
|
+
}
|
package/postinstall.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
if (process.env.REPO_FALCON_SKIP_INSTALL) {
|
|
5
|
+
console.log("repo-falcon: skipping binary download (REPO_FALCON_SKIP_INSTALL is set)");
|
|
6
|
+
process.exit(0);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
require("./install").ensureBinary().catch((err) => {
|
|
10
|
+
console.error(`repo-falcon: ${err.message}`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
package/run.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { execFileSync } = require("child_process");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
9
|
+
const bin = path.join(__dirname, "bin", "falcon" + ext);
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
// If binary is missing (postinstall failed or --ignore-scripts), download it now
|
|
13
|
+
if (!fs.existsSync(bin)) {
|
|
14
|
+
await require("./install").ensureBinary();
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
execFileSync(bin, process.argv.slice(2), { stdio: "inherit" });
|
|
18
|
+
} catch (e) {
|
|
19
|
+
process.exit(e.status ?? 1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main().catch((e) => {
|
|
24
|
+
console.error(`repo-falcon: ${e.message}`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|