diff options
author | 2023-10-03 02:17:21 -0700 | |
---|---|---|
committer | 2023-10-03 02:17:21 -0700 | |
commit | 745b6b94ee56cad24d475799690cc9a89957d15b (patch) | |
tree | 634bd13b4fdb1c331538e968258143764a414449 /test | |
parent | 47651f321ae5eb82686da5d759e9b1b5b12340ad (diff) | |
download | bun-745b6b94ee56cad24d475799690cc9a89957d15b.tar.gz bun-745b6b94ee56cad24d475799690cc9a89957d15b.tar.zst bun-745b6b94ee56cad24d475799690cc9a89957d15b.zip |
Store workspace package versions (#6258)bun-v1.0.4
* Store workspace package versions in the lockfile
* more logging
* wip
* keep information from workspace name array and cache
* hash key
* remove cache, compare workspaces with initially loaded
* uncomment sort
* remove comments
* remove allocation
* package json
* test `bun add <package>` without workspace prefix
* Update test/cli/install/bun-install.test.ts
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Markus Staab <maggus.staab@googlemail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/cli/install/bun-install.test.ts | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/test/cli/install/bun-install.test.ts b/test/cli/install/bun-install.test.ts index 19a5851a1..ce61268a0 100644 --- a/test/cli/install/bun-install.test.ts +++ b/test/cli/install/bun-install.test.ts @@ -5550,6 +5550,85 @@ it("should handle installing packages from inside a workspace with `*`", async ( await access(join(package_dir, "bun.lockb")); }); +it("should handle installing packages from inside a workspace without prefix", async () => { + await writeFile( + join(package_dir, "package.json"), + JSON.stringify({ + name: "main", + workspaces: ["packages/*"], + private: true, + }), + ); + await mkdir(join(package_dir, "packages", "p1"), { recursive: true }); + const p1_package = JSON.stringify({ + name: "p1", + version: "0.0.1", + dependencies: { + p2: "0.1.0", + }, + }); + await writeFile(join(package_dir, "packages", "p1", "package.json"), p1_package); + + await mkdir(join(package_dir, "packages", "p2")); + const p2_package = JSON.stringify({ + name: "p2", + version: "0.1.0", + }); + await writeFile(join(package_dir, "packages", "p2", "package.json"), p2_package); + + const urls: string[] = []; + setHandler(dummyRegistry(urls)); + + const { + stdout: stdout1, + stderr: stderr1, + exited: exited1, + } = spawn({ + cmd: [bunExe(), "install"], + cwd: join(package_dir, "packages", "p1"), + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr1).toBeDefined(); + const err1 = await new Response(stderr1).text(); + expect(err1).toContain("Saved lockfile"); + expect(stdout1).toBeDefined(); + const out1 = await new Response(stdout1).text(); + expect(out1.replace(/\s*\[[0-9\.]+m?s\]\s*$/, "").split(/\r?\n/)).toEqual([ + " + p1@workspace:packages/p1", + " + p2@workspace:packages/p2", + "", + " 2 packages installed", + ]); + expect(await exited1).toBe(0); + expect(requested).toBe(0); + await access(join(package_dir, "bun.lockb")); + + const { + stdout: stdout2, + stderr: stderr2, + exited: exited2, + } = spawn({ + cmd: [bunExe(), "install", "bar"], + cwd: join(package_dir, "packages", "p1"), + stdout: null, + stdin: "pipe", + stderr: "pipe", + env, + }); + expect(stderr1).toBeDefined(); + const err2 = await new Response(stderr2).text(); + expect(err2).toContain("Saved lockfile"); + expect(stdout2).toBeDefined(); + const out2 = await new Response(stdout2).text(); + expect(out2).toContain("installed bar"); + expect(await exited2).toBe(0); + expect(urls.sort()).toEqual([`${root_url}/bar`, `${root_url}/bar-0.0.2.tgz`]); + await access(join(package_dir, "bun.lockb")); +}); + it("should handle installing packages inside workspaces with difference versions", async () => { let package_jsons = [ JSON.stringify({ |