xkat-cli 2.0.11 → 2.0.13
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/checksums.json +5 -5
- package/bin/xkat-cli.js +28 -18
- package/package.json +1 -1
package/bin/checksums.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"xkat-agent-macos-aarch64": "
|
|
3
|
-
"xkat-agent-macos-x64": "
|
|
4
|
-
"xkat-agent-linux-x64": "
|
|
5
|
-
"xkat-agent-linux-aarch64": "
|
|
6
|
-
"xkat-agent-win-x64.exe": "
|
|
2
|
+
"xkat-agent-macos-aarch64": "86f31067c76c45186b695ffd1c634ff3e2d70989b4652984f63e25414403030a",
|
|
3
|
+
"xkat-agent-macos-x64": "ca119955031bb8c916f6fa6e9c711f5131fc1140364a2e46a2152652273ee5d5",
|
|
4
|
+
"xkat-agent-linux-x64": "e98e269e9e1807781546f3a7f483d082281746c2769beef9ffe349310504170e",
|
|
5
|
+
"xkat-agent-linux-aarch64": "17a5df8bf618ae1c6c90ebed9576c2c24c665683ed6aa05eb791f220232b7ab5",
|
|
6
|
+
"xkat-agent-win-x64.exe": "c9921bd91c0bc3f937ed0e137e4c8adee8efbd7e35a50ed5a04541d0831e7ee7"
|
|
7
7
|
}
|
package/bin/xkat-cli.js
CHANGED
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* xkat-cli.js
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* Fallback: When the native binary is not found, `lab shell` and `lab reset`
|
|
10
|
-
* commands are handled directly via multipass, since they are thin wrappers
|
|
11
|
-
* around `multipass shell xkat-lab` and `multipass delete/launch` respectively.
|
|
12
|
-
* This allows `npx xkat-cli@latest lab shell` to work without a compiled binary.
|
|
5
|
+
* Lightweight CLI entry point for `npx -y xkat-cli@latest`.
|
|
6
|
+
* Launches the live local agent bridge in the foreground by default,
|
|
7
|
+
* connecting your browser to your local environment with zero manual configuration.
|
|
13
8
|
*/
|
|
14
9
|
const { spawnSync } = require('child_process');
|
|
15
10
|
const path = require('path');
|
|
@@ -51,11 +46,28 @@ const candidatePaths = [
|
|
|
51
46
|
|
|
52
47
|
const binaryPath = candidatePaths.find((p) => fs.existsSync(p));
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
const args = process.argv.slice(2);
|
|
50
|
+
const subCmd = args.join(' ').trim();
|
|
51
|
+
|
|
52
|
+
// ── 1. Zero-Touch Port 10022 Cleanup Command ──
|
|
53
|
+
if (subCmd === 'down' || subCmd === 'stop' || subCmd === 'kill' || subCmd === 'clean') {
|
|
54
|
+
console.log('🛑 Cleaning up port 10022 and stopping existing xkat agent instances...');
|
|
55
|
+
if (os.platform() === 'win32') {
|
|
56
|
+
spawnSync('powershell', [
|
|
57
|
+
'-NoProfile',
|
|
58
|
+
'-NonInteractive',
|
|
59
|
+
'-Command',
|
|
60
|
+
'Get-NetTCPConnection -LocalPort 10022 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess -Unique | Where-Object { $_ -gt 0 } | ForEach-Object { Stop-Process -Id $_ -Force -ErrorAction SilentlyContinue }; Get-Process -Name xkat-agent*, xkat* -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue'
|
|
61
|
+
], { stdio: 'inherit' });
|
|
62
|
+
} else {
|
|
63
|
+
spawnSync('sh', ['-c', 'fuser -k 10022/tcp 2>/dev/null || true; pgrep -f "xkat-agent" | xargs -r kill -9 2>/dev/null || true'], { stdio: 'inherit' });
|
|
64
|
+
}
|
|
65
|
+
console.log('✅ Port 10022 is now completely free.');
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
58
68
|
|
|
69
|
+
// ── 2. Fallback for Lab VM commands when native agent is not built ──
|
|
70
|
+
if (!binaryPath) {
|
|
59
71
|
if (subCmd === 'lab shell') {
|
|
60
72
|
const result = spawnSync('multipass', ['shell', LAB_NAME], { stdio: 'inherit' });
|
|
61
73
|
process.exit(result.status || 0);
|
|
@@ -68,7 +80,7 @@ if (!binaryPath) {
|
|
|
68
80
|
const launch = spawnSync('multipass', ['launch', '--name', LAB_NAME, '24.04', '--cpus', '2', '--memory', '2G', '--disk', '10G'], { stdio: 'inherit' });
|
|
69
81
|
if (launch.status === 0) {
|
|
70
82
|
console.log('✅ Lab reset complete.');
|
|
71
|
-
console.log(' Enter: xkat lab shell');
|
|
83
|
+
console.log(' Enter: npx -y xkat-cli@latest lab shell');
|
|
72
84
|
} else {
|
|
73
85
|
console.error('❌ Could not recreate Lab. Check multipass installation.');
|
|
74
86
|
}
|
|
@@ -76,7 +88,6 @@ if (!binaryPath) {
|
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
if (subCmd === 'lab up' || subCmd === 'lab install') {
|
|
79
|
-
// Ensure multipass VM exists and is running
|
|
80
91
|
const info = spawnSync('multipass', ['info', LAB_NAME], { encoding: 'utf8' });
|
|
81
92
|
if (info.status !== 0) {
|
|
82
93
|
console.log('🚀 Creating Lab VM...');
|
|
@@ -84,7 +95,7 @@ if (!binaryPath) {
|
|
|
84
95
|
process.exit(launch.status || 0);
|
|
85
96
|
} else {
|
|
86
97
|
console.log(`✅ Lab VM '${LAB_NAME}' already exists.`);
|
|
87
|
-
console.log(' Enter: xkat lab shell');
|
|
98
|
+
console.log(' Enter: npx -y xkat-cli@latest lab shell');
|
|
88
99
|
process.exit(0);
|
|
89
100
|
}
|
|
90
101
|
}
|
|
@@ -95,11 +106,10 @@ if (!binaryPath) {
|
|
|
95
106
|
process.exit(1);
|
|
96
107
|
}
|
|
97
108
|
|
|
98
|
-
//
|
|
99
|
-
const result = spawnSync(binaryPath,
|
|
109
|
+
// ── 3. Forward to Rust binary ──
|
|
110
|
+
const result = spawnSync(binaryPath, args, {
|
|
100
111
|
stdio: 'inherit',
|
|
101
112
|
env: process.env,
|
|
102
113
|
});
|
|
103
114
|
|
|
104
115
|
process.exit(result.status || 0);
|
|
105
|
-
|