@jayasuryajsk/codex-kaioken 0.1.4 → 0.1.6
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/README.md +1 -1
- package/bin/codex-kaioken +0 -0
- package/bin/main.js +2 -1
- package/bin/postinstall.js +39 -13
- package/package.json +21 -7
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ This package installs the Codex Kaioken CLI by downloading the appropriate binar
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install -g codex-kaioken
|
|
8
|
+
npm install -g @jayasuryajsk/codex-kaioken
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
During `postinstall` the package fetches the `codex-kaioken` binary for your platform, marks it executable, and exposes it on your `PATH`.
|
|
Binary file
|
package/bin/main.js
CHANGED
|
@@ -5,7 +5,8 @@ import { dirname, join } from 'node:path';
|
|
|
5
5
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
|
-
const
|
|
8
|
+
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
9
|
+
const binary = join(__dirname, `codex-kaioken${ext}`);
|
|
9
10
|
const args = process.argv.slice(2);
|
|
10
11
|
const child = spawn(binary, args, { stdio: 'inherit' });
|
|
11
12
|
child.on('exit', (code, signal) => {
|
package/bin/postinstall.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { chmodSync, createWriteStream, existsSync, renameSync, rmSync } from 'node:fs';
|
|
2
|
+
import { chmodSync, createReadStream, createWriteStream, existsSync, renameSync, rmSync } from 'node:fs';
|
|
3
3
|
import { pipeline } from 'node:stream/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { dirname, join } from 'node:path';
|
|
7
7
|
import fetch from 'node-fetch';
|
|
8
8
|
import tar from 'tar';
|
|
9
|
+
import unzipper from 'unzipper';
|
|
9
10
|
|
|
10
|
-
const version = process.env.CODEX_KAIOKEN_VERSION || '0.1.
|
|
11
|
+
const version = process.env.CODEX_KAIOKEN_VERSION || '0.1.6';
|
|
11
12
|
const platform = process.platform;
|
|
12
13
|
const arch = process.arch;
|
|
13
14
|
|
|
@@ -16,6 +17,8 @@ const mapping = {
|
|
|
16
17
|
'darwin-arm64': 'codex-kaioken-aarch64-apple-darwin.tar.gz',
|
|
17
18
|
'linux-x64': 'codex-kaioken-x86_64-unknown-linux-musl.tar.gz',
|
|
18
19
|
'linux-arm64': 'codex-kaioken-aarch64-unknown-linux-musl.tar.gz',
|
|
20
|
+
'win32-x64': 'codex-kaioken-x86_64-pc-windows-msvc.zip',
|
|
21
|
+
'win32-arm64': 'codex-kaioken-aarch64-pc-windows-msvc.zip',
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
const key = `${platform}-${arch}`;
|
|
@@ -25,6 +28,7 @@ if (!mapping[key]) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
const asset = mapping[key];
|
|
31
|
+
const isZip = asset.endsWith('.zip');
|
|
28
32
|
const url = `https://github.com/jayasuryajsk/codex-kaioken/releases/download/v${version}/${asset}`;
|
|
29
33
|
const dest = join(tmpdir(), asset);
|
|
30
34
|
const localTarball = process.env.CODEX_KAIOKEN_LOCAL_TARBALL;
|
|
@@ -45,25 +49,47 @@ async function main() {
|
|
|
45
49
|
console.log(`Using local tarball ${archivePath}`);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
// Determine expected binary name after extraction
|
|
53
|
+
const ext = platform === 'win32' ? '.exe' : '';
|
|
54
|
+
const finalBinaryName = `codex-kaioken${ext}`;
|
|
55
|
+
const extractedPath = join(here, finalBinaryName);
|
|
49
56
|
rmSync(extractedPath, { force: true });
|
|
50
57
|
|
|
51
58
|
console.log('Extracting...');
|
|
52
|
-
await tar.x({ file: archivePath, cwd: here });
|
|
53
|
-
const binaryName = asset.replace('.tar.gz', '');
|
|
54
|
-
const platformPath = join(here, binaryName);
|
|
55
59
|
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
if (isZip) {
|
|
61
|
+
// Extract zip archive (Windows)
|
|
62
|
+
// The zip contains codex-kaioken.exe directly
|
|
63
|
+
await pipeline(
|
|
64
|
+
createReadStream(archivePath),
|
|
65
|
+
unzipper.Extract({ path: here })
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// Verify the binary was extracted
|
|
69
|
+
if (!existsSync(extractedPath)) {
|
|
70
|
+
console.error(`Extracted binary missing: ${extractedPath}`);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
// Extract tar.gz archive (macOS/Linux)
|
|
75
|
+
await tar.x({ file: archivePath, cwd: here });
|
|
76
|
+
const binaryName = asset.replace('.tar.gz', '');
|
|
77
|
+
const platformPath = join(here, binaryName);
|
|
60
78
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
if (!existsSync(platformPath) && !existsSync(extractedPath)) {
|
|
80
|
+
console.error(`Extracted binary missing: tried ${platformPath} and ${extractedPath}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (existsSync(platformPath) && platformPath !== extractedPath) {
|
|
85
|
+
rmSync(extractedPath, { force: true });
|
|
86
|
+
renameSync(platformPath, extractedPath);
|
|
87
|
+
}
|
|
64
88
|
}
|
|
65
89
|
|
|
90
|
+
// Make executable (no-op on Windows, but harmless)
|
|
66
91
|
chmodSync(extractedPath, 0o755);
|
|
92
|
+
console.log(`Installed ${finalBinaryName}`);
|
|
67
93
|
}
|
|
68
94
|
|
|
69
95
|
main().catch((err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayasuryajsk/codex-kaioken",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "CLI wrapper that downloads the Codex Kaioken binary",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,13 +11,27 @@
|
|
|
11
11
|
},
|
|
12
12
|
"author": "Codex Kaioken",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
|
-
"files": [
|
|
14
|
+
"files": [
|
|
15
|
+
"bin"
|
|
16
|
+
],
|
|
15
17
|
"preferGlobal": true,
|
|
16
|
-
"os": [
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
"os": [
|
|
19
|
+
"darwin",
|
|
20
|
+
"linux",
|
|
21
|
+
"win32"
|
|
22
|
+
],
|
|
23
|
+
"cpu": [
|
|
24
|
+
"x64",
|
|
25
|
+
"arm64"
|
|
26
|
+
],
|
|
27
|
+
"keywords": [
|
|
28
|
+
"codex",
|
|
29
|
+
"kaioken",
|
|
30
|
+
"cli"
|
|
31
|
+
],
|
|
19
32
|
"dependencies": {
|
|
20
33
|
"node-fetch": "^3.3.2",
|
|
21
|
-
"tar": "^6.2.0"
|
|
34
|
+
"tar": "^6.2.0",
|
|
35
|
+
"unzipper": "^0.12.3"
|
|
22
36
|
}
|
|
23
|
-
}
|
|
37
|
+
}
|