@mosaic/mosaic is now the single package providing both: - 'mosaic' binary (CLI: yolo, coord, prdy, tui, gateway, etc.) - 'mosaic-wizard' binary (installation wizard) Changes: - Move packages/cli/src/* into packages/mosaic/src/ - Convert dynamic @mosaic/mosaic imports to static relative imports - Add CLI deps (ink, react, socket.io-client, @mosaic/config) to mosaic - Add jsx: react-jsx to mosaic's tsconfig - Exclude packages/cli from workspace (pnpm-workspace.yaml) - Update install.sh to install @mosaic/mosaic instead of @mosaic/cli - Bump version to 0.0.17 This eliminates the circular dependency between @mosaic/cli and @mosaic/mosaic that was blocking the build graph.
38 lines
983 B
TypeScript
38 lines
983 B
TypeScript
import { existsSync, readFileSync } from 'node:fs';
|
|
import { spawn } from 'node:child_process';
|
|
import { LOG_FILE } from './daemon.js';
|
|
|
|
interface LogsOpts {
|
|
follow?: boolean;
|
|
lines?: number;
|
|
}
|
|
|
|
export function runLogs(opts: LogsOpts): void {
|
|
if (!existsSync(LOG_FILE)) {
|
|
console.log('No log file found. Is the gateway installed?');
|
|
return;
|
|
}
|
|
|
|
if (opts.follow) {
|
|
const lines = opts.lines ?? 50;
|
|
const tail = spawn('tail', ['-n', lines.toString(), '-f', LOG_FILE], {
|
|
stdio: 'inherit',
|
|
});
|
|
tail.on('error', () => {
|
|
// Fallback for systems without tail
|
|
console.log(readLastLines(opts.lines ?? 50));
|
|
console.log('\n(--follow requires `tail` command)');
|
|
});
|
|
return;
|
|
}
|
|
|
|
// Just print last N lines
|
|
console.log(readLastLines(opts.lines ?? 50));
|
|
}
|
|
|
|
function readLastLines(n: number): string {
|
|
const content = readFileSync(LOG_FILE, 'utf-8');
|
|
const lines = content.split('\n');
|
|
return lines.slice(-n).join('\n');
|
|
}
|