5.1.2 • Published 3 months ago

lerna-cli v5.1.2

Weekly downloads
83
License
MIT
Repository
github
Last release
3 months ago

lerna-cli

Build status Test coverage NPM version NPM Downloads Prettier Conventional Commits

lerna cli with custom command extensions, forked with official lerna

See https://github.com/lerna/lerna/issues/2742

Features (VS Official lerna)

  • Use local lerna even in global command. see import-local
  • Custom command
  • Nested lerna.json in packages
    packages/
      foo/
        projects/
          bar/
        lerna.json
    lerna.json
  • Respect pnpm-workspace.yaml
    1. overwriting packages
    2. dependencies' version allows workspace:version
    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

npm install lerna-cli -D

lerna --help

Custom commands

  1. lerna.json

Add extendCommands field, supports local file or npm package

+ "extendCommands": [
+   "./commands/custom",
+   "lerna-custom-command",
+ ],
  1. Write myself custom command

Add command.js

/**
 * @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)
}
  1. Run custom command
lerna custom

Custom preset

  1. lerna.json

Add extendCommands field, supports local file or npm package

+ "extendCommands": [
+   "lerna-custom-preset-command",
+ ],
  1. Write myself custom command preset in command.js or command/index.js
module.exports = [
  require('lerna-command-a/command'),
  require('lerna-command-b/command'),
  require('lerna-command-c/command')
]
  1. Run custom command
lerna custom-a
lerna custom-b
lerna custom-c

Recommanded Commands

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 🐟