@sk-labs/copilot-kit 3.0.0 → 3.0.1
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/lib/commands.js +22 -2
- package/package.json +1 -1
package/lib/commands.js
CHANGED
|
@@ -4,6 +4,7 @@ const https = require('https');
|
|
|
4
4
|
const chalk = require('chalk');
|
|
5
5
|
const ora = require('ora');
|
|
6
6
|
const AdmZip = require('adm-zip');
|
|
7
|
+
const readline = require('readline');
|
|
7
8
|
|
|
8
9
|
const GITHUB_REPO = 'sk-labs/copilot-kit';
|
|
9
10
|
const GITHUB_API = 'https://api.github.com';
|
|
@@ -19,8 +20,13 @@ async function init(options) {
|
|
|
19
20
|
// Check if .github exists
|
|
20
21
|
if (fs.existsSync(githubPath) && !options.force && !options.dryRun) {
|
|
21
22
|
console.log(chalk.yellow('⚠️ .github folder already exists!'));
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
const shouldOverwrite = await askConfirmation(chalk.bold('Do you want to overwrite it? (y/N) '));
|
|
25
|
+
|
|
26
|
+
if (!shouldOverwrite) {
|
|
27
|
+
console.log(chalk.yellow('Aborted.\n'));
|
|
28
|
+
process.exit(0); // Exit gracefully if user says no
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
if (options.dryRun) {
|
|
@@ -201,4 +207,18 @@ function downloadRepo(branch = 'main') {
|
|
|
201
207
|
});
|
|
202
208
|
}
|
|
203
209
|
|
|
210
|
+
function askConfirmation(question) {
|
|
211
|
+
const rl = readline.createInterface({
|
|
212
|
+
input: process.stdin,
|
|
213
|
+
output: process.stdout
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return new Promise(resolve => {
|
|
217
|
+
rl.question(question, (answer) => {
|
|
218
|
+
rl.close();
|
|
219
|
+
resolve(answer.trim().toLowerCase().startsWith('y'));
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
204
224
|
module.exports = { init, update, status };
|