fix cliamp panel header, home dir lookup, and go install path
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import type { ServerWebSocket } from 'bun';
|
||||
import { spawn, type Subprocess } from 'bun';
|
||||
import { resolve, normalize, dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { getHomeDir } from '@@/data-path';
|
||||
import { getHomeDirForRole } from '@@/data-path';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const ASOUNDRC_PATH = join(__dirname, 'asoundrc');
|
||||
@@ -49,12 +49,18 @@ const validateFilePaths = (files: string[], homeDir: string): string[] | null =>
|
||||
const findCliamp = (): string | null => {
|
||||
const which = Bun.which('cliamp');
|
||||
if (which) return which;
|
||||
const goPath = process.env.GOPATH ?? `${process.env.HOME}/go`;
|
||||
const goBin = `${goPath}/bin/cliamp`;
|
||||
try {
|
||||
const stat = Bun.spawnSync({ cmd: ['test', '-x', goBin], stdout: 'ignore', stderr: 'ignore' });
|
||||
if (stat.exitCode === 0) return goBin;
|
||||
} catch { /* ignore */ }
|
||||
const candidates = [
|
||||
process.env.GOPATH ? `${process.env.GOPATH}/bin/cliamp` : null,
|
||||
`${process.env.HOME}/.local/go-path/bin/cliamp`,
|
||||
`${process.env.HOME}/go/bin/cliamp`,
|
||||
];
|
||||
for (const bin of candidates) {
|
||||
if (!bin) continue;
|
||||
try {
|
||||
const stat = Bun.spawnSync({ cmd: ['test', '-x', bin], stdout: 'ignore', stderr: 'ignore' });
|
||||
if (stat.exitCode === 0) return bin;
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -62,7 +68,7 @@ const shellEscape = (s: string) => `'${s.replace(/'/g, "'\\''")}'`;
|
||||
|
||||
export const cliampWebsocket = {
|
||||
async open(ws: ServerWebSocket<WSData>) {
|
||||
const { email, files: filesParam } = ws.data;
|
||||
const { email, role, files: filesParam } = ws.data;
|
||||
|
||||
if (!filesParam) {
|
||||
sendOutput(ws, '\r\n[Error] No files specified.\r\n');
|
||||
@@ -75,7 +81,7 @@ export const cliampWebsocket = {
|
||||
return;
|
||||
}
|
||||
|
||||
const homeDir = getHomeDir(email);
|
||||
const homeDir = getHomeDirForRole(email, role);
|
||||
const rawFiles = [filesParam];
|
||||
|
||||
// Resolve paths relative to user home dir
|
||||
|
||||
Reference in New Issue
Block a user