https://github.com/imcuttle/lerna-cli
lerna cli with custom command extensions, forked with official lerna
https://github.com/imcuttle/lerna-cli
Last synced: 8 months ago
JSON representation
lerna cli with custom command extensions, forked with official lerna
- Host: GitHub
- URL: https://github.com/imcuttle/lerna-cli
- Owner: imcuttle
- License: mit
- Created: 2020-10-22T04:56:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-10T10:29:14.000Z (almost 2 years ago)
- Last Synced: 2025-03-23T02:34:02.392Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.36 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: License
Awesome Lists containing this project
README
# lerna-cli
[](https://travis-ci.org/imcuttle/lerna-cli)
[](https://codecov.io/github/imcuttle/lerna-cli?branch=master)
[](https://www.npmjs.com/package/lerna-cli)
[](https://www.npmjs.com/package/lerna-cli)
[](https://prettier.io/)
[](https://conventionalcommits.org)
> lerna cli with custom command extensions, forked with official [lerna](https://www.npmjs.com/package/lerna)
See https://github.com/lerna/lerna/issues/2742
## Features (VS Official lerna)
- Use local `lerna` even in global command. see [import-local](https://www.npmjs.com/package/import-local)
- Custom command
- Nested `lerna.json` in packages
```text
packages/
foo/
projects/
bar/
lerna.json
lerna.json
```
- Respect pnpm-workspace.yaml
1. overwriting `packages`
2. dependencies' version allows `workspace:version`
```text
packages/
lerna.json
pnpm-workspace.yaml
```
In my best practices case: use pnpm as a monorepo manager, use lerna for publishing or some custom commands.
## Installation
```bash
npm install lerna-cli -D
lerna --help
```
## Custom commands
1. `lerna.json`
Add `extendCommands` field, supports local file or npm package
```diff
+ "extendCommands": [
+ "./commands/custom",
+ "lerna-custom-command",
+ ],
```
2. Write myself custom command
- See official command: [@lerna/init](https://github.com/lerna/lerna/tree/master/commands/init), [@lerna/add](https://github.com/lerna/lerna/tree/master/commands/add)
Add `command.js`
```javascript
/**
* @see https://github.com/yargs/yargs/blob/master/docs/advanced.md#providing-a-command-module
*/
exports.command = 'custom'
exports.describe = 'custom command.'
exports.builder = {
exact: {
describe: 'Specify lerna dependency version in package.json without a caret (^)',
type: 'boolean'
},
independent: {
describe: 'Version packages independently',
alias: 'i',
type: 'boolean'
}
}
exports.handler = function handler(argv) {
return require('..')(argv)
}
```
3. Run custom command
```bash
lerna custom
```
## Custom preset
1. `lerna.json`
Add `extendCommands` field, supports local file or npm package
```diff
+ "extendCommands": [
+ "lerna-custom-preset-command",
+ ],
```
2. Write myself custom command preset in `command.js` or `command/index.js`
```javascript
module.exports = [
require('lerna-command-a/command'),
require('lerna-command-b/command'),
require('lerna-command-c/command')
]
```
3. Run custom command
```bash
lerna custom-a
lerna custom-b
lerna custom-c
```
## Recommanded Commands
- [lerna-gpm](https://github.com/imcuttle/lerna-gpm) - lerna command for git package manager
- [lerna-command-toc](https://github.com/imcuttle/lerna-command-toc) - lerna command for generate toc of packages in markdown
## Contributing
- Fork it!
- Create your new branch:
`git checkout -b feature-new` or `git checkout -b fix-which-bug`
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
`git commit -am 'feat: some description (close #123)'` or `git commit -am 'fix: some description (fix #123)'`
- Push to the branch: `git push`
- Submit a pull request :)
## Authors
This library is written and maintained by imcuttle, imcuttle@163.com.com.
## License
MIT - [imcuttle](https://github.com/imcuttle) 🐟