Skip to content

Commit

Permalink
feat(changed): add Lerna changed as optional command
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jun 20, 2022
1 parent 909ba05 commit b08417c
Show file tree
Hide file tree
Showing 36 changed files with 635 additions and 67 deletions.
28 changes: 16 additions & 12 deletions README.md
Expand Up @@ -29,6 +29,7 @@
- ☁️ [`publish`](https://github.com/ghiscoding/lerna-lite/tree/main/packages/publish#readme) - publish every workspace packages that changed
- 📑 [`version`](https://github.com/ghiscoding/lerna-lite/tree/main/packages/version#readme) - create new version for each workspace packages
- optional (**separate install**, see [installation](#installation) table below)
- 🕜 [`changed`](https://github.com/ghiscoding/lerna-lite/tree/main/packages/changed#readme) - list local packages that changed since last tagged release
- 👷 [`exec`](https://github.com/ghiscoding/lerna-lite/tree/main/packages/exec#readme) - execute shell command in each workspace package
- 📖 [`list`](https://github.com/ghiscoding/lerna-lite/tree/main/packages/list#readme) - list local packages
- 🏃 [`run`](https://github.com/ghiscoding/lerna-lite/tree/main/packages/run#readme) - run npm script in each workspace packages
Expand Down Expand Up @@ -83,8 +84,9 @@ Mainly for the following reasons:
- each package will get its own Changelog and a merged Changelog will also be created in the root.
- Automate the repository Publishing of your new version for all your packages (NPM or other platform).

#### Other useful, but optional, commands
#### Other useful, **but optional**, commands

- [Changed](https://github.com/ghiscoding/lerna-lite/tree/main/packages/changed#readme) command, when installed, will list all local packages that have changed since the last tagged release
- [Exec](https://github.com/ghiscoding/lerna-lite/tree/main/packages/exec#readme) command, when installed, will help you execute shell commands in parallel and in topological order.
- [List](https://github.com/ghiscoding/lerna-lite/tree/main/packages/list#readme) command, when installed, will list all workspace local packages
- [Run](https://github.com/ghiscoding/lerna-lite/tree/main/packages/run#readme) command, when installed, will help you run npm script in parallel and in topological order.
Expand Down Expand Up @@ -128,15 +130,16 @@ Run the following commands to install Lerna-Lite in your project and/or install

If you are new to Lerna-Lite, you could also run the [lerna init](https://github.com/ghiscoding/lerna-lite/tree/main/packages/init#readme) command which will create the `lerna.json` for you. If you are using a different client other than npm, then make sure to update the `npmClient` property in `lerna.json` (for example: `"npmClient": "yarn"`).

| Command | Install | Description | Included |
| ---------------------------------------------------------------------------------------- | ------------------------------ | --------------------------------------------- | -------- |
| 🛠️ [init](https://github.com/ghiscoding/lerna-lite/tree/main/packages/init#readme) | `npm i @lerna-lite/cli -D -W` | create/initialize a new Lerna-Lite repo | Yes |
| 💻 [info](https://github.com/ghiscoding/lerna-lite/tree/main/packages/info#readme) | `npm i @lerna-lite/cli -D -W` | print local environment information | Yes |
| 📑 [version](https://github.com/ghiscoding/lerna-lite/tree/main/packages/version#readme) | `npm i @lerna-lite/cli -D -W` | create new version for each workspace package | Yes |
| ☁️ [publish](https://github.com/ghiscoding/lerna-lite/tree/main/packages/publish#readme) | `npm i @lerna-lite/cli -D -W` | publish each workspace package | Yes |
| 👷 [exec](https://github.com/ghiscoding/lerna-lite/tree/main/packages/exec#readme) | `npm i @lerna-lite/exec -D -W` | execute an command in each workspace package | Optional |
| 📖 [list](https://github.com/ghiscoding/lerna-lite/tree/main/packages/list#readme) | `npm i @lerna-lite/list -D -W` | list local packages | Optional |
| 🏃 [run](https://github.com/ghiscoding/lerna-lite/tree/main/packages/run#readme) | `npm i @lerna-lite/run -D -W` | run npm script in each workspace package | Optional |
| Command | Install | Description | Included |
| ---------------------------------------------------------------------------------------- | --------------------------------- | ---------------------------------------------- | -------- |
| 🛠️ [init](https://github.com/ghiscoding/lerna-lite/tree/main/packages/init#readme) | `npm i @lerna-lite/cli -D -W` | create/initialize a new Lerna-Lite repo | Yes |
| 💻 [info](https://github.com/ghiscoding/lerna-lite/tree/main/packages/info#readme) | `npm i @lerna-lite/cli -D -W` | print local environment information | Yes |
| 📑 [version](https://github.com/ghiscoding/lerna-lite/tree/main/packages/version#readme) | `npm i @lerna-lite/cli -D -W` | create new version for each workspace package | Yes |
| ☁️ [publish](https://github.com/ghiscoding/lerna-lite/tree/main/packages/publish#readme) | `npm i @lerna-lite/cli -D -W` | publish each workspace package | Yes |
| 🕜 [changed](https://github.com/ghiscoding/lerna-lite/tree/main/packages/changed#readme) | `npm i @lerna-lite/changed -D -W` | list local packages changed since last release | Optional |
| 👷 [exec](https://github.com/ghiscoding/lerna-lite/tree/main/packages/exec#readme) | `npm i @lerna-lite/exec -D -W` | execute an command in each workspace package | Optional |
| 📖 [list](https://github.com/ghiscoding/lerna-lite/tree/main/packages/list#readme) | `npm i @lerna-lite/list -D -W` | list local packages | Optional |
| 🏃 [run](https://github.com/ghiscoding/lerna-lite/tree/main/packages/run#readme) | `npm i @lerna-lite/run -D -W` | run npm script in each workspace package | Optional |

**Note:** the default `lerna` CLI is including only 4 built-in commands (`init`,`info`,`publish`,`version`), all other commands are optional commands and must be installed separately as shown in the table.

Expand Down Expand Up @@ -189,10 +192,10 @@ npm uninstall -g lerna # OR yarn global remove lerna
npm install @lerna-lite/cli -D -W
```

3. optionally install `exec`, `list` and/or `run` commands (refer to [installation](#installation) table)
3. optionally install `changed`, `exec`, `list` and/or `run` commands (refer to [installation](#installation) table)

```sh
# optionally install `exec`, `list` and/or `run` command(s)
# install any of the optional commands (refer to installation table)
npm install @lerna-lite/run -D -W
```

Expand Down Expand Up @@ -234,6 +237,7 @@ If you have problems running the lib and your problems are related to Git comman
| [@lerna-lite/publish](https://github.com/ghiscoding/lerna-lite/tree/main/packages/publish) | [![npm](https://img.shields.io/npm/v/@lerna-lite/publish.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/publish) | Publish packages in the current workspace | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/publish/CHANGELOG.md) |
| [@lerna-lite/version](https://github.com/ghiscoding/lerna-lite/tree/main/packages/version) | [![npm](https://img.shields.io/npm/v/@lerna-lite/version.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/version) | Bump Version & write Changelogs | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/version/CHANGELOG.md) |
| [@lerna-lite/exec](https://github.com/ghiscoding/lerna-lite/tree/main/packages/exec) | [![npm](https://img.shields.io/npm/v/@lerna-lite/exec.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/exec) | Execute shell command in current workspace | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/exec/CHANGELOG.md) |
| [@lerna-lite/changed](https://github.com/ghiscoding/lerna-lite/tree/main/packages/changed) | [![npm](https://img.shields.io/npm/v/@lerna-lite/changed.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/changed) | List local packages that changed since last release | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/changed/CHANGELOG.md) |
| [@lerna-lite/list](https://github.com/ghiscoding/lerna-lite/tree/main/packages/list) | [![npm](https://img.shields.io/npm/v/@lerna-lite/list.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/list) | List local packages | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/list/CHANGELOG.md) |
| [@lerna-lite/run](https://github.com/ghiscoding/lerna-lite/tree/main/packages/run) | [![npm](https://img.shields.io/npm/v/@lerna-lite/run.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/run) | Run npm scripts in current workspace | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/run/CHANGELOG.md) |
| [@lerna-lite/optional-cmd-common](https://github.com/ghiscoding/lerna-lite/tree/main/packages/optional-cmd-common) | [![npm](https://img.shields.io/npm/v/@lerna-lite/optional-cmd-common.svg?logo=npm&logoColor=fff&label=npm)](https://www.npmjs.com/package/@lerna-lite/optional-cmd-common) | Lerna-Lite common utils for optional commands Exec/List/Run | [changelog](https://github.com/ghiscoding/lerna-lite/blob/main/packages/optional-cmd-common/CHANGELOG.md) |
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -11,6 +11,8 @@
"postbuild": "pnpm run lint",
"dist-info-cmd": "node ./packages/cli/dist/cli.js info",
"dist-init-cmd": "node ./packages/cli/dist/cli.js init --independent --exact --use-workspaces",
"dist-changed-cmd": "node ./packages/cli/dist/cli.js changed",
"dist-list-cmd": "node ./packages/cli/dist/cli.js list --all",
"dist-roll-version": "node ./packages/cli/dist/cli.js version",
"dist-roll-publish": "node ./packages/cli/dist/cli.js publish from-package",
"dist-roll-version-dry-run": "node ./packages/cli/dist/cli.js version --git-dry-run",
Expand Down Expand Up @@ -40,6 +42,7 @@
"pnpm": "7"
},
"devDependencies": {
"@lerna-lite/changed": "workspace:*",
"@lerna-lite/cli": "workspace:*",
"@lerna-lite/core": "workspace:*",
"@lerna-lite/exec": "workspace:*",
Expand Down
58 changes: 58 additions & 0 deletions packages/changed/README.md
@@ -0,0 +1,58 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)
[![npm](https://img.shields.io/npm/dy/@lerna-lite/changed?color=forest)](https://www.npmjs.com/package/@lerna-lite/changed)
[![npm](https://img.shields.io/npm/v/@lerna-lite/changed.svg?logo=npm&logoColor=fff)](https://www.npmjs.com/package/@lerna-lite/changed)

# @lerna-lite/changed

## (`lerna changed`) - Changed command [optional] 🕜

List local packages that have changed since the last tagged release

---

## Installation

```sh
npm install @lerna-lite/changed -D -W

# then use it (see usage below)
lerna changed

# OR use npx
npx lerna changed
```

## 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.

```sh
$ 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`](https://github.com/lerna/lerna/tree/main/commands/list#options):

- [`--json`](https://github.com/lerna/lerna/tree/main/commands/list#--json)
- [`--ndjson`](https://github.com/lerna/lerna/tree/main/commands/list#--ndjson)
- [`-a`, `--all`](https://github.com/lerna/lerna/tree/main/commands/list#--all)
- [`-l`, `--long`](https://github.com/lerna/lerna/tree/main/commands/list#--long)
- [`-p`, `--parseable`](https://github.com/lerna/lerna/tree/main/commands/list#--parseable)
- [`--toposort`](https://github.com/lerna/lerna/tree/main/commands/list#--toposort)
- [`--graph`](https://github.com/lerna/lerna/tree/main/commands/list#--graph)

Unlike `lerna ls`, however, `lerna changed` **does not** support [filter options](https://www.npmjs.com/package/@lerna/filter-options), as filtering is not supported by `lerna version` or `lerna publish`.

`lerna changed` supports the following options of [`lerna version`](https://github.com/lerna/lerna/tree/main/commands/version#options) (the others are irrelevant):

- [`--conventional-graduate`](https://github.com/lerna/lerna/tree/main/commands/version#--conventional-graduate).
- [`--force-publish`](https://github.com/lerna/lerna/tree/main/commands/version#--force-publish).
- [`--ignore-changes`](https://github.com/lerna/lerna/tree/main/commands/version#--ignore-changes).
- [`--include-merged-tags`](https://github.com/lerna/lerna/tree/main/commands/version#--include-merged-tags).
37 changes: 37 additions & 0 deletions packages/changed/package.json
@@ -0,0 +1,37 @@
{
"name": "@lerna-lite/changed",
"description": "Lerna-Lite changed commmand - List local packages that have changed since the last tagged release",
"version": "1.5.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"typings": "dist/index.d.ts",
"files": [
"/dist"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc --project tsconfig.bundle.json --newLine LF",
"pack-tarball": "npm pack"
},
"license": "MIT",
"author": "Ghislain B.",
"homepage": "https://github.com/ghiscoding/lerna-lite",
"repository": {
"type": "git",
"url": "https://github.com/ghiscoding/lerna-lite.git",
"directory": "packages/changed"
},
"bugs": {
"url": "https://github.com/ghiscoding/lerna-lite/issues"
},
"engines": {
"node": ">=14.15.0",
"npm": ">=8.0.0"
},
"dependencies": {
"@lerna-lite/core": "workspace:*",
"@lerna-lite/list": "workspace:*"
}
}
3 changes: 3 additions & 0 deletions packages/changed/src/__tests__/__fixtures__/basic/lerna.json
@@ -0,0 +1,3 @@
{
"version": "1.0.0"
}
@@ -0,0 +1,3 @@
{
"name": "independent"
}
@@ -0,0 +1,4 @@
{
"name": "package-1",
"version": "1.0.0"
}
@@ -0,0 +1,7 @@
{
"name": "package-2",
"version": "1.0.0",
"dependencies": {
"package-1": "^1.0.0"
}
}
@@ -0,0 +1,7 @@
{
"name": "package-3",
"version": "1.0.0",
"devDependencies": {
"package-2": "^1.0.0"
}
}
@@ -0,0 +1,7 @@
{
"name": "package-4",
"version": "1.0.0",
"dependencies": {
"package-1": "^0.0.0"
}
}
@@ -0,0 +1,8 @@
{
"name": "package-5",
"version": "1.0.0",
"private": "true",
"dependencies": {
"package-1": "^1.0.0"
}
}
@@ -0,0 +1,3 @@
{
"version": "1.0.0"
}
@@ -0,0 +1,3 @@
{
"name": "independent"
}
@@ -0,0 +1,4 @@
{
"name": "package-1",
"version": "1.0.0"
}
@@ -0,0 +1,7 @@
{
"name": "package-2",
"version": "1.0.0",
"dependencies": {
"package-1": "^1.0.0"
}
}
@@ -0,0 +1,7 @@
{
"name": "package-3",
"version": "1.0.0",
"dependencies": {
"package-4": "^1.0.0"
}
}
@@ -0,0 +1,7 @@
{
"name": "package-4",
"version": "1.0.0",
"dependencies": {
"package-3": "^1.0.0"
}
}
@@ -0,0 +1,8 @@
{
"name": "package-5",
"version": "1.0.0",
"private": "true",
"dependencies": {
"package-1": "^1.0.0"
}
}

0 comments on commit b08417c

Please sign in to comment.