diff --git a/bin/env.ts b/bin/env.ts index ff45582..3370ec2 100644 --- a/bin/env.ts +++ b/bin/env.ts @@ -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}"`, diff --git a/nose/sys/bin/sys.ts b/nose/root/bin/root.ts similarity index 55% rename from nose/sys/bin/sys.ts rename to nose/root/bin/root.ts index 7a25c01..11bb0f3 100644 --- a/nose/sys/bin/sys.ts +++ b/nose/root/bin/root.ts @@ -1,2 +1,2 @@ export default () => - "sys online" \ No newline at end of file + "root online" \ No newline at end of file diff --git a/src/commands.ts b/src/commands.ts index 929f545..566007c 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -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 { +export async function commands(project = DEFAULT_PROJECT): Promise { 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() }) diff --git a/src/config.ts b/src/config.ts index 71cca6a..124a3a8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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() \ No newline at end of file diff --git a/src/project.ts b/src/project.ts index 1b7cdd3..3ce6d87 100644 --- a/src/project.ts +++ b/src/project.ts @@ -1,17 +1,17 @@ -//// +//// // Helpers for working with projects in the CLI. 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[] { diff --git a/src/server.tsx b/src/server.tsx index 2ebb454..3d0b6cd 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -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()