vite-shadcn-ui-cli 1.0.11 → 1.0.13
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 +15 -18
- package/package.json +1 -1
package/index.js
CHANGED
@@ -36,22 +36,19 @@ program
|
|
36
36
|
output: process.stdout,
|
37
37
|
});
|
38
38
|
|
39
|
-
//
|
40
|
-
rl.question('Do you want to overwrite it? (y/N): ',
|
39
|
+
// 提示用户选择
|
40
|
+
rl.question('Do you want to overwrite it? (y/N): ', (answer) => {
|
41
41
|
rl.close();
|
42
42
|
if (answer.toLowerCase() === 'y') {
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
// fs.rmdirSync(targetPath, { recursive: true, force: true });
|
44
|
+
fs.rm(targetPath, { recursive: true, force: true }, (err) => {
|
45
|
+
if (err) {
|
46
|
+
console.error('Error deleting directory:', err);
|
47
|
+
} else {
|
48
|
+
console.log(chalk.yellow(`\n⚠️ The existing directory "${projectDir}" was removed.`));
|
49
49
|
cloneRepo(projectDir);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
console.error(chalk.red(`Failed to remove directory: ${err.message}`));
|
53
|
-
process.exit(1);
|
54
|
-
}
|
50
|
+
}
|
51
|
+
});
|
55
52
|
} else {
|
56
53
|
console.log(chalk.blue('\nOperation cancelled.'));
|
57
54
|
process.exit(1);
|
@@ -62,29 +59,29 @@ program
|
|
62
59
|
}
|
63
60
|
});
|
64
61
|
|
62
|
+
program.parse(process.argv);
|
63
|
+
|
65
64
|
// 克隆 GitHub 仓库的函数
|
66
65
|
async function cloneRepo(projectDir) {
|
67
66
|
const spinner = ora('Cloning the repository...').start();
|
68
67
|
const repoUrl = 'https://github.com/kyrie668/vite-shadcn-ui.git';
|
69
68
|
|
70
69
|
try {
|
71
|
-
|
70
|
+
await git.clone(repoUrl, projectDir);
|
72
71
|
spinner.succeed('Project cloned successfully!');
|
73
72
|
|
74
73
|
// 移除 .git 文件夹以断开 Git 关联
|
75
|
-
|
74
|
+
fs.rmSync(path.join(projectDir, '.git'), { recursive: true, force: true });
|
76
75
|
console.log(
|
77
76
|
chalk.green('\n✅ Git history removed. You can now initialize your own repository.')
|
78
77
|
);
|
79
|
-
|
80
78
|
console.log(chalk.cyan(`\n👉 Next steps:`));
|
81
79
|
console.log(` cd ${projectDir}`);
|
82
80
|
console.log(' npm install');
|
83
81
|
console.log(' npm run dev');
|
84
82
|
} catch (error) {
|
85
83
|
spinner.fail('Failed to clone the repository.');
|
86
|
-
console.error(
|
84
|
+
console.error(error);
|
87
85
|
process.exit(1);
|
88
86
|
}
|
89
87
|
}
|
90
|
-
program.parse();
|