@jlchain/cli-utils

打包cli工具用到的基础能力

Usage no npm install needed!

<script type="module">
  import jlchainCliUtils from 'https://cdn.skypack.dev/@jlchain/cli-utils';
</script>

README

cli-utils

cli most commonly used utils

Features

  • master branch check
  • commander inhanced package
  • cross-spawn inhanced package
  • intelligent npm version manage

Installation

To install cli-utils, use npm

npm install @jlchain/cli-utils

Usage

Methods

import {
  branch,
  commanderHelper,
  packageJson,
  spawn,
} from '@jlchain/cli-utils';
// check branch 
const b = branch();
if (b !== 'master') {
if (isMaster) {
  console.log('please select master branch');
  process.exit(1);
}
commanderHelper.initHelp({
  desc: 'you can use command as this:',
  options: [
    {
      flags: 'release',
      desc: 'version release',
    },
    {
      flags: 'publish',
      desc: 'publish to npm',
    },
  ],
});
// get json data of package.json in current project
const { version } = packageJsonn();
console.log(version);
// execute cli command
spawn('tcm -p src/**/*.less -c -s -w');
spawn.sync('yarn start');

commands

# version release
jlchain-cli-utils release
# version options
patch
minor
major
# publish to npm, by default to use https://registry.npmjs.org/
jlchain-cli-utils publish
# publish to npm, custom to use https://registry.npm.taobao.org/
jlchain-cli-utils publish https://registry.npm.taobao.org/