piddly little docs
This commit is contained in:
parent
3e02b3d348
commit
7385900445
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Show the webapps hosted on this NOSEputer.
|
||||||
|
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
import { apps } from "app/src/webapp"
|
import { apps } from "app/src/webapp"
|
||||||
|
|
||||||
|
|
@ -12,6 +14,6 @@ export default async function () {
|
||||||
port = port === "80" ? "" : `:${port}`
|
port = port === "80" ? "" : `:${port}`
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
{apps().map(app => <><a href={`http://${app}.${domain}${port}`}>{app}</a>{" "}</>)}
|
{apps().map(app => <a href={`http://${app}.${domain}${port}`}>{app}</a>)}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Show the contents of a file, if possible.
|
||||||
|
|
||||||
import { escapeHTML } from "bun"
|
import { escapeHTML } from "bun"
|
||||||
import { readdirSync } from "fs"
|
import { readdirSync } from "fs"
|
||||||
import { join, extname } from "path"
|
import { join, extname } from "path"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Change directory.
|
||||||
|
|
||||||
import { dirname, resolve, isAbsolute } from "path"
|
import { dirname, resolve, isAbsolute } from "path"
|
||||||
import { statSync } from "fs"
|
import { statSync } from "fs"
|
||||||
import { projectDir } from "@/project"
|
import { projectDir } from "@/project"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// stream() demo. Counts.
|
||||||
|
|
||||||
import { stream } from "@/stream"
|
import { stream } from "@/stream"
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Monkey see, monkey do.
|
||||||
|
|
||||||
export default function (...args: string[]): string {
|
export default function (...args: string[]): string {
|
||||||
return args.join(" ")
|
return args.join(" ")
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Open the Advanced Text Editor and start editing a file.
|
||||||
|
|
||||||
import { readdirSync } from "fs"
|
import { readdirSync } from "fs"
|
||||||
import { join, extname } from "path"
|
import { join, extname } from "path"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
// NOSE developer feature.
|
||||||
|
//
|
||||||
|
// Show some debugging information.
|
||||||
|
|
||||||
import { NOSE_STARTED, NOSE_SYS, NOSE_DIR, GIT_SHA } from "@/config"
|
import { NOSE_STARTED, NOSE_SYS, NOSE_DIR, GIT_SHA } from "@/config"
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
/// <reference lib="dom" />
|
/// <reference lib="dom" />
|
||||||
|
// Small game demo.
|
||||||
|
|
||||||
export const game = true
|
export const game = true
|
||||||
|
|
||||||
import type { InputState } from "@/shared/types"
|
import type { InputState } from "@/shared/types"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export default function (name: string): string {
|
|
||||||
return `Hi, ${name || "stranger"}!!!!`
|
|
||||||
}
|
|
||||||
26
app/nose/bin/help.ts
Normal file
26
app/nose/bin/help.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Show helpful information about a command.
|
||||||
|
//
|
||||||
|
// (Hopefully.)
|
||||||
|
|
||||||
|
import { commandPath } from "@/commands"
|
||||||
|
|
||||||
|
export default async function (cmd: string) {
|
||||||
|
const path = commandPath(cmd)
|
||||||
|
if (!path) throw `${cmd} not found`
|
||||||
|
|
||||||
|
const code = (await Bun.file(path).text()).split("\n")
|
||||||
|
let docs = []
|
||||||
|
|
||||||
|
for (const line of code) {
|
||||||
|
if (line.startsWith("///")) {
|
||||||
|
docs.push("Runs in the browser.\n")
|
||||||
|
continue
|
||||||
|
} else if (line.startsWith("//")) {
|
||||||
|
docs.push(line.slice(2).trim())
|
||||||
|
} else if (line.trim()) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return docs.join("\n")
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
|
// Load a project so you can work on it.
|
||||||
|
|
||||||
import { apps } from "app/src/webapp"
|
import { apps } from "app/src/webapp"
|
||||||
import { getState } from "@/session"
|
import { getState } from "@/session"
|
||||||
|
|
||||||
export default function (project: string) {
|
export default function (project: string) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
|
if (!project) throw `usage: load <project name>`
|
||||||
|
|
||||||
if (state && apps().includes(project)) {
|
if (state && apps().includes(project)) {
|
||||||
state.project = project
|
state.project = project
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Look around.
|
||||||
|
|
||||||
import { readdirSync } from "fs"
|
import { readdirSync } from "fs"
|
||||||
import { NOSE_WWW } from "app/src/config"
|
import { NOSE_WWW } from "app/src/config"
|
||||||
import { projectName, projectDir } from "@/project"
|
import { projectName, projectDir } from "@/project"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
// Makes a directory inside the current directory.
|
||||||
|
//
|
||||||
|
// Essentially `mkdir -p`.
|
||||||
|
|
||||||
import { mkdirSync } from "fs"
|
import { mkdirSync } from "fs"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { projectDir } from "@/project"
|
import { projectDir } from "@/project"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
// Create a new project.
|
||||||
|
//
|
||||||
|
// We should probably rename this...
|
||||||
|
|
||||||
import { mkdirSync, writeFileSync } from "fs"
|
import { mkdirSync, writeFileSync } from "fs"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
|
|
||||||
|
|
@ -8,7 +12,7 @@ import { isDir } from "app/src/utils"
|
||||||
import load from "./load"
|
import load from "./load"
|
||||||
|
|
||||||
export default function (project: string) {
|
export default function (project: string) {
|
||||||
if (!project) throw "Please provide a name for your new project\n> new <project>"
|
if (!project) throw "usage: new <project name>"
|
||||||
|
|
||||||
if (apps().includes(project)) throw `${project} already exists`
|
if (apps().includes(project)) throw `${project} already exists`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Print the currently loaded project.
|
||||||
|
|
||||||
import { getState } from "@/session"
|
import { getState } from "@/session"
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Show the projects on this NOSEputer.
|
||||||
|
|
||||||
import { apps } from "app/src/webapp"
|
import { apps } from "app/src/webapp"
|
||||||
import { getState } from "@/session"
|
import { getState } from "@/session"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Show the current working directory.
|
||||||
|
|
||||||
import { dirname } from "path"
|
import { dirname } from "path"
|
||||||
import { projectDir } from "@/project"
|
import { projectDir } from "@/project"
|
||||||
import { getState } from "@/session"
|
import { getState } from "@/session"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Remove a file.
|
||||||
|
|
||||||
import { unlinkSync, readdirSync } from "fs"
|
import { unlinkSync, readdirSync } from "fs"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { projectDir } from "@/project"
|
import { projectDir } from "@/project"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Remove a directory, and all its children.
|
||||||
|
|
||||||
import { rmdirSync, readdirSync } from "fs"
|
import { rmdirSync, readdirSync } from "fs"
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { projectDir } from "@/project"
|
import { projectDir } from "@/project"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Share a webapp with the public internet.
|
||||||
|
|
||||||
import { apps } from "app/src/webapp"
|
import { apps } from "app/src/webapp"
|
||||||
import { connectSneaker, sneakers, sneakerUrl } from "app/src/sneaker"
|
import { connectSneaker, sneakers, sneakerUrl } from "app/src/sneaker"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Create an empty text file.
|
||||||
|
|
||||||
import { join } from "path"
|
import { join } from "path"
|
||||||
import { readdirSync } from "fs"
|
import { readdirSync } from "fs"
|
||||||
import { projectDir } from "@/project"
|
import { projectDir } from "@/project"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Stop sharing a webapp with the public internet.
|
||||||
|
|
||||||
import { apps } from "app/src/webapp"
|
import { apps } from "app/src/webapp"
|
||||||
import { disconnectSneaker, sneakers } from "app/src/sneaker"
|
import { disconnectSneaker, sneakers } from "app/src/sneaker"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
// Update NOSE itself and restart.
|
||||||
|
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
// How long has the NOSE app been running?
|
||||||
|
//
|
||||||
|
// Totally different from the host computer's uptime. Usually.
|
||||||
|
|
||||||
import { NOSE_STARTED } from "@/config"
|
import { NOSE_STARTED } from "@/config"
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user