{"id":15290162,"url":"https://github.com/npm/map-workspaces","last_synced_at":"2025-05-16T09:06:36.055Z","repository":{"id":37797833,"uuid":"245538213","full_name":"npm/map-workspaces","owner":"npm","description":"Retrieves a name:pathname Map for a given workspaces config","archived":false,"fork":false,"pushed_at":"2025-04-28T18:53:52.000Z","size":425,"stargazers_count":22,"open_issues_count":0,"forks_count":11,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-10T03:04:41.815Z","etag":null,"topics":["npm-cli"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-06T23:57:14.000Z","updated_at":"2025-04-28T18:53:54.000Z","dependencies_parsed_at":"2024-05-03T19:28:04.513Z","dependency_job_id":"ee165be5-6086-464c-97a6-f2e4f1c83ee2","html_url":"https://github.com/npm/map-workspaces","commit_stats":{"total_commits":129,"total_committers":9,"mean_commits":"14.333333333333334","dds":0.5891472868217054,"last_synced_commit":"25c582b3e0c5462bc920e52b8850d5231ef440df"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmap-workspaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmap-workspaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmap-workspaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fmap-workspaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/map-workspaces/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227582,"owners_count":22035664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["npm-cli"],"created_at":"2024-09-30T16:05:56.574Z","updated_at":"2025-05-16T09:06:31.030Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @npmcli/map-workspaces\n\n[![NPM version](https://img.shields.io/npm/v/@npmcli/map-workspaces)](https://www.npmjs.com/package/@npmcli/map-workspaces)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/npm/map-workspaces/ci.yml?branch=main)](https://github.com/npm/map-workspaces)\n[![License](https://img.shields.io/npm/l/@npmcli/map-workspaces)](https://github.com/npm/map-workspaces/blob/main/LICENSE.md)\n\nRetrieves a name:pathname Map for a given workspaces config.\n\nLong version: Reads the `workspaces` property from a valid **workspaces configuration** object and traverses the paths and globs defined there in order to find valid nested packages and return a **Map** of all found packages where keys are package names and values are folder locations.\n\n## Install\n\n`npm install @npmcli/map-workspaces`\n\n## Usage:\n\n```js\nconst mapWorkspaces = require('@npmcli/map-workspaces')\nawait mapWorkspaces({\n  cwd,\n  pkg: {\n    workspaces: {\n      packages: [\n        \"a\",\n        \"b\"\n      ]\n    }\n  }\n})\n// -\u003e\n// Map {\n//   'a': '\u003ccwd\u003e/a'\n//   'b': '\u003ccwd\u003e/b'\n// }\n```\n\n## Examples:\n\n### Glob usage:\n\nGiven a folder structure such as:\n\n```\n├── package.json\n└── apps\n   ├── a\n   │   └── package.json\n   ├── b\n   │   └── package.json\n   └── c\n       └── package.json\n```\n\n```js\nconst mapWorkspaces = require('@npmcli/map-workspaces')\nawait mapWorkspaces({\n  cwd,\n  pkg: {\n    workspaces: [\n      \"apps/*\"\n    ]\n  }\n})\n// -\u003e\n// Map {\n//   'a': '\u003ccwd\u003e/apps/a'\n//   'b': '\u003ccwd\u003e/apps/b'\n//   'c': '\u003ccwd\u003e/apps/c'\n// }\n```\n\n## API:\n\n### `mapWorkspaces(opts) -\u003e Promise\u003cMap\u003e`\n\n- `opts`:\n  - `pkg`: A valid `package.json` **Object**\n  - `cwd`: A **String** defining the base directory to use when reading globs and paths.\n  - `ignore`: An **Array** of paths to be ignored when using [globs](https://www.npmjs.com/package/glob) to look for nested package.\n  - ...[Also support all other glob options](https://www.npmjs.com/package/glob#options)\n\n#### Returns\n\nA **Map** in which keys are **package names** and values are the **pathnames** for each found **workspace**.\n\n## LICENSE\n\n[ISC](./LICENSE)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fmap-workspaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Fmap-workspaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fmap-workspaces/lists"}