codexctl 0.4.2 → 0.4.4

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "codexctl",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
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
11
  "test": "echo 'Binary package - no tests'"
@@ -25,8 +25,8 @@
25
25
  "node": ">=16"
26
26
  },
27
27
  "files": [
28
- "bin/",
29
- "install.js",
28
+ "run.js",
29
+ "index.js",
30
30
  "README.md",
31
31
  "LICENSE"
32
32
  ]
package/run.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 = 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); });
package/bin/cdx.exe DELETED
Binary file
package/bin/codexctl DELETED
Binary file
package/bin/codexctl.exe DELETED
Binary file
package/install.js DELETED
@@ -1,149 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * CodexCTL Installation Script
4
- * Downloads the appropriate binary for the current platform from GitHub Releases
5
- */
6
-
7
- const https = require('https');
8
- const http = require('http');
9
- const fs = require('fs');
10
- const path = require('path');
11
- const os = require('os');
12
- const { execSync, spawn } = require('child_process');
13
-
14
- const VERSION = require('./package.json').version;
15
-
16
- const platforms = {
17
- 'darwin-x64': 'x86_64-apple-darwin',
18
- 'darwin-arm64': 'aarch64-apple-darwin',
19
- 'linux-x64': 'x86_64-unknown-linux-gnu',
20
- 'linux-arm64': 'aarch64-unknown-linux-gnu',
21
- 'win32-x64': 'x86_64-pc-windows-msvc'
22
- };
23
-
24
- function getPlatform() {
25
- const platform = os.platform();
26
- const arch = os.arch();
27
- const key = `${platform}-${arch}`;
28
-
29
- if (!platforms[key]) {
30
- console.error(`Unsupported platform: ${platform} ${arch}`);
31
- console.error('Supported platforms:', Object.keys(platforms).join(', '));
32
- process.exit(1);
33
- }
34
-
35
- return platforms[key];
36
- }
37
-
38
- function getDownloadUrl(target) {
39
- const ext = target.includes('windows') ? 'zip' : 'tar.gz';
40
- return `https://github.com/repohelper/codexctl/releases/download/v${VERSION}/codexctl-${target}.${ext}`;
41
- }
42
-
43
- function downloadFile(url, dest) {
44
- return new Promise((resolve, reject) => {
45
- const protocol = url.startsWith('https') ? https : http;
46
-
47
- const request = protocol.get(url, { headers: { 'User-Agent': 'codexctl-install' } }, (response) => {
48
- if (response.statusCode === 302 || response.statusCode === 301) {
49
- const redirectUrl = response.headers.location;
50
- if (redirectUrl) {
51
- downloadFile(redirectUrl, dest).then(resolve).catch(reject);
52
- return;
53
- }
54
- }
55
-
56
- if (response.statusCode !== 200) {
57
- reject(new Error(`Download failed with status ${response.statusCode}: ${url}`));
58
- return;
59
- }
60
-
61
- const file = fs.createWriteStream(dest);
62
- response.pipe(file);
63
- file.on('finish', () => {
64
- file.close();
65
- resolve();
66
- });
67
- });
68
-
69
- request.on('error', reject);
70
- });
71
- }
72
-
73
- function extractArchive(archivePath, destDir) {
74
- const ext = path.extname(archivePath);
75
-
76
- if (ext === '.zip') {
77
- if (os.platform() === 'win32') {
78
- execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
79
- } else {
80
- execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: 'inherit' });
81
- }
82
- } else {
83
- execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: 'inherit' });
84
- }
85
- }
86
-
87
- async function install() {
88
- const binDir = path.join(__dirname, 'bin');
89
-
90
- // Skip if binaries already exist
91
- if (fs.existsSync(path.join(binDir, 'codexctl'))) {
92
- console.log('CodexCTL binaries already exist, skipping download');
93
- return;
94
- }
95
-
96
- if (!fs.existsSync(binDir)) {
97
- fs.mkdirSync(binDir, { recursive: true });
98
- }
99
-
100
- const target = getPlatform();
101
- const ext = target.includes('windows') ? 'zip' : 'tar.gz';
102
- const archivePath = path.join(binDir, `codexctl-${target}.${ext}`);
103
-
104
- console.log(`Downloading CodexCTL v${VERSION} for ${target}...`);
105
-
106
- const url = getDownloadUrl(target);
107
- console.log(`URL: ${url}`);
108
-
109
- try {
110
- // First try direct download
111
- await downloadFile(url, archivePath);
112
- } catch (err) {
113
- // If direct fails, try latest tag
114
- const latestUrl = getDownloadUrl(target).replace(`/v${VERSION}`, '/latest');
115
- console.log(`Retrying with latest...`);
116
- await downloadFile(latestUrl, archivePath);
117
- }
118
-
119
- console.log('Extracting...');
120
- extractArchive(archivePath, binDir);
121
-
122
- // Clean up archive
123
- fs.unlinkSync(archivePath);
124
-
125
- // Make executable
126
- if (os.platform() !== 'win32') {
127
- try {
128
- fs.chmodSync(path.join(binDir, 'codexctl'), 0o755);
129
- } catch (e) {
130
- // Try cdx if codexctl name differs
131
- const cdxPath = path.join(binDir, 'cdx');
132
- if (fs.existsSync(cdxPath)) {
133
- fs.chmodSync(cdxPath, 0o755);
134
- }
135
- }
136
- }
137
-
138
- console.log('CodexCTL installed successfully!');
139
- console.log('Run: codexctl --help');
140
- }
141
-
142
- install().catch(err => {
143
- console.error('Installation failed:', err.message);
144
- console.error('');
145
- console.error('To install manually:');
146
- console.error(`1. Download from: https://github.com/repohelper/codexctl/releases`);
147
- console.error(`2. Extract and add to your PATH`);
148
- process.exit(1);
149
- });