feat(web): add shell-first runbook UI and mock demo (#2)
Add notebook parameters, literal highlighted scripts, copy helpers, streamed runs, host-key confirmation, artifacts, conditional notes, login and optimistic Markdown editing. Keep the temporary core renderer isolated to mock mode. Use React and Vite for the UI, react-markdown for safe Markdown rendering, highlight.js for shell syntax, and CodeMirror 6 for Markdown editing. Add Testing Library, jsdom and Vitest for component and event-state coverage. Validate pnpm install, root typecheck and test (29 web tests, 1 server test), plus normal and mock web builds. Core contracts remain unchanged; real backend execution awaits the parallel core/server implementations.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { shellQuote } from "@shellbook/core";
|
||||
import type { HostInfo } from "@shellbook/core";
|
||||
|
||||
/** Copy transport only: the script body is preserved byte for byte. */
|
||||
export function sshCommand(
|
||||
host: HostInfo,
|
||||
script: string,
|
||||
sudo = false,
|
||||
): string {
|
||||
if (
|
||||
!Number.isInteger(host.port) ||
|
||||
host.port < 1 ||
|
||||
host.port > 65535 ||
|
||||
!host.user ||
|
||||
!host.address ||
|
||||
/[\r\n\0]/.test(host.user + host.address)
|
||||
) {
|
||||
throw new Error("Invalid SSH destination");
|
||||
}
|
||||
let delimiter = "EOF";
|
||||
const lines = script.split(/\r?\n/);
|
||||
while (lines.includes(delimiter)) delimiter += "_";
|
||||
return `ssh -p ${host.port} -- ${shellQuote(`${host.user}@${host.address}`)} ${shellQuote(`${sudo ? "sudo -n " : ""}bash -euo pipefail -s`)} <<'${delimiter}'\n${script}${script.endsWith("\n") ? "" : "\n"}${delimiter}`;
|
||||
}
|
||||
Reference in New Issue
Block a user