Skip to content

Commit 749b3ee

Browse files
fix(doctor): keep plugin runtime deps repair explicit
1 parent 78a8e3c commit 749b3ee

1 file changed

Lines changed: 31 additions & 21 deletions

File tree

src/commands/doctor-bundled-plugin-runtime-deps.test.ts

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ function expectNoLegacyRuntimeDepsManifest(installRoot: string): void {
121121
expect(fs.existsSync(path.join(installRoot, ".openclaw-runtime-deps.json"))).toBe(false);
122122
}
123123

124-
function createNonInteractivePrompter(
124+
function createNonInteractiveDoctorPrompter(
125125
options: { repair?: boolean; updateInProgress?: boolean } = {},
126126
): DoctorPrompter {
127-
const shouldRepair = options.repair ?? true;
127+
const shouldRepair = options.repair ?? false;
128128
return {
129129
shouldRepair,
130130
shouldForce: false,
@@ -143,6 +143,16 @@ function createNonInteractivePrompter(
143143
} as DoctorPrompter;
144144
}
145145

146+
function createPlainNonInteractivePrompter(): DoctorPrompter {
147+
return createNonInteractiveDoctorPrompter();
148+
}
149+
150+
function createNonInteractiveRepairPrompter(
151+
options: { updateInProgress?: boolean } = {},
152+
): DoctorPrompter {
153+
return createNonInteractiveDoctorPrompter({ ...options, repair: true });
154+
}
155+
146156
function createRuntime(options: { logs?: string[]; errors?: string[] } = {}): RuntimeEnv {
147157
return {
148158
log: (message: unknown) => {
@@ -488,7 +498,7 @@ describe("doctor bundled plugin runtime deps", () => {
488498

489499
await maybeRepairBundledPluginRuntimeDeps({
490500
runtime: createRuntime(),
491-
prompter: createNonInteractivePrompter(),
501+
prompter: createNonInteractiveRepairPrompter(),
492502
packageRoot: root,
493503
config: {
494504
plugins: { enabled: true },
@@ -512,7 +522,7 @@ describe("doctor bundled plugin runtime deps", () => {
512522

513523
await maybeRepairBundledPluginRuntimeDeps({
514524
runtime: createRuntime(),
515-
prompter: createNonInteractivePrompter({ repair: false }),
525+
prompter: createPlainNonInteractivePrompter(),
516526
packageRoot: root,
517527
config: {
518528
plugins: {
@@ -548,7 +558,7 @@ describe("doctor bundled plugin runtime deps", () => {
548558

549559
await maybeRepairBundledPluginRuntimeDeps({
550560
runtime: createRuntime(),
551-
prompter: createNonInteractivePrompter(),
561+
prompter: createNonInteractiveRepairPrompter(),
552562
packageRoot: root,
553563
config: {
554564
plugins: {
@@ -582,7 +592,7 @@ describe("doctor bundled plugin runtime deps", () => {
582592

583593
await maybeRepairBundledPluginRuntimeDeps({
584594
runtime: createRuntime(),
585-
prompter: createNonInteractivePrompter(),
595+
prompter: createNonInteractiveRepairPrompter(),
586596
packageRoot: root,
587597
config: {
588598
plugins: { enabled: true },
@@ -617,7 +627,7 @@ describe("doctor bundled plugin runtime deps", () => {
617627

618628
await maybeRepairBundledPluginRuntimeDeps({
619629
runtime: createRuntime(),
620-
prompter: createNonInteractivePrompter(),
630+
prompter: createNonInteractiveRepairPrompter(),
621631
packageRoot: root,
622632
config: {
623633
plugins: { enabled: true },
@@ -653,15 +663,15 @@ describe("doctor bundled plugin runtime deps", () => {
653663
]);
654664
});
655665

656-
it("repairs missing deps during non-interactive doctor", async () => {
666+
it("repairs missing deps during doctor --fix --non-interactive", async () => {
657667
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-doctor-bundled-"));
658668
writeJson(path.join(root, "package.json"), { name: "openclaw" });
659669
writeBundledChannelPlugin(root, "telegram", { grammy: "1.37.0" });
660670
const installed = createInstalledRuntimeDeps();
661671

662672
await maybeRepairBundledPluginRuntimeDeps({
663673
runtime: createRuntime(),
664-
prompter: createNonInteractivePrompter(),
674+
prompter: createNonInteractiveRepairPrompter(),
665675
packageRoot: root,
666676
config: {
667677
plugins: { enabled: true },
@@ -688,7 +698,7 @@ describe("doctor bundled plugin runtime deps", () => {
688698
expectNoLegacyRuntimeDepsManifest(installRoot);
689699
});
690700

691-
it("repairs a previous incomplete runtime deps install during non-interactive doctor", async () => {
701+
it("repairs a previous incomplete runtime deps install during doctor --fix --non-interactive", async () => {
692702
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-doctor-bundled-"));
693703
writeJson(path.join(root, "package.json"), { name: "openclaw" });
694704
writeBundledChannelPlugin(root, "telegram", { grammy: "1.37.0" });
@@ -701,7 +711,7 @@ describe("doctor bundled plugin runtime deps", () => {
701711

702712
await maybeRepairBundledPluginRuntimeDeps({
703713
runtime: createRuntime(),
704-
prompter: createNonInteractivePrompter(),
714+
prompter: createNonInteractiveRepairPrompter(),
705715
packageRoot: root,
706716
config: {
707717
plugins: { enabled: true },
@@ -730,7 +740,7 @@ describe("doctor bundled plugin runtime deps", () => {
730740

731741
await maybeRepairBundledPluginRuntimeDeps({
732742
runtime: createRuntime({ logs }),
733-
prompter: createNonInteractivePrompter(),
743+
prompter: createNonInteractiveRepairPrompter(),
734744
packageRoot: root,
735745
config: {
736746
plugins: { enabled: true },
@@ -757,7 +767,7 @@ describe("doctor bundled plugin runtime deps", () => {
757767

758768
const repair = maybeRepairBundledPluginRuntimeDeps({
759769
runtime: createRuntime({ logs }),
760-
prompter: createNonInteractivePrompter(),
770+
prompter: createNonInteractiveRepairPrompter(),
761771
packageRoot: root,
762772
config: {
763773
plugins: { enabled: true },
@@ -789,7 +799,7 @@ describe("doctor bundled plugin runtime deps", () => {
789799

790800
const repair = maybeRepairBundledPluginRuntimeDeps({
791801
runtime: { error: () => {}, log: () => {} } as never,
792-
prompter: createNonInteractivePrompter(),
802+
prompter: createNonInteractiveRepairPrompter(),
793803
packageRoot: root,
794804
config: {
795805
plugins: { enabled: true },
@@ -819,7 +829,7 @@ describe("doctor bundled plugin runtime deps", () => {
819829

820830
await maybeRepairBundledPluginRuntimeDeps({
821831
runtime: createRuntime(),
822-
prompter: createNonInteractivePrompter(),
832+
prompter: createNonInteractiveRepairPrompter(),
823833
packageRoot: root,
824834
config: {
825835
plugins: { enabled: true },
@@ -849,7 +859,7 @@ describe("doctor bundled plugin runtime deps", () => {
849859

850860
await maybeRepairBundledPluginRuntimeDeps({
851861
runtime: createRuntime(),
852-
prompter: createNonInteractivePrompter(),
862+
prompter: createNonInteractiveRepairPrompter(),
853863
packageRoot: root,
854864
config: {
855865
plugins: {
@@ -880,7 +890,7 @@ describe("doctor bundled plugin runtime deps", () => {
880890
await expect(
881891
maybeRepairBundledPluginRuntimeDeps({
882892
runtime: createRuntime({ errors }),
883-
prompter: createNonInteractivePrompter(),
893+
prompter: createNonInteractiveRepairPrompter(),
884894
packageRoot: root,
885895
config: {
886896
plugins: { enabled: true },
@@ -905,7 +915,7 @@ describe("doctor bundled plugin runtime deps", () => {
905915

906916
await maybeRepairBundledPluginRuntimeDeps({
907917
runtime: createRuntime(),
908-
prompter: createNonInteractivePrompter({ updateInProgress: true }),
918+
prompter: createNonInteractiveRepairPrompter({ updateInProgress: true }),
909919
packageRoot: root,
910920
includeConfiguredChannels: true,
911921
config: {
@@ -938,7 +948,7 @@ describe("doctor bundled plugin runtime deps", () => {
938948

939949
await maybeRepairBundledPluginRuntimeDeps({
940950
runtime: createRuntime(),
941-
prompter: createNonInteractivePrompter(),
951+
prompter: createNonInteractiveRepairPrompter(),
942952
env,
943953
packageRoot: root,
944954
config: {
@@ -992,7 +1002,7 @@ describe("doctor bundled plugin runtime deps", () => {
9921002

9931003
await maybeRepairBundledPluginRuntimeDeps({
9941004
runtime: createRuntime(),
995-
prompter: createNonInteractivePrompter(),
1005+
prompter: createNonInteractiveRepairPrompter(),
9961006
env,
9971007
packageRoot: root,
9981008
config: {
@@ -1028,7 +1038,7 @@ describe("doctor bundled plugin runtime deps", () => {
10281038

10291039
await maybeRepairBundledPluginRuntimeDeps({
10301040
runtime: createRuntime(),
1031-
prompter: createNonInteractivePrompter(),
1041+
prompter: createNonInteractiveRepairPrompter(),
10321042
packageRoot: root,
10331043
includeConfiguredChannels: true,
10341044
config: {

0 commit comments

Comments
 (0)