{"_id":"find-yarn-workspace-root2@1.2.57","bugs":{"url":"https://github.com/bluelovers/ws-yarn-workspaces/issues"},"dist":{"shasum":"92b2e848721f39f50c5e9b10176344b43f40fb24","tarball":"http://registry-npm.ywwl.com/find-yarn-workspace-root2/download/find-yarn-workspace-root2-1.2.57.tgz","fileCount":10,"integrity":"sha512-ty43WPB+XWG5TF37xIwL6iO8I7ZeigOfHNmtbbUNjHX+psaVn5/KzmXU/BqdBukwve5sRO669DKgyLHmpfd9iA==","signatures":[{"sig":"MEUCIQC7UktmgvkqQvyFkHTl2MpIVZy3zy0+bbG7Ln2je84KhgIgfe0KISKYhmghnxa/SefUnG9QFFHeOXQ2CqzA5kosAFA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD+8vPI/gKmRzUh6M++XdiS9uXPuUZMWNpDsczj94A9KgIgboaNtRAugoywYIQEMdtNYaekHX7tEMr0TZnIgs2FYAM="}],"unpackedSize":76658,"size":20831,"noattachment":false,"key":"/find-yarn-workspace-root2/-/find-yarn-workspace-root2-1.2.57.tgz"},"main":"index.js","name":"find-yarn-workspace-root2","types":"index.d.ts","author":{"name":"Square, Inc."},"gitHead":"cf2f309300d7e01680c5b8bd91114fe16dbadb24","license":"Apache-2.0","scripts":{"ncu":"npx yarn-tool ncu -u","test":"node --run test:node","coverage":"pnpm run test -- --coverage","test:tsc":"tsc --noEmit & echo typescript check done","test:tsd":"ynpx tsd","test:jest":"jest --passWithNoTests","test:node":"tsx --test --test-update-snapshots **/*.node-spec.ts **/*.node-test.ts **/*.spec.ts **/*.test.ts","preversion":"pnpm run test","test:snapshot":"pnpm run test -u","prepublishOnly":"echo prepublishOnly","tsc:showConfig":"ynpx get-current-tsconfig -p","prepublishOnly_":"pnpm run prepublishOnly:check-bin && pnpm run test","sort-package-json":"npx yarn-tool sort","test:jest:coverage":"pnpm run test:jest -- --coverage","test:jest:snapshot":"pnpm run test:jest -- -u","prepublishOnly:update":"pnpm run ncu && pnpm run sort-package-json","prepublishOnly:check-bin":"ynpx --quiet @yarn-tool/check-pkg-bin"},"version":"1.2.57","_npmUser":{"name":"bluelovers","email":"codelovers@users.sourceforge.net"},"homepage":"https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/find-yarn-workspace-root2#readme","keywords":["yarn","workspace","yarn-workspace","yarn-workspaces","workspace-root","monorepo","find-workspace-root"],"repository":{"url":"git+https://github.com/bluelovers/ws-yarn-workspaces.git","type":"git","directory":"packages/find-yarn-workspace-root2"},"_npmVersion":"lerna/7.4.2/node@v26.7.0+x64 (win32)","description":"Algorithm for finding the root of a yarn workspace, extracted from yarnpkg.com","directories":{"test":"tests"},"maintainers":[{"name":"bluelovers","email":"codelovers@users.sourceforge.net"}],"_nodeVersion":"26.7.0","dependencies":{"tslib":">=2.8.1","upath2":"^3.1.25","pkg-dir":"<6 >=5","micromatch":"^4.0.8"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/find-yarn-workspace-root2_1.2.57_1791824636678_0.5997693440067611"},"readme":"# find-yarn-workspace-root2\n\n[![Build Status](https://travis-ci.org/square/find-yarn-workspace-root.svg?branch=master)](https://travis-ci.org/square/find-yarn-workspace-root)\n\n用於尋找 Yarn workspace 根目錄 (Workspace Root) 的演算法，擷取自 yarnpkg.com，並加強為 `find-yarn-workspace-root` 的增強版本。\n\n當前版本：`1.2.55`\n\n## Features\n\n- 從指定目錄（預設為當前工作目錄）向上遍歷 (Traverse) 目錄樹，找出宣告 `workspaces` 的 `package.json` 所在目錄\n- 同時支援 Yarn workspaces 的兩種配置格式：陣列格式與物件格式\n- 使用 [micromatch](https://github.com/micromatch/micromatch) 進行 glob 模式 (Pattern) 匹配，確認起始目錄確實落在 workspace 範圍內\n- 找不到 workspace 根目錄時回傳 `null`，不會丟出例外\n- 演算法改編自 Yarn 原始碼，行為與 Yarn 官方判斷一致\n- 提供同步 API，並附帶 `readPackageJSON`、`extractWorkspaces`、`isMatchWorkspaces` 等輔助函式\n\n## Installation\n\n```bash\nyarn add find-yarn-workspace-root2\n```\n\n或使用 npm：\n\n```bash\nnpm install find-yarn-workspace-root2\n```\n\n## Usage\n\n```js\nconst findWorkspaceRoot = require('find-yarn-workspace-root2');\n\nconst workspaceRoot = findWorkspaceRoot(__dirname); // Absolute path or null\n```\n\n在 TypeScript 中也可直接匯入具名函式：\n\n```ts\nimport { findWorkspaceRoot } from 'find-yarn-workspace-root2/core';\n\nfindWorkspaceRoot('/path/to/project');\n```\n\n若起始目錄本身即為 workspace 根目錄，會回傳該目錄的絕對路徑；若起始目錄不屬於任何 workspace，則回傳 `null`。\n\n## API Documentation\n\n### findWorkspaceRoot(initial?: string): string | null\n\n主入口函式，從 `initial` 開始向上尋找 workspace 根目錄。\n\n| 參數 | 型別 | 說明 |\n| --- | --- | --- |\n| `initial` | `string?` | 起始搜尋目錄，未提供時使用 `process.cwd()` |\n\n| 回傳值 | 說明 |\n| --- | --- |\n| `string` | workspace 根目錄的絕對路徑 |\n| `null` | 找不到 `package.json`，或路徑不符合 `workspaces` 模式 |\n\n### 其他輔助 API（自 `find-yarn-workspace-root2/core` 匯入）\n\n| 函式 | 說明 |\n| --- | --- |\n| `checkWorkspaces(current, initial)` | 檢查 `current` 是否為有效的 workspace 根目錄，回傳 `{ done, found, relativePath }` |\n| `isMatchWorkspaces(relativePath, workspaces)` | 判斷相對路徑是否符合 `workspaces` 的 glob 模式，回傳 `boolean` |\n| `extractWorkspaces(manifest)` | 自 `package.json` 內容中取出 `workspaces` 的 `packages` 陣列，無配置時回傳 `null` |\n| `readPackageJSON(dir)` | 讀取並解析指定目錄下的 `package.json`，檔案不存在時回傳 `null` |\n\n這些輔助函式同時被附加為 `findWorkspaceRoot` 的靜態屬性，例如 `findWorkspaceRoot.extractWorkspaces(manifest)`。\n\n## Configuration\n\n本套件本身沒有需設定的選項，行為完全取決於目標專案 `package.json` 的 `workspaces` 設定。\n\nYarn 支援兩種格式，本套件皆可辨識：\n\n```json\n{\n  \"workspaces\": [\"packages/*\"]\n}\n```\n\n```json\n{\n  \"workspaces\": {\n    \"packages\": [\"packages/*\"]\n  }\n}\n```\n\n判斷流程：\n\n1. 自起始目錄向上尋找最近的 `package.json`\n2. 讀取該 `package.json` 的 `workspaces` 設定\n3. 若無 `workspaces` 設定，繼續往父目錄查找；已到達檔案系統根目錄則回傳 `null`\n4. 若有 `workspaces` 設定，計算起始目錄相對該目錄的路徑並進行 glob 匹配\n5. 路徑為空（同一目錄）或匹配成功即回傳該目錄，否則回傳 `null`\n\n更多相關工具的比較與遷移方式，請參閱 [docs/find-path-tools.md](../docs/find-path-tools.md)。\n\n## Contributing\n\nContributions are welcome! Just clone this repository and install the dependencies:\n\n```bash\ngit clone https://github.com/square/find-yarn-workspace-root.git\ncd find-yarn-workspace-root\nyarn\n```\n\nNote that you'll need `node` and `yarn` installed. Next, verify the tests all pass:\n\n```bash\nyarn test\n```\n\nThen create a branch for your bugfix/feature, make changes and update the tests, and submit a pull request. Please do not change the version in `package.json` when submitting a pull request. We determine the next version automatically based on the commits since the last release.\n\n> *NOTE*: Commit messages follow the [Angular commit message guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits).\n\n## Releases\n\nReleases are handled by Travis CI once a build succeeds on `master`. To trigger a release, bump the version using `standard-version`:\n\n```bash\n$(yarn bin)/standard-version\n```\n\nThat should update the CHANGELOG, bump the version in `package.json`, and create a git tag. Then, just `git push && git push --tags`.\n\n---\nCopyright 2017 Square, Inc.\n","publish_time":1791824636779,"_cnpm_publish_time":1791824636779,"dist-tags":{"latest":"1.2.59"}}