fix(release): keep private QA bundles out of npm pack

This commit is contained in:
Peter Steinberger
2026-04-11 13:10:42 +01:00
parent a733e92c45
commit cd89892b1f
10 changed files with 81 additions and 10 deletions

View File

@@ -216,7 +216,13 @@ const entrySpecs: readonly CommandGroupDescriptorSpec<SubCliRegistrar>[] = [
];
function resolveSubCliCommandGroups(): CommandGroupEntry[] {
return buildCommandGroupEntries(getSubCliEntryDescriptors(), entrySpecs, (register) => register);
const descriptors = getSubCliEntryDescriptors();
const descriptorNames = new Set(descriptors.map((descriptor) => descriptor.name));
return buildCommandGroupEntries(
descriptors,
entrySpecs.filter((spec) => spec.commandNames.every((name) => descriptorNames.has(name))),
(register) => register,
);
}
export function getSubCliEntries(): ReadonlyArray<SubCliDescriptor> {

View File

@@ -19,8 +19,9 @@ const { nodesAction, registerNodesCli } = vi.hoisted(() => {
return { nodesAction: action, registerNodesCli: register };
});
const { registerQaCli } = vi.hoisted(() => ({
registerQaCli: vi.fn((program: Command) => {
const { isQaLabCliAvailable, registerQaLabCli } = vi.hoisted(() => ({
isQaLabCliAvailable: vi.fn(() => true),
registerQaLabCli: vi.fn((program: Command) => {
const qa = program.command("qa");
qa.command("run").action(() => undefined);
}),
@@ -36,8 +37,8 @@ const { inferAction, registerCapabilityCli } = vi.hoisted(() => {
vi.mock("../acp-cli.js", () => ({ registerAcpCli }));
vi.mock("../nodes-cli.js", () => ({ registerNodesCli }));
vi.mock("../qa-cli.js", () => ({ registerQaCli }));
vi.mock("../capability-cli.js", () => ({ registerCapabilityCli }));
vi.mock("../../plugin-sdk/qa-lab.js", () => ({ isQaLabCliAvailable, registerQaLabCli }));
describe("registerSubCliCommands", () => {
const originalArgv = process.argv;
@@ -63,6 +64,8 @@ describe("registerSubCliCommands", () => {
acpAction.mockClear();
registerNodesCli.mockClear();
nodesAction.mockClear();
isQaLabCliAvailable.mockReset().mockReturnValue(true);
registerQaLabCli.mockClear();
registerCapabilityCli.mockClear();
inferAction.mockClear();
});
@@ -98,6 +101,14 @@ describe("registerSubCliCommands", () => {
expect(registerAcpCli).not.toHaveBeenCalled();
});
it("omits the qa placeholder when the private qa bundle is unavailable", () => {
isQaLabCliAvailable.mockReturnValue(false);
const program = createRegisteredProgram(["node", "openclaw"]);
expect(program.commands.map((cmd) => cmd.name())).not.toContain("qa");
});
it("re-parses argv for lazy subcommands", async () => {
const program = createRegisteredProgram(["node", "openclaw", "nodes", "list"], "openclaw");

View File

@@ -1,3 +1,4 @@
import { isQaLabCliAvailable } from "../../plugin-sdk/qa-lab.js";
import { defineCommandDescriptorCatalog } from "./command-descriptor-utils.js";
import type { NamedCommandDescriptor } from "./command-group-descriptors.js";
@@ -157,9 +158,17 @@ const subCliCommandCatalog = defineCommandDescriptorCatalog([
export const SUB_CLI_DESCRIPTORS = subCliCommandCatalog.descriptors;
export function getSubCliEntries(): ReadonlyArray<SubCliDescriptor> {
return subCliCommandCatalog.getDescriptors();
const descriptors = subCliCommandCatalog.getDescriptors();
if (isQaLabCliAvailable()) {
return descriptors;
}
return descriptors.filter((descriptor) => descriptor.name !== "qa");
}
export function getSubCliCommandsWithSubcommands(): string[] {
return subCliCommandCatalog.getCommandsWithSubcommands();
const commands = subCliCommandCatalog.getCommandsWithSubcommands();
if (isQaLabCliAvailable()) {
return commands;
}
return commands.filter((command) => command !== "qa");
}