From 150a54858bc2ca835489da094343bc6faf884a58 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 12 Apr 2024 20:52:52 -0700 Subject: [PATCH 1/2] which-pm: add bun support --- .gitignore | 1 + which-pm/index.d.ts | 6 +- which-pm/index.js | 2 + which-pm/package.json | 1 + which-pm/test/fixtures/bun/.gitignore | 175 +++++++++++++++++++++++ which-pm/test/fixtures/bun/README.md | 15 ++ which-pm/test/fixtures/bun/bun.lockb | Bin 0 -> 3125 bytes which-pm/test/fixtures/bun/index.ts | 1 + which-pm/test/fixtures/bun/package.json | 11 ++ which-pm/test/fixtures/bun/tsconfig.json | 27 ++++ which-pm/test/index.js | 6 + 11 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 which-pm/test/fixtures/bun/.gitignore create mode 100644 which-pm/test/fixtures/bun/README.md create mode 100755 which-pm/test/fixtures/bun/bun.lockb create mode 100644 which-pm/test/fixtures/bun/index.ts create mode 100644 which-pm/test/fixtures/bun/package.json create mode 100644 which-pm/test/fixtures/bun/tsconfig.json diff --git a/.gitignore b/.gitignore index 585a88d1..3ae014eb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ npm-debug.log* # Dependency directory node_modules +bun.lockb # Coverage directory used by tools like istanbul coverage diff --git a/which-pm/index.d.ts b/which-pm/index.d.ts index a5ecac7b..17835e0e 100644 --- a/which-pm/index.d.ts +++ b/which-pm/index.d.ts @@ -1,7 +1,7 @@ declare function whichpm (pkgPath: string): Promise declare namespace whichpm { - type Result = NPM | YARN | PNPM | Other + type Result = NPM | YARN | PNPM | BUN | Other interface NPM { readonly name: 'npm' @@ -16,6 +16,10 @@ declare namespace whichpm { readonly version: string } + interface BUN { + readonly name: 'bun' + } + interface Other { readonly name: string readonly version?: string diff --git a/which-pm/index.js b/which-pm/index.js index 1f0d8f96..68564b22 100644 --- a/which-pm/index.js +++ b/which-pm/index.js @@ -8,6 +8,8 @@ module.exports = async function (pkgPath) { const exists = await pathExists(path.join(modulesPath, '.yarn-integrity')) if (exists) return { name: 'yarn' } + if (await pathExists(path.join(pkgPath, 'bun.lockb'))) return { name: 'bun' } + try { const modules = await loadYamlFile(path.join(modulesPath, '.modules.yaml')) return toNameAndVersion(modules.packageManager) diff --git a/which-pm/package.json b/which-pm/package.json index 64f02baf..9090f826 100644 --- a/which-pm/package.json +++ b/which-pm/package.json @@ -21,6 +21,7 @@ "keywords": [ "npm", "pnpm", + "bun", "yarn" ], "author": "Zoltan Kochan", diff --git a/which-pm/test/fixtures/bun/.gitignore b/which-pm/test/fixtures/bun/.gitignore new file mode 100644 index 00000000..9b1ee42e --- /dev/null +++ b/which-pm/test/fixtures/bun/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/which-pm/test/fixtures/bun/README.md b/which-pm/test/fixtures/bun/README.md new file mode 100644 index 00000000..4a63de9a --- /dev/null +++ b/which-pm/test/fixtures/bun/README.md @@ -0,0 +1,15 @@ +# bun + +To install dependencies: + +```bash +bun install +``` + +To run: + +```bash +bun run index.ts +``` + +This project was created using `bun init` in bun v1.1.3. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/which-pm/test/fixtures/bun/bun.lockb b/which-pm/test/fixtures/bun/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..320a269be3c9eae1ff6090d2a11efe763b81a74c GIT binary patch literal 3125 zcmY#Z)GsYA(of3F(@)JSQ%EY!;{sycoc!eMw9K4T-L(9o+{6;yG6OCq1_lO>%ik6+ z*L7=u%bWUgS*DDDmU@oD2kWRwDN0k-WsbBQU&;+s1O)65ih%=-Zh-Q$VG0<4mVw2% zfFuw%cmZinAUzXG_W^03p$!6z3=BL#8ps8!JJ5J<<=K1IS5C2M?)5fk{8IfU{cMNO zYo*1fXH?G5x|BIlKdM)4tF0wxzRj^$fwOkcS8dSIZcR-B8bc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K1P5r42{1_l9R*E)gN_0KS)f5* literal 0 HcmV?d00001 diff --git a/which-pm/test/fixtures/bun/index.ts b/which-pm/test/fixtures/bun/index.ts new file mode 100644 index 00000000..2a5e4b80 --- /dev/null +++ b/which-pm/test/fixtures/bun/index.ts @@ -0,0 +1 @@ +console.log("Hello via Bun!"); diff --git a/which-pm/test/fixtures/bun/package.json b/which-pm/test/fixtures/bun/package.json new file mode 100644 index 00000000..7a72be86 --- /dev/null +++ b/which-pm/test/fixtures/bun/package.json @@ -0,0 +1,11 @@ +{ + "name": "bun", + "module": "index.ts", + "type": "module", + "devDependencies": { + "@types/bun": "latest" + }, + "peerDependencies": { + "typescript": "^5.0.0" + } +} diff --git a/which-pm/test/fixtures/bun/tsconfig.json b/which-pm/test/fixtures/bun/tsconfig.json new file mode 100644 index 00000000..238655f2 --- /dev/null +++ b/which-pm/test/fixtures/bun/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + // Enable latest features + "lib": ["ESNext", "DOM"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", + "jsx": "react-jsx", + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false + } +} diff --git a/which-pm/test/index.js b/which-pm/test/index.js index e6cdb9e0..a10b8d48 100644 --- a/which-pm/test/index.js +++ b/which-pm/test/index.js @@ -23,6 +23,12 @@ test('identifies yarn installation', async t => { t.end() }) +test('identifies bun installation', async t => { + const pm = await whichpm(path.join(fixturesDir, 'bun')) + t.deepEqual(pm, { name: 'bun' }) + t.end() +}) + test('identifies npm installation', async t => { const pm = await whichpm(path.join(fixturesDir, 'npm')) t.deepEqual(pm, { name: 'npm' }) From e5acd79a298476e423762c9f98057677d9cd0988 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 15 May 2024 13:57:56 -0700 Subject: [PATCH 2/2] remove unneeded files --- which-pm/test/fixtures/bun/.gitignore | 175 ----------------------- which-pm/test/fixtures/bun/README.md | 15 -- which-pm/test/fixtures/bun/index.ts | 1 - which-pm/test/fixtures/bun/tsconfig.json | 27 ---- 4 files changed, 218 deletions(-) delete mode 100644 which-pm/test/fixtures/bun/.gitignore delete mode 100644 which-pm/test/fixtures/bun/README.md delete mode 100644 which-pm/test/fixtures/bun/index.ts delete mode 100644 which-pm/test/fixtures/bun/tsconfig.json diff --git a/which-pm/test/fixtures/bun/.gitignore b/which-pm/test/fixtures/bun/.gitignore deleted file mode 100644 index 9b1ee42e..00000000 --- a/which-pm/test/fixtures/bun/.gitignore +++ /dev/null @@ -1,175 +0,0 @@ -# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore - -# Logs - -logs -_.log -npm-debug.log_ -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Caches - -.cache - -# Diagnostic reports (https://nodejs.org/api/report.html) - -report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json - -# Runtime data - -pids -_.pid -_.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover - -lib-cov - -# Coverage directory used by tools like istanbul - -coverage -*.lcov - -# nyc test coverage - -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) - -.grunt - -# Bower dependency directory (https://bower.io/) - -bower_components - -# node-waf configuration - -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) - -build/Release - -# Dependency directories - -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) - -web_modules/ - -# TypeScript cache - -*.tsbuildinfo - -# Optional npm cache directory - -.npm - -# Optional eslint cache - -.eslintcache - -# Optional stylelint cache - -.stylelintcache - -# Microbundle cache - -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history - -.node_repl_history - -# Output of 'npm pack' - -*.tgz - -# Yarn Integrity file - -.yarn-integrity - -# dotenv environment variable files - -.env -.env.development.local -.env.test.local -.env.production.local -.env.local - -# parcel-bundler cache (https://parceljs.org/) - -.parcel-cache - -# Next.js build output - -.next -out - -# Nuxt.js build / generate output - -.nuxt -dist - -# Gatsby files - -# Comment in the public line in if your project uses Gatsby and not Next.js - -# https://nextjs.org/blog/next-9-1#public-directory-support - -# public - -# vuepress build output - -.vuepress/dist - -# vuepress v2.x temp and cache directory - -.temp - -# Docusaurus cache and generated files - -.docusaurus - -# Serverless directories - -.serverless/ - -# FuseBox cache - -.fusebox/ - -# DynamoDB Local files - -.dynamodb/ - -# TernJS port file - -.tern-port - -# Stores VSCode versions used for testing VSCode extensions - -.vscode-test - -# yarn v2 - -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# IntelliJ based IDEs -.idea - -# Finder (MacOS) folder config -.DS_Store diff --git a/which-pm/test/fixtures/bun/README.md b/which-pm/test/fixtures/bun/README.md deleted file mode 100644 index 4a63de9a..00000000 --- a/which-pm/test/fixtures/bun/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# bun - -To install dependencies: - -```bash -bun install -``` - -To run: - -```bash -bun run index.ts -``` - -This project was created using `bun init` in bun v1.1.3. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/which-pm/test/fixtures/bun/index.ts b/which-pm/test/fixtures/bun/index.ts deleted file mode 100644 index 2a5e4b80..00000000 --- a/which-pm/test/fixtures/bun/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello via Bun!"); diff --git a/which-pm/test/fixtures/bun/tsconfig.json b/which-pm/test/fixtures/bun/tsconfig.json deleted file mode 100644 index 238655f2..00000000 --- a/which-pm/test/fixtures/bun/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false - } -}