Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshuajaco/find-workspaces
Find all the workspaces of a monorepo.
https://github.com/joshuajaco/find-workspaces
bolt lerna-monorepo monorepo npm-workspaces pnpm-workspaces workspaces yarn-workspaces
Last synced: 2 months ago
JSON representation
Find all the workspaces of a monorepo.
- Host: GitHub
- URL: https://github.com/joshuajaco/find-workspaces
- Owner: joshuajaco
- License: mit
- Created: 2021-10-19T17:50:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-28T18:25:26.000Z (4 months ago)
- Last Synced: 2024-10-12T17:41:14.892Z (3 months ago)
- Topics: bolt, lerna-monorepo, monorepo, npm-workspaces, pnpm-workspaces, workspaces, yarn-workspaces
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/find-workspaces
- Size: 258 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# find-workspaces ![npm downloads](https://img.shields.io/npm/dw/find-workspaces) [![Coverage Status](https://coveralls.io/repos/github/joshuajaco/find-workspaces/badge.svg)](https://coveralls.io/github/joshuajaco/find-workspaces) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Find all the workspaces of a monorepo.
It supports:
- [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces)
- [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
- [pnpm workspaces](https://pnpm.io/workspaces)
- [lerna](https://github.com/lerna/lerna)
- [bolt](https://github.com/boltpkg/bolt)## Installation
```sh
# npm
npm i find-workspaces# yarn
yarn add find-workspaces# pnpm
pnpm add find-workspaces
```## Usage
```javascript
// esm
import { findWorkspaces } from "find-workspaces";
// commonjs
const { findWorkspaces } = require("find-workspaces");const workspaces = findWorkspaces();
console.log(workspaces);
```## API
### findWorkspaces(dirname, options)
Finds all workspaces.
Returns [`Workspace[]`](#workspace) or `null` if `dirname` is not inside a monorepo.#### dirname
Type: `string | undefined`
Default: `process.cwd()`The directory to start searching for the monorepo root.
#### Options
Type: `Options`
Default: `{}`See [`Options`](#options-2)
### findWorkspacesRoot(dirname, options)
Finds the monorepo root.
Returns [`WorkspacesRoot`](#workspaceroot) or `null` if `dirname` is not inside a monorepo.#### dirname
Type: `string | undefined`
Default: `process.cwd()`The directory to start searching for the monorepo root.
#### Options
Type: `Options`
Default: `{}`See [`Options`](#options-2)
### createWorkspacesCache()
Returns a cache which can be provided to [`findWorkspaces`](#findworkspacesdirname-options) and [`findWorkspacesRoot`](#findworkspacesrootdirname-options).
### Options
#### stopDir
Type: `string | undefined`
Default: `os.homedir()`The directory to stop searching for the monorepo root.
The provided directory will not be included in the search.#### cache
Type: `Cache | undefined`
An optional cache created by [`createWorkspacesCache`](#createworkspacescache).
### Workspace
#### location
Type: `string`
The location of the workspace as an absolute path.
#### package
Type: [`PackageJson`](https://github.com/sindresorhus/type-fest/blob/main/source/package-json.d.ts)
The parsed `package.json` file of the workspace.
### WorkspaceRoot
#### location
Type: `string`
The location of the workspace as an absolute path.
#### globs
Type: `string[]`
A list of the glob patterns used to define the workspaces.
## License
[MIT](https://github.com/joshuajaco/find-workspaces/blob/main/LICENSE)