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