mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 17:05:12 +00:00
fix(cli): improve config startup progress
This commit is contained in:
@@ -168,6 +168,7 @@ describe("registerPreActionHooks", () => {
|
||||
.option("--json")
|
||||
.action(() => {});
|
||||
const config = program.command("config");
|
||||
config.option("--section <section>");
|
||||
setCommandJsonMode(config.command("set"), "parse-only")
|
||||
.argument("<path>")
|
||||
.argument("<value>")
|
||||
@@ -313,6 +314,26 @@ describe("registerPreActionHooks", () => {
|
||||
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("lets bare config own config validation and plugin loading", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["config"],
|
||||
processArgv: ["node", "openclaw", "config"],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).not.toHaveBeenCalled();
|
||||
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("lets guided config sections own config validation and plugin loading", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["config"],
|
||||
processArgv: ["node", "openclaw", "config", "--section", "models"],
|
||||
});
|
||||
|
||||
expect(ensureConfigReadyMock).not.toHaveBeenCalled();
|
||||
expect(ensurePluginRegistryLoadedMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("only allows invalid config for explicit official recovery reinstall requests", async () => {
|
||||
await runPreAction({
|
||||
parseArgv: ["plugins", "install", "@openclaw/discord"],
|
||||
|
||||
@@ -75,6 +75,10 @@ function isBareParentDefaultHelpInvocation(actionCommand: Command, argv: string[
|
||||
return primary === actionCommand.name() || actionCommand.aliases().includes(primary);
|
||||
}
|
||||
|
||||
function isGuidedConfigAction(actionCommand: Command): boolean {
|
||||
return actionCommand.name() === "config" && actionCommand.parent?.parent === undefined;
|
||||
}
|
||||
|
||||
export function registerPreActionHooks(program: Command, programVersion: string) {
|
||||
program.hook("preAction", async (_thisCommand, actionCommand) => {
|
||||
setProcessTitleForCommand(actionCommand);
|
||||
@@ -101,7 +105,7 @@ export function registerPreActionHooks(program: Command, programVersion: string)
|
||||
if (!verbose) {
|
||||
process.env.NODE_NO_WARNINGS ??= "1";
|
||||
}
|
||||
if (shouldBypassConfigGuardForCommandPath(commandPath)) {
|
||||
if (shouldBypassConfigGuardForCommandPath(commandPath) || isGuidedConfigAction(actionCommand)) {
|
||||
return;
|
||||
}
|
||||
await ensureCliExecutionBootstrap({
|
||||
|
||||
Reference in New Issue
Block a user