Socket
Socket
Sign inDemoInstall

@lerna/package-graph

Package Overview
Dependencies
2
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lerna/package-graph


Version published
Maintainers
4
Created

Package description

What is @lerna/package-graph?

@lerna/package-graph is a utility for managing and analyzing the dependency graph of packages within a monorepo. It helps in understanding the relationships between different packages and can be used to perform operations like finding dependencies, dependents, and traversing the graph.

What are @lerna/package-graph's main functionalities?

Creating a Package Graph

This feature allows you to create a graph of packages from an array of package objects. The graph can then be used to analyze the relationships between the packages.

const { PackageGraph } = require('@lerna/package-graph');
const packages = [
  { name: 'package-a', version: '1.0.0', dependencies: { 'package-b': '^1.0.0' } },
  { name: 'package-b', version: '1.0.0', dependencies: {} }
];
const graph = new PackageGraph(packages);
console.log(graph);

Finding Package Dependencies

This feature allows you to find the dependencies of a specific package within the graph. In this example, it retrieves the dependencies of 'package-a'.

const { PackageGraph } = require('@lerna/package-graph');
const packages = [
  { name: 'package-a', version: '1.0.0', dependencies: { 'package-b': '^1.0.0' } },
  { name: 'package-b', version: '1.0.0', dependencies: {} }
];
const graph = new PackageGraph(packages);
const packageA = graph.get('package-a');
console.log(packageA.localDependencies);

Finding Package Dependents

This feature allows you to find the dependents of a specific package within the graph. In this example, it retrieves the dependents of 'package-b'.

const { PackageGraph } = require('@lerna/package-graph');
const packages = [
  { name: 'package-a', version: '1.0.0', dependencies: { 'package-b': '^1.0.0' } },
  { name: 'package-b', version: '1.0.0', dependencies: {} }
];
const graph = new PackageGraph(packages);
const packageB = graph.get('package-b');
console.log(packageB.localDependents);

Other packages similar to @lerna/package-graph

Changelog

Source

3.0.0-rc.0 (2018-07-27)

Bug Fixes

  • changed: Clarify early exit log message (b132c3a)
  • cli: Pass global defaults into option factory instead of yargs.config() (cf4008a), closes #1449
  • command: Prevent premature resolution during tests from nested commands (151363f)
  • core/package: Serialize hosted git URLs with original protocol/shorthand (60ff432), closes #1499
  • project: Report syntax errors in root package.json (f674f35), closes #1452
  • publish: Add default description 'npm' for --npm-client (649048c)
  • publish: Avoid fs-extra warning on 32-bit machines (e908d23)
  • publish: Do not leave unstaged changes with --skip-git (2d497ed)
  • publish: Exit early when publishing w/o commits (#1453) (6cbae35), closes #773
  • publish: Pass --repo-version argument through semver.valid() (272e9f1), closes #1483
  • publish: Update lerna.json version after root preversion lifecycle (7b3817c), closes #1495
  • tests: Special handling for Windows CI issues (#1441) (1a01125)

Code Refactoring

  • collect-updates: Make argument signature explicit (e6ba19f)
  • command: Do not store raw packages list as instance property (32a211a)

Features

  • Add description from --help summary [skip ci] (9b65d8e)
  • Count packages affected in command summary logging (5f5e585)
  • publish: Ensure published packages contain a LICENSE file (#1465) (5863564), closes #1213
  • Upgrade to fs-extra 6 (079d873)
  • add: Add --exact option to lerna add (#1478) (346d156), closes #1470
  • cli: Upgrade to Yargs 12 (7899ab8)
  • command: Remove .defaultOptions() from option resolution stack (2b27a54)
  • ls: Log number of packages listed (855fff6)
  • package-graph: Add rawPackageList getter (0ad5faf)
  • project: Move collect-packages into getPackages() method (06b88d4)
  • publish: Add --require-scripts option to opt-in to raw JS lifecycle scripts (054392b)
  • publish: Add --amend flag (#1422) (ef5f0db)
  • run-lifecycle: Encapsulate npm-conf with createRunner() factory (488f98d)

BREAKING CHANGES

  • publish: External $PKGDIR/scripts/{pre,post}publish.js lifecycles are now opt-in instead of automatic. Pass --require-scripts explicitly to restore previous functionality.
  • collect-updates: Instead of an opaque command instance, distinct positional arguments are required.
  • command: this.packages no longer exists in Command subclasses, use this.packageGraph.rawPackageList

<a name="3.0.0-beta.21"></a>

Readme

Source

@lerna/package-graph

Lerna's internal representation of a package graph

Usage

You probably shouldn't, at least directly.

Install lerna for access to the lerna CLI.

Keywords

FAQs

Last updated on 27 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc