vite-shadcn-ui-cli 1.0.6 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +18 -10
- package/package.json +1 -1
package/index.js
CHANGED
@@ -36,13 +36,22 @@ program
|
|
36
36
|
output: process.stdout,
|
37
37
|
});
|
38
38
|
|
39
|
-
//
|
40
|
-
rl.question('Do you want to overwrite it? (y/N): ', (answer) => {
|
39
|
+
// 提示用户是否覆盖
|
40
|
+
rl.question('Do you want to overwrite it? (y/N): ', async (answer) => {
|
41
41
|
rl.close();
|
42
42
|
if (answer.toLowerCase() === 'y') {
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
try {
|
44
|
+
await fs.promises.rm(targetPath, { recursive: true, force: true });
|
45
|
+
console.log(chalk.yellow(`\n⚠️ The existing directory "${projectDir}" was removed.`));
|
46
|
+
|
47
|
+
// 增加延时确保系统释放资源
|
48
|
+
setTimeout(() => {
|
49
|
+
cloneRepo(projectDir);
|
50
|
+
}, 500); // 500ms 延时
|
51
|
+
} catch (err) {
|
52
|
+
console.error(chalk.red(`Failed to remove directory: ${err.message}`));
|
53
|
+
process.exit(1);
|
54
|
+
}
|
46
55
|
} else {
|
47
56
|
console.log(chalk.blue('\nOperation cancelled.'));
|
48
57
|
process.exit(1);
|
@@ -61,23 +70,22 @@ async function cloneRepo(projectDir) {
|
|
61
70
|
const repoUrl = 'https://github.com/kyrie668/vite-shadcn-ui.git';
|
62
71
|
|
63
72
|
try {
|
64
|
-
|
73
|
+
execSync(`git clone ${repoUrl} ${projectDir}`, { stdio: 'ignore' });
|
65
74
|
spinner.succeed('Project cloned successfully!');
|
66
75
|
|
67
76
|
// 移除 .git 文件夹以断开 Git 关联
|
68
|
-
fs.
|
77
|
+
await fs.promises.rm(path.join(projectDir, '.git'), { recursive: true, force: true });
|
69
78
|
console.log(
|
70
79
|
chalk.green('\n✅ Git history removed. You can now initialize your own repository.')
|
71
80
|
);
|
81
|
+
|
72
82
|
console.log(chalk.cyan(`\n👉 Next steps:`));
|
73
83
|
console.log(` cd ${projectDir}`);
|
74
84
|
console.log(' npm install');
|
75
85
|
console.log(' npm run dev');
|
76
86
|
} catch (error) {
|
77
87
|
spinner.fail('Failed to clone the repository.');
|
78
|
-
console.error(error);
|
88
|
+
console.error(chalk.red(`\nError: ${error.message}`));
|
79
89
|
process.exit(1);
|
80
90
|
}
|
81
91
|
}
|
82
|
-
|
83
|
-
program.parse();
|