@onkernel/cli 0.10.2 → 0.10.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/lib.js +54 -9
  2. package/package.json +20 -19
package/lib.js CHANGED
@@ -6,8 +6,11 @@ const path = require("path");
6
6
  const JSZip = require("jszip");
7
7
  const tar = require("tar");
8
8
  const axios = require("axios");
9
+ const { ProxyAgent } = require("proxy-agent");
9
10
  const { spawnSync } = require("child_process");
10
11
 
12
+ const agent = new ProxyAgent();
13
+
11
14
  const getArchive = () => {
12
15
  let target = `${process.platform}-${process.arch}`;
13
16
  const archive = archives[target];
@@ -19,31 +22,61 @@ const getArchive = () => {
19
22
 
20
23
  const binDir = path.join(__dirname, "bin");
21
24
 
22
- async function extractTar(tarPath, binaries, dir) {
25
+ async function extractTar(tarPath, binaries, dir, wrappedIn) {
23
26
  try {
27
+ const filesToExtract = wrappedIn
28
+ ? binaries.map((bin) =>
29
+ path.join(wrappedIn, bin).replace(/\\/g, "/"),
30
+ )
31
+ : binaries;
32
+
24
33
  await tar.x({
25
34
  file: tarPath,
26
35
  cwd: dir,
27
- filter: (path) => binaries.includes(path),
36
+ filter: (path) => filesToExtract.includes(path),
28
37
  });
29
- console.log(`Successfully extracted binaries to "${dir}"`);
38
+
39
+ // If wrapped, move files from wrapped directory to bin directory
40
+ if (wrappedIn) {
41
+ const wrappedDir = path.join(dir, wrappedIn);
42
+ for (const binary of binaries) {
43
+ const srcPath = path.join(wrappedDir, binary);
44
+ const destPath = path.join(dir, binary);
45
+ if (fs.existsSync(srcPath)) {
46
+ fs.renameSync(srcPath, destPath);
47
+ }
48
+ }
49
+ // Clean up empty wrapped directory
50
+ try {
51
+ fs.rmSync(wrappedDir, { recursive: true, force: true });
52
+ } catch (err) {
53
+ // Ignore cleanup errors
54
+ }
55
+ }
56
+
57
+ console.log(`Successfully extracted ${binaries} to "${dir}"`);
30
58
  } catch (err) {
31
59
  throw new Error(`Extraction failed: ${err.message}`);
32
60
  }
33
61
  }
34
62
 
35
- async function extractZip(zipPath, binaries, dir) {
63
+ async function extractZip(zipPath, binaries, dir, wrappedIn) {
36
64
  try {
37
65
  const zipData = fs.readFileSync(zipPath);
38
66
  const zip = await JSZip.loadAsync(zipData);
67
+
39
68
  for (const binary of binaries) {
40
- if (!zip.files[binary]) {
69
+ const binaryPath = wrappedIn
70
+ ? path.join(wrappedIn, binary).replace(/\\/g, "/")
71
+ : binary;
72
+
73
+ if (!zip.files[binaryPath]) {
41
74
  throw new Error(
42
- `Error: ${binary} does not exist in ${zipPath}`,
75
+ `Error: ${binaryPath} does not exist in ${zipPath}`,
43
76
  );
44
77
  }
45
78
 
46
- const content = await zip.files[binary].async("nodebuffer");
79
+ const content = await zip.files[binaryPath].async("nodebuffer");
47
80
  if (!fs.existsSync(dir)) {
48
81
  fs.mkdirSync(dir, { recursive: true });
49
82
  }
@@ -94,11 +127,21 @@ const install = async () => {
94
127
  fs.chmodSync(bin, 0o755);
95
128
  return;
96
129
  case "zip":
97
- return extractZip(archivePath, archive.bins, binDir);
130
+ return extractZip(
131
+ archivePath,
132
+ archive.bins,
133
+ binDir,
134
+ archive.wrappedIn,
135
+ );
98
136
  case "tar":
99
137
  case "tar.gz":
100
138
  case "tgz":
101
- return extractTar(archivePath, archive.bins, binDir);
139
+ return extractTar(
140
+ archivePath,
141
+ archive.bins,
142
+ binDir,
143
+ archive.wrappedIn,
144
+ );
102
145
  case "tar.zst":
103
146
  case "tzst":
104
147
  case "tar.xz":
@@ -140,6 +183,8 @@ const download = async (url, filename) => {
140
183
  url: url,
141
184
  responseType: "stream",
142
185
  timeout: 300000, // 5min
186
+ httpAgent: agent,
187
+ httpsAgent: agent,
143
188
  });
144
189
 
145
190
  const writer = fs.createWriteStream(filename);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onkernel/cli",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Kernel CLI",
5
5
  "scripts": {
6
6
  "postinstall": "node install.js",
@@ -29,79 +29,80 @@
29
29
  "dependencies": {
30
30
  "axios": "^1.8.2",
31
31
  "jszip": "^3.10.1",
32
+ "proxy-agent": "^6.5.0",
32
33
  "tar": "^7.4.3"
33
34
  },
34
35
  "archives": {
35
36
  "darwin-arm64": {
36
- "name": "kernel_0.10.2_darwin_arm64.tar.gz",
37
- "url": "https://github.com/onkernel/cli/releases/download/v0.10.2/kernel_0.10.2_darwin_arm64.tar.gz",
37
+ "name": "kernel_0.10.3_darwin_arm64.tar.gz",
38
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.3/kernel_0.10.3_darwin_arm64.tar.gz",
38
39
  "bins": [
39
40
  "kernel"
40
41
  ],
41
42
  "format": "tar.gz",
42
43
  "checksum": {
43
44
  "algorithm": "sha256",
44
- "digest": "117c02a06ee73fdbb91b9c2fa3ea427def7de2ef2d8c60a5c2390f61a646e7db"
45
+ "digest": "22fcb0c0fafe3d0722336c5894db94f457c9e44a691d66b38b7e5a85d37e6a26"
45
46
  }
46
47
  },
47
48
  "darwin-x64": {
48
- "name": "kernel_0.10.2_darwin_amd64.tar.gz",
49
- "url": "https://github.com/onkernel/cli/releases/download/v0.10.2/kernel_0.10.2_darwin_amd64.tar.gz",
49
+ "name": "kernel_0.10.3_darwin_amd64.tar.gz",
50
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.3/kernel_0.10.3_darwin_amd64.tar.gz",
50
51
  "bins": [
51
52
  "kernel"
52
53
  ],
53
54
  "format": "tar.gz",
54
55
  "checksum": {
55
56
  "algorithm": "sha256",
56
- "digest": "5456760000a041064dafda8c9cc184c89d3552154006a6f370b5dbd2841e4ab8"
57
+ "digest": "9a166306480a8b8daa3de3200c7247454b9a1181010d1885bcf88a2dec275df2"
57
58
  }
58
59
  },
59
60
  "linux-arm64": {
60
- "name": "kernel_0.10.2_linux_arm64.tar.gz",
61
- "url": "https://github.com/onkernel/cli/releases/download/v0.10.2/kernel_0.10.2_linux_arm64.tar.gz",
61
+ "name": "kernel_0.10.3_linux_arm64.tar.gz",
62
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.3/kernel_0.10.3_linux_arm64.tar.gz",
62
63
  "bins": [
63
64
  "kernel"
64
65
  ],
65
66
  "format": "tar.gz",
66
67
  "checksum": {
67
68
  "algorithm": "sha256",
68
- "digest": "5426208fa8116a12048a7ec8afbc2c2e9a79a5cdef3104d2f1d9380b5d76b557"
69
+ "digest": "baaf5757920ed9bcf8cb08ef2a9195377c07aab67abff9a47f4ce2e4e4403f8e"
69
70
  }
70
71
  },
71
72
  "linux-x64": {
72
- "name": "kernel_0.10.2_linux_amd64.tar.gz",
73
- "url": "https://github.com/onkernel/cli/releases/download/v0.10.2/kernel_0.10.2_linux_amd64.tar.gz",
73
+ "name": "kernel_0.10.3_linux_amd64.tar.gz",
74
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.3/kernel_0.10.3_linux_amd64.tar.gz",
74
75
  "bins": [
75
76
  "kernel"
76
77
  ],
77
78
  "format": "tar.gz",
78
79
  "checksum": {
79
80
  "algorithm": "sha256",
80
- "digest": "afc3dce0374a4738dc3971c9cf3ba8f75bda54272ce6f493680f2439b36ca4d6"
81
+ "digest": "6205bb5ff5cec729260294c0ba8b9a19e2287aa3754eb1f4a661e2c16ee85fcc"
81
82
  }
82
83
  },
83
84
  "win32-arm64": {
84
- "name": "kernel_0.10.2_windows_arm64.tar.gz",
85
- "url": "https://github.com/onkernel/cli/releases/download/v0.10.2/kernel_0.10.2_windows_arm64.tar.gz",
85
+ "name": "kernel_0.10.3_windows_arm64.tar.gz",
86
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.3/kernel_0.10.3_windows_arm64.tar.gz",
86
87
  "bins": [
87
88
  "kernel.exe"
88
89
  ],
89
90
  "format": "tar.gz",
90
91
  "checksum": {
91
92
  "algorithm": "sha256",
92
- "digest": "1ff7130ed53e428412647d7bc9907bba8150898fca61802ce5bccfa74f196a72"
93
+ "digest": "efecc450df76d7460d17062f34128ddf3eefb689f4ca17ec0cd580365c35dd60"
93
94
  }
94
95
  },
95
96
  "win32-x64": {
96
- "name": "kernel_0.10.2_windows_amd64.tar.gz",
97
- "url": "https://github.com/onkernel/cli/releases/download/v0.10.2/kernel_0.10.2_windows_amd64.tar.gz",
97
+ "name": "kernel_0.10.3_windows_amd64.tar.gz",
98
+ "url": "https://github.com/onkernel/cli/releases/download/v0.10.3/kernel_0.10.3_windows_amd64.tar.gz",
98
99
  "bins": [
99
100
  "kernel.exe"
100
101
  ],
101
102
  "format": "tar.gz",
102
103
  "checksum": {
103
104
  "algorithm": "sha256",
104
- "digest": "dd3300a9ede1ea056d2516e5cca841702e57a669625ddf4f149dda4b4c5940f7"
105
+ "digest": "a967faf273e30f0e3eaee0637465f05f387020df78de0be138d3aec2216463c7"
105
106
  }
106
107
  }
107
108
  }