1.1.6 • Published 2 years ago

packages-list v1.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

npm package License Quality

Contents

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.

Supported Package Managers

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

Install

npm i packages-list

Example

Given file structure

/
└─┬ packages
  ├─┬ my-package-a
  │ └── package.json
  ├─┬ my-package-b
  │ └── package.json
  └─┬ my-package-c
    └── package.json
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" }
//     }
// ]

Usage

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

API

listPackages(options?)

Returns a promise that resolves to an array of packages. Every package contains:

{
    "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.
  • 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'
1.0.1

2 years ago

1.0.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

0.0.0

2 years ago