first commit

This commit is contained in:
编码猿
2024-09-27 00:58:46 +08:00
commit 92916abf8f
156 changed files with 19331 additions and 0 deletions

74
Vue3TCli/bin/tsvue-init Executable file
View File

@@ -0,0 +1,74 @@
#!/usr/bin/env node
const program = require('commander');
const exec = require('child_process').exec;
const chalk = require('chalk');
const ora = require('ora');
const { GetUserInfo } = require('./../lib');
const config = require('../package');
program.on('--help', () => {
console.log();
console.log(' Examples:');
console.log();
console.log(chalk.gray(' # create a new project with an official template'));
console.log(' $ tsvue init myProject');
console.log()
});
function help () {
program.parse(process.argv)
if (program.args.length < 1) return program.help()
}
help();
let projectName = program.args[0], gitUrl, branch, cmdStr;
gitUrl = config.git.url, branch = config.git.branch;
cmdStr = `git clone ${gitUrl} ${projectName} && cd ${projectName} && git checkout ${branch}`;
const down = ora('Download template...');
const dependency = ora('Initializing dependency...');
console.log();
console.log(" 🎉 欢迎使用脚手架模板 Vue3Template\n 🎉 基于Vue-cli3+Vue3+TypeScript开发一起感受Vue3+TypeScript的魅力吧\n\n 📦 项目地址https://github.com/helpcode/Vue3Template\n 📦 注解包地址https://www.npmjs.com/package/vue3decorators\n 📦 自动路由插件https://www.npmjs.com/package/vue-cli-plugin-autorouter\n\n");
down.start();
run(cmdStr, (status) => {
if (status) {
down.stop();
console.log(chalk.green(' 🎉 Download Success...'));
console.log(chalk.green(' 📦 Initializing Dependency...\n'));
dependency.start();
let install = `cd ${projectName} && npm i`;
run(install, (res) => {
if(res) {
dependency.stop();
console.log("\n Dependency Installed Success...")
console.log(chalk.green(`\n cd ${projectName} #Enter the folder\n npm run dev #Running project`))
console.log();
process.exit();
}
});
} else {
console.log("项目初始化出错请确保已经安装git并保持网络通畅")
process.exit()
}
});
//GetUserInfo()
function run(url, callback){
exec(url, (error, stdout, stderr) => {
if (error) {
console.log(error);
callback(false)
} else {
callback(true);
}
})
}