{"id":21152876,"url":"https://github.com/pilaton/pubun","last_synced_at":"2026-02-07T11:04:18.343Z","repository":{"id":210427424,"uuid":"726201050","full_name":"Pilaton/pubun","owner":"Pilaton","description":"Library for identifying available package managers (npm, yarn, pnpm, bun)","archived":false,"fork":false,"pushed_at":"2025-01-22T04:58:14.000Z","size":644,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-09T11:26:22.663Z","etag":null,"topics":["bun","npm","package-json","package-lock","package-manager","pnpm","pubun","yarn"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pubun","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pilaton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-01T18:50:50.000Z","updated_at":"2024-12-05T18:32:18.000Z","dependencies_parsed_at":"2023-12-11T15:28:26.887Z","dependency_job_id":"cdddd261-9112-4932-846d-6266e59c4539","html_url":"https://github.com/Pilaton/pubun","commit_stats":null,"previous_names":["pilaton/pmjs","pilaton/pubun"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/Pilaton/pubun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fpubun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fpubun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fpubun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fpubun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pilaton","download_url":"https://codeload.github.com/Pilaton/pubun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pilaton%2Fpubun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29193089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","npm","package-json","package-lock","package-manager","pnpm","pubun","yarn"],"created_at":"2024-11-20T10:47:11.591Z","updated_at":"2026-02-07T11:04:18.326Z","avatar_url":"https://github.com/Pilaton.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-configure-file {\n  \"MD033\": false,\n  \"MD041\": false,\n} --\u003e\n\n# Pubun \u003c!-- omit from toc --\u003e\n\n![npm](https://img.shields.io/npm/v/pubun?style=for-the-badge\u0026logo=npm\u0026logoColor=white\u0026labelColor=CB3837\u0026color=CB3837)\n![Static Badge](\u003chttps://img.shields.io/badge/Coverage%20(istanbul)-100%25-green?style=for-the-badge\u0026logo=vitest\u0026logoColor=black\u0026labelColor=298D46\u0026color=298D46\u003e)\n\nAsynchronous library with built-in caching to identify available package managers.\n\n## Table of contents \u003c!-- omit from toc --\u003e\n\n- [📡 Features](#-features)\n- [🕹️ Install](#️-install)\n- [🏄‍♀️ Usage](#️-usage)\n  - [Example of defining a package manager for the current project](#example-of-defining-a-package-manager-for-the-current-project)\n  - [Example of detecting all globally installed package managers](#example-of-detecting-all-globally-installed-package-managers)\n  - [Clearing Pubun cache](#clearing-pubun-cache)\n- [📜 API](#-api)\n  - [defineManager()](#definemanager)\n  - [defineGlobalManagers()](#defineglobalmanagers)\n  - [clearCache()](#clearcache)\n\n## 📡 Features\n\n- [x] Defines the package manager that manages your application.\n- [x] Identifies all available globally installed package managers and their versions.\n- [x] Can detect package managers such as: **`npm`**, **`yarn`**, **`pnpm`** and **`bun`**.\n- [x] **Uses cache** at all stages, which can be forcibly cleared.\n\n\u003c!-- markdownlint-disable --\u003e\n\u003cdiv align=\"right\"\u003e...\u003c/div\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n## 🕹️ Install\n\n```bash\nnpm install pubun\n```\n\nPubun offers several import options - default import, or named import.\n\n```js\n// default import\nimport pubun from 'pubun';\n\n// or named import. Recommended!\nimport { defineManager, defineGlobalManagers } from 'pubun';\n```\n\n\u003c!-- markdownlint-disable --\u003e\n\u003cdiv align=\"right\"\u003e...\u003c/div\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n## 🏄‍♀️ Usage\n\n### Example of defining a package manager for the current project\n\n```js\nimport { defineManager } from 'pubun';\n\nasync function demoFunction() {\n  const packageManager = await defineManager('/path/to/project');\n\n  console.log(packageManager); // npm | yarn | pnpm | bun\n}\n\ndemoFunction();\n```\n\n### Example of detecting all globally installed package managers\n\n```js\nimport { defineGlobalManagers } from 'pubun';\n\nasync function demoFunction() {\n  const globalManagers = await defineGlobalManagers();\n\n  console.log(globalManagers);\n  // [\n  //   {\n  //     manager: 'pnpm';\n  //     version: '8.11.0';\n  //   },\n  //   {\n  //     manager: 'bun';\n  //     version: '1.0.14';\n  //   },\n  //   ...\n  // ]\n}\n\ndemoFunction();\n```\n\n### Clearing Pubun cache\n\nSince all Pubun operations are cached in order to optimize speed, sometimes you may need to clear the cache manually.\n\n```js\nimport { clearCache } from 'pubun';\n\nclearCache();\n```\n\n\u003c!-- markdownlint-disable --\u003e\n\u003cdiv align=\"right\"\u003e...\u003c/div\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n## 📜 API\n\n### defineManager()\n\nDefines the package manager used in a given directory.  \nChecks for the presence of characteristic files (e.g., package-lock.json for npm) for each known package manager.\n\nSupported package managers: **`npm`**, **`yarn`**, **`pnpm`**, **`bun`**\n\n```ts\ntype PackageManager = 'npm' | 'yarn' | 'pnpm' | 'bun';\n\ndefineManager: (path?: string) =\u003e Promise\u003cPackageManager | null\u003e;\n```\n\n| Argument | Type     | Default value                                                     | Description                                                                                     |\n| -------- | -------- | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |\n| `path`   | `string` | [`process.cwd()`](https://nodejs.org/api/process.html#processcwd) | The path to the directory to check. If not provided, defaults to the current working directory. |\n\n**Return**: A promise that resolves to the type of package manager used or `null` if no package manager can be defined.\n\n### defineGlobalManagers()\n\n```ts\ninterface GlobalManagerData {\n  manager: PackageManager;\n  version: string;\n}\n\ndefineGlobalManagers: () =\u003e Promise\u003cGlobalManagerData[] | null\u003e;\n```\n\n**Return:** A promise that resolves to an array of global manager data, including the name and version of each installed package manager, or `null` if none is installed.\n\n### clearCache()\n\nClears the entire cache.  \nThis function removes all cached data related to package manager checks.\nUseful for resetting the state to ensure fresh data is fetched.\n\n```ts\nclearCache: () =\u003e void\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilaton%2Fpubun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpilaton%2Fpubun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpilaton%2Fpubun/lists"}