@snapcommit/cli 2.0.4 ā 2.0.5
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/dist/commands/cursor-style.js +23 -16
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.executeCursorStyle = executeCursorStyle;
|
|
11
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
12
|
const child_process_1 = require("child_process");
|
|
13
|
+
const readline_1 = __importDefault(require("readline"));
|
|
13
14
|
const git_1 = require("../utils/git");
|
|
14
15
|
const auth_1 = require("../lib/auth");
|
|
15
16
|
async function executeCursorStyle(userInput) {
|
|
@@ -35,20 +36,24 @@ async function executeCursorStyle(userInput) {
|
|
|
35
36
|
console.log(chalk_1.default.gray('š Commit message: ') + chalk_1.default.cyan(`"${plan.commitMessage}"`));
|
|
36
37
|
console.log();
|
|
37
38
|
}
|
|
38
|
-
// Ask for confirmation
|
|
39
|
+
// Ask for confirmation (natural language!)
|
|
39
40
|
const needsConfirm = plan.actions.some(a => a.requiresConfirmation);
|
|
40
41
|
if (needsConfirm) {
|
|
41
|
-
const
|
|
42
|
-
? chalk_1.default.
|
|
43
|
-
: chalk_1.default.
|
|
44
|
-
const answer = await askQuestion(
|
|
45
|
-
|
|
42
|
+
const confirmPrompt = plan.commitMessage
|
|
43
|
+
? chalk_1.default.cyan('What next? ') + chalk_1.default.gray('(') + chalk_1.default.white('continue') + chalk_1.default.gray(' ⢠') + chalk_1.default.white('cancel') + chalk_1.default.gray(' ⢠') + chalk_1.default.white('edit message') + chalk_1.default.gray('): ')
|
|
44
|
+
: chalk_1.default.cyan('What next? ') + chalk_1.default.gray('(') + chalk_1.default.white('continue') + chalk_1.default.gray(' ⢠') + chalk_1.default.white('cancel') + chalk_1.default.gray('): ');
|
|
45
|
+
const answer = await askQuestion(confirmPrompt);
|
|
46
|
+
const input = answer.toLowerCase().trim();
|
|
47
|
+
// Cancel commands
|
|
48
|
+
if (input === 'cancel' || input === 'no' || input === 'n' || input === 'stop' || input === 'abort') {
|
|
46
49
|
console.log(chalk_1.default.gray('\nā Cancelled\n'));
|
|
47
50
|
return;
|
|
48
51
|
}
|
|
49
|
-
|
|
52
|
+
// Edit commands
|
|
53
|
+
if (plan.commitMessage && (input === 'edit' || input === 'e' || input === 'change' || input === 'edit message')) {
|
|
50
54
|
plan.commitMessage = await editMessage(plan.commitMessage);
|
|
51
55
|
}
|
|
56
|
+
// Everything else (including "continue", "yes", "go ahead", "do it", "y", or just Enter) ā proceed
|
|
52
57
|
}
|
|
53
58
|
// Execute the plan
|
|
54
59
|
console.log(chalk_1.default.blue('\nāļø Executing...\n'));
|
|
@@ -287,17 +292,19 @@ async function tryAutoFix(error, action) {
|
|
|
287
292
|
return false;
|
|
288
293
|
}
|
|
289
294
|
function askQuestion(query) {
|
|
295
|
+
const rl = readline_1.default.createInterface({
|
|
296
|
+
input: process.stdin,
|
|
297
|
+
output: process.stdout,
|
|
298
|
+
terminal: false, // Don't process terminal escape sequences
|
|
299
|
+
});
|
|
290
300
|
return new Promise((resolve) => {
|
|
301
|
+
// Write prompt manually
|
|
291
302
|
process.stdout.write(query);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
process.stdin.pause();
|
|
298
|
-
resolve(data.toString().trim());
|
|
299
|
-
};
|
|
300
|
-
process.stdin.once('data', onData);
|
|
303
|
+
// Listen for ONE line of input
|
|
304
|
+
rl.once('line', (answer) => {
|
|
305
|
+
rl.close();
|
|
306
|
+
resolve(answer.trim());
|
|
307
|
+
});
|
|
301
308
|
});
|
|
302
309
|
}
|
|
303
310
|
async function editMessage(originalMessage) {
|