juggernaut-bedrock 4.2.1 → 4.2.3

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/index.js +63 -25
  2. package/package.json +9 -6
package/index.js CHANGED
@@ -1,54 +1,92 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
 
3
- const path = require("path");
4
- const { spawnSync } = require("child_process");
4
+ var path = require("path");
5
+ var child_process = require("child_process");
6
+ var fs = require("fs");
5
7
 
6
- const PACKAGES_DIR = path.join(__dirname, "packages");
7
-
8
- const PLATFORM_MAP = {
9
- "linux-x64": "juggernaut-bedrock-linux-x64",
10
- "linux-arm64": "juggernaut-bedrock-linux-arm64",
11
- "darwin-x64": "juggernaut-bedrock-darwin-x64",
8
+ var PLATFORM_MAP = {
9
+ "linux-x64": "juggernaut-bedrock-linux-x64",
10
+ "linux-arm64": "juggernaut-bedrock-linux-arm64",
11
+ "darwin-x64": "juggernaut-bedrock-darwin-x64",
12
12
  "darwin-arm64": "juggernaut-bedrock-darwin-arm64",
13
- "win32-x64": "juggernaut-bedrock-win32-x64",
13
+ "win32-x64": "juggernaut-bedrock-win32-x64"
14
14
  };
15
15
 
16
+ var VALID_PACKAGES = [
17
+ "juggernaut-bedrock-linux-x64",
18
+ "juggernaut-bedrock-linux-arm64",
19
+ "juggernaut-bedrock-darwin-x64",
20
+ "juggernaut-bedrock-darwin-arm64",
21
+ "juggernaut-bedrock-win32-x64"
22
+ ];
23
+
24
+ /**
25
+ * @param {string} platform
26
+ * @param {string} arch
27
+ * @returns {string|void}
28
+ */
16
29
  function getPlatformPackage(platform, arch) {
17
- return PLATFORM_MAP[`${platform}-${arch}`] || null;
30
+ return PLATFORM_MAP[platform + "-" + arch] || void 0;
31
+ }
32
+
33
+ function containsPackage(pkgName) {
34
+ for (var i = 0; i < VALID_PACKAGES.length; i++) {
35
+ if (VALID_PACKAGES[i] === pkgName) {
36
+ return true;
37
+ }
38
+ }
39
+ return false;
40
+ }
41
+
42
+ /**
43
+ * @param {string} pkgName
44
+ * @param {string} platform
45
+ * @returns {string}
46
+ */
47
+ function resolvePkgDir(pkgName) {
48
+ try {
49
+ return path.dirname(require.resolve(pkgName + "/package.json"));
50
+ } catch (_) {
51
+ return path.join(__dirname, "packages", pkgName); // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
52
+ }
18
53
  }
19
54
 
20
55
  function getBinaryPath(pkgName, platform) {
21
- const binaryName = platform === "win32" ? "juggernaut.exe" : "juggernaut";
22
- return path.join(PACKAGES_DIR, pkgName, "bin", binaryName);
56
+ if (!containsPackage(pkgName)) {
57
+ throw new Error("unexpected package name: " + pkgName);
58
+ }
59
+ var binaryName = platform === "win32" ? "juggernaut.exe" : "juggernaut";
60
+ return path.join(resolvePkgDir(pkgName), "bin", binaryName); // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
23
61
  }
24
62
 
25
63
  if (require.main === module) {
26
- const pkg = getPlatformPackage(process.platform, process.arch);
64
+ var pkg = getPlatformPackage(process.platform, process.arch);
27
65
  if (!pkg) {
28
66
  process.stderr.write(
29
- `juggernaut-bedrock: unsupported platform ${process.platform}/${process.arch}\n` +
30
- `Please file an issue: https://github.com/jpvelasco/juggernaut/issues\n`
67
+ "juggernaut-bedrock: unsupported platform " + process.platform + "/" + process.arch + "\n" +
68
+ "Please file an issue: https://github.com/jpvelasco/juggernaut/issues\n"
31
69
  );
32
70
  process.exit(1);
33
71
  }
34
72
 
35
- const bin = getBinaryPath(pkg, process.platform);
36
- const fs = require("fs");
73
+ var bin = getBinaryPath(pkg, process.platform);
74
+ // nosemgrep: javascript_pathtraversal_rule-non-literal-fs-filename, javascript.lang.security.audit.detect-non-literal-fs-filename
37
75
  if (!fs.existsSync(bin)) {
38
76
  process.stderr.write(
39
- `juggernaut-bedrock: binary not found at ${bin}\n` +
40
- `Try reinstalling: npm install -g juggernaut-bedrock\n` +
41
- `If the problem persists, file an issue: https://github.com/jpvelasco/juggernaut/issues\n`
77
+ "juggernaut-bedrock: binary not found at " + bin + "\n" +
78
+ "Try reinstalling: npm install -g juggernaut-bedrock\n" +
79
+ "If the problem persists, file an issue: https://github.com/jpvelasco/juggernaut/issues\n"
42
80
  );
43
81
  process.exit(1);
44
82
  }
45
83
 
46
- // nosemgrep: javascript.lang.security.detect-child-process
47
- const result = spawnSync(bin, process.argv.slice(2), {
84
+ // nosemgrep: javascript.lang.security.detect-child-process, javascript_exec_rule-child-process
85
+ var result = child_process.spawnSync(bin, process.argv.slice(2), {
48
86
  stdio: "inherit",
49
- env: process.env,
87
+ env: process.env
50
88
  });
51
- process.exit(result.status ?? 1);
89
+ process.exit(result.status !== null ? result.status : 1);
52
90
  }
53
91
 
54
- module.exports = { getPlatformPackage, getBinaryPath };
92
+ module.exports = { getPlatformPackage: getPlatformPackage, getBinaryPath: getBinaryPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juggernaut-bedrock",
3
- "version": "4.2.1",
3
+ "version": "4.2.3",
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": "./index.js"
@@ -9,11 +9,11 @@
9
9
  "test": "node --test index.test.js"
10
10
  },
11
11
  "optionalDependencies": {
12
- "juggernaut-bedrock-linux-x64": "4.2.1",
13
- "juggernaut-bedrock-linux-arm64": "4.2.1",
14
- "juggernaut-bedrock-darwin-x64": "4.2.1",
15
- "juggernaut-bedrock-darwin-arm64": "4.2.1",
16
- "juggernaut-bedrock-win32-x64": "4.2.1"
12
+ "juggernaut-bedrock-linux-x64": "4.2.3",
13
+ "juggernaut-bedrock-linux-arm64": "4.2.3",
14
+ "juggernaut-bedrock-darwin-x64": "4.2.3",
15
+ "juggernaut-bedrock-darwin-arm64": "4.2.3",
16
+ "juggernaut-bedrock-win32-x64": "4.2.3"
17
17
  },
18
18
  "os": [
19
19
  "darwin",
@@ -40,6 +40,9 @@
40
40
  "sso",
41
41
  "developer-tools"
42
42
  ],
43
+ "engines": {
44
+ "node": ">=20.0.0"
45
+ },
43
46
  "license": "MIT",
44
47
  "repository": {
45
48
  "type": "git",