@inboxapi/cli 0.1.8 → 0.1.9
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/index.js +51 -0
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
3
3
|
const { spawn } = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
|
+
const https = require('https');
|
|
7
|
+
|
|
8
|
+
function compareVersions(a, b) {
|
|
9
|
+
const pa = a.split('.').map(Number);
|
|
10
|
+
const pb = b.split('.').map(Number);
|
|
11
|
+
for (let i = 0; i < 3; i++) {
|
|
12
|
+
const na = pa[i] || 0;
|
|
13
|
+
const nb = pb[i] || 0;
|
|
14
|
+
if (na < nb) return -1;
|
|
15
|
+
if (na > nb) return 1;
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function checkForUpdates() {
|
|
21
|
+
try {
|
|
22
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
|
|
23
|
+
const localVersion = pkg.version;
|
|
24
|
+
if (!localVersion) return;
|
|
25
|
+
|
|
26
|
+
const req = https.get('https://registry.npmjs.org/@inboxapi/cli/latest', { timeout: 3000 }, (res) => {
|
|
27
|
+
let data = '';
|
|
28
|
+
res.on('data', (chunk) => { data += chunk; });
|
|
29
|
+
res.on('end', () => {
|
|
30
|
+
try {
|
|
31
|
+
const remote = JSON.parse(data);
|
|
32
|
+
const remoteVersion = remote.version;
|
|
33
|
+
if (remoteVersion && compareVersions(localVersion, remoteVersion) < 0) {
|
|
34
|
+
process.stderr.write(`[inboxapi] Update available: ${localVersion} → ${remoteVersion}. Updating...\n`);
|
|
35
|
+
const child = spawn('npm', ['install', '-g', `@inboxapi/cli@${remoteVersion}`], {
|
|
36
|
+
stdio: 'ignore',
|
|
37
|
+
detached: true,
|
|
38
|
+
shell: process.platform === 'win32',
|
|
39
|
+
});
|
|
40
|
+
child.unref();
|
|
41
|
+
process.stderr.write(`[inboxapi] Update installing in background. Restart to use new version.\n`);
|
|
42
|
+
}
|
|
43
|
+
} catch {}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
req.on('error', () => {});
|
|
47
|
+
req.on('timeout', () => { req.destroy(); });
|
|
48
|
+
} catch {}
|
|
49
|
+
}
|
|
6
50
|
|
|
7
51
|
const PLATFORM_PACKAGES = {
|
|
8
52
|
'darwin-arm64': '@inboxapi/cli-darwin-arm64',
|
|
@@ -40,6 +84,13 @@ function findBinary() {
|
|
|
40
84
|
const binPath = findBinary();
|
|
41
85
|
const args = process.argv.slice(2);
|
|
42
86
|
|
|
87
|
+
// Auto-update check for proxy mode only (default, no subcommand, or explicit "proxy")
|
|
88
|
+
const firstArg = args[0];
|
|
89
|
+
const isProxyMode = !firstArg || firstArg === 'proxy' || firstArg.startsWith('--endpoint');
|
|
90
|
+
if (isProxyMode) {
|
|
91
|
+
checkForUpdates();
|
|
92
|
+
}
|
|
93
|
+
|
|
43
94
|
if (binPath) {
|
|
44
95
|
const child = spawn(binPath, args, { stdio: 'inherit' });
|
|
45
96
|
child.on('exit', (code, signal) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inboxapi/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "STDIO Proxy for InboxAPI MCP service",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"test": "cargo test"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@inboxapi/cli-darwin-arm64": "0.1.
|
|
31
|
-
"@inboxapi/cli-darwin-x64": "0.1.
|
|
32
|
-
"@inboxapi/cli-linux-x64": "0.1.
|
|
33
|
-
"@inboxapi/cli-linux-arm64": "0.1.
|
|
34
|
-
"@inboxapi/cli-win32-x64": "0.1.
|
|
30
|
+
"@inboxapi/cli-darwin-arm64": "0.1.9",
|
|
31
|
+
"@inboxapi/cli-darwin-x64": "0.1.9",
|
|
32
|
+
"@inboxapi/cli-linux-x64": "0.1.9",
|
|
33
|
+
"@inboxapi/cli-linux-arm64": "0.1.9",
|
|
34
|
+
"@inboxapi/cli-win32-x64": "0.1.9"
|
|
35
35
|
}
|
|
36
36
|
}
|