text: #!/usr/bin/env node
  const program = require('commander');
  const checkNodeVersion = require('@alib/build-scripts/lib/utils/checkNodeVersion');
  const packageInfo = require('../package.json');
  const build = require('./build');
  const start = require('./start');
  const test = require('./test');
  
  (async () => {
    console.log(packageInfo.name, packageInfo.version);
    // finish check before run command
    checkNodeVersion(packageInfo.engines.node);
  
    program
      .version(packageInfo.version)
      .usage('<command> [options]');
  
    program
      .command('build')
      .description('build project')
      .allowUnknownOption()
      .option('--config <config>', 'use custom config')
      .option('--analyzer', 'use webpack-bundle-analyzer')
      .option('--analyzer-port <port>', 'webpack-bundle-analyzer port', '9000')
      .action(build);
  
    program
      .command('start')
      .description('start server')
      .allowUnknownOption()
      .option('--config <config>', 'use custom config')
      .option('-h, --host <host>', 'dev server host', '0.0.0.0')
      .option('-p, --port <port>', 'dev server port')
      .option('--https', 'use https protocol')
      .option('--analyzer', 'use webpack-bundle-analyzer')
      .option('--analyzer-port <port>', 'webpack-bundle-analyzer port', '9000')
      .option('--disable-reload', 'disable hot-loader module')
      .option('--disable-mock', 'diable mock service')
      .option('--disable-open', 'disable automatically open browser')
      .option('--disable-assets', 'disable the output of webpack assets')
      .action(start);
  
    program
      .command('test')
      .description('run tests with jest')
      .allowUnknownOption() // allow jest config
      .option('--config <config>', 'use custom config')
      .action(test);
  
    program.parse(process.argv);
  
    const proc = program.runningCommand;
  
    if (proc) {
      proc.on('close', process.exit.bind(process));
      proc.on('error', () => {
        process.exit(1);
      });
    }
  
    const subCmd = program.args[0];
    if (!subCmd) {
      program.help();
    }
  })();
  