diff options
author | 2023-10-11 02:27:07 -0700 | |
---|---|---|
committer | 2023-10-11 02:27:07 -0700 | |
commit | 1bf28e0d77a8b2261befbdb708cefd03e0126960 (patch) | |
tree | 1d1120922f2fd935be47ab4255ac57455a0bede8 /test/cli/install/migration/migrate.test.ts | |
parent | 6a17ebe6696ebdf5c20de9de3281d308959c13b5 (diff) | |
download | bun-1bf28e0d77a8b2261befbdb708cefd03e0126960.tar.gz bun-1bf28e0d77a8b2261befbdb708cefd03e0126960.tar.zst bun-1bf28e0d77a8b2261befbdb708cefd03e0126960.zip |
feat(install): automatically migrate package-lock.json to bun.lockb (#6352)bun-v1.0.5
* work so far
* stuff
* a
* basics work
* stuff
* yoo
* build lockfile
* correct
* f
* a
* install fixture havent tested
* i made it worse
* lol
* be more reasonable
* make the test easier to pass because bun install doesn't handle obscure lockfile edge cases :/
* a
* works now
* ok
* a
* a
* cool
* nah
* fix stuff
* l
* a
* idfk
* LAME
* prettier errors
* does this fix tests?
* Add more safety checks to Integrity
* Add another check
* More careful lifetime handling
* Fix linux debugger issue
* a
* tmp dir and snapshot test
---------
Co-authored-by: Jarred SUmner <jarred@jarredsumner.com>
Diffstat (limited to 'test/cli/install/migration/migrate.test.ts')
-rw-r--r-- | test/cli/install/migration/migrate.test.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/cli/install/migration/migrate.test.ts b/test/cli/install/migration/migrate.test.ts new file mode 100644 index 000000000..28ccac2a0 --- /dev/null +++ b/test/cli/install/migration/migrate.test.ts @@ -0,0 +1,54 @@ +import fs from "fs"; +import { test, expect } from "bun:test"; +import { bunEnv, bunExe } from "harness"; +import { join } from "path"; +import { mkdtempSync } from "js/node/fs/export-star-from"; +import { tmpdir } from "os"; + +test("migrate from npm during `bun add`", async () => { + const testDir = mkdtempSync(join(tmpdir(), "migrate-")); + + fs.writeFileSync( + join(testDir, "package.json"), + JSON.stringify({ + name: "test3", + dependencies: { + "svelte": "*", + }, + }), + ); + fs.cpSync(join(import.meta.dir, "add-while-migrate-fixture.json"), join(testDir, "package-lock.json")); + + Bun.spawnSync([bunExe(), "add", "lodash@4.17.21"], { + env: bunEnv, + cwd: testDir, + }); + + expect(fs.existsSync(join(testDir, "node_modules/lodash"))).toBeTrue(); + + const svelte_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/svelte/package.json"), "utf8")).version; + expect(svelte_version).toBe("4.0.0"); + + const lodash_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/lodash/package.json"), "utf8")).version; + expect(lodash_version).toBe("4.17.21"); +}); + +// Currently this upgrades svelte :( +test.todo("migrate workspace from npm during `bun add`", async () => { + const testDir = join(tmpdir(), "migrate-" + Math.random().toString(36).slice(2)); + + fs.cpSync(join(import.meta.dir, "add-while-migrate-workspace"), testDir, { recursive: true }); + + Bun.spawnSync([bunExe(), "add", "lodash@4.17.21"], { + env: bunEnv, + cwd: join(testDir, "packages", "a"), + }); + + expect(fs.existsSync(join(testDir, "node_modules/lodash"))).toBeTrue(); + + const lodash_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/lodash/package.json"), "utf8")).version; + expect(lodash_version).toBe("4.17.21"); + + const svelte_version = JSON.parse(fs.readFileSync(join(testDir, "node_modules/svelte/package.json"), "utf8")).version; + expect(svelte_version).toBe("3.0.0"); +}); |