controversial

This commit is contained in:
Chris Wanstrath 2025-09-21 11:32:28 -07:00
parent 66b4552def
commit 7ab885d658
4 changed files with 50 additions and 4 deletions

27
nose/bin/ls.ts Normal file
View File

@ -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(" ")
}

View File

@ -97,4 +97,8 @@
#scrollback .input .content {
margin-left: var(--cli-status-width);
}
#scrollback .output {
white-space: pre-wrap;
}

View File

@ -119,7 +119,7 @@ app.get("/apps", c => {
app.get("/", c => c.html(<Layout><Terminal /></Layout>))
//
// hot mode cleanup
// hot reload mode cleanup
//
if (process.env.BUN_HOT) {
@ -143,7 +143,6 @@ if (process.env.BUN_HOT) {
}
//
// server start
//

View File

@ -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<Response>
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<App | undefined> {
const paths = [
`${name}.ts`,