@agentfare/forge 0.1.0 → 0.2.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/install.js +24 -27
- package/package.json +2 -2
package/install.js
CHANGED
|
@@ -28,21 +28,27 @@ function getBinaryName() {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async function download(url, dest) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
let currentUrl = url;
|
|
32
|
+
while (true) {
|
|
33
|
+
const res = await new Promise((resolve, reject) => {
|
|
34
|
+
https
|
|
35
|
+
.get(currentUrl, { timeout: 30000 }, resolve)
|
|
36
|
+
.on("error", reject);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
40
|
+
res.destroy();
|
|
41
|
+
currentUrl = res.headers.location;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (res.statusCode !== 200) {
|
|
45
|
+
res.destroy();
|
|
46
|
+
throw new Error(`Download failed: HTTP ${res.statusCode}`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await pipeline(res, createWriteStream(dest));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
async function main() {
|
|
@@ -50,8 +56,7 @@ async function main() {
|
|
|
50
56
|
fs.mkdirSync(binDir, { recursive: true });
|
|
51
57
|
|
|
52
58
|
const { goos, goarch } = getPlatform();
|
|
53
|
-
const
|
|
54
|
-
const archiveName = `forge_${VERSION}_${goos}_${goarch}.${ext}`;
|
|
59
|
+
const archiveName = `forge_${VERSION}_${goos}_${goarch}.tar.gz`;
|
|
55
60
|
const url = `https://github.com/MjxUpUp/forge/releases/download/v${VERSION}/${archiveName}`;
|
|
56
61
|
|
|
57
62
|
const archivePath = path.join(binDir, archiveName);
|
|
@@ -60,16 +65,8 @@ async function main() {
|
|
|
60
65
|
await download(url, archivePath);
|
|
61
66
|
console.log(`Downloaded to ${archivePath}`);
|
|
62
67
|
|
|
63
|
-
// Extract
|
|
64
|
-
|
|
65
|
-
if (process.platform === "win32") {
|
|
66
|
-
execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${binDir}' -Force"`, { stdio: "inherit" });
|
|
67
|
-
} else {
|
|
68
|
-
execSync(`unzip -o "${archivePath}" -d "${binDir}"`, { stdio: "inherit" });
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
execSync(`tar xzf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
|
|
72
|
-
}
|
|
68
|
+
// Extract (tar.gz works on all platforms: Linux, macOS, Windows 10+)
|
|
69
|
+
execSync(`tar xzf "${archivePath}" -C "${binDir}"`, { stdio: "inherit" });
|
|
73
70
|
|
|
74
71
|
// Make executable
|
|
75
72
|
const binaryName = getBinaryName();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentfare/forge",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "AI
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "AI 开发质量门禁引擎 — 结构化门禁管道,在 AI 生成的代码进入仓库前进行质量锻造",
|
|
5
5
|
"bin": {
|
|
6
6
|
"forge": "run.js"
|
|
7
7
|
},
|