From a121f18d645d0a81c79b8eff41064c6f5531e9ec Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Mon, 11 Sep 2023 12:20:03 -0600 Subject: [PATCH 1/4] add bun to config.json --- config.json | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/config.json b/config.json index b0c842adb..ee1f1c176 100644 --- a/config.json +++ b/config.json @@ -136,6 +136,40 @@ } } } + }, + "bun": { + "default": "1.0.0", + "fetchLatestFrom": { + "type": "npm", + "package": "bun" + }, + "transparent": { + "commands": [ + [ + "bun", + "init" + ], + [ + "bunx" + ] + ] + }, + "ranges": { + "*": { + "url": "https://registry.npmjs.org/bun/-/bun-{}.tgz", + "bin": { + "bun": "./bin/bun", + "bunx": "./bin/bun" + }, + "registry": { + "type": "npm", + "package": "bun" + }, + "commands": { + "use": ["bun", "install"] + } + } + } } } } From 4dd0b44418bee234a3f671685549a249ab78b30b Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Mon, 11 Sep 2023 12:40:46 -0600 Subject: [PATCH 2/4] add bun to more places --- .github/workflows/sync.yml | 4 ++++ config.json | 2 +- package.json | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index dcfaf1d5b..d83afde50 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -26,6 +26,7 @@ jobs: LATEST_PNPM=$(curl https://registry.npmjs.org/pnpm | jq '.["dist-tags"].latest + "+sha1." + .versions[.["dist-tags"].latest].dist.shasum') LATEST_YARN=$(curl https://registry.npmjs.org/yarn | jq '.["dist-tags"].latest + "+sha1." + .versions[.["dist-tags"].latest].dist.shasum') LATEST_BERRY=$(jq -n '$version + "+sha224." + $checksum' --arg version "$LATEST_BERRY_VERSION" --arg checksum "$(curl https://repo.yarnpkg.com/"$LATEST_BERRY_VERSION"/packages/yarnpkg-cli/bin/yarn.js | openssl dgst -sha224 | cut -d' ' -f2)") + LATEST_BUN=$(curl https://registry.npmjs.org/bun | jq '.["dist-tags"].latest + "+sha1." + .versions[.["dist-tags"].latest].dist.shasum') git --no-pager show HEAD:config.json | jq '. * '"{ definitions: { @@ -41,6 +42,9 @@ jobs: default: $LATEST_BERRY, }, }, + bun: { + default: $LATEST_BUN, + } }, }" > config.json diff --git a/config.json b/config.json index ee1f1c176..f1c29be94 100644 --- a/config.json +++ b/config.json @@ -138,7 +138,7 @@ } }, "bun": { - "default": "1.0.0", + "default": "1.0.0+sha1.318110dc2c46e1559fb5fef40884ebe77b711934", "fetchLatestFrom": { "type": "npm", "package": "bun" diff --git a/package.json b/package.json index 1ecc5ffe1..6d98413d7 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,9 @@ "pnpm": "./dist/pnpm.js", "pnpx": "./dist/pnpx.js", "yarn": "./dist/yarn.js", - "yarnpkg": "./dist/yarnpkg.js" + "yarnpkg": "./dist/yarnpkg.js", + "bun": "./dist/bun", + "bunx": "./dist/bunx" }, "executableFiles": [ "./dist/npm.js", @@ -81,6 +83,7 @@ "./dist/yarn.js", "./dist/yarnpkg.js", "./dist/corepack.js", + "./dist/bun", "./shims/npm", "./shims/npm.ps1", "./shims/npx", From a3bfbb2c9c1a6980d589c2039292152a026578ac Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Mon, 11 Sep 2023 16:55:14 -0600 Subject: [PATCH 3/4] maybe add tests --- tests/main.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/main.test.ts b/tests/main.test.ts index f72a97fb6..82d7b24aa 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -48,6 +48,8 @@ const testedPackageManagers: Array<[string, string]> = [ [`npm`, `6.14.2`], [`npm`, `6.14.2+sha1.f057d35cd4792c4c511bb1fa332edb43143d07b0`], [`npm`, `6.14.2+sha224.50512c1eb404900ee78586faa6d756b8d867ff46a328e6fb4cdf3a87`], + [`bun`, `1.0.0`], + [`bun`, `1.0.0+sha1.318110dc2c46e1559fb5fef40884ebe77b711934`], ]; for (const [name, version] of testedPackageManagers) { @@ -192,6 +194,12 @@ it(`should use the pinned version when local projects don't list any spec`, asyn stderr: ``, exitCode: 0, }); + + await expect(runCli(cwd, [`bun`, `--version`])).resolves.toMatchObject({ + stdout: `${config.definitions.bun.default.split(`+`, 1)[0]}\n`, + stderr: ``, + exitCode: 0, + }); }); }); From d5dec552058a324ff46141fbae216218d387f40e Mon Sep 17 00:00:00 2001 From: Ethan Arrowood Date: Mon, 5 Feb 2024 13:53:29 -0700 Subject: [PATCH 4/4] add more test --- tests/main.test.ts | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/tests/main.test.ts b/tests/main.test.ts index 82d7b24aa..055d46f54 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -48,8 +48,9 @@ const testedPackageManagers: Array<[string, string]> = [ [`npm`, `6.14.2`], [`npm`, `6.14.2+sha1.f057d35cd4792c4c511bb1fa332edb43143d07b0`], [`npm`, `6.14.2+sha224.50512c1eb404900ee78586faa6d756b8d867ff46a328e6fb4cdf3a87`], - [`bun`, `1.0.0`], - [`bun`, `1.0.0+sha1.318110dc2c46e1559fb5fef40884ebe77b711934`], + [`bun`, `1.0.26`], + [`bun`, `1.0.26+sha1.a27af658d87e0487321c3e8b8bbd69f9e408a9f1`], + [`bun`, `1.0.26+sha224.a27af658d87e0487321c3e8b8bbd69f9e408a9f1`], ]; for (const [name, version] of testedPackageManagers) { @@ -294,6 +295,11 @@ it(`should refuse to run a different package manager within a configured project stderr: ``, exitCode: 0, }); + await expect(runCli(cwd, [`bun`, `--version`])).resolves.toMatchObject({ + stdout: `${config.definitions.bun.default.split(`+`, 1)[0]}\n`, + stderr: ``, + exitCode: 0, + }); } finally { delete process.env.COREPACK_ENABLE_STRICT; delete process.env.FORCE_COLOR; @@ -320,6 +326,11 @@ it(`should always use fallback version when project spec env is disabled`, async stderr: ``, exitCode: 0, }); + await expect(runCli(cwd, [`bun`, `--version`])).resolves.toMatchObject({ + stdout: `${config.definitions.bun.default.split(`+`, 1)[0]}\n`, + stderr: ``, + exitCode: 0, + }); } finally { delete process.env.COREPACK_ENABLE_PROJECT_SPEC; } @@ -357,6 +368,12 @@ it(`should allow to call "corepack install -g --all" to prepare all package mana stderr: ``, exitCode: 0, }); + + await expect(runCli(cwd, [`bun`, `--version`])).resolves.toMatchObject({ + stdout: `${config.definitions.bun.default.split(`+`, 1)[0]}\n`, + stderr: ``, + exitCode: 0, + }); } finally { delete process.env.COREPACK_ENABLE_NETWORK; } @@ -456,7 +473,7 @@ it(`should support hydrating package managers if cache folder was removed`, asyn it(`should support hydrating multiple package managers from cached archives`, async () => { await xfs.mktempPromise(async cwd => { - await expect(runCli(cwd, [`pack`, `yarn@2.2.2`, `pnpm@5.8.0`])).resolves.toMatchObject({ + await expect(runCli(cwd, [`pack`, `yarn@2.2.2`, `pnpm@5.8.0`, `bun@1.0.26`])).resolves.toMatchObject({ exitCode: 0, stderr: ``, }); @@ -492,6 +509,16 @@ it(`should support hydrating multiple package managers from cached archives`, as stderr: ``, exitCode: 0, }); + + await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), { + packageManager: `bun@1.0.26`, + }); + + await expect(runCli(cwd, [`bun`, `--version`])).resolves.toMatchObject({ + stdout: `1.0.26\n`, + stderr: ``, + exitCode: 0, + }); } finally { delete process.env.COREPACK_ENABLE_NETWORK; }