From df6f715f2637b8a85550cfd759e58b3962eb4c29 Mon Sep 17 00:00:00 2001 From: Harvey Lee Date: Wed, 31 Jul 2024 11:39:07 +1000 Subject: [PATCH 1/4] Add basic support for bun package manager --- src/lib/lockfile/process-lockfile.ts | 10 ++++++++++ src/lib/package-manager/names.ts | 4 +++- src/lib/registry/helpers/find-packages-globs.ts | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/lockfile/process-lockfile.ts b/src/lib/lockfile/process-lockfile.ts index 3c56d81..e8dcdc9 100644 --- a/src/lib/lockfile/process-lockfile.ts +++ b/src/lib/lockfile/process-lockfile.ts @@ -77,6 +77,16 @@ export async function processLockfile({ }); break; } + case "bun": { + log.warn(`Ouput lockfiles for Bun are not yet supported. Using NPM for output`); + await generateNpmLockfile({ + workspaceRootDir, + isolateDir, + }); + + usedFallbackToNpm = true; + break; + } default: log.warn(`Unexpected package manager ${name}. Using NPM for output`); await generateNpmLockfile({ diff --git a/src/lib/package-manager/names.ts b/src/lib/package-manager/names.ts index dbda321..b058b12 100644 --- a/src/lib/package-manager/names.ts +++ b/src/lib/package-manager/names.ts @@ -1,4 +1,4 @@ -export const supportedPackageManagerNames = ["pnpm", "yarn", "npm"] as const; +export const supportedPackageManagerNames = ["pnpm", "yarn", "npm", "bun"] as const; export type PackageManagerName = (typeof supportedPackageManagerNames)[number]; @@ -11,6 +11,8 @@ export type PackageManager = { export function getLockfileFileName(name: PackageManagerName) { switch (name) { + case "bun": + return "bun.lockb"; case "pnpm": return "pnpm-lock.yaml"; case "yarn": diff --git a/src/lib/registry/helpers/find-packages-globs.ts b/src/lib/registry/helpers/find-packages-globs.ts index 71c64cf..83ad124 100644 --- a/src/lib/registry/helpers/find-packages-globs.ts +++ b/src/lib/registry/helpers/find-packages-globs.ts @@ -27,6 +27,7 @@ export function findPackagesGlobs(workspaceRootDir: string) { log.debug("Detected pnpm packages globs:", inspectValue(globs)); return globs; } + case "bun": case "yarn": case "npm": { const workspaceRootManifestPath = path.join( From 5f8d8168e6ec9bd8b514131a7763e56d007b018a Mon Sep 17 00:00:00 2001 From: Harvey Lee Date: Sun, 4 Aug 2024 16:31:47 +1000 Subject: [PATCH 2/4] Run prettier --- src/lib/lockfile/process-lockfile.ts | 4 +++- src/lib/package-manager/names.ts | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/lockfile/process-lockfile.ts b/src/lib/lockfile/process-lockfile.ts index e8dcdc9..8db9472 100644 --- a/src/lib/lockfile/process-lockfile.ts +++ b/src/lib/lockfile/process-lockfile.ts @@ -78,7 +78,9 @@ export async function processLockfile({ break; } case "bun": { - log.warn(`Ouput lockfiles for Bun are not yet supported. Using NPM for output`); + log.warn( + `Ouput lockfiles for Bun are not yet supported. Using NPM for output` + ); await generateNpmLockfile({ workspaceRootDir, isolateDir, diff --git a/src/lib/package-manager/names.ts b/src/lib/package-manager/names.ts index b058b12..0dc472f 100644 --- a/src/lib/package-manager/names.ts +++ b/src/lib/package-manager/names.ts @@ -1,4 +1,9 @@ -export const supportedPackageManagerNames = ["pnpm", "yarn", "npm", "bun"] as const; +export const supportedPackageManagerNames = [ + "pnpm", + "yarn", + "npm", + "bun", +] as const; export type PackageManagerName = (typeof supportedPackageManagerNames)[number]; From a7fb75fba587a6ed57575b92efa1a657e680eb08 Mon Sep 17 00:00:00 2001 From: Harvey Lee Date: Sun, 4 Aug 2024 16:40:57 +1000 Subject: [PATCH 3/4] Add README line describing Bun support --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ae667c..641243b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ integrated, check out [mono-ts](https://github.com/0x80/mono-ts) deployments. - Preserve packages file structure, without code bundling - Should work with any package manager, and tested with NPM, PNPM, and Yarn - (both classic and modern) + (both classic and modern). + - There is partial support for Bun - the process will detect the Bun package manager but will not output a Bun lockfile for the isolated package; instead it will fall back to generating an NPM lockfile. - Zero-config for the vast majority of use-cases - Isolates dependencies recursively. If package A depends on internal package B which depends on internal package C, all of them will be included From 10a82debe6ff7a4bbadd8f91c74346696cfff00d Mon Sep 17 00:00:00 2001 From: Harvey Lee Date: Sun, 4 Aug 2024 16:40:57 +1000 Subject: [PATCH 4/4] Add README line describing Bun support --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 641243b..67d1e13 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ integrated, check out [mono-ts](https://github.com/0x80/mono-ts) deployments. - Preserve packages file structure, without code bundling - Should work with any package manager, and tested with NPM, PNPM, and Yarn - (both classic and modern). + (both classic and modern) - There is partial support for Bun - the process will detect the Bun package manager but will not output a Bun lockfile for the isolated package; instead it will fall back to generating an NPM lockfile. - Zero-config for the vast majority of use-cases - Isolates dependencies recursively. If package A depends on internal package B