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ACZ,QAAQ,KAAI,IA4DpB,QAAQ,MAAM,QAAQ","file":"/npm/xyoct-cli@0.0.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/xyoct-cli@0.0.2/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#!/usr/bin/env node\n// 文件系统\nconst fs = require('fs');\n// 用户输入命令\nconst program = require('commander');\n// 用户交互信息\nconst inquirer = require('inquirer');\n// 从仓库拉取模板\nconst download = require('download-git-repo');\n// handlebars修改文件\nconst hbs = require('handlebars');\n// download 动画效果\nconst ora = require('ora');\n// 提示图标\nconst symbols = require('log-symbols');\n// 字体颜色\nconst chalk = require('chalk');\n\n\n/**\n * Usage\n */\nprogram\n    .usage('init [koa-template]')\n    .version('1.0.0', '-v, --version')\n    .command('init <name>')\n    .action(name => {\n        if (fs.existsSync(name)) {\n            console.log(symbols.error, chalk.red('该项目已存在！'));\n            return;\n        }\n        main(name);\n    });\n\n/**\n * Help.\n */\nprogram\n    .on('--help', () => {\n        console.log()\n        console.log('  Examples:')\n        console.log()\n        console.log(chalk.green('    # create a new project with an Github template: xyoct-cli init <project-name>'))\n        console.log('    $ xyoct-cli init my-project')\n        console.log()\n    })\n\n/**\n * main\n */\nfunction main(name) {\n    inquirer.prompt([\n        {\n            name: 'description',\n            message: '请输入项目描述！',\n            default: 'description'\n        },\n        {\n            name: 'author',\n            message: '请输入项目作者',\n            default: '王二狗'\n        },\n        {\n            type: 'list',\n            message: '请选择项目中的数据库类型:',\n            name: 'dbtype',\n            choices: [\n                \"MongoDB\",\n                \"Mysql\"\n            ]\n        }\n    ]).then((answers) => {\n        const spinner = ora('Downloading……');\n        let downloadUrl = 'Xyoct/cli-temp'\n        if (answers.dbtype == 'MongoDB') {\n            downloadUrl += '#db'\n        }\n        if (answers.dbtype == 'Mysql') {\n            downloadUrl += '#mysql'\n        }\n        spinner.start();\n        download(downloadUrl, name, function (err) {\n            if (err) {\n                spinner.fail();\n                console.log(symbols.error, chalk.red(err));\n                return;\n            }\n            spinner.succeed();\n            const fileName = `${name}/package.json`;\n            const meta = {\n                name,\n                description: answers.description,\n                author: answers.author\n            }\n            if (fs.existsSync(fileName)) {\n                const content = fs.readFileSync(fileName).toString();\n                const result = hbs.compile(content)(meta);\n                fs.writeFileSync(fileName, result);\n            }\n            console.log(symbols.success, chalk.green('Successfully!'));\n        })\n    })\n}\n\nprogram.parse(process.argv);\n"]}