sys -> root

This commit is contained in:
Chris Wanstrath 2025-10-02 11:11:56 -07:00
parent ea7d538618
commit 8a6e95a500
6 changed files with 22 additions and 21 deletions

View File

@ -2,7 +2,7 @@
//
// Show some debugging information.
import { NOSE_STARTED, NOSE_SYS_BIN, NOSE_BIN, NOSE_DATA, NOSE_DIR, GIT_SHA } from "@/config"
import { NOSE_STARTED, NOSE_ROOT_BIN, NOSE_BIN, NOSE_DATA, NOSE_DIR, GIT_SHA } from "@/config"
import { highlightToHTML } from "../lib/highlight"
export default function () {
@ -15,7 +15,7 @@ export default function () {
`PWD=${valueOrNone(process.env.PWD)}`,
`NOSE_STARTED=${NOSE_STARTED}`,
`NOSE_BIN="${NOSE_BIN}"`,
`NOSE_SYS_BIN="${NOSE_SYS_BIN}"`,
`NOSE_ROOT_BIN="${NOSE_ROOT_BIN}"`,
`NOSE_DATA="${NOSE_DATA}"`,
`NOSE_DIR="${NOSE_DIR}"`,
`GIT_SHA="${GIT_SHA}"`,

View File

@ -1,2 +1,2 @@
export default () =>
"sys online"
"root online"

View File

@ -1,5 +1,5 @@
////
// Manages the commands on disk, in NOSE_SYS_BIN and NOSE_BIN
// Manages the commands on disk, in NOSE_ROOT_BIN and NOSE_BIN
import { Glob } from "bun"
import { watch } from "fs"
@ -9,17 +9,17 @@ import { sendAll } from "./websocket"
import { expectDir } from "./utils"
import { unique } from "./shared/utils"
import { projectBin, projectName } from "./project"
import { NOSE_DIR, NOSE_SYS_BIN, NOSE_BIN } from "./config"
import { DEFAULT_PROJECT, NOSE_DIR, NOSE_ROOT_BIN, NOSE_BIN } from "./config"
export function initCommands() {
startWatchers()
}
export async function commands(project = "sys"): Promise<string[]> {
export async function commands(project = DEFAULT_PROJECT): Promise<string[]> {
let cmds = (await findCommands(NOSE_BIN))
.concat(await findCommands(NOSE_SYS_BIN))
.concat(await findCommands(NOSE_ROOT_BIN))
if (project !== "sys")
if (project !== DEFAULT_PROJECT)
cmds = cmds.concat(await findCommands(projectBin()))
return unique(cmds).sort()
@ -39,11 +39,11 @@ export function commandPath(cmd: string): string | undefined {
let paths = [
join(NOSE_BIN, cmd + ".ts"),
join(NOSE_BIN, cmd + ".tsx"),
join(NOSE_SYS_BIN, cmd + ".ts"),
join(NOSE_SYS_BIN, cmd + ".tsx"),
join(NOSE_ROOT_BIN, cmd + ".ts"),
join(NOSE_ROOT_BIN, cmd + ".tsx"),
]
if (projectName() !== "sys")
if (projectName() !== DEFAULT_PROJECT)
paths = paths.concat(
join(projectBin(), cmd + ".ts"),
join(projectBin(), cmd + ".tsx"),
@ -72,7 +72,7 @@ let noseDirWatcher
let binCmdWatcher
function startWatchers() {
if (!expectDir(NOSE_BIN)) return
if (!expectDir(NOSE_SYS_BIN)) return
if (!expectDir(NOSE_ROOT_BIN)) return
binCmdWatcher = watch(NOSE_BIN, async (event, filename) => {
sendAll({ type: "commands", data: await commands() })

View File

@ -8,7 +8,8 @@ export const NOSE_BIN = resolve("./bin")
export const NOSE_DATA = resolve("./data")
export const NOSE_DIR = resolve(untilde(process.env.NOSE_DIR || "./nose"))
export const NOSE_SYS_BIN = join(NOSE_DIR, "sys", "bin")
export const DEFAULT_PROJECT = "root"
export const NOSE_ROOT_BIN = join(NOSE_DIR, DEFAULT_PROJECT, "bin")
export const NOSE_STARTED = Date.now()
export const GIT_SHA = (await $`git rev-parse --short HEAD`.text()).trim()

View File

@ -4,14 +4,14 @@
import { join } from "path"
import { readdirSync, type Dirent } from "fs"
import { sessionGet } from "./session"
import { NOSE_DIR } from "./config"
import { DEFAULT_PROJECT, NOSE_DIR } from "./config"
import { isDir } from "./utils"
export function projectName(): string {
const state = sessionGet()
if (!state) throw "no state"
return state.project || "sys"
return state.project || DEFAULT_PROJECT
}
export function projects(): string[] {

View File

@ -7,7 +7,7 @@ import { prettyJSON } from "hono/pretty-json"
import color from "kleur"
import type { Message } from "./shared/types"
import { NOSE_ICON, NOSE_BIN, NOSE_DATA, NOSE_DIR, NOSE_SYS_BIN } from "./config"
import { NOSE_ICON, NOSE_BIN, NOSE_DATA, NOSE_DIR, NOSE_ROOT_BIN } from "./config"
import { transpile, isFile, tilde, isDir } from "./utils"
import { serveApp } from "./webapp"
import { commands, commandPath, loadCommandModule } from "./commands"
@ -193,10 +193,10 @@ if (process.env.NODE_ENV === "production") {
//
console.log(color.cyan(NOSE_ICON))
console.log(color.blue(" NOSE_BIN:"), color.yellow(tilde(NOSE_BIN)))
console.log(color.blue(" NOSE_DATA:"), color.yellow(tilde(NOSE_DATA)))
console.log(color.blue(" NOSE_DIR:"), color.yellow(tilde(NOSE_DIR)))
console.log(color.blue("NOSE_SYS_BIN:"), color.yellow(tilde(NOSE_SYS_BIN)))
console.log(color.blue(" NOSE_BIN:"), color.yellow(tilde(NOSE_BIN)))
console.log(color.blue(" NOSE_DATA:"), color.yellow(tilde(NOSE_DATA)))
console.log(color.blue(" NOSE_DIR:"), color.yellow(tilde(NOSE_DIR)))
console.log(color.blue("NOSE_ROOT_BIN:"), color.yellow(tilde(NOSE_ROOT_BIN)))
await initNoseDir()
initCommands()