#!/usr/bin/env node const { program } = require('commander'); // 命令行提示工具 const path = require('path'); // 引入操作路径 const { CommandLogHelp, CommandLogStart } = require('./command-log'); const { fileIsExist, createProject, downloadProject } = require('./utils'); // 首行显示 CommandLogStart(); // 创建项目命令 program .command('create ') .description('创建一个新项目') .action(async function (name) { // 创建项目-创建一个名字为name的项目,如果存在是否覆盖? const targetPath = path.join(process.cwd(), name); // 文件夹下是否有这个名字 const result = await fileIsExist(targetPath, name); if (result) { // 新建项目 const key = await createProject(); // clone项目 downloadProject(targetPath, key, name); } }); // 给help信息添加提示 CommandLogHelp(); program.parse(process.argv);