mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-20 00:23:58 +01:00
Some small refactoring
This commit is contained in:
@@ -76,12 +76,12 @@ async function* errorHandlingMiddleware<Request, Response>(
|
||||
server = server.use(errorHandlingMiddleware);
|
||||
server.add(PluginRuntimeDefinition, new PluginRuntimeService());
|
||||
|
||||
// Start on random port if GRPC_PORT_FILE_PATH is set, or :4000
|
||||
const addr = process.env.GRPC_PORT_FILE_PATH ? 'localhost:0' : 'localhost:4000';
|
||||
// Start on random port if YAAK_GRPC_PORT_FILE_PATH is set, or :4000
|
||||
const addr = process.env.YAAK_GRPC_PORT_FILE_PATH ? 'localhost:0' : 'localhost:4000';
|
||||
server.listen(addr).then((port) => {
|
||||
console.log('gRPC server listening on', `http://localhost:${port}`);
|
||||
if (process.env.GRPC_PORT_FILE_PATH) {
|
||||
console.log('Wrote port file to', process.env.GRPC_PORT_FILE_PATH);
|
||||
fs.writeFileSync(process.env.GRPC_PORT_FILE_PATH, JSON.stringify({ port }, null, 2));
|
||||
if (process.env.YAAK_GRPC_PORT_FILE_PATH) {
|
||||
console.log('Wrote port file to', process.env.YAAK_GRPC_PORT_FILE_PATH);
|
||||
fs.writeFileSync(process.env.YAAK_GRPC_PORT_FILE_PATH, JSON.stringify({ port }, null, 2));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface PluginInfo {
|
||||
}
|
||||
|
||||
export function loadPlugins(): PluginHandle[] {
|
||||
const pluginsDir = process.env.PLUGINS_DIR;
|
||||
const pluginsDir = process.env.YAAK_PLUGINS_DIR;
|
||||
if (!pluginsDir) throw new Error('PLUGINS_DIR is not set');
|
||||
console.log('Loading plugins from', pluginsDir);
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
const {readdirSync, cpSync} = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const {execSync} = require("node:child_process");
|
||||
const PLUGINS_DIR = process.env.YAAK_PLUGINS_DIR;
|
||||
if (!PLUGINS_DIR) {
|
||||
const pluginsDir = process.env.YAAK_PLUGINS_DIR;
|
||||
if (!pluginsDir) {
|
||||
console.log("YAAK_PLUGINS_DIR is not set");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('Installing Yaak plugins dependencies', PLUGINS_DIR);
|
||||
execSync('npm ci', {cwd: PLUGINS_DIR});
|
||||
console.log('Building Yaak plugins', PLUGINS_DIR);
|
||||
execSync('npm run build', {cwd: PLUGINS_DIR});
|
||||
console.log('Installing Yaak plugins dependencies', pluginsDir);
|
||||
execSync('npm ci', {cwd: pluginsDir});
|
||||
console.log('Building Yaak plugins', pluginsDir);
|
||||
execSync('npm run build', {cwd: pluginsDir});
|
||||
|
||||
console.log('Copying Yaak plugins to', PLUGINS_DIR);
|
||||
console.log('Copying Yaak plugins to', pluginsDir);
|
||||
|
||||
const pluginsRoot = path.join(PLUGINS_DIR, 'plugins');
|
||||
const pluginsRoot = path.join(pluginsDir, 'plugins');
|
||||
for (const name of readdirSync(pluginsRoot)) {
|
||||
const dir = path.join(pluginsRoot, name);
|
||||
if (name.startsWith('.')) continue;
|
||||
|
||||
@@ -45,8 +45,8 @@ pub async fn node_start<R: Runtime>(app: &AppHandle<R>, temp_dir: &PathBuf) -> S
|
||||
.shell()
|
||||
.sidecar("node")
|
||||
.unwrap()
|
||||
.env("GRPC_PORT_FILE_PATH", port_file_path.clone())
|
||||
.env("PLUGINS_DIR", plugins_dir)
|
||||
.env("YAAK_GRPC_PORT_FILE_PATH", port_file_path.clone())
|
||||
.env("YAAK_PLUGINS_DIR", plugins_dir)
|
||||
.args(&[plugin_runtime_dir.join("index.cjs")])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user