qkpr 1.0.1 → 1.0.3
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 +28 -67
- package/package.json +41 -44
package/dist/index.mjs
CHANGED
|
@@ -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 ━━━━━━━━")));
|
|
@@ -1295,25 +1267,17 @@ async function promptBranchSelection(branches, options) {
|
|
|
1295
1267
|
});
|
|
1296
1268
|
choices.push(new inquirer.Separator(" "));
|
|
1297
1269
|
}
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
else categoryLabel = `${category}/*`;
|
|
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
|
-
});
|
|
1270
|
+
if (regularBranches.length > 0) {
|
|
1271
|
+
choices.push(new inquirer.Separator(cyan("━━━━━━━━ 🌿 All Branches (Alphabetical) ━━━━━━━━")));
|
|
1272
|
+
regularBranches.forEach((branch) => {
|
|
1273
|
+
choices.push({
|
|
1274
|
+
name: ` ${branch.name.padEnd(45)} ${dim(`(${branch.lastCommitTimeFormatted})`)}`,
|
|
1275
|
+
value: branch.name,
|
|
1276
|
+
short: branch.name
|
|
1313
1277
|
});
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1278
|
+
});
|
|
1279
|
+
choices.push(new inquirer.Separator(" "));
|
|
1280
|
+
}
|
|
1317
1281
|
const searchBranches = async (_answers, input = "") => {
|
|
1318
1282
|
const lowerInput = input.toLowerCase();
|
|
1319
1283
|
return choices.filter((choice) => {
|
|
@@ -1332,20 +1296,11 @@ async function promptBranchSelection(branches, options) {
|
|
|
1332
1296
|
}]);
|
|
1333
1297
|
return selectedBranch;
|
|
1334
1298
|
} 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
1299
|
const { selectedBranches } = await inquirer.prompt([{
|
|
1345
1300
|
type: "search-checkbox",
|
|
1346
1301
|
name: "selectedBranches",
|
|
1347
1302
|
message,
|
|
1348
|
-
choices
|
|
1303
|
+
choices
|
|
1349
1304
|
}]);
|
|
1350
1305
|
return selectedBranches || [];
|
|
1351
1306
|
}
|
|
@@ -1514,14 +1469,22 @@ async function checkForUpdates(packageName$1, currentVersion) {
|
|
|
1514
1469
|
"pipe",
|
|
1515
1470
|
"ignore"
|
|
1516
1471
|
],
|
|
1517
|
-
timeout:
|
|
1472
|
+
timeout: 5e3
|
|
1518
1473
|
}).trim();
|
|
1474
|
+
const hasUpdate = compareVersions(currentVersion, latestVersion) < 0;
|
|
1475
|
+
if (process.env.DEBUG_QKPR_UPDATE) {
|
|
1476
|
+
console.log(`[DEBUG] Package: ${packageName$1}`);
|
|
1477
|
+
console.log(`[DEBUG] Current: ${currentVersion}`);
|
|
1478
|
+
console.log(`[DEBUG] Latest: ${latestVersion}`);
|
|
1479
|
+
console.log(`[DEBUG] Has update: ${hasUpdate}`);
|
|
1480
|
+
}
|
|
1519
1481
|
return {
|
|
1520
|
-
hasUpdate
|
|
1482
|
+
hasUpdate,
|
|
1521
1483
|
currentVersion,
|
|
1522
1484
|
latestVersion
|
|
1523
1485
|
};
|
|
1524
|
-
} catch {
|
|
1486
|
+
} catch (error) {
|
|
1487
|
+
if (process.env.DEBUG_QKPR_UPDATE) console.log(`[DEBUG] Update check failed: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
1525
1488
|
return {
|
|
1526
1489
|
hasUpdate: false,
|
|
1527
1490
|
currentVersion,
|
|
@@ -1700,6 +1663,7 @@ async function showSettingsMenu() {
|
|
|
1700
1663
|
}
|
|
1701
1664
|
}
|
|
1702
1665
|
async function showMainMenu() {
|
|
1666
|
+
await checkAndNotifyUpdate(packageName, version);
|
|
1703
1667
|
console.log(bold(cyan("\n╔══════════════════════════════════════════════════════════════╗")));
|
|
1704
1668
|
console.log(bold(cyan("║ 🚀 Quick PR Tool ║")));
|
|
1705
1669
|
console.log(bold(cyan("║ ║")));
|
|
@@ -1750,17 +1714,14 @@ async function showMainMenu() {
|
|
|
1750
1714
|
switch (feature) {
|
|
1751
1715
|
case "pr":
|
|
1752
1716
|
await handlePRCommand();
|
|
1753
|
-
await checkAndNotifyUpdate(packageName, version);
|
|
1754
1717
|
await showMainMenu();
|
|
1755
1718
|
break;
|
|
1756
1719
|
case "commit":
|
|
1757
1720
|
await handleCommitCommand();
|
|
1758
|
-
await checkAndNotifyUpdate(packageName, version);
|
|
1759
1721
|
await showMainMenu();
|
|
1760
1722
|
break;
|
|
1761
1723
|
case "branch":
|
|
1762
1724
|
await handleBranchCommand();
|
|
1763
|
-
await checkAndNotifyUpdate(packageName, version);
|
|
1764
1725
|
await showMainMenu();
|
|
1765
1726
|
break;
|
|
1766
1727
|
case "pinned":
|
|
@@ -1778,9 +1739,9 @@ async function showMainMenu() {
|
|
|
1778
1739
|
}
|
|
1779
1740
|
function printPRBanner() {
|
|
1780
1741
|
console.log(bold(cyan("\n╔══════════════════════════════════════════════════════════════╗")));
|
|
1781
|
-
console.log(bold(cyan("║ 🔧 Quick PR Creator
|
|
1742
|
+
console.log(bold(cyan("║ 🔧 Quick PR Creator ║")));
|
|
1782
1743
|
console.log(bold(cyan("║ ║")));
|
|
1783
|
-
console.log(bold(cyan("║ Interactive PR Creation Tool
|
|
1744
|
+
console.log(bold(cyan("║ Interactive PR Creation Tool ║")));
|
|
1784
1745
|
console.log(bold(cyan("╚══════════════════════════════════════════════════════════════╝")));
|
|
1785
1746
|
console.log(` Version: ${version}\n`);
|
|
1786
1747
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qkpr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"packageManager": "pnpm@10.20.0",
|
|
4
|
+
"version": "1.0.3",
|
|
6
5
|
"description": "Create a Pull Request with interactive branch selection",
|
|
7
6
|
"author": "KazooTTT <work@kazoottt.top>",
|
|
8
7
|
"license": "MIT",
|
|
@@ -33,11 +32,48 @@
|
|
|
33
32
|
"files": [
|
|
34
33
|
"dist"
|
|
35
34
|
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@google/generative-ai": "^0.24.1",
|
|
37
|
+
"inquirer": "^9.2.20",
|
|
38
|
+
"inquirer-autocomplete-prompt": "^3.0.1",
|
|
39
|
+
"inquirer-search-checkbox": "^1.0.0",
|
|
40
|
+
"is-ip": "^5.0.1",
|
|
41
|
+
"kolorist": "^1.8.0",
|
|
42
|
+
"open": "^8.4.2",
|
|
43
|
+
"ora": "^9.0.0",
|
|
44
|
+
"yargs": "^17.7.2"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@antfu/eslint-config": "^6.2.0",
|
|
48
|
+
"@antfu/ni": "^27.0.1",
|
|
49
|
+
"@antfu/utils": "^9.3.0",
|
|
50
|
+
"@types/inquirer": "^9.0.7",
|
|
51
|
+
"@types/inquirer-autocomplete-prompt": "^3.0.3",
|
|
52
|
+
"@types/node": "^24.10.0",
|
|
53
|
+
"@types/yargs": "^17.0.32",
|
|
54
|
+
"bumpp": "^10.3.1",
|
|
55
|
+
"eslint": "^9.39.1",
|
|
56
|
+
"lint-staged": "^16.2.6",
|
|
57
|
+
"simple-git-hooks": "^2.13.1",
|
|
58
|
+
"tinyexec": "^1.0.2",
|
|
59
|
+
"tsdown": "^0.16.0",
|
|
60
|
+
"tsx": "^4.20.6",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vite": "^7.2.1",
|
|
63
|
+
"vitest": "^4.0.7",
|
|
64
|
+
"vitest-package-exports": "^0.1.1",
|
|
65
|
+
"yaml": "^2.8.1"
|
|
66
|
+
},
|
|
67
|
+
"simple-git-hooks": {
|
|
68
|
+
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
|
|
69
|
+
},
|
|
70
|
+
"lint-staged": {
|
|
71
|
+
"*": "eslint --fix"
|
|
72
|
+
},
|
|
36
73
|
"scripts": {
|
|
37
74
|
"build": "tsdown",
|
|
38
75
|
"dev": "tsdown --watch",
|
|
39
76
|
"lint": "eslint",
|
|
40
|
-
"prepublishOnly": "nr build",
|
|
41
77
|
"release": "bumpp",
|
|
42
78
|
"release:next": "bumpp next --yes",
|
|
43
79
|
"release:patch": "bumpp patch --yes",
|
|
@@ -45,45 +81,6 @@
|
|
|
45
81
|
"release:major": "bumpp major --yes",
|
|
46
82
|
"start": "tsx src/index.ts",
|
|
47
83
|
"test": "vitest",
|
|
48
|
-
"typecheck": "tsc"
|
|
49
|
-
"prepare": "simple-git-hooks"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@google/generative-ai": "catalog:prod",
|
|
53
|
-
"inquirer": "catalog:prod",
|
|
54
|
-
"inquirer-autocomplete-prompt": "catalog:prod",
|
|
55
|
-
"inquirer-search-checkbox": "catalog:prod",
|
|
56
|
-
"is-ip": "catalog:prod",
|
|
57
|
-
"kolorist": "catalog:prod",
|
|
58
|
-
"open": "catalog:prod",
|
|
59
|
-
"ora": "catalog:prod",
|
|
60
|
-
"yargs": "catalog:prod"
|
|
61
|
-
},
|
|
62
|
-
"devDependencies": {
|
|
63
|
-
"@antfu/eslint-config": "catalog:lint",
|
|
64
|
-
"@antfu/ni": "catalog:script",
|
|
65
|
-
"@antfu/utils": "catalog:inlined",
|
|
66
|
-
"@types/inquirer": "catalog:types",
|
|
67
|
-
"@types/inquirer-autocomplete-prompt": "catalog:types",
|
|
68
|
-
"@types/node": "catalog:types",
|
|
69
|
-
"@types/yargs": "catalog:types",
|
|
70
|
-
"bumpp": "catalog:script",
|
|
71
|
-
"eslint": "catalog:lint",
|
|
72
|
-
"lint-staged": "catalog:script",
|
|
73
|
-
"simple-git-hooks": "catalog:script",
|
|
74
|
-
"tinyexec": "catalog:script",
|
|
75
|
-
"tsdown": "catalog:build",
|
|
76
|
-
"tsx": "catalog:script",
|
|
77
|
-
"typescript": "catalog:build",
|
|
78
|
-
"vite": "catalog:build",
|
|
79
|
-
"vitest": "catalog:test",
|
|
80
|
-
"vitest-package-exports": "catalog:test",
|
|
81
|
-
"yaml": "catalog:test"
|
|
82
|
-
},
|
|
83
|
-
"simple-git-hooks": {
|
|
84
|
-
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
|
|
85
|
-
},
|
|
86
|
-
"lint-staged": {
|
|
87
|
-
"*": "eslint --fix"
|
|
84
|
+
"typecheck": "tsc"
|
|
88
85
|
}
|
|
89
|
-
}
|
|
86
|
+
}
|