-
Notifications
You must be signed in to change notification settings - Fork 180
feat: add bun support #159
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'create-solana-dapp': minor | ||
| --- | ||
|
|
||
| add bun support |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,26 +11,28 @@ | |
| */ | ||
| import { execSync } from 'node:child_process' | ||
| import { existsSync } from 'node:fs' | ||
| import { join } from 'node:path' | ||
| import { join, sep } from 'node:path' | ||
|
|
||
| export const packageManagers = ['pnpm', 'npm', 'yarn'] as const | ||
| export const packageManagers = ['pnpm', 'npm', 'yarn', 'bun'] as const | ||
| export type PackageManager = (typeof packageManagers)[number] | ||
|
|
||
| export function detectInvokedPackageManager(): PackageManager { | ||
| let detectedPackageManager: PackageManager = 'npm' | ||
| const invoker = require.main | ||
|
|
||
| if (!invoker) { | ||
| return detectedPackageManager | ||
| if (process.env.npm_config_user_agent) { | ||
| for (const pm of packageManagers) { | ||
| if (process.env.npm_config_user_agent.startsWith(`${pm}/`)) { | ||
| return pm | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (const pkgManager of packageManagers) { | ||
| if (invoker.path.includes(pkgManager)) { | ||
| detectedPackageManager = pkgManager | ||
| break | ||
| if (process.env.npm_execpath) { | ||
| for (const pm of packageManagers) { | ||
| if (process.env.npm_execpath.split(sep).includes(pm)) { | ||
| return pm | ||
| } | ||
| } | ||
| } | ||
| return detectedPackageManager | ||
| return 'npm' | ||
| } | ||
|
Comment on lines
19
to
36
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beeman i am not sure if this function needs to change or not but this is what nx is using now https://github.com/nrwl/nx/blob/master/packages/create-nx-workspace/src/utils/package-manager.ts is there a way to test currently this code is working for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would appear that the old way with For example if I do Also, if you currently try bun on the current version it thinks it's i think the changes i made to the function should work for
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just did some local testing and managed to get a working project with I reckon we can merge it and see how it works in the wild and fix any issues
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good to me |
||
|
|
||
| /** | ||
|
|
@@ -99,6 +101,15 @@ export function getPackageManagerCommand( | |
| lockFile: 'package-lock.json', | ||
| } | ||
| } | ||
|
|
||
| case 'bun': { | ||
| return { | ||
| install: `bun install ${silent}`, | ||
| exec: 'bun', | ||
| globalAdd: 'bun add -g', | ||
| lockFile: 'bun.lock', | ||
| } | ||
| } | ||
| } | ||
| } | ||
| const pmVersionCache = new Map<PackageManager, string>() | ||
|
|
@@ -123,6 +134,9 @@ export function detectPackageManager(dir: string = ''): PackageManager { | |
| if (existsSync(join(dir, 'pnpm-lock.yaml'))) { | ||
| return 'pnpm' | ||
| } | ||
| if (existsSync(join(dir, 'bun.lock'))) { | ||
| return 'bun' | ||
| } | ||
|
|
||
| return 'npm' | ||
| } | ||


Uh oh!
There was an error while loading. Please reload this page.