From 3b12e6a67f3ee7f549e92b0d2f8f4b3de81c48a6 Mon Sep 17 00:00:00 2001 From: Raine Revere Date: Thu, 25 Apr 2024 11:51:59 -0400 Subject: [PATCH] Enable bun on Windows (#1401) --- package-lock.json | 139 +++++++++++++++++++++++- package.json | 5 +- src/index.ts | 2 +- src/package-managers/bun.ts | 7 -- test/bun-setup.sh | 12 -- test/doctor.test.ts | 1 - test/package-managers/bun/index.test.ts | 5 +- 7 files changed, 142 insertions(+), 29 deletions(-) delete mode 100755 test/bun-setup.sh diff --git a/package-lock.json b/package-lock.json index 28d6508f..f1c4665d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "npm-check-updates", - "version": "16.14.19", + "version": "16.14.20-0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "npm-check-updates", - "version": "16.14.19", + "version": "16.14.20-0", "license": "Apache-2.0", "dependencies": { "@types/semver-utils": "^1.1.1", @@ -74,6 +74,7 @@ "@types/update-notifier": "^6.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", + "bun": "^1.1.4", "c8": "^7.14.0", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", @@ -792,6 +793,110 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/@oven/bun-darwin-aarch64": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.1.4.tgz", + "integrity": "sha512-/eysHyAfoEda+/HHLVx0u5f/ZGxb6bR/xLQ4E/u/c5Emue5npeJBLD2P8Kjt9efz/A0xalPW8jHvtuEmYTnuoA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-darwin-x64": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.1.4.tgz", + "integrity": "sha512-d9oUj2e5TCR3UzhTDYgASLSQHDh2UCVS7UeOq32cPbhY4bBa3UQPO8Mn5HXNBgXck1EoFHRjrB44qgNPNUWJvw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-darwin-x64-baseline": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.1.4.tgz", + "integrity": "sha512-VJBlJNMXV7VgMa2yrni6k/qaFVEAZikPaKF315TGrCFUVjBFcUSMpmQDAOFfajzqzdaFcZCrCTPMlgfvASptCA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@oven/bun-linux-aarch64": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.1.4.tgz", + "integrity": "sha512-iLZC9Kk9T/sKVNn0VZODmCk9wSqPy49yTY3J0HXtYRzaeXO3f7M22SuqMZibU0XC4kCPCYNG/4x3+mkBpVYlBw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.1.4.tgz", + "integrity": "sha512-W4ASgbY/+42IIa7R5fkLVptLt59P5d0jlpEYDghJLWK0bdosfMAu3xB05FuqO90Te7BI+LWMaGFoKAXLcatjdg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-linux-x64-baseline": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.1.4.tgz", + "integrity": "sha512-gswEWKO7ajyosUqitcv7h/MO+dylt8Qb5CwnSOy6NQNyu77LKGhpgy2g5aASN9Vlbubihzhze1mRhCnhz41gmw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@oven/bun-windows-x64": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.1.4.tgz", + "integrity": "sha512-1OUXrxN6NewDDlnwYJUA8qc3xoENuzXAl6NBQ4DQUzvG7sf+woidB0US4kyMU4UM00yZ30R377bHYelZBbyHBg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@oven/bun-windows-x64-baseline": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.1.4.tgz", + "integrity": "sha512-WREwoHUf+J7MwGcaLnlgQQcyNOkvxQhoh7dMOkF8KrkMAJdrnila8mD4qaJUFjAUwnMOVW28R6xZ23G8N4AMNQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@pkgjs/parseargs": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", @@ -1944,6 +2049,36 @@ "semver": "^7.0.0" } }, + "node_modules/bun": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/bun/-/bun-1.1.4.tgz", + "integrity": "sha512-J78P9T2gMv2eki64AJnHjmAgSU1WuE4QPVvlYuhy/UmLClTwFaCnyoU0Rza7T5q97O4JIoGhmVCpEfI0Ri6anw==", + "cpu": [ + "arm64", + "x64" + ], + "dev": true, + "hasInstallScript": true, + "os": [ + "darwin", + "linux", + "win32" + ], + "bin": { + "bun": "bin/bun.exe", + "bunx": "bin/bun.exe" + }, + "optionalDependencies": { + "@oven/bun-darwin-aarch64": "1.1.4", + "@oven/bun-darwin-x64": "1.1.4", + "@oven/bun-darwin-x64-baseline": "1.1.4", + "@oven/bun-linux-aarch64": "1.1.4", + "@oven/bun-linux-x64": "1.1.4", + "@oven/bun-linux-x64-baseline": "1.1.4", + "@oven/bun-windows-x64": "1.1.4", + "@oven/bun-windows-x64-baseline": "1.1.4" + } + }, "node_modules/c8": { "version": "7.14.0", "resolved": "https://registry.npmjs.org/c8/-/c8-7.14.0.tgz", diff --git a/package.json b/package.json index a86fe43f..ba2160d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "npm-check-updates", - "version": "16.14.19", + "version": "16.14.20-0", "author": "Tomas Junnonen ", "license": "Apache-2.0", "contributors": [ @@ -37,7 +37,7 @@ "lint:lockfile": "lockfile-lint", "lint:markdown": "markdownlint \"**/*.md\" --ignore node_modules --ignore build --config .markdownlint.js", "lint:src": "eslint --cache --cache-location node_modules/.cache/.eslintcache --ignore-path .gitignore --report-unused-disable-directives .", - "prepare": "src/scripts/install-hooks && test/bun-setup.sh", + "prepare": "src/scripts/install-hooks", "prepublishOnly": "npm run build", "prettier": "prettier .", "test": "mocha test test/package-managers/*", @@ -117,6 +117,7 @@ "@types/update-notifier": "^6.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", + "bun": "^1.1.4", "c8": "^7.14.0", "chai": "^4.3.10", "chai-as-promised": "^7.1.1", diff --git a/src/index.ts b/src/index.ts index 0d2c0e15..c8809ff1 100755 --- a/src/index.ts +++ b/src/index.ts @@ -139,7 +139,7 @@ const install = async ( pkgsNormalized.forEach(async pkgFile => { const packageManager = await getPackageManagerForInstall(options, pkgFile) - const cmd = packageManager + (process.platform === 'win32' ? '.cmd' : '') + const cmd = packageManager + (process.platform === 'win32' && packageManager !== 'bun' ? '.cmd' : '') const cwd = options.cwd || path.resolve(pkgFile, '..') let stdout = '' try { diff --git a/src/package-managers/bun.ts b/src/package-managers/bun.ts index 31ad0b3b..debe7ea8 100644 --- a/src/package-managers/bun.ts +++ b/src/package-managers/bun.ts @@ -2,7 +2,6 @@ import { Options } from 'pacote' import path from 'path' import spawn from 'spawn-please' import keyValueBy from '../lib/keyValueBy' -import programError from '../lib/programError' import { Index } from '../types/IndexType' import { NpmOptions } from '../types/NpmOptions' import * as npm from './npm' @@ -13,12 +12,6 @@ async function spawnBun( npmOptions: NpmOptions = {}, spawnOptions: Index = {}, ): Promise { - // Bun not yet supported on Windows. - // @see https://github.com/oven-sh/bun/issues/43 - if (process.platform === 'win32') { - programError(npmOptions, 'Bun not yet supported on Windows') - } - const fullArgs = [ ...(npmOptions.prefix ? [`--prefix=${npmOptions.prefix}`] : []), ...(npmOptions.location === 'global' ? ['--global'] : []), diff --git a/test/bun-setup.sh b/test/bun-setup.sh deleted file mode 100755 index 42d43a23..00000000 --- a/test/bun-setup.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Install bun if not installed. -# Must be run in a prepare script instead of devDependencies to avoid npm install failing on Windows. -bun -v &> /dev/null -BUN_EXISTS="$?" - -if [ $BUN_EXISTS -ne 0 ]; then - npm install -g bun -fi - -# Always return success, even if the install script fails. -# Windows is expected to fail and the bun tests will be skipped. -exit 0 \ No newline at end of file diff --git a/test/doctor.test.ts b/test/doctor.test.ts index 47e70e50..77625f4f 100644 --- a/test/doctor.test.ts +++ b/test/doctor.test.ts @@ -456,7 +456,6 @@ else { testFail({ packageManager: 'yarn' }) }) - // Bun not yet supported on Windows // const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe // TODO: Works locally, but not in GitHub action. describe.skip('bun', () => { diff --git a/test/package-managers/bun/index.test.ts b/test/package-managers/bun/index.test.ts index a2fd263d..637ff9bf 100644 --- a/test/package-managers/bun/index.test.ts +++ b/test/package-managers/bun/index.test.ts @@ -1,12 +1,9 @@ -import os from 'os' import * as bun from '../../../src/package-managers/bun' import chaiSetup from '../../helpers/chaiSetup' chaiSetup() -// Bun not yet supported on Windows -const describeSkipWindows = os.platform() === 'win32' ? describe.skip : describe -describeSkipWindows('bun', function () { +describe('bun', function () { it('list', async () => { const result = await bun.list({ cwd: __dirname }) result.should.have.property('ncu-test-v2')