mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
feat: add apps/p2 (imported from pi-private at 7dadff697)
p2 (Pi Mobile on Chord v2) moves from pi-private into pi as one commit. Root scripts that loop all workspaces use --if-present; npm test, ./test.sh and the release script cover packages/* only (p2: cd apps/p2 && npm test); sync-versions also updates apps' workspace pins.
This commit is contained in:
parent
f409847473
commit
05dc8d239d
630 changed files with 119796 additions and 13 deletions
36
apps/p2/plugins/envs/worker.ts
Normal file
36
apps/p2/plugins/envs/worker.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { contribute, defineFacet } from "@p2/app/v1";
|
||||
import { HarnessEnvironments, workerOf } from "@p2/app/v1/worker";
|
||||
import { loadEnvs } from "./config.ts";
|
||||
import { remoteSession } from "./remote-env.ts";
|
||||
import { EnvStore } from "./store.ts";
|
||||
|
||||
export default defineFacet((host) => {
|
||||
contribute(host, "p2.worker-envs", (self) => {
|
||||
const worker = workerOf(self);
|
||||
self.open(
|
||||
async () => {
|
||||
const store = new EnvStore(worker().init.dataDir);
|
||||
await store.observer.start();
|
||||
return store;
|
||||
},
|
||||
(store) => store.observer.close(),
|
||||
);
|
||||
self.contribute(HarnessEnvironments, {
|
||||
remote: {
|
||||
open: async (env) => {
|
||||
const { dataDir } = worker().init;
|
||||
const configs = await loadEnvs(dataDir);
|
||||
const config = Object.hasOwn(configs, env) ? configs[env] : undefined;
|
||||
if (!config) throw new Error(`Environment "${env}" is not configured; refusing local execution`);
|
||||
// One connection for every conversation working on this environment, at its directories.
|
||||
const remote = remoteSession(dataDir, env, config, "/");
|
||||
return { at: remote.at, close: () => remote.connection.close() };
|
||||
},
|
||||
host: async (env) => {
|
||||
const configs = await loadEnvs(worker().init.dataDir);
|
||||
return Object.hasOwn(configs, env) ? configs[env]?.host : undefined;
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue