@jx0/jmux 0.5.2 → 0.5.3
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 +1 -1
- package/src/main.ts +64 -1
package/package.json
CHANGED
package/src/main.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { homedir } from "os";
|
|
|
12
12
|
|
|
13
13
|
// --- CLI commands (run and exit before TUI) ---
|
|
14
14
|
|
|
15
|
-
const VERSION = "0.5.
|
|
15
|
+
const VERSION = "0.5.3";
|
|
16
16
|
|
|
17
17
|
const HELP = `jmux — the terminal workspace for agentic development
|
|
18
18
|
|
|
@@ -164,6 +164,69 @@ for (let i = 2; i < process.argv.length; i++) {
|
|
|
164
164
|
process.exit(1);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
// Preflight checks — offer to install missing dependencies
|
|
168
|
+
async function preflight(): Promise<void> {
|
|
169
|
+
const missing: string[] = [];
|
|
170
|
+
if (Bun.spawnSync(["tmux", "-V"], { stdout: "pipe", stderr: "pipe" }).exitCode !== 0) {
|
|
171
|
+
missing.push("tmux");
|
|
172
|
+
}
|
|
173
|
+
if (Bun.spawnSync(["fzf", "--version"], { stdout: "pipe", stderr: "pipe" }).exitCode !== 0) {
|
|
174
|
+
missing.push("fzf");
|
|
175
|
+
}
|
|
176
|
+
if (missing.length === 0) return;
|
|
177
|
+
|
|
178
|
+
const isMac = process.platform === "darwin";
|
|
179
|
+
const hasBrew = isMac && Bun.spawnSync(["brew", "--version"], { stdout: "pipe", stderr: "pipe" }).exitCode === 0;
|
|
180
|
+
const hasApt = !isMac && Bun.spawnSync(["apt", "--version"], { stdout: "pipe", stderr: "pipe" }).exitCode === 0;
|
|
181
|
+
|
|
182
|
+
console.log(`\njmux requires ${missing.join(" and ")} to run.\n`);
|
|
183
|
+
|
|
184
|
+
if (hasBrew || hasApt) {
|
|
185
|
+
const pm = hasBrew ? "brew" : "sudo apt";
|
|
186
|
+
const installCmd = `${pm} install ${missing.join(" ")}`;
|
|
187
|
+
console.log(`Install with:\n\n ${installCmd}\n`);
|
|
188
|
+
|
|
189
|
+
// Prompt to install
|
|
190
|
+
process.stdout.write("Install now? [Y/n] ");
|
|
191
|
+
const response = await new Promise<string>((resolve) => {
|
|
192
|
+
process.stdin.setRawMode?.(false);
|
|
193
|
+
process.stdin.resume();
|
|
194
|
+
process.stdin.once("data", (data) => {
|
|
195
|
+
process.stdin.pause();
|
|
196
|
+
resolve(data.toString().trim().toLowerCase());
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
if (response === "" || response === "y" || response === "yes") {
|
|
201
|
+
console.log(`\nRunning: ${installCmd}\n`);
|
|
202
|
+
const args = hasBrew
|
|
203
|
+
? ["brew", "install", ...missing]
|
|
204
|
+
: ["sudo", "apt", "install", "-y", ...missing];
|
|
205
|
+
const result = Bun.spawnSync(args, { stdout: "inherit", stderr: "inherit" });
|
|
206
|
+
if (result.exitCode !== 0) {
|
|
207
|
+
console.error("\nInstallation failed. Please install manually and try again.");
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
console.log("\nDependencies installed. Starting jmux...\n");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
// No package manager detected — just show instructions
|
|
215
|
+
if (isMac) {
|
|
216
|
+
console.log("Install Homebrew first: https://brew.sh");
|
|
217
|
+
console.log(`Then run: brew install ${missing.join(" ")}`);
|
|
218
|
+
} else {
|
|
219
|
+
console.log(`Install with your package manager, e.g.:`);
|
|
220
|
+
console.log(` apt install ${missing.join(" ")}`);
|
|
221
|
+
console.log(` dnf install ${missing.join(" ")}`);
|
|
222
|
+
console.log(` pacman -S ${missing.join(" ")}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
process.exit(1);
|
|
227
|
+
}
|
|
228
|
+
await preflight();
|
|
229
|
+
|
|
167
230
|
const cols = process.stdout.columns || 80;
|
|
168
231
|
const rows = process.stdout.rows || 24;
|
|
169
232
|
const sidebarVisible = cols >= 80;
|