codexctl 0.5.14 → 0.5.16
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 +20 -76
- package/package.json +12 -11
- package/bin/darwin/codexctl +0 -0
- package/bin/linux/codexctl +0 -0
- package/bin/win/cdx.exe +0 -0
- package/bin/win/codexctl.exe +0 -0
- package/run.js +0 -75
package/codexctl.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* CodexCTL
|
|
3
|
+
* CodexCTL - Wrapper that uses platform-specific binary from optionalDependencies
|
|
4
|
+
*
|
|
5
|
+
* When npm installs this package, it automatically downloads the correct
|
|
6
|
+
* @codexctl/{platform} package based on OS/arch. The binary is then available
|
|
7
|
+
* in node_modules/@codexctl/{platform}/bin/
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
|
-
const fs = require('fs');
|
|
7
10
|
const path = require('path');
|
|
8
11
|
const os = require('os');
|
|
9
12
|
const { spawn } = require('child_process');
|
|
10
13
|
|
|
11
14
|
'use strict';
|
|
12
|
-
const VERSION = '0.5.13';
|
|
13
15
|
|
|
14
16
|
const PLATFORMS = {
|
|
15
|
-
'linux-x64':
|
|
16
|
-
'linux-arm64':
|
|
17
|
-
'darwin-x64':
|
|
18
|
-
'darwin-arm64':
|
|
19
|
-
'win32-x64':
|
|
17
|
+
'linux-x64': '@codexctl/linux-x64',
|
|
18
|
+
'linux-arm64': '@codexctl/linux-arm64',
|
|
19
|
+
'darwin-x64': '@codexctl/darwin-x64',
|
|
20
|
+
'darwin-arm64': '@codexctl/darwin-arm64',
|
|
21
|
+
'win32-x64': '@codexctl/win32-x64'
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
function getPlatform() {
|
|
@@ -24,73 +26,15 @@ function getPlatform() {
|
|
|
24
26
|
return PLATFORMS[key] || PLATFORMS['linux-x64'];
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
29
|
+
const platformPackage = getPlatform();
|
|
30
|
+
const binDir = path.join(__dirname, '..', platformPackage, 'bin');
|
|
31
|
+
const isWindows = os.platform() === 'win32';
|
|
32
|
+
const binaryName = isWindows ? 'codexctl.exe' : 'codexctl';
|
|
33
|
+
const binaryPath = path.join(binDir, binaryName);
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
const doDownload = (downloadUrl) => {
|
|
43
|
-
https.get(downloadUrl, (res) => {
|
|
44
|
-
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
45
|
-
const redirectUrl = res.headers.location;
|
|
46
|
-
if (!redirectUrl) {
|
|
47
|
-
reject(new Error('Redirect without location'));
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
doDownload(redirectUrl);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (res.statusCode !== 200) {
|
|
54
|
-
reject(new Error(`Download failed with status ${res.statusCode}`));
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const file = fs.createWriteStream(path.join(binDir, 'download' + platform.ext));
|
|
58
|
-
res.pipe(file);
|
|
59
|
-
file.on('finish', () => {
|
|
60
|
-
try {
|
|
61
|
-
if (platform.ext === '.zip') {
|
|
62
|
-
const { execSync } = require('child_process');
|
|
63
|
-
execSync(`powershell -Command "Expand-Archive -Path '${file.path}' -DestinationPath '${binDir}' -Force"`, { stdio: 'ignore' });
|
|
64
|
-
} else {
|
|
65
|
-
const { execSync } = require('child_process');
|
|
66
|
-
execSync(`tar -xzf '${file.path}' -C '${binDir}'`, { stdio: 'ignore' });
|
|
67
|
-
}
|
|
68
|
-
fs.unlinkSync(file.path);
|
|
69
|
-
if (!fs.existsSync(binPath)) {
|
|
70
|
-
reject(new Error('Downloaded file not found after extraction'));
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
resolve();
|
|
74
|
-
} catch (err) {
|
|
75
|
-
reject(err);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
file.on('error', reject);
|
|
79
|
-
}).on('error', reject);
|
|
80
|
-
};
|
|
81
|
-
doDownload(url);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async function main() {
|
|
86
|
-
await download();
|
|
87
|
-
|
|
88
|
-
if (os.platform() !== 'win32') {
|
|
89
|
-
try { fs.chmodSync(binPath, 0o755); } catch {}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit', windowsHide: true });
|
|
93
|
-
child.on('exit', (code) => process.exit(code ?? 0));
|
|
94
|
-
}
|
|
35
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
36
|
+
stdio: 'inherit',
|
|
37
|
+
windowsHide: true
|
|
38
|
+
});
|
|
95
39
|
|
|
96
|
-
|
|
40
|
+
child.on('exit', (code) => process.exit(code ?? 0));
|
package/package.json
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codexctl",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.16",
|
|
4
4
|
"description": "Codex CLI Profile Manager - Manage multiple AI CLI accounts",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"codexctl": "./codexctl.js",
|
|
8
|
-
"cdx": "./codexctl.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"test": "echo 'Binary package - no tests'"
|
|
12
|
-
},
|
|
13
5
|
"repository": {
|
|
14
6
|
"type": "git",
|
|
15
7
|
"url": "git+https://github.com/repohelper/codexctl.git"
|
|
@@ -24,9 +16,18 @@
|
|
|
24
16
|
"engines": {
|
|
25
17
|
"node": ">=16"
|
|
26
18
|
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"codexctl": "./codexctl.js",
|
|
21
|
+
"cdx": "./codexctl.js"
|
|
22
|
+
},
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@codexctl/linux-x64": "0.5.14",
|
|
25
|
+
"@codexctl/linux-arm64": "0.5.14",
|
|
26
|
+
"@codexctl/darwin-x64": "0.5.14",
|
|
27
|
+
"@codexctl/darwin-arm64": "0.5.14",
|
|
28
|
+
"@codexctl/win32-x64": "0.5.14"
|
|
29
|
+
},
|
|
27
30
|
"files": [
|
|
28
|
-
"bin",
|
|
29
|
-
"run.js",
|
|
30
31
|
"codexctl.js",
|
|
31
32
|
"index.js",
|
|
32
33
|
"README.md",
|
package/bin/darwin/codexctl
DELETED
|
Binary file
|
package/bin/linux/codexctl
DELETED
|
Binary file
|
package/bin/win/cdx.exe
DELETED
|
Binary file
|
package/bin/win/codexctl.exe
DELETED
|
Binary file
|
package/run.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
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 = require('./package.json').version;
|
|
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); });
|