qkpr 1.0.2 → 1.0.4
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/index.mjs +34 -78
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1237,7 +1237,7 @@ inquirer.registerPrompt("search-checkbox", searchCheckbox);
|
|
|
1237
1237
|
* 通用的分支选择函数,支持单选和多选
|
|
1238
1238
|
*/
|
|
1239
1239
|
async function promptBranchSelection(branches, options) {
|
|
1240
|
-
const { title, message, mode, filterPinned = false } = options;
|
|
1240
|
+
const { title, message, mode, filterPinned = false, defaultSelected = [] } = options;
|
|
1241
1241
|
console.log(cyan(`\n${title}`));
|
|
1242
1242
|
console.log(dim(""));
|
|
1243
1243
|
if (branches.length === 0) {
|
|
@@ -1252,37 +1252,9 @@ async function promptBranchSelection(branches, options) {
|
|
|
1252
1252
|
pinnedBranches.sort((a, b) => {
|
|
1253
1253
|
return pinnedBranchNames.indexOf(a.name) - pinnedBranchNames.indexOf(b.name);
|
|
1254
1254
|
});
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
categorizedBranches.get(branch.category).push(branch);
|
|
1259
|
-
});
|
|
1260
|
-
categorizedBranches.forEach((branches$1) => {
|
|
1261
|
-
branches$1.sort((a, b) => b.lastCommitTime - a.lastCommitTime);
|
|
1262
|
-
});
|
|
1263
|
-
const categoryOrder = [
|
|
1264
|
-
"main",
|
|
1265
|
-
"release",
|
|
1266
|
-
"feat",
|
|
1267
|
-
"fix",
|
|
1268
|
-
"merge",
|
|
1269
|
-
"refactor",
|
|
1270
|
-
"hotfix",
|
|
1271
|
-
"chore",
|
|
1272
|
-
"docs",
|
|
1273
|
-
"test",
|
|
1274
|
-
"style"
|
|
1275
|
-
];
|
|
1276
|
-
const sortedCategories = Array.from(categorizedBranches.keys()).sort((a, b) => {
|
|
1277
|
-
const aIndex = categoryOrder.indexOf(a);
|
|
1278
|
-
const bIndex = categoryOrder.indexOf(b);
|
|
1279
|
-
if (aIndex !== -1 && bIndex !== -1) return aIndex - bIndex;
|
|
1280
|
-
if (aIndex !== -1) return -1;
|
|
1281
|
-
if (bIndex !== -1) return 1;
|
|
1282
|
-
if (a === "other") return 1;
|
|
1283
|
-
if (b === "other") return -1;
|
|
1284
|
-
return a.localeCompare(b);
|
|
1285
|
-
});
|
|
1255
|
+
regularBranches.sort((a, b) => a.name.localeCompare(b.name));
|
|
1256
|
+
const MAX_BRANCHES = 100;
|
|
1257
|
+
if (regularBranches.length > MAX_BRANCHES) regularBranches.splice(MAX_BRANCHES);
|
|
1286
1258
|
const choices = [];
|
|
1287
1259
|
if (pinnedBranches.length > 0) {
|
|
1288
1260
|
choices.push(new inquirer.Separator(magenta("━━━━━━━━ 📌 Pinned Branches ━━━━━━━━")));
|
|
@@ -1290,30 +1262,24 @@ async function promptBranchSelection(branches, options) {
|
|
|
1290
1262
|
choices.push({
|
|
1291
1263
|
name: `📌 ${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1292
1264
|
value: branch.name,
|
|
1293
|
-
short: branch.name
|
|
1265
|
+
short: branch.name,
|
|
1266
|
+
checked: defaultSelected.includes(branch.name)
|
|
1294
1267
|
});
|
|
1295
1268
|
});
|
|
1296
1269
|
choices.push(new inquirer.Separator(" "));
|
|
1297
1270
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
choices.push(new inquirer.Separator(cyan(`━━━━━━━━ ${categoryLabel} ━━━━━━━━`)));
|
|
1307
|
-
branches$1.forEach((branch) => {
|
|
1308
|
-
choices.push({
|
|
1309
|
-
name: ` ${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1310
|
-
value: branch.name,
|
|
1311
|
-
short: branch.name
|
|
1312
|
-
});
|
|
1271
|
+
if (regularBranches.length > 0) {
|
|
1272
|
+
choices.push(new inquirer.Separator(cyan("━━━━━━━━ 🌿 All Branches (Alphabetical) ━━━━━━━━")));
|
|
1273
|
+
regularBranches.forEach((branch) => {
|
|
1274
|
+
choices.push({
|
|
1275
|
+
name: ` ${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1276
|
+
value: branch.name,
|
|
1277
|
+
short: branch.name,
|
|
1278
|
+
checked: defaultSelected.includes(branch.name)
|
|
1313
1279
|
});
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1280
|
+
});
|
|
1281
|
+
choices.push(new inquirer.Separator(" "));
|
|
1282
|
+
}
|
|
1317
1283
|
const searchBranches = async (_answers, input = "") => {
|
|
1318
1284
|
const lowerInput = input.toLowerCase();
|
|
1319
1285
|
return choices.filter((choice) => {
|
|
@@ -1332,20 +1298,11 @@ async function promptBranchSelection(branches, options) {
|
|
|
1332
1298
|
}]);
|
|
1333
1299
|
return selectedBranch;
|
|
1334
1300
|
} else {
|
|
1335
|
-
const allBranches = [...pinnedBranches, ...regularBranches];
|
|
1336
|
-
allBranches.sort((a, b) => a.name.localeCompare(b.name));
|
|
1337
|
-
const simpleChoices = allBranches.map((branch) => {
|
|
1338
|
-
return {
|
|
1339
|
-
name: `${pinnedBranchNames.includes(branch.name) ? "📌 " : " "}${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1340
|
-
value: branch.name,
|
|
1341
|
-
short: branch.name
|
|
1342
|
-
};
|
|
1343
|
-
});
|
|
1344
1301
|
const { selectedBranches } = await inquirer.prompt([{
|
|
1345
1302
|
type: "search-checkbox",
|
|
1346
1303
|
name: "selectedBranches",
|
|
1347
1304
|
message,
|
|
1348
|
-
choices:
|
|
1305
|
+
choices: choices.filter((c) => c.value)
|
|
1349
1306
|
}]);
|
|
1350
1307
|
return selectedBranches || [];
|
|
1351
1308
|
}
|
|
@@ -1413,25 +1370,24 @@ async function handlePinCommand(branchName) {
|
|
|
1413
1370
|
return;
|
|
1414
1371
|
}
|
|
1415
1372
|
const pinnedBranches = getPinnedBranches();
|
|
1416
|
-
const
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
const selectedBranches = await promptBranchSelection(availableBranches, {
|
|
1422
|
-
title: "📌 Pin Branches",
|
|
1423
|
-
message: "Select branches to pin (type to search, Space to select, Enter to confirm):",
|
|
1373
|
+
const selectedBranches = await promptBranchSelection(branches, {
|
|
1374
|
+
title: "📌 Manage Pinned Branches",
|
|
1375
|
+
message: "Select branches to pin (type to search, Space to toggle, Enter to confirm):",
|
|
1424
1376
|
mode: "multiple",
|
|
1425
|
-
|
|
1377
|
+
defaultSelected: pinnedBranches
|
|
1426
1378
|
});
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
}
|
|
1431
|
-
selectedBranches.forEach((branch) => {
|
|
1379
|
+
const toAdd = selectedBranches.filter((b) => !pinnedBranches.includes(b));
|
|
1380
|
+
const toRemove = pinnedBranches.filter((b) => !selectedBranches.includes(b));
|
|
1381
|
+
toAdd.forEach((branch) => {
|
|
1432
1382
|
addPinnedBranch(branch);
|
|
1433
1383
|
});
|
|
1434
|
-
|
|
1384
|
+
toRemove.forEach((branch) => {
|
|
1385
|
+
removePinnedBranch(branch);
|
|
1386
|
+
});
|
|
1387
|
+
if (toAdd.length > 0 || toRemove.length > 0) {
|
|
1388
|
+
if (toAdd.length > 0) console.log(green(`✅ Pinned ${toAdd.length} branch(es)`));
|
|
1389
|
+
if (toRemove.length > 0) console.log(green(`✅ Unpinned ${toRemove.length} branch(es)`));
|
|
1390
|
+
} else console.log(dim("No changes made"));
|
|
1435
1391
|
}
|
|
1436
1392
|
const updatedPinnedBranches = getPinnedBranches();
|
|
1437
1393
|
console.log(cyan("\n📌 Current pinned branches:"));
|
|
@@ -1784,9 +1740,9 @@ async function showMainMenu() {
|
|
|
1784
1740
|
}
|
|
1785
1741
|
function printPRBanner() {
|
|
1786
1742
|
console.log(bold(cyan("\n╔══════════════════════════════════════════════════════════════╗")));
|
|
1787
|
-
console.log(bold(cyan("║ 🔧 Quick PR Creator
|
|
1743
|
+
console.log(bold(cyan("║ 🔧 Quick PR Creator ║")));
|
|
1788
1744
|
console.log(bold(cyan("║ ║")));
|
|
1789
|
-
console.log(bold(cyan("║ Interactive PR Creation Tool
|
|
1745
|
+
console.log(bold(cyan("║ Interactive PR Creation Tool ║")));
|
|
1790
1746
|
console.log(bold(cyan("╚══════════════════════════════════════════════════════════════╝")));
|
|
1791
1747
|
console.log(` Version: ${version}\n`);
|
|
1792
1748
|
}
|