What is @lerna/changed?
@lerna/changed is a part of the Lerna monorepo management toolset. It is used to list local packages that have changed since the last tagged release. This is particularly useful in monorepo setups where you need to identify which packages have been modified and need to be published.
What are @lerna/changed's main functionalities?
List Changed Packages
This feature allows you to list all the packages that have changed since the last tagged release. The code sample uses Node.js to execute the `lerna changed` command and prints the list of changed packages.
const { execSync } = require('child_process');
const changedPackages = execSync('npx lerna changed').toString();
console.log(changedPackages);
Filter by Scope
This feature allows you to filter the list of changed packages by a specific scope. The code sample demonstrates how to list changed packages that match the given scope.
const { execSync } = require('child_process');
const changedPackages = execSync('npx lerna changed --scope my-package').toString();
console.log(changedPackages);
Include Private Packages
This feature allows you to include private packages in the list of changed packages. The code sample shows how to list all changed packages, including those that are private.
const { execSync } = require('child_process');
const changedPackages = execSync('npx lerna changed --include-private').toString();
console.log(changedPackages);
Other packages similar to @lerna/changed
changesets
Changesets is a tool for managing versioning and changelogs with a focus on monorepos. It allows you to track changes across multiple packages and generate changelogs. Compared to @lerna/changed, Changesets offers more comprehensive versioning and changelog management features.
lerna
Lerna is a tool for managing JavaScript projects with multiple packages. While @lerna/changed is a specific command within Lerna, the full Lerna toolset offers a wide range of functionalities including bootstrapping, linking dependencies, and publishing packages. It is more comprehensive compared to the single-purpose @lerna/changed.
nx
Nx is a smart, fast, and extensible build system with first-class monorepo support and powerful integrations. It provides advanced features for managing monorepos, including affected package detection, which is similar to what @lerna/changed offers. However, Nx also includes additional features like task running and caching.
lerna changed
List local packages that have changed since the last tagged release
Install lerna for access to the lerna
CLI.
Usage
The output of lerna changed
is a list of packages that would be the subjects of the next lerna version
or lerna publish
execution.
$ lerna changed
package-1
package-2
Note: lerna.json
configuration for lerna publish
and lerna version
also affects
lerna changed
, e.g. command.publish.ignoreChanges
.
Options
lerna changed
supports all of the flags supported by lerna ls
:
Unlike lerna ls
, however, lerna changed
does not support filter options, as filtering is not supported by lerna version
or lerna publish
.
lerna changed
supports the following options of lerna version
(the others are irrelevant):