# packages-list

> List all packages in a monorepo.

Latest version **1.1.6** (published 2022-08-15) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install packages-list
pnpm add packages-list
yarn add packages-list
bun add packages-list
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2022-08-15 |
| First published | 2022-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14 |
| Dependencies | 6 |
| Unpacked size | 13.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | jacobley |
| Maintainers | jacobley |
| Keywords | list, packages, workspace |

## Links

- npm: https://www.npmjs.com/package/packages-list
- Repository: https://github.com/jacobley/jacobley
- Homepage: https://github.com/JacobLey/jacobley/tree/main/tools/packages-list#readme
- Issues: https://github.com/jacobley/jacobley/issues
- npm.io page: https://npm.io/package/packages-list

## Dependencies (6)

- [which](https://npm.io/package/which.md) ^2.0.2
- [globby](https://npm.io/package/globby.md) ^13.1.1
- [parse-cwd](https://npm.io/package/parse-cwd.md) ^1.0.8
- [find-import](https://npm.io/package/find-import.md) ^1.0.6
- [named-patch](https://npm.io/package/named-patch.md) ^1.0.8
- [root-package-json](https://npm.io/package/root-package-json.md) ^1.1.6

## Recent versions

- 1.1.6 (latest) — 2022-08-15
- 1.1.6-dev.9fb29c6527f5a68dbe4552abeb4905b183a56e6b3b9c2b65363da54bc3001d9d (dev) — 2022-08-15
- 1.1.6-dev.1e6fb2eb001cea38d49407180d13e11c4ed1c25c — 2022-08-15
- 1.1.6-dev.f06a40de2660f60c5585c205c68c46e390914f4688f0779e5dbc0b165e0b01b1 — 2022-08-14
- 1.1.6-dev.6d40ad53c428177f21d8b184fccd23db6500aa4c — 2022-08-14
- 1.1.5 — 2022-08-10
- 1.1.5-dev.9604dfc2e2ad87eba67a44c9366a4bf96e80705ed408d76bae9e7d59b4efc4f5 — 2022-08-10
- 1.1.5-dev.6150c44a1e003315375046a34cb8cb25c1c54c47 — 2022-08-10
- 1.1.4 — 2022-07-06
- 1.1.4-dev.8f41f15a189a2a681d9f70d9b3551b106a3b43f956cb3c902222c8b50291d035 — 2022-07-05
- 1.1.4-dev.2ddecc8d51e299e6bb7119e88876bad3f86a3dc2 — 2022-07-05
- 1.1.4-dev.bf1592d2ca77e5943eca9de7c17c9d4dd16be991e170f385e0bad352fa644236 — 2022-07-05
- 1.1.4-dev.4c46e6462b38fb852efea6fa0f1f3a68da9ec757 — 2022-07-05
- 1.1.3 — 2022-07-02
- 1.1.3-dev.01725b5afbc8f7c1fcea7942e525cb964e5ed9e38c4293c5e2b8477e154a853e — 2022-07-02
- … 37 more at https://npm.io/package/packages-list/versions

## README

<div style="text-align:center">

<h1>packages-list</h1>
<p>List all packages in a monorepo.</p>

[![npm package](https://badge.fury.io/js/packages-list.svg)](https://www.npmjs.com/package/packages-list)
[![License](https://img.shields.io/npm/l/packages-list.svg)](https://github.com/JacobLey/jacobley/blob/main/common/config/publish/LICENSE)
[![Quality](https://img.shields.io/npms-io/quality-score/packages-list.svg)](https://github.com/JacobLey/jacobley/blob/main/tools/packages-list)

</div>

## Contents
- [Introduction](#introduction)
- [Supported Package Managers](#supported-package-managers)
- [Install](#install)
- [Example](#example)
- [Usage](#usage)
- [API](#api)

<a name="Introduction"></a>
## Introduction

Lists all packages in a monorepo.

Includes directory, name, and contents of package.json. Order is non-deterministic.

Can be called from any location inside a monorepo.

<a name="Supported Package Managers"></a>
## Supported Package Managers

Package managers that are supported for finding/parsing packages are:

* ✅ [Lerna](https://lerna.js.org/)
* ✅ [NPM](https://docs.npmjs.com/cli/v8/using-npm/workspaces)
* ✅ [Nx](https://nx.dev/configuration/projectjson#workspace-json)
* ✅ [Rush](https://rushjs.io/pages/configs/rush_json/)
* ✅ [Yarn](https://yarnpkg.com/features/workspaces)

<a name="Install"></a>
## Install

```sh
npm i packages-list
```

<a name="Example"></a>
## Example

Given file structure
```
/
└─┬ packages
  ├─┬ my-package-a
  │ └── package.json
  ├─┬ my-package-b
  │ └── package.json
  └─┬ my-package-c
    └── package.json
```

```ts
import { listPackages } from 'packagesList';

const packages = await listPackages();

console.log(packages);
// [
//     {
//         "directory": "/packages/my-package-a",
//         "name": "my-package-a",
//         "packageJson": { "name": "my-package-a" }
//     },
//     {
//         "directory": "/packages/my-package-b",
//         "name": "my-package-b",
//         "packageJson": { "name": "my-package-b" }
//     },
//     {
//         "directory": "/packages/my-package-c",
//         "name": "my-package-c",
//         "packageJson": { "name": "my-package-c" }
//     }
// ]
```

<a name="Usage"></a>
## Usage

`packages-list` is an ESM module. That means it _must_ be `import`ed. To load from a CJS module, use dynamic import `const { listPackages } = await import('packages-list');`.

<a name="Api"></a>
## API

### listPackages(options?)

Returns a promise that resolves to an array of packages. Every package contains:
```json
{
    "directory": "string",
    "name": "string",
    "packageJson": { "name": "string", "version": "..." }
}
```

#### options

* cwd
  * Type: `string` or `URL`
  * optional, defaults to `process.cwd()`
  * Directory to use as base directory.
  * See [`parse-cwd`](https://www.npmjs.com/package/parse-cwd).

* manager
  * Specify package manager to use
  * `'lerna'` | `'npm'` | `'nx'` | `'rush'` | `'yarn'`
  * If omitted, will try all and take first found
    * e.g. would use `lerna.json` to load packages if found, but can be forced to use npm workspaces if `manager = 'npm'`

---
_Source: https://npm.io/package/packages-list · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
