From 7ab885d658b0c52a9c775587a63b06d581451506 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath <2+defunkt@users.noreply.github.com> Date: Sun, 21 Sep 2025 11:32:28 -0700 Subject: [PATCH] controversial --- nose/bin/ls.ts | 27 +++++++++++++++++++++++++++ src/css/terminal.css | 4 ++++ src/server.tsx | 3 +-- src/webapp.ts | 20 ++++++++++++++++++-- 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 nose/bin/ls.ts diff --git a/nose/bin/ls.ts b/nose/bin/ls.ts new file mode 100644 index 0000000..66e7929 --- /dev/null +++ b/nose/bin/ls.ts @@ -0,0 +1,27 @@ +import { readdirSync } from "fs" +import { NOSE_USR, NOSE_USR_WWW } from "@/config" +import { Thread } from "@/shell" +import { appPath } from "@/webapp" + +export default function () { + const state = Thread.getStore() + if (!state) return "error: no state" + + const project = state.project + if (!project) return "no project loaded" + + const root = appPath(project) + if (!root) return "error loading project" + + let files: string[] = [] + + for (const file of readdirSync(root, { withFileTypes: true })) { + files.push(file.name) + } + + if (root === NOSE_USR_WWW) { + files = files.filter(file => file.endsWith(`${project}.ts`) || file.endsWith(`${project}.tsx`)) + } + + return `* project: ${project}\n` + files.join(" ") +} \ No newline at end of file diff --git a/src/css/terminal.css b/src/css/terminal.css index 824ff14..a3d378a 100644 --- a/src/css/terminal.css +++ b/src/css/terminal.css @@ -97,4 +97,8 @@ #scrollback .input .content { margin-left: var(--cli-status-width); +} + +#scrollback .output { + white-space: pre-wrap; } \ No newline at end of file diff --git a/src/server.tsx b/src/server.tsx index 7ec2900..ec796fa 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -119,7 +119,7 @@ app.get("/apps", c => { app.get("/", c => c.html()) // -// hot mode cleanup +// hot reload mode cleanup // if (process.env.BUN_HOT) { @@ -143,7 +143,6 @@ if (process.env.BUN_HOT) { } - // // server start // diff --git a/src/webapp.ts b/src/webapp.ts index 22e3cd8..3967cff 100644 --- a/src/webapp.ts +++ b/src/webapp.ts @@ -1,10 +1,10 @@ import { type Context, Hono } from "hono" import type { Child } from "hono/jsx" import { renderToString } from "hono/jsx/dom/server" -import { join } from "path" +import { join, dirname } from "path" import { readdirSync, watch } from "fs" import { NOSE_USR_WWW, NOSE_SYS_WWW } from "./config" -import { expectDir } from "./utils" +import { expectDir, isFile } from "./utils" export type Handler = (r: Context) => string | Child | Response | Promise export type App = Hono | Handler @@ -32,6 +32,22 @@ export function apps(): string[] { return apps.sort() } +export function appPath(name: string): string | undefined { + const path = [ + `${name}.ts`, + `${name}.tsx`, + join(name, "index.ts"), + join(name, "index.tsx") + ] + .map(path => [join(NOSE_SYS_WWW, path), join(NOSE_USR_WWW, path)]) + .flat() + .filter(path => isFile(path))[0] + + if (!path) return + + return dirname(path) +} + async function findApp(name: string): Promise { const paths = [ `${name}.ts`,