Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(diff): add Lerna
diff
as optional command
- Loading branch information
1 parent
e032e66
commit 44dabb2
Showing
21 changed files
with
561 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/cli/src/cli-commands/__tests__/cli-diff-commands.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
jest.mock('@lerna-lite/diff', () => null); | ||
const cliDiff = require('../cli-diff-commands'); | ||
|
||
describe('DiffCommand CLI options', () => { | ||
it('should log a console error when DiffCommand is not provided', async () => { | ||
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
|
||
await cliDiff.handler(); | ||
|
||
expect(consoleSpy).toHaveBeenCalledWith( | ||
expect.stringContaining('"@lerna-lite/diff" is optional and was not found.') | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module | ||
*/ | ||
exports.command = 'diff [pkgName]'; | ||
exports.describe = 'Diff all packages or a single package since the last release'; | ||
|
||
exports.builder = { | ||
'ignore-changes': { | ||
group: 'Command Options:', | ||
describe: 'Ignore changes in files matched by glob(s).', | ||
type: 'array', | ||
}, | ||
}; | ||
|
||
exports.handler = async function handler(argv) { | ||
try { | ||
// @ts-ignore | ||
// eslint-disable-next-line import/no-unresolved | ||
const { DiffCommand } = await import('@lerna-lite/diff'); | ||
new DiffCommand(argv); | ||
} catch (e) { | ||
console.error( | ||
'"@lerna-lite/diff" is optional and was not found. Please install it with `npm install @lerna-lite/diff -D -W`' | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[![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/diff?color=forest)](https://www.npmjs.com/package/@lerna-lite/diff) | ||
[![npm](https://img.shields.io/npm/v/@lerna-lite/diff.svg?logo=npm&logoColor=fff)](https://www.npmjs.com/package/@lerna-lite/diff) | ||
|
||
# @lerna-lite/diff | ||
|
||
## (`lerna diff`) - Diff command [optional] 🌓 | ||
|
||
Diff all packages or a single package since the last release | ||
|
||
--- | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install @lerna-lite/diff -D -W | ||
|
||
# then use it (see usage below) | ||
lerna diff | ||
|
||
# OR use npx | ||
npx lerna diff | ||
``` | ||
|
||
## Usage | ||
|
||
```sh | ||
$ lerna diff [package] | ||
|
||
$ lerna diff | ||
# diff a specific package | ||
$ lerna diff package-name | ||
``` | ||
|
||
Diff all packages or a single package since the last release. | ||
|
||
> Similar to `lerna changed`. This command runs `git diff`. |
Oops, something went wrong.