fix(cli): keep plugin command metadata intact

This commit is contained in:
Peter Steinberger
2026-05-24 01:04:08 +01:00
parent 15ff89bf5d
commit 9ab0af270a
4 changed files with 16 additions and 11 deletions

View File

@@ -59,10 +59,11 @@ async function registerGatewayRunOnly(program: Command): Promise<void> {
async function registerSubCliWithPluginCommands(
program: Command,
argv: string[],
registerSubCli: () => Promise<void>,
pluginCliPosition: "before" | "after",
) {
const invocation = resolveCliArgvInvocation(process.argv);
const invocation = resolveCliArgvInvocation(argv);
const shouldRegisterPluginCommands =
!invocation.hasHelpOrVersion &&
resolveCliCommandPathPolicy(invocation.commandPath).loadPlugins !== "never";
@@ -204,9 +205,10 @@ const entrySpecs: readonly CommandGroupDescriptorSpec<SubCliRegistrar>[] = [
]),
{
commandNames: ["pairing"],
register: async (program) => {
register: async (program, argv) => {
await registerSubCliWithPluginCommands(
program,
argv,
async () => {
const mod = await import("../pairing-cli.js");
mod.registerPairingCli(program);
@@ -217,9 +219,10 @@ const entrySpecs: readonly CommandGroupDescriptorSpec<SubCliRegistrar>[] = [
},
{
commandNames: ["plugins"],
register: async (program) => {
register: async (program, argv) => {
await registerSubCliWithPluginCommands(
program,
argv,
async () => {
const mod = await import("../plugins-cli.js");
mod.registerPluginsCli(program);

View File

@@ -50,9 +50,7 @@ export const routedCommands: RouteSpec[] = cliCommandCatalog
): entry is CliCommandCatalogEntry & { route: { id: keyof typeof routedCommandDefinitions } } =>
Boolean(entry.route),
)
.map((entry) =>
createParsedRoute({
entry,
definition: routedCommandDefinitions[entry.route.id],
}),
);
.flatMap((entry) => {
const definition = routedCommandDefinitions[entry.route.id];
return definition ? [createParsedRoute({ entry, definition })] : [];
});