UNPKG

zyk-cli

Version:

生成 React 或 Vue初始代码,生成 webpack 配置,以及配置 webpack 优化项

35 lines (29 loc) 880 B
#! /usr/bin/env node import chalk from "chalk"; import { Command } from "commander"; import create from "../main/create"; import { readFileSync } from "node:fs"; const { version } = JSON.parse( readFileSync(new URL("../../package.json", import.meta.url)).toString() ); const program = new Command(); // 创建文件命令 program .command("create <project-name>") .description("create a new project") .option("-f --force", "if it exist, overwrite directory") .action((name: string, options: any) => { create(name, options); }); // 配置版本号信息 program.version(version).usage("<command> [option]"); // 配置帮助信息 program.on("--help", () => { console.log( `\r\n Run ${chalk.green( `zyk <command> --help` )} to understand the details \r\n ` ); }); // 解析参数 program.parse(process.argv);