-
Notifications
You must be signed in to change notification settings - Fork 461
feat(package-managers): add bun support #3258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kamilmysliwiec
merged 7 commits into
nestjs:v12.0.0
from
awaiden:feat/add-bun-package-manager
Apr 24, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d7948e
feat(package-managers): add bun support
awaiden 2361a56
chore(deps): update node.js to v24.15.0
renovate[bot] 54394ea
Merge pull request #3397 from nestjs/renovate/cimg-node-24.x
kamilmysliwiec 6f6bca6
chore(deps): update swc monorepo
renovate[bot] 8fc3259
Merge pull request #3406 from nestjs/renovate/swc-monorepo
kamilmysliwiec 8deeb54
Merge branch 'nestjs:master' into feat/add-bun-package-manager
awaiden 753110d
Merge branch 'v12.0.0' into feat/add-bun-package-manager
awaiden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { Runner, RunnerFactory } from '../runners/index.js'; | ||
| import { BunRunner } from '../runners/bun.runner.js'; | ||
| import { AbstractPackageManager } from './abstract.package-manager.js'; | ||
| import { PackageManager } from './package-manager.js'; | ||
| import { PackageManagerCommands } from './package-manager-commands.js'; | ||
|
|
||
| export class BunPackageManager extends AbstractPackageManager { | ||
| constructor() { | ||
| super(RunnerFactory.create(Runner.BUN) as BunRunner); | ||
| } | ||
|
|
||
| public get name() { | ||
| return PackageManager.BUN.toUpperCase(); | ||
| } | ||
|
|
||
| get cli(): PackageManagerCommands { | ||
| return { | ||
| install: 'install', | ||
| add: 'add', | ||
| update: 'update', | ||
| remove: 'remove', | ||
| saveFlag: '--save', | ||
| saveDevFlag: '--dev', | ||
| silentFlag: '--silent', | ||
|
awaiden marked this conversation as resolved.
|
||
| }; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ export enum PackageManager { | |
| NPM = 'npm', | ||
| YARN = 'yarn', | ||
| PNPM = 'pnpm', | ||
| BUN = 'bun', | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { AbstractRunner } from './abstract.runner.js'; | ||
|
|
||
| export class BunRunner extends AbstractRunner { | ||
| constructor() { | ||
| super('bun'); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,5 @@ export enum Runner { | |
| NPM, | ||
| YARN, | ||
| PNPM, | ||
| BUN, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { join } from 'path'; | ||
| import { | ||
| BunPackageManager, | ||
| PackageManagerCommands, | ||
| } from '../../../lib/package-managers'; | ||
| import { BunRunner } from '../../../lib/runners/bun.runner'; | ||
|
|
||
| vi.mock('../../../lib/runners/bun.runner.js'); | ||
|
|
||
| describe('BunPackageManager', () => { | ||
| let packageManager: BunPackageManager; | ||
| beforeEach(() => { | ||
| (BunRunner as any).mockClear(); | ||
| (BunRunner as any).mockImplementation(function () { | ||
| return { | ||
| run: (): Promise<void> => Promise.resolve(), | ||
| }; | ||
| }); | ||
| packageManager = new BunPackageManager(); | ||
| }); | ||
| it('should be created', () => { | ||
| expect(packageManager).toBeInstanceOf(BunPackageManager); | ||
| }); | ||
| it('should have the correct cli commands', () => { | ||
| const expectedValues: PackageManagerCommands = { | ||
| install: 'install', | ||
| add: 'add', | ||
| update: 'update', | ||
| remove: 'remove', | ||
| saveFlag: '--save', | ||
| saveDevFlag: '--dev', | ||
| silentFlag: '--silent', | ||
| }; | ||
| expect(packageManager.cli).toMatchObject(expectedValues); | ||
| }); | ||
| describe('install', () => { | ||
| it('should use the proper command for installing', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dirName = '/tmp'; | ||
| const testDir = join(process.cwd(), dirName); | ||
| packageManager.install(dirName, 'npm'); | ||
| expect(spy).toBeCalledWith('install --silent', true, testDir); | ||
|
awaiden marked this conversation as resolved.
|
||
| }); | ||
| }); | ||
| describe('addProduction', () => { | ||
| it('should use the proper command for adding production dependencies', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dependencies = ['@nestjs/common', '@nestjs/core']; | ||
| const tag = '5.0.0'; | ||
| const command = `add --save ${dependencies | ||
| .map((dependency) => `${dependency}@${tag}`) | ||
| .join(' ')}`; | ||
| packageManager.addProduction(dependencies, tag); | ||
| expect(spy).toBeCalledWith(command, true); | ||
|
awaiden marked this conversation as resolved.
|
||
| }); | ||
| }); | ||
| describe('addDevelopment', () => { | ||
| it('should use the proper command for adding development dependencies', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dependencies = ['@nestjs/common', '@nestjs/core']; | ||
| const tag = '5.0.0'; | ||
| const command = `add --dev ${dependencies | ||
| .map((dependency) => `${dependency}@${tag}`) | ||
| .join(' ')}`; | ||
| packageManager.addDevelopment(dependencies, tag); | ||
| expect(spy).toBeCalledWith(command, true); | ||
| }); | ||
| }); | ||
| describe('updateProduction', () => { | ||
| it('should use the proper command for updating production dependencies', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dependencies = ['@nestjs/common', '@nestjs/core']; | ||
| const command = `update ${dependencies.join(' ')}`; | ||
| packageManager.updateProduction(dependencies); | ||
| expect(spy).toBeCalledWith(command, true); | ||
| }); | ||
| }); | ||
| describe('updateDevelopment', () => { | ||
| it('should use the proper command for updating development dependencies', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dependencies = ['@nestjs/common', '@nestjs/core']; | ||
| const command = `update ${dependencies.join(' ')}`; | ||
| packageManager.updateDevelopment(dependencies); | ||
| expect(spy).toBeCalledWith(command, true); | ||
| }); | ||
| }); | ||
| describe('upgradeProduction', () => { | ||
| it('should use the proper command for upgrading production dependencies', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dependencies = ['@nestjs/common', '@nestjs/core']; | ||
| const tag = '5.0.0'; | ||
| const uninstallCommand = `remove --save ${dependencies.join(' ')}`; | ||
|
awaiden marked this conversation as resolved.
|
||
|
|
||
| const installCommand = `add --save ${dependencies | ||
| .map((dependency) => `${dependency}@${tag}`) | ||
| .join(' ')}`; | ||
|
awaiden marked this conversation as resolved.
|
||
|
|
||
| return packageManager.upgradeProduction(dependencies, tag).then(() => { | ||
| expect(spy.mock.calls).toEqual([ | ||
| [uninstallCommand, true], | ||
| [installCommand, true], | ||
| ]); | ||
| }); | ||
| }); | ||
| }); | ||
| describe('upgradeDevelopment', () => { | ||
| it('should use the proper command for upgrading development dependencies', () => { | ||
| const spy = vi.spyOn((packageManager as any).runner, 'run'); | ||
| const dependencies = ['@nestjs/common', '@nestjs/core']; | ||
| const tag = '5.0.0'; | ||
| const uninstallCommand = `remove --dev ${dependencies.join(' ')}`; | ||
|
|
||
| const installCommand = `add --dev ${dependencies | ||
| .map((dependency) => `${dependency}@${tag}`) | ||
| .join(' ')}`; | ||
|
|
||
| return packageManager.upgradeDevelopment(dependencies, tag).then(() => { | ||
| expect(spy.mock.calls).toEqual([ | ||
| [uninstallCommand, true], | ||
| [installCommand, true], | ||
| ]); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.