juggernaut-bedrock 4.0.0

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.
Files changed (2) hide show
  1. package/install.js +116 -0
  2. package/package.json +24 -0
package/install.js ADDED
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ const https = require("https");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+ const crypto = require("crypto");
8
+
9
+ const REPO = "jpvelasco/juggernaut";
10
+ const BIN_DIR = path.join(__dirname, "bin");
11
+
12
+ function getPlatform() {
13
+ const osMap = { darwin: "darwin", linux: "linux", win32: "windows" };
14
+ const archMap = { x64: "amd64", arm64: "arm64" };
15
+ const p = osMap[process.platform];
16
+ const a = archMap[process.arch];
17
+ if (!p || !a) {
18
+ throw new Error(`Unsupported platform: ${process.platform}/${process.arch}`);
19
+ }
20
+ return { os: p, arch: a, platform: `${p}_${a}` };
21
+ }
22
+
23
+ function httpsGet(url) {
24
+ return new Promise((resolve, reject) => {
25
+ https
26
+ .get(url, { headers: { "User-Agent": "juggernaut-npm-installer/1.0" } }, (res) => {
27
+ if (res.statusCode === 301 || res.statusCode === 302) {
28
+ return httpsGet(res.headers.location).then(resolve).catch(reject);
29
+ }
30
+ const chunks = [];
31
+ res.on("data", (chunk) => chunks.push(chunk));
32
+ res.on("end", () => resolve(Buffer.concat(chunks)));
33
+ res.on("error", reject);
34
+ })
35
+ .on("error", reject);
36
+ });
37
+ }
38
+
39
+ function downloadFile(url, dest) {
40
+ return new Promise((resolve, reject) => {
41
+ const file = fs.createWriteStream(dest);
42
+ function fetch(fetchUrl) {
43
+ https
44
+ .get(fetchUrl, { headers: { "User-Agent": "juggernaut-npm-installer/1.0" } }, (res) => {
45
+ if (res.statusCode === 301 || res.statusCode === 302) {
46
+ return fetch(res.headers.location);
47
+ }
48
+ res.pipe(file);
49
+ file.on("finish", () => file.close(resolve));
50
+ file.on("error", reject);
51
+ })
52
+ .on("error", reject);
53
+ }
54
+ fetch(url);
55
+ });
56
+ }
57
+
58
+ async function getLatestVersion() {
59
+ const data = await httpsGet(`https://api.github.com/repos/${REPO}/releases/latest`);
60
+ const release = JSON.parse(data.toString());
61
+ return release.tag_name.replace(/^v/, "");
62
+ }
63
+
64
+ async function main() {
65
+ const { platform, os: osName } = getPlatform();
66
+ const version = await getLatestVersion();
67
+ const ext = osName === "windows" ? "zip" : "tar.gz";
68
+ const archive = `juggernaut_${platform}.${ext}`;
69
+ const baseUrl = `https://github.com/${REPO}/releases/download/v${version}`;
70
+
71
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "juggernaut-"));
72
+ const archivePath = path.join(tmp, archive);
73
+ const checksumPath = path.join(tmp, "checksums.txt");
74
+
75
+ try {
76
+ console.log(`Downloading Juggernaut v${version} (${platform})...`);
77
+ await downloadFile(`${baseUrl}/${archive}`, archivePath);
78
+ await downloadFile(`${baseUrl}/checksums.txt`, checksumPath);
79
+
80
+ // Verify checksum.
81
+ const checksums = fs.readFileSync(checksumPath, "utf8");
82
+ const line = checksums.split("\n").find((l) => l.includes(archive));
83
+ if (!line) throw new Error(`Checksum not found for ${archive}`);
84
+ const expected = line.trim().split(/\s+/)[0].toLowerCase();
85
+ const actual = crypto
86
+ .createHash("sha256")
87
+ .update(fs.readFileSync(archivePath))
88
+ .digest("hex")
89
+ .toLowerCase();
90
+ if (actual !== expected) {
91
+ throw new Error(`Checksum mismatch for ${archive}\n expected: ${expected}\n got: ${actual}`);
92
+ }
93
+
94
+ fs.mkdirSync(BIN_DIR, { recursive: true });
95
+
96
+ if (ext === "zip") {
97
+ const AdmZip = require("adm-zip");
98
+ const zip = new AdmZip(archivePath);
99
+ zip.extractEntryTo("juggernaut.exe", BIN_DIR, false, true);
100
+ } else {
101
+ const tar = require("tar");
102
+ await tar.x({ file: archivePath, cwd: BIN_DIR });
103
+ fs.chmodSync(path.join(BIN_DIR, "juggernaut"), 0o755);
104
+ }
105
+
106
+ console.log(`Juggernaut v${version} installed successfully.`);
107
+ console.log(`Run: juggernaut apply`);
108
+ } finally {
109
+ fs.rmSync(tmp, { recursive: true, force: true });
110
+ }
111
+ }
112
+
113
+ main().catch((err) => {
114
+ console.error("Installation failed:", err.message);
115
+ process.exit(1);
116
+ });
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "juggernaut-bedrock",
3
+ "version": "4.0.0",
4
+ "description": "Configure Claude Code to use Amazon Bedrock — cross-platform installer",
5
+ "bin": {
6
+ "juggernaut": "./bin/juggernaut"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "dependencies": {
12
+ "tar": "^6.0.0",
13
+ "adm-zip": "^0.5.0"
14
+ },
15
+ "os": ["darwin", "linux", "win32"],
16
+ "cpu": ["x64", "arm64"],
17
+ "keywords": ["claude", "bedrock", "aws", "anthropic", "claude-code"],
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/jpvelasco/juggernaut"
22
+ },
23
+ "homepage": "https://github.com/jpvelasco/juggernaut#readme"
24
+ }