load other apps
This commit is contained in:
parent
ba7b14937e
commit
bf18eb4168
6 changed files with 47 additions and 8 deletions
6
apps/calendar/manifest.yml
Normal file
6
apps/calendar/manifest.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
name: panorama/calendar
|
||||||
|
|
||||||
|
depends:
|
||||||
|
- name: panorama
|
||||||
|
|
||||||
|
# code: dist/index.js
|
BIN
bun.lockb
Normal file
BIN
bun.lockb
Normal file
Binary file not shown.
8
package.json
Normal file
8
package.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "panorama",
|
||||||
|
"private": true,
|
||||||
|
"workspaces": [
|
||||||
|
"packages/*",
|
||||||
|
"apps/*"
|
||||||
|
]
|
||||||
|
}
|
Binary file not shown.
|
@ -3,6 +3,7 @@
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@biomejs/biome": "^1.8.3",
|
||||||
"@types/bun": "latest",
|
"@types/bun": "latest",
|
||||||
"@types/koa-json": "^2.0.23",
|
"@types/koa-json": "^2.0.23",
|
||||||
"@types/koa__router": "^12.0.4"
|
"@types/koa__router": "^12.0.4"
|
||||||
|
@ -21,5 +22,8 @@
|
||||||
"uuidv7": "^1.0.1",
|
"uuidv7": "^1.0.1",
|
||||||
"yaml": "^2.4.5",
|
"yaml": "^2.4.5",
|
||||||
"zod": "^3.23.8"
|
"zod": "^3.23.8"
|
||||||
}
|
},
|
||||||
|
"trustedDependencies": [
|
||||||
|
"@biomejs/biome"
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import { join } from "node:path";
|
import { join, dirname } from "node:path";
|
||||||
import { parse } from "yaml";
|
import { parse } from "yaml";
|
||||||
import { readFile } from "node:fs/promises";
|
import { readdir, readFile } from "node:fs/promises";
|
||||||
import Router from "@koa/router";
|
import Router from "@koa/router";
|
||||||
import { manifestSchema, type Manifest } from "./manifest";
|
import { manifestSchema, type Manifest } from "./manifest";
|
||||||
import { dataSource } from "../db";
|
import { dataSource } from "../db";
|
||||||
|
@ -18,18 +18,39 @@ export function sanitizeName(name: string): string {
|
||||||
export async function loadApps(): Promise<Map<string, CustomApp>> {
|
export async function loadApps(): Promise<Map<string, CustomApp>> {
|
||||||
const apps = new Map();
|
const apps = new Map();
|
||||||
const paths = [
|
const paths = [
|
||||||
"/Users/michael/Projects/panorama/apps/std",
|
join(dirname(dirname(dirname(dirname(dirname(import.meta.path))))), "apps"),
|
||||||
"/Users/michael/Projects/panorama/apps/codetrack",
|
"/Users/michael/Projects/panorama/apps",
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const path of paths) {
|
for (const basePath of paths) {
|
||||||
const app = await loadApp(path);
|
try {
|
||||||
apps.set(app.name, app);
|
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;
|
return apps;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadApp(path: string): Promise<CustomApp> {
|
export async function loadApp(path: string): Promise<CustomApp> {
|
||||||
|
console.log("Loading app from", path);
|
||||||
const manifestPath = join(path, "manifest.yml");
|
const manifestPath = join(path, "manifest.yml");
|
||||||
const manifestRaw = parse(await readFile(manifestPath, "utf-8"));
|
const manifestRaw = parse(await readFile(manifestPath, "utf-8"));
|
||||||
const manifest = manifestSchema.parse(manifestRaw);
|
const manifest = manifestSchema.parse(manifestRaw);
|
||||||
|
|
Loading…
Reference in a new issue