test: 测试: ✅ 添加git仓库地址
This commit is contained in:
parent
9407d63be5
commit
2c2a9b7df7
|
@ -51,16 +51,16 @@ const vue = [
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// 项目列表
|
// 项目列表
|
||||||
projectList: {
|
projectList: {
|
||||||
'vue&js&vuex': '1',
|
'vue&js&vuex': 'https://gitee.com/BunnyBoss/vue_js_vuex.git',
|
||||||
'vue&js&pina': '2',
|
'vue&js&pina': 'https://gitee.com/BunnyBoss/vue_js_pina.git',
|
||||||
'vue&ts&vuex': '3',
|
'vue&ts&vuex': 'https://gitee.com/BunnyBoss/vue_ts_vuex.git',
|
||||||
'vue&ts&pina': '4',
|
'vue&ts&pina': 'https://gitee.com/BunnyBoss/vue_ts_pina.git',
|
||||||
'react&js&': '5',
|
'react&js&': 'http://129.211.31.58:3000/Bunny-Cli/react_js.git',
|
||||||
'react&ts&': '6',
|
'react&ts&': 'http://129.211.31.58:3000/Bunny-Cli/react_ts.git',
|
||||||
'react&js&userouter': '7',
|
'react&js&userouter': 'http://129.211.31.58:3000/Bunny-Cli/react_js_userouter.git',
|
||||||
'react&ts&userouter': '8',
|
'react&ts&userouter': 'http://129.211.31.58:3000/Bunny-Cli/react_ts_userouter.git',
|
||||||
'react&js&RouterProvider': '9',
|
'react&js&RouterProvider': 'http://129.211.31.58:3000/Bunny-Cli/react_js_routerprovider.git',
|
||||||
'react&ts&RouterProvider': '10',
|
'react&ts&RouterProvider': 'http://129.211.31.58:3000/Bunny-Cli/react_ts_routerprovider.git',
|
||||||
},
|
},
|
||||||
// 问题
|
// 问题
|
||||||
question: { frame, react, vue },
|
question: { frame, react, vue },
|
||||||
|
|
12
bin/index.js
12
bin/index.js
|
@ -16,12 +16,14 @@ program
|
||||||
const targetPath = path.join(process.cwd(), name);
|
const targetPath = path.join(process.cwd(), name);
|
||||||
|
|
||||||
// 文件夹下是否有这个名字
|
// 文件夹下是否有这个名字
|
||||||
await fileIsExist(targetPath, name);
|
const result = await fileIsExist(targetPath, name);
|
||||||
|
|
||||||
// 新建项目
|
if (result) {
|
||||||
const key = await createProject();
|
// 新建项目
|
||||||
// clone项目
|
const key = await createProject();
|
||||||
downloadProject(targetPath, key, name);
|
// clone项目
|
||||||
|
downloadProject(targetPath, key, name);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 给help信息添加提示
|
// 给help信息添加提示
|
||||||
|
|
56
bin/utils.js
56
bin/utils.js
|
@ -12,7 +12,6 @@ module.exports = {
|
||||||
* 是否需要覆盖
|
* 是否需要覆盖
|
||||||
*/
|
*/
|
||||||
async fileIsExist(targetPath, name) {
|
async fileIsExist(targetPath, name) {
|
||||||
console.log(targetPath);
|
|
||||||
if (fs.existsSync(targetPath, name)) {
|
if (fs.existsSync(targetPath, name)) {
|
||||||
const awsaner = await inquirer.prompt({
|
const awsaner = await inquirer.prompt({
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
|
@ -25,7 +24,11 @@ module.exports = {
|
||||||
if (awsaner.overWrite) {
|
if (awsaner.overWrite) {
|
||||||
fs.remove(targetPath);
|
fs.remove(targetPath);
|
||||||
console.log(chalk.green('✅删除成功'));
|
console.log(chalk.green('✅删除成功'));
|
||||||
} else return;
|
return true;
|
||||||
|
} else {
|
||||||
|
console.log(chalk.yellow('❌程序退出'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -53,32 +56,31 @@ module.exports = {
|
||||||
/**
|
/**
|
||||||
* 从仓库clone项目
|
* 从仓库clone项目
|
||||||
*/
|
*/
|
||||||
downloadProject(targetPath, key, name) {
|
async downloadProject(targetPath, key, name) {
|
||||||
const spinner = ora('下载中...').start(); // 注意要使用x几版本因为不支持
|
const spinner = ora('下载中...\n').start();
|
||||||
|
|
||||||
// 如果有git,删除原有的git
|
try {
|
||||||
if (fs.existsSync(targetPath, '.git')) {
|
await gitClone(key, name, { checkout: 'master' });
|
||||||
fs.remove(path.join(targetPath, '.git'));
|
spinner.succeed('😄下载成功');
|
||||||
}
|
// 如果有git,删除原有的git
|
||||||
|
if (fs.existsSync(targetPath, '.git')) {
|
||||||
gitClone(projectList[key], name, { checkout: 'main' }, function (error) {
|
fs.remove(path.join(targetPath, '.git'));
|
||||||
if (error) {
|
|
||||||
spinner.fail('😭下载失败,请稍后重试'); // 注意要使用x几版本因为不支持
|
|
||||||
} else {
|
|
||||||
spinner.succeed('😄下载成功'); // 注意要使用x几版本因为不支持
|
|
||||||
const overText = `
|
|
||||||
⚓ Running completion hooks...
|
|
||||||
|
|
||||||
📄 Generating README.md...
|
|
||||||
|
|
||||||
🎉 Successfully created project ${name}
|
|
||||||
👉 Get started with the following commands:
|
|
||||||
|
|
||||||
cd vue_js_vuex
|
|
||||||
npm run serve
|
|
||||||
`;
|
|
||||||
console.log(overText);
|
|
||||||
}
|
}
|
||||||
});
|
const overText = `
|
||||||
|
⚓ Running completion hooks...
|
||||||
|
|
||||||
|
📄 Generating README.md...
|
||||||
|
|
||||||
|
🎉 Successfully created project ${name}
|
||||||
|
👉 Get started with the following commands:
|
||||||
|
|
||||||
|
cd vue_js_vuex
|
||||||
|
npm run serve
|
||||||
|
`;
|
||||||
|
console.log(overText);
|
||||||
|
console.log(chalk.whiteBright('Happy hacking!'));
|
||||||
|
} catch (error) {
|
||||||
|
spinner.fail('😭下载失败,请稍后重试');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue