@bragduck/cli 2.0.23 → 2.1.0
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/bin/bragduck.js +40 -31
- package/dist/bin/bragduck.js.map +1 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/bragduck.js
CHANGED
|
@@ -1071,11 +1071,8 @@ var init_api_service = __esm({
|
|
|
1071
1071
|
this.client = ofetch2.create({
|
|
1072
1072
|
baseURL: this.baseURL,
|
|
1073
1073
|
// Request interceptor
|
|
1074
|
-
onRequest: async ({ options }) => {
|
|
1075
|
-
|
|
1076
|
-
logger.debug(
|
|
1077
|
-
`API Request: ${options.method} ${extendedOptions.baseURL}${extendedOptions.url}`
|
|
1078
|
-
);
|
|
1074
|
+
onRequest: async ({ request, options }) => {
|
|
1075
|
+
logger.debug(`API Request: ${options.method || "GET"} ${request}`);
|
|
1079
1076
|
const cliVersion = getCliVersion();
|
|
1080
1077
|
const platform = getPlatformInfo();
|
|
1081
1078
|
const userAgent = `BragDuck-CLI/${cliVersion} (${platform})`;
|
|
@@ -1084,10 +1081,13 @@ var init_api_service = __esm({
|
|
|
1084
1081
|
"User-Agent": userAgent
|
|
1085
1082
|
};
|
|
1086
1083
|
if (options.headers) {
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1084
|
+
if (typeof options.headers === "object" && !Array.isArray(options.headers)) {
|
|
1085
|
+
Object.entries(options.headers).forEach(([key, value]) => {
|
|
1086
|
+
if (typeof value === "string") {
|
|
1087
|
+
newHeaders[key] = value;
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
1091
|
}
|
|
1092
1092
|
if (token) {
|
|
1093
1093
|
newHeaders.Authorization = `Bearer ${token}`;
|
|
@@ -1102,11 +1102,9 @@ var init_api_service = __esm({
|
|
|
1102
1102
|
logger.debug(`API Response: ${response.status} ${response.statusText}`);
|
|
1103
1103
|
},
|
|
1104
1104
|
// Response interceptor for errors
|
|
1105
|
-
onResponseError: async ({
|
|
1105
|
+
onResponseError: async ({ request, response }) => {
|
|
1106
1106
|
const status = response.status;
|
|
1107
|
-
|
|
1108
|
-
const url = `${extendedOptions.baseURL}${extendedOptions.url}`;
|
|
1109
|
-
logger.debug(`API Error: ${status} ${response.statusText} - ${url}`);
|
|
1107
|
+
logger.debug(`API Error: ${status} ${response.statusText} - ${request}`);
|
|
1110
1108
|
if (status === HTTP_STATUS.UNAUTHORIZED) {
|
|
1111
1109
|
logger.debug("Token expired, attempting refresh");
|
|
1112
1110
|
try {
|
|
@@ -2301,24 +2299,35 @@ async function promptSortOption() {
|
|
|
2301
2299
|
default: "date"
|
|
2302
2300
|
});
|
|
2303
2301
|
}
|
|
2304
|
-
async function promptReviewBrags(
|
|
2302
|
+
async function promptReviewBrags(refinedBrags, selectedCommits) {
|
|
2305
2303
|
const acceptedBrags = [];
|
|
2306
2304
|
console.log("\n" + theme.info("Review each brag before creation:") + "\n");
|
|
2307
|
-
for (let i = 0; i <
|
|
2308
|
-
const
|
|
2305
|
+
for (let i = 0; i < refinedBrags.length; i++) {
|
|
2306
|
+
const brag = refinedBrags[i];
|
|
2309
2307
|
const current = i + 1;
|
|
2310
|
-
const total =
|
|
2311
|
-
const
|
|
2308
|
+
const total = refinedBrags.length;
|
|
2309
|
+
const isNewBragType = !("sha" in brag);
|
|
2310
|
+
let displaySha;
|
|
2311
|
+
if (isNewBragType && selectedCommits) {
|
|
2312
|
+
const commit = selectedCommits[i];
|
|
2313
|
+
displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
|
|
2314
|
+
} else if (!isNewBragType) {
|
|
2315
|
+
const commit = brag;
|
|
2316
|
+
displaySha = commit.sha.startsWith("pr-") ? commit.sha.replace("pr-", "#") : commit.sha.substring(0, 7);
|
|
2317
|
+
} else {
|
|
2318
|
+
displaySha = `#${i + 1}`;
|
|
2319
|
+
}
|
|
2320
|
+
const impactScore = isNewBragType ? brag.suggested_impactLevel?.toString() || "N/A" : brag.impact_score?.toString() || "N/A";
|
|
2312
2321
|
const bragDetails = `${theme.step(current, total)} ${colors.highlight(displaySha)}
|
|
2313
2322
|
|
|
2314
|
-
${theme.label("Title")} ${colors.white(
|
|
2323
|
+
${theme.label("Title")} ${colors.white(brag.refined_title)}
|
|
2315
2324
|
|
|
2316
2325
|
${theme.label("Description")}
|
|
2317
|
-
${colors.white(
|
|
2326
|
+
${colors.white(brag.refined_description)}
|
|
2318
2327
|
|
|
2319
|
-
${theme.label("Tags")} ${colors.primary((
|
|
2328
|
+
${theme.label("Tags")} ${colors.primary((brag.suggested_tags || []).join(", ") || "none")}
|
|
2320
2329
|
|
|
2321
|
-
${theme.label("Impact Score")} ${colors.highlight(
|
|
2330
|
+
${theme.label("Impact Score")} ${colors.highlight(impactScore)}`;
|
|
2322
2331
|
console.log(boxen4(bragDetails, boxStyles.info));
|
|
2323
2332
|
console.log("");
|
|
2324
2333
|
const action = await select({
|
|
@@ -2343,31 +2352,31 @@ ${theme.label("Impact Score")} ${colors.highlight(commit.impact_score?.toString(
|
|
|
2343
2352
|
return [];
|
|
2344
2353
|
}
|
|
2345
2354
|
if (action === "accept-all") {
|
|
2346
|
-
acceptedBrags.push(
|
|
2347
|
-
for (let j = i + 1; j <
|
|
2348
|
-
acceptedBrags.push(
|
|
2355
|
+
acceptedBrags.push(brag);
|
|
2356
|
+
for (let j = i + 1; j < refinedBrags.length; j++) {
|
|
2357
|
+
acceptedBrags.push(refinedBrags[j]);
|
|
2349
2358
|
}
|
|
2350
2359
|
break;
|
|
2351
2360
|
}
|
|
2352
2361
|
if (action === "skip") {
|
|
2353
2362
|
continue;
|
|
2354
2363
|
}
|
|
2355
|
-
let
|
|
2364
|
+
let editedBrag = { ...brag };
|
|
2356
2365
|
if (action === "edit-title" || action === "edit-both") {
|
|
2357
2366
|
const newTitle = await input({
|
|
2358
2367
|
message: "Enter new title:",
|
|
2359
|
-
default:
|
|
2368
|
+
default: brag.refined_title
|
|
2360
2369
|
});
|
|
2361
|
-
|
|
2370
|
+
editedBrag.refined_title = newTitle;
|
|
2362
2371
|
}
|
|
2363
2372
|
if (action === "edit-desc" || action === "edit-both") {
|
|
2364
2373
|
const newDesc = await editor({
|
|
2365
2374
|
message: "Edit description (will open your default editor):",
|
|
2366
|
-
default:
|
|
2375
|
+
default: brag.refined_description
|
|
2367
2376
|
});
|
|
2368
|
-
|
|
2377
|
+
editedBrag.refined_description = newDesc;
|
|
2369
2378
|
}
|
|
2370
|
-
acceptedBrags.push(
|
|
2379
|
+
acceptedBrags.push(editedBrag);
|
|
2371
2380
|
}
|
|
2372
2381
|
return acceptedBrags;
|
|
2373
2382
|
}
|