juggernaut-bedrock 4.0.3 → 4.0.4
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 +72 -12
- package/package.json +2 -6
package/install.js
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
const https = require("https");
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const
|
|
6
|
+
const os = require("os");
|
|
7
7
|
const crypto = require("crypto");
|
|
8
|
+
const { execFile, execFileSync } = require("child_process");
|
|
9
|
+
const { promisify } = require("util");
|
|
10
|
+
|
|
11
|
+
const execFileAsync = promisify(execFile);
|
|
8
12
|
|
|
9
13
|
const REPO = "jpvelasco/juggernaut";
|
|
10
14
|
const BIN_DIR = path.join(__dirname, "bin");
|
|
@@ -58,18 +62,77 @@ async function getLatestVersion() {
|
|
|
58
62
|
return release.tag_name.replace(/^v/, "");
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
function pickArchive(platform, checksumsText) {
|
|
66
|
+
const tarArchive = `juggernaut_${platform}.tar.gz`;
|
|
67
|
+
if (checksumsText.includes(tarArchive)) {
|
|
68
|
+
return { name: tarArchive, kind: "tar.gz" };
|
|
69
|
+
}
|
|
70
|
+
const zipArchive = `juggernaut_${platform}.zip`;
|
|
71
|
+
if (process.platform === "win32" && checksumsText.includes(zipArchive)) {
|
|
72
|
+
return { name: zipArchive, kind: "zip" };
|
|
73
|
+
}
|
|
74
|
+
throw new Error(`No supported archive found in release checksums for ${platform}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function extractTarGz(archiveBuf) {
|
|
78
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "juggernaut-install-"));
|
|
79
|
+
const archivePath = path.join(tmpDir, "archive.tar.gz");
|
|
80
|
+
try {
|
|
81
|
+
fs.writeFileSync(archivePath, archiveBuf);
|
|
82
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
83
|
+
try {
|
|
84
|
+
execFileSync("tar", ["-xzf", archivePath, "-C", BIN_DIR], { stdio: "pipe" });
|
|
85
|
+
} catch (err) {
|
|
86
|
+
if (err.code === "ENOENT") {
|
|
87
|
+
throw new Error(
|
|
88
|
+
"tar not found on PATH. On Windows, use Windows 10 version 1803 or later (includes tar.exe)."
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const detail = err.stderr ? err.stderr.toString().trim() : err.message;
|
|
92
|
+
throw new Error(`tar extraction failed: ${detail}`);
|
|
93
|
+
}
|
|
94
|
+
if (process.platform !== "win32") {
|
|
95
|
+
const binPath = path.join(BIN_DIR, "juggernaut");
|
|
96
|
+
if (fs.existsSync(binPath)) {
|
|
97
|
+
fs.chmodSync(binPath, 0o700);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} finally {
|
|
101
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async function extractZip(archiveBuf) {
|
|
106
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "juggernaut-install-"));
|
|
107
|
+
const archivePath = path.join(tmpDir, "archive.zip");
|
|
108
|
+
try {
|
|
109
|
+
fs.writeFileSync(archivePath, archiveBuf);
|
|
110
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
111
|
+
const script = [
|
|
112
|
+
"$ErrorActionPreference = 'Stop'",
|
|
113
|
+
`Expand-Archive -LiteralPath '${archivePath.replace(/'/g, "''")}' -DestinationPath '${BIN_DIR.replace(/'/g, "''")}' -Force`
|
|
114
|
+
].join("; ");
|
|
115
|
+
await execFileAsync(
|
|
116
|
+
"powershell",
|
|
117
|
+
["-NoProfile", "-NonInteractive", "-Command", script],
|
|
118
|
+
{ stdio: "pipe" }
|
|
119
|
+
);
|
|
120
|
+
} finally {
|
|
121
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
61
125
|
async function main() {
|
|
62
|
-
const { platform
|
|
126
|
+
const { platform } = getPlatform();
|
|
63
127
|
const version = await getLatestVersion();
|
|
64
|
-
const ext = osName === "windows" ? "zip" : "tar.gz";
|
|
65
|
-
const archive = `juggernaut_${platform}.${ext}`;
|
|
66
128
|
const baseUrl = `https://github.com/${REPO}/releases/download/v${version}`;
|
|
129
|
+
const checksumsBuf = await httpsGetBuffer(`${baseUrl}/checksums.txt`);
|
|
130
|
+
const checksums = checksumsBuf.toString("utf8");
|
|
131
|
+
const { name: archive, kind } = pickArchive(platform, checksums);
|
|
67
132
|
|
|
68
133
|
console.log(`Downloading Juggernaut v${version} (${platform})...`);
|
|
69
134
|
const archiveBuf = await httpsGetBuffer(`${baseUrl}/${archive}`);
|
|
70
|
-
const checksumsBuf = await httpsGetBuffer(`${baseUrl}/checksums.txt`);
|
|
71
135
|
|
|
72
|
-
const checksums = checksumsBuf.toString("utf8");
|
|
73
136
|
const line = checksums.split("\n").find((l) => l.includes(archive));
|
|
74
137
|
if (!line) throw new Error(`Checksum not found for ${archive}`);
|
|
75
138
|
const expected = line.trim().split(/\s+/)[0].toLowerCase();
|
|
@@ -78,13 +141,10 @@ async function main() {
|
|
|
78
141
|
throw new Error(`Checksum mismatch for ${archive}\n expected: ${expected}\n got: ${actual}`);
|
|
79
142
|
}
|
|
80
143
|
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
const zip = new AdmZip(archiveBuf);
|
|
84
|
-
zip.extractEntryTo("juggernaut.exe", BIN_DIR, false, true);
|
|
144
|
+
if (kind === "zip") {
|
|
145
|
+
await extractZip(archiveBuf);
|
|
85
146
|
} else {
|
|
86
|
-
|
|
87
|
-
await tar.x({ cwd: BIN_DIR, mode: 0o700, strict: true }, Readable.from(archiveBuf));
|
|
147
|
+
extractTarGz(archiveBuf);
|
|
88
148
|
}
|
|
89
149
|
|
|
90
150
|
console.log(`Juggernaut v${version} installed successfully.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "juggernaut-bedrock",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Route Claude Code through Amazon Bedrock in one command — IAM, SSO, or API key. Cross-platform CLI for GenAI developers.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"juggernaut": "./bin/juggernaut"
|
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"postinstall": "node install.js"
|
|
10
10
|
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"tar": "7.5.16",
|
|
13
|
-
"adm-zip": "0.5.17"
|
|
14
|
-
},
|
|
15
11
|
"os": ["darwin", "linux", "win32"],
|
|
16
12
|
"cpu": ["x64", "arm64"],
|
|
17
13
|
"keywords": [
|
|
@@ -39,4 +35,4 @@
|
|
|
39
35
|
"url": "https://github.com/jpvelasco/juggernaut/issues"
|
|
40
36
|
},
|
|
41
37
|
"homepage": "https://github.com/jpvelasco/juggernaut#readme"
|
|
42
|
-
}
|
|
38
|
+
}
|