mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Adds plugin discovery, loading, and management to the omniroute CLI. - bin/cli/plugins.mjs: discoverPlugins / loadPlugins / buildPluginContext - bin/cli/commands/plugin.mjs: list / install / remove / info / search / update / scaffold - examples/omniroute-cmd-hello/: minimal working plugin example - docs/dev/plugins.md: plugin API contract and authoring guide - .env.example + ENVIRONMENT.md: document OMNIROUTE_PLUGIN_PATH
29 lines
860 B
JavaScript
29 lines
860 B
JavaScript
export const meta = {
|
|
name: "hello",
|
|
version: "0.1.0",
|
|
description: "Example OmniRoute plugin — greets the user and shows server health",
|
|
omnirouteApi: ">=4.0.0",
|
|
};
|
|
|
|
export function register(program, ctx) {
|
|
program
|
|
.command("hello")
|
|
.description(meta.description)
|
|
.option("-n, --name <name>", "Name to greet", "World")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
process.stdout.write(`Hello, ${opts.name}! 👋\n`);
|
|
|
|
try {
|
|
const res = await ctx.apiFetch("/api/health", {
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const health = await res.json();
|
|
ctx.emit({ greeting: `Hello, ${opts.name}!`, health }, gOpts);
|
|
} catch {
|
|
ctx.emit({ greeting: `Hello, ${opts.name}!`, health: "unavailable" }, gOpts);
|
|
}
|
|
});
|
|
}
|