fix: keep bundled plugin peers nested · openclaw/openclaw@86faf65
steipete
·
2026-05-22
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -701,6 +701,71 @@ describe("managed npm root", () => {
|
701 | 701 | }); |
702 | 702 | }); |
703 | 703 | |
| 704 | +it("does not promote nested bundled peer ranges without a root peer package", async () => { |
| 705 | +const npmRoot = await makeTempRoot(); |
| 706 | +await fs.writeFile( |
| 707 | +path.join(npmRoot, "package.json"), |
| 708 | +`${JSON.stringify( |
| 709 | + { |
| 710 | + private: true, |
| 711 | + dependencies: { |
| 712 | + plugin: "file:./plugin.tgz", |
| 713 | + }, |
| 714 | + }, |
| 715 | + null, |
| 716 | + 2, |
| 717 | + )}\n`, |
| 718 | +); |
| 719 | + |
| 720 | +const runCommand = vi.fn(async (_args: string[], optionsOrTimeout: number | CommandOptions) => { |
| 721 | +const options = requireCommandOptions(optionsOrTimeout, "npm peer plan"); |
| 722 | +if (!options.cwd) { |
| 723 | +throw new Error("expected npm peer plan cwd"); |
| 724 | +} |
| 725 | +await fs.writeFile( |
| 726 | +path.join(options.cwd, "package-lock.json"), |
| 727 | +`${JSON.stringify( |
| 728 | + { |
| 729 | + lockfileVersion: 3, |
| 730 | + packages: { |
| 731 | + "": { |
| 732 | + dependencies: { |
| 733 | + plugin: "file:./plugin.tgz", |
| 734 | + }, |
| 735 | + }, |
| 736 | + "node_modules/plugin": { |
| 737 | + version: "1.0.0", |
| 738 | + }, |
| 739 | + "node_modules/plugin/node_modules/runtime-lib": { |
| 740 | + peerDependencies: { |
| 741 | + zod: "^4.0.0", |
| 742 | + }, |
| 743 | + version: "1.0.0", |
| 744 | + }, |
| 745 | + "node_modules/plugin/node_modules/zod": { |
| 746 | + version: "4.4.3", |
| 747 | + }, |
| 748 | + }, |
| 749 | + }, |
| 750 | + null, |
| 751 | + 2, |
| 752 | + )}\n`, |
| 753 | +); |
| 754 | +return successfulSpawn; |
| 755 | +}); |
| 756 | + |
| 757 | +await expect(syncManagedNpmRootPeerDependencies({ npmRoot, runCommand })).resolves.toBe(false); |
| 758 | + |
| 759 | +await expect( |
| 760 | +fs.readFile(path.join(npmRoot, "package.json"), "utf8").then((raw) => JSON.parse(raw)), |
| 761 | +).resolves.toEqual({ |
| 762 | +private: true, |
| 763 | +dependencies: { |
| 764 | +plugin: "file:./plugin.tgz", |
| 765 | +}, |
| 766 | +}); |
| 767 | +}); |
| 768 | + |
704 | 769 | it("removes one managed dependency without dropping unrelated metadata", async () => { |
705 | 770 | const npmRoot = await makeTempRoot(); |
706 | 771 | await fs.writeFile( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。