diff --git a/apps/calendar/manifest.yml b/apps/calendar/manifest.yml new file mode 100644 index 0000000..9bfad4a --- /dev/null +++ b/apps/calendar/manifest.yml @@ -0,0 +1,6 @@ +name: panorama/calendar + +depends: +- name: panorama + +# code: dist/index.js \ No newline at end of file diff --git a/bun.lockb b/bun.lockb new file mode 100644 index 0000000..4a14181 Binary files /dev/null and b/bun.lockb differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..59151fa --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "panorama", + "private": true, + "workspaces": [ + "packages/*", + "apps/*" + ] +} \ No newline at end of file diff --git a/packages/panorama-daemon/bun.lockb b/packages/panorama-daemon/bun.lockb index 2ba2afa..d27c17f 100755 Binary files a/packages/panorama-daemon/bun.lockb and b/packages/panorama-daemon/bun.lockb differ diff --git a/packages/panorama-daemon/package.json b/packages/panorama-daemon/package.json index 62ada9a..c48912f 100644 --- a/packages/panorama-daemon/package.json +++ b/packages/panorama-daemon/package.json @@ -3,6 +3,7 @@ "module": "src/index.ts", "type": "module", "devDependencies": { + "@biomejs/biome": "^1.8.3", "@types/bun": "latest", "@types/koa-json": "^2.0.23", "@types/koa__router": "^12.0.4" @@ -21,5 +22,8 @@ "uuidv7": "^1.0.1", "yaml": "^2.4.5", "zod": "^3.23.8" - } + }, + "trustedDependencies": [ + "@biomejs/biome" + ] } \ No newline at end of file diff --git a/packages/panorama-daemon/src/apps/index.ts b/packages/panorama-daemon/src/apps/index.ts index f0ebca3..52aacb5 100644 --- a/packages/panorama-daemon/src/apps/index.ts +++ b/packages/panorama-daemon/src/apps/index.ts @@ -1,6 +1,6 @@ -import { join } from "node:path"; +import { join, dirname } from "node:path"; import { parse } from "yaml"; -import { readFile } from "node:fs/promises"; +import { readdir, readFile } from "node:fs/promises"; import Router from "@koa/router"; import { manifestSchema, type Manifest } from "./manifest"; import { dataSource } from "../db"; @@ -18,18 +18,39 @@ export function sanitizeName(name: string): string { export async function loadApps(): Promise> { const apps = new Map(); const paths = [ - "/Users/michael/Projects/panorama/apps/std", - "/Users/michael/Projects/panorama/apps/codetrack", + join(dirname(dirname(dirname(dirname(dirname(import.meta.path))))), "apps"), + "/Users/michael/Projects/panorama/apps", ]; - for (const path of paths) { - const app = await loadApp(path); - apps.set(app.name, app); + for (const basePath of paths) { + try { + const children = await readdir(basePath); + for (const name of children) { + const child = join(basePath, name); + try { + const app = await loadApp(child); + apps.set(app.name, app); + } catch (e) { + console.error("Error setting up " + child + ": " + e.message) + throw e; + } + } + } catch (e) { + if (e.name === "ResolveMessage") { + console.warn("Path " + basePath + " not found") + } + else { + console.error("Error: " + e.message); + console.error(e.stackTrace) + throw e; + } + } } return apps; } export async function loadApp(path: string): Promise { + console.log("Loading app from", path); const manifestPath = join(path, "manifest.yml"); const manifestRaw = parse(await readFile(manifestPath, "utf-8")); const manifest = manifestSchema.parse(manifestRaw);