diff --git a/package.json b/package.json index d57d95a4..377fd970 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "npm": ">=9", "git": ">=2.11.0", "yarn": ">=1.7.0", - "pnpm": ">=8" + "pnpm": ">=8", + "bun": ">=1" }, "scripts": { "test": "xo && ava" diff --git a/readme.md b/readme.md index c68ee7b5..204e0639 100644 --- a/readme.md +++ b/readme.md @@ -25,7 +25,7 @@ - Warns about the possibility of extraneous files being published - See exactly what will be executed with [preview mode](https://github.com/sindresorhus/np/issues/391), without pushing or publishing anything remotely - Supports [GitHub Packages](https://github.com/features/packages) -- Supports npm 9+, Yarn (Classic and Berry), and pnpm 8+ +- Supports npm 9+, Yarn (Classic and Berry), npm 8+, and Bun ### Why not @@ -111,6 +111,7 @@ Currently, these are the flags you can configure: For example, this configures `np` to use `unit-test` as a test script, and to use `dist` as the subdirectory to publish: `package.json` + ```json { "name": "superb-package", @@ -122,6 +123,7 @@ For example, this configures `np` to use `unit-test` as a test script, and to us ``` `.np-config.json` + ```json { "testScript": "unit-test", @@ -130,18 +132,20 @@ For example, this configures `np` to use `unit-test` as a test script, and to us ``` `.np-config.js` or `.np-config.cjs` + ```js module.exports = { - testScript: 'unit-test', - contents: 'dist' + testScript: "unit-test", + contents: "dist", }; ``` `.np-config.mjs` + ```js export default { - testScript: 'unit-test', - contents: 'dist' + testScript: "unit-test", + contents: "dist", }; ``` diff --git a/source/package-manager/configs.js b/source/package-manager/configs.js index 05f9e23d..d9d4e687 100644 --- a/source/package-manager/configs.js +++ b/source/package-manager/configs.js @@ -52,3 +52,18 @@ export const yarnBerryConfig = { throwOnExternalRegistry: true, lockfiles: ['yarn.lock'], }; + +/** @type {import('./types.d.ts').PackageManagerConfig} */ +export const bunConfig = { + cli: 'bun', + id: 'bun', + installCommand: ['bun', ['install', '--frozen-lockfile']], + installCommandNoLockfile: ['bun', ['install', '--no-save']], + versionCommand: version => ['npm', ['version', version]], + // Bun doesn't support publishing, so we use npm instead + publishCommand: arguments_ => ['npm', arguments_], + // TODO: Bun doesn't support config get registry, this should be added in the future + getRegistryCommand: ['npm', ['config', 'get', 'registry']], + tagVersionPrefixCommand: ['npm', ['config', 'get', 'tag-version-prefix']], + lockfiles: ['bun.lockb'], +}; diff --git a/source/package-manager/index.js b/source/package-manager/index.js index 19279191..e779cb3c 100644 --- a/source/package-manager/index.js +++ b/source/package-manager/index.js @@ -46,6 +46,10 @@ function configFromPackageManagerField(package_) { return configs.yarnConfig; } + if (packageManager === 'bun') { + return configs.bunConfig; + } + throw new Error(`Invalid package manager: ${package_.packageManager}`); }