codexctl 0.4.2 → 0.4.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.
package/bin/codexctl.exe CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "codexctl",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Codex CLI Profile Manager - Manage multiple AI CLI accounts",
5
5
  "main": "index.js",
6
6
  "bin": {
7
- "codexctl": "./bin/codexctl",
8
- "cdx": "./bin/cdx"
7
+ "codexctl": "./run.js",
8
+ "cdx": "./run.js"
9
9
  },
10
10
  "scripts": {
11
+ "postinstall": "node run.js",
11
12
  "test": "echo 'Binary package - no tests'"
12
13
  },
13
14
  "repository": {
package/run.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CodexCTL Runner - Downloads binary on first run if not present
4
+ */
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const os = require('os');
9
+ const { spawn } = require('child_process');
10
+
11
+ const VERSION = require('./package.json').version;
12
+
13
+ const PLATFORMS = {
14
+ 'linux-x64': { url: 'codexctl-x86_64-unknown-linux-gnu.tar.gz', ext: '.tar.gz' },
15
+ 'linux-arm64': { url: 'codexctl-aarch64-unknown-linux-gnu.tar.gz', ext: '.tar.gz' },
16
+ 'darwin-x64': { url: 'codexctl-x86_64-apple-darwin.tar.gz', ext: '.tar.gz' },
17
+ 'darwin-arm64': { url: 'codexctl-aarch64-apple-darwin.tar.gz', ext: '.tar.gz' },
18
+ 'win32-x64': { url: 'codexctl-x86_64-pc-windows-msvc.zip', ext: '.zip' }
19
+ };
20
+
21
+ function getPlatform() {
22
+ const key = `${os.platform()}-${os.arch()}`;
23
+ return PLATFORMS[key] || PLATFORMS['linux-x64'];
24
+ }
25
+
26
+ const binDir = path.join(__dirname, 'bin');
27
+ const platform = getPlatform();
28
+ const binName = platform.ext === '.zip' ? 'codexctl.exe' : 'codexctl';
29
+ const binPath = path.join(binDir, binName);
30
+
31
+ async function download() {
32
+ if (!fs.existsSync(binDir)) fs.mkdirSync(binDir, { recursive: true });
33
+ if (fs.existsSync(binPath)) return;
34
+
35
+ const https = require('https');
36
+ const url = `https://github.com/repohelper/codexctl/releases/download/v${VERSION}/${platform.url}`;
37
+
38
+ console.log(`Downloading codexctl ${VERSION} for ${os.platform()}-${os.arch()}...`);
39
+
40
+ return new Promise((resolve, reject) => {
41
+ https.get(url, (res) => {
42
+ if (res.statusCode === 302 || res.statusCode === 301) {
43
+ download(res.headers.location).then(resolve).catch(reject);
44
+ return;
45
+ }
46
+ const file = fs.createWriteStream(path.join(binDir, 'download' + platform.ext));
47
+ res.pipe(file);
48
+ file.on('finish', () => {
49
+ if (platform.ext === '.zip') {
50
+ const { execSync } = require('child_process');
51
+ execSync(`powershell -Command "Expand-Archive -Path '${file.path}' -DestinationPath '${binDir}' -Force"`);
52
+ } else {
53
+ const { execSync } = require('child_process');
54
+ execSync(`tar -xzf '${file.path}' -C '${binDir}'`);
55
+ }
56
+ fs.unlinkSync(file.path);
57
+ resolve();
58
+ });
59
+ }).on('error', reject);
60
+ });
61
+ }
62
+
63
+ async function main() {
64
+ await download();
65
+
66
+ if (os.platform() !== 'win32') {
67
+ try { fs.chmodSync(binPath, 0o755); } catch {}
68
+ }
69
+
70
+ const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit', windowsHide: true });
71
+ child.on('exit', (code) => process.exit(code ?? 0));
72
+ }
73
+
74
+ main().catch((err) => { console.error(err.message); process.exit(1); });