All files index.ts

83.33% Statements 15/18
100% Branches 8/8
100% Functions 1/1
83.33% Lines 15/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59            4x 4x                           4x 1x 1x   3x 3x 1x 1x   2x 2x 2x               3x                 3x               3x  
import minimist from 'minimist';
 
import { create, CreateOptions } from './create';
export * from './create';
 
export async function run(): Promise<void> {
  try {
    const argvs: CreateOptions = minimist(process.argv.slice(2), {
      alias: {
        output: 'o',
        force: 'f',
        path: 'p',
        example: 'e',
      },
      default: {
        path: 'https://kktjs.github.io/zip/',
        output: '.',
        force: false,
        example: 'basic',
      },
    });
    if (argvs.h || argvs.help) {
      console.log(`${helpCli}${helpExample}${helpCopyright}`);
      return;
    }
    const { version } = require('../package.json');
    if (argvs.v || argvs.version) {
      console.log(`\n create-kkt v${version}\n`);
      return;
    }
    argvs.appName = argvs._[0];
    argvs.example = argvs.e = String(argvs.example).toLocaleLowerCase();
    await create(argvs, helpExample);
  } catch (error) {
    console.log(`\x1b[31m${error.message}\x1b[0m`);
    console.log(error);
    process.exit(1);
  }
}
 
export const helpCli = `\n  Usage: create-kkt <app-name> [options] [--help|h]
  Options:
    --version, -v  Show version number
    --help, -h     Displays help information.
    --output, -o   Output directory.
    --example, -e  Example from: \x1b[34mhttps://kktjs.github.io/zip/ \x1b[0m , default: "basic"
    --force, -f    Overwrite target directory if it exists. default: false
    --path, -p     Specify the download target git address. default: "\x1b[34mhttps://kktjs.github.io/zip/ \x1b[0m"
`;
export const helpExample: string = `\n  Example:
 
    \x1b[35myarn\x1b[0m create kkt \x1b[33mappName\x1b[0m
    \x1b[35mnpx\x1b[0m create-kkt \x1b[33mmy-app\x1b[0m
    \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m
    \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m -f
    \x1b[35mnpm\x1b[0m create kkt \x1b[33mmy-app\x1b[0m -p \x1b[34mhttps://kktjs.github.io/zip/\x1b[0m
`;
export const helpCopyright: string = `\n  Copyright 2021`;